Posts

Showing posts from February, 2013

http post to login in c# -

i'm noob in c# programming. i want implement http post login on web server. correct implemetation (test advanced rest) http post http://localhost:8080/pentaho/j_spring_security_check "j_username=admin&j_password=password" payload , application encoded content type . advanced rest, server responses 302 , redirects home (and right way). i tried implement same thing in c# code (copied google) server responsens 500 .... here code: public partial class webform1 : system.web.ui.page { private static readonly httpclient client = new httpclient(); protected void page_load(object sender, eventargs e) { } private void dorequest() { // create request using url can receive post. webrequest request = webrequest.create("http://localhost:8080/pentaho/j_spring_security_check"); // set method property of request post. request.method = "post"; // create post data , convert byte a

r - How do I get information for new element in column from other rows in dataframe? -

for project want total time used scrabble. have data frame in there localtime column. want add column dataframe difference between localtime now, , localtime previous element. when using diff function, following message: error in `$<-.data.frame`(`*tmp*`, "timespend", value = c(1.5577, 1.0657, : replacement has 49313 rows, data has 49314 how can fix this? at moment have used this: dualtasktime$timespend <- na dualtasktime$timespend <- diff(dualtasktime$localtime)

convert text into PDF file using python -

Image
a quick question: i opened .pdf file notepad++ , saved .txt file. has following value: %pdf-1.7\n\n4 0 obj\n(identity)\nendobj\n5 0 obj(adobe)endobj8 0 obj> stream xœì½x\ÅÕ7>sïÝÞ«¶hµ»zíjòªkv³,­Õ­b[’ek²ekvqaÝmlÜ0Íу˜nb Á$ÙÆ¢›¼¦…’˜4jph€ " éæÎcxóþŸïý¾g#Ÿ=¿™;3wæÌ™3gæÞ]#Œ²Ã‡€:Ê›fwÕþ°ã ’ý~+bž£¥åó_{óÒÕ¿™€õ®ŠÒº²‹u3¯ý!e¤ª¼¢rÁ«|ˆ{w!.................................. i thinking of converting text pdf using python. may know modules needed? python python-2.7 pdf share | improve question edited mar 29 @ 2:33 asked mar 28 @ 10:14 grqm. 35 6

visual studio - Gulps Ability for unit testing? -

i'm newbie in gulp , have questions: is possible use gulp unit testing in visual studio? is possibility use gulp qunit, jasmine etc? thank you! gulp simple task runner. can use define jobs perform via single command. here's 1 plugin might help: https://github.com/karma-runner/gulp-karma and here's 1 article might interesting: https://taco.visualstudio.com/en-us/docs/unit-test-03-basic-testing/

java - Apache Camel - Is clear method in org.apache.camel.spi.IdempotentRepository interface called by camel framework ? -

i trying upgrade product uses older camel version. in code base, there custom idempotentrepository implementation. as far understand, clear method added idempotentrepository interface in 2.16.0 version : http://camel.apache.org/camel-2160-release.html for clearing repository ( https://issues.apache.org/jira/browse/camel-8478 ) my question : clear method ever called framework ? or added utility exposed on jmx or etc? want know whether or not camel framework calls new method , if ever calls when happen? based on need implement clear method or leave blank. thanks

angularjs - how to select values from mongodb using mongoose -

i using meanstack try fetch data mongodb of angularjs new in technology.i insert values correctly want retrieve mongodb-mongoose i using meanstack try fetch data mongodb of angularjs new in technology.i insert values correctly want retrieve mongodb-mongoose var app = angular.module("app", [ ]); app.controller('mongoosecontroller', ['$scope', '$http' ,'$window', '$filter', function ($scope, $http, $window, $filter) { debugger; var refresh = function () { $http.get('/viewuser').then(function (response) { $scope.viewusers = response.data; }); }; refresh(); $scope.addnewdetails = function ( ) { $http.post('/addnewdetails', $scope.user).then(function (response) { }); }; }]); server var express = require('express'); var app = express(); var mongoose

installation - Condition in components list in WIX -

is there way check file existence during installation. idea implement thing this: 1. install "file1.txt" 2. if fileexists("file2.txt") install "file3.txt" else install "file4.txt" 3. install "file5.txt" how can done using wix? you can use file search check if file2 exists. ( example ) result of search stored in property. use property condition component hold file3 , file4.

C# Create temp file, write to it, print it, then delete it -

i'm trying create temp file, write it, print it, delete it. here's code: string filepathreceipt = path.gettempfilename(); try { using (filestream fs = new filestream(filepathreceipt, filemode.open)) { file.writealltext(filepathreceipt, datatobewritten.tostring()); } } catch (exception ex) { messagebox.show(ex.message); } //printing receipt: start processstartinfo psi = new processstartinfo(filepathreceipt); psi.verb = "print"; try { process.start(psi); } catch (exception ex) { messagebox.show(ex.message); } //printing receipt: end if (file.exists(filepathreceipt)) { //delete file after has been printed file.delete(filepathreceipt); } i exception message saying: can't write because it's used process. edit #2: found works: string filepathreceipt = appdomain.currentdomain.basedirectory + @"receipt.txt"; while generates exception: string filepathreceipt = path.gettempfilename(); full, current co

keyboard shortcuts - Is there any way to Reformat Code in all files under a director/project/solution in Rider? -

i have checked in version of rider till eap 2017.1 . have searched in context menu of director/project/solution , have checked in reformat file dialogue ( ctrl + alt + shift + l in "default xwin" keymap).

html - Change checkbox label css property with checkbox checked -

i have following html: <label> <input type="checkbox" value="cb_val" name="cb_name"> checkbox text </label> with css added background-color <label> tag. label { background-color:#333; color:#fff; } now i'd liked change background color of label when checkbox checked. know how javascript, there way to using css? i have seen solutions, use adjacent sibling selector , work when label appears after checkbox. i still hope fix without javascript, have clue? update: as afraid of, cannot done way, must js, or achieve same visual effect different html structure. want set background color of label , textbox in 1 go, can go solution checkbox placed absolute on top of label. point planttheldea! or can apply background color label , checkbox both. thanks everyone! you can achieve pure css so, <input type="checkbox" id="cb_1" value="cb_val" name="cb_name&q

garbage collection - How to hint C# runtime that myclass is using X amount of unmanaged memory -

to let call myclass destructor or idisposable release method? class myclass:idisposable { [dllimport(..)] public static extern intptr allocate(...); public myclass() { allocate(); } ~myclass() { dispose(); } } where client developer doesn't care (or doesn't remember) using myclass as using(myclass foo = new myclass()) { } but uses like myclass bar = new myclass(); without memory control designs in method. need guaranteed way(or @ least hint) of telling garbage collector may call destructor of myclass or call dispose method after scope exited(or when memory gets fragmented enough) of hint. is there kind of hint applicable these attribute: just adding struct layout bu different [memoryattribute.uses10mbunmanaged] class myclass {} garbage collector: i don't know how relate garbage collection class instances gc.addmemorypressure(10*1024*1024) in myclass constructor

twitter - Error: spawn sh ENOENT Node.js -

i trying trigger pifm on raspberry pi tweets specific twitter account using node.js. when run twitpifm.js on command line: node twitpifm.js i following error: events.js:141 throw er; // unhandled 'error' event ^ error: spawn sh enoent @ exports._errnoexception (util.js:874:11) @ process.childprocess._handle.onexit (internal/child_process.js:178:32) @ onerrornt (internal/child_process.js:344:16) @ dontcallback2 (node.js:439:9) @ process._tickcallback (node.js:353:17) @ function.module.runmain (module.js:469:11) @ startup (node.js:134:18) @ node.js:961:3 i using version of pifm on pi2 https://github.com/asmello/fm_transmitter i have written script (test.sh) start pifm command line without parameters #!/bin/bash /home/pi/pifm/fm_transmitter/bin/release/fm_transmitter music.wav 103.50 i aware need need use child_process within node.js activate shell script having trouble it; first invoke child process with: v

mysql - PHP : How to get Sum of values in column in a variable -

i'm trying sum of salary column table. need echo total salary. tried, select sum(salarycol) my_table; how can query result variable in php? select sum(salarycol) total_salary my_table;

wordpress - Fatal error: Can't use function return value in PHP Code -

im getting error code, , can't understand why. code hasn't been changed: fatal error: can't use function return value in write context in /var/www/vhosts[...] code: if ($this->edit_mode) { // check if submission genuine , not trying change entry $id = $form_data['id']; if (!is_numeric($id) || !isset($submissions[$id]) || $submissions[$id]['hash'] != $form_data['hash']) { echo '<p class="attention">'.sprintf(__('you have been submit form of inconsistent state.', self::textdomain)).'</p>'."\n"; return false; } // preserve of existing data not exposed in edit form if (isset($submissions[$id]['note'])) $form_data['note'] = $submissions[$id]['note']; $form_data['paid'] = $submissions[$id]['paid']; $form

c - How to calculate number of lines in file? -

i work in c-language @ first time , have question. how can number of lines in file? file *in; char c; int lines = 1; ... while (fscanf(in,"%c",&c) == 1) { if (c == '\n') { lines++; } } am right? don't know how moment , when string cross new line. op's code functions aside maybe off-by-one issue , last line issue. standard c library definition a text stream ordered sequence of characters composed lines, each line consisting of 0 or more characters plus terminating new-line character. whether last line requires terminating new-line character implementation-defined. c11dr §7.21.2 2 a line ends '\n' , last line may or may not end '\n '. if using idea last line of file not require final '\n , goal count number of occurrences character read after '\n' . // let use wide type // start @ 0 file may empty unsigned long long line_count = 0; int previous = '\n'; int ch; while ((ch = fget

pandas - sorting a dataframe by values and storing index and columns -

i have pandas dataframe matrix. looks shown below b c d 1 0 5 e 0 6 2 f 2 0 3 i need values sorted , need values of index , columns of them. result should be index column value e b 6 d c 5 f c 3 you need stack reshape nlargest : df1 = df.stack().nlargest(3).rename_axis(['idx','col']).reset_index(name='val') print (df1) idx col val 0 e b 6 1 d c 5 2 f c 3 for multiindex : df2 = df.stack().nlargest(3).to_frame(name='val') print (df2) val e b 6 d c 5 f c 3

How to build the simplest multi module Maven project using Windows command line? -

i have multi module project very simple . directory structure: c:\acme-project\parent c:\acme-project\alpha c:\acme-project\beta logical structure: parent / \ alpha <- beta i cannot build beta because depends on alpha . , meven doesn't want build alpha during beta's build process! c:\acme-project\beta> mvn package [info] scanning projects... [info] [info] ------------------------------------------------------------------------ [info] building beta 1.0-snapshot [info] ------------------------------------------------------------------------ [warning] pom com.company:alpha:jar:1.0-snapshot missing, no dependency information available [info] ------------------------------------------------------------------------ [info] build failure [info] ------------------------------------------------------------------------ [info] total time: 1.263 s [info] finished at:

javascript - How to reverse action on sibling element by jquery -

i want create menu bar sub menu using jquery. there 2 item sub menu. when click on once want slide down , when click second 1 second 1 need slide down first 1 or 1 need slide up. tried following: html <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> <div class="footer-lang"> <ul> <li class="lang"> <a href="">eng <i class="fa fa-caret-down" aria-hidden="true"></i></a> <ul> <li><a href="#">en</a></li> <li><a href="#">bn</a></li> </ul> </li> <li class="lang"> <a href="">usd <i class="fa fa-caret-down" aria-hidden="true"></i></a> <ul> <li><a href=&qu

Calculating column wise for a matrix using numpy in python -

by following program, trying calculate number of occurance of '0','1','2',and '3' each column. program not working desired. read somewhere slicing of matrix should done computing occurance column wise not sure how it. program written using numpy in python. how using numpy? import numpy np a=np.array([[ 2,1,1,2,1,1,2], #t1 horizontal [1,1,2,2,1,1,1], [2,1,1,1,1,2,1], [3,3,3,2,3,3,3], [3,3,2,3,3,3,2], [3,3,3,2,2,2,3], [3,2,2,1,1,1,0]]) print(a) i=0 j=0 two=0 zero=0 one=0 three=0 r=a.shape[0] c=a.shape[1] in range(1,r): #print(repr(a)) j in range(1,c): #sele=a[i,j] if (a[i,j]==0): zero+=1 if (a[i,j]==1): one+=1 if (a[i,j]==2): two+=1 if (a[i,j]==3): three+=1 if i==c-1: #print(zero) print(one) i+=0 j=j+1 #print(two) #print(three) i=i+1 #print(zero)` also want print in following manner: column: 0 1 2 3 4 5 6 occurrenc

powershell - Catch exception when it doesn't find any member from AD -

i made code check groups , authorities of every member in ad group specific drive. works every drive select, breaks when finds both , ad group , user member. get-adgroupmember : cannot find object identity: 'gf05856_adm' under: 'dc=gescoeurope,dc=fiatgesco,dc=com'. it breaks because tries search member inside group, can't find member inside user. cls $result = [system.windows.messagebox]::show("select path of drive.`n" + "once drive selected, excel file made informations`n" + "of selected harddrive's directory premissions") if ($result = "ok") { add-type -assemblyname system.windows.forms $folderbrowser = new-object system.windows.forms.folderbrowserdialog [void]$folderbrowser.showdialog() $selection = $folderbrowser.selectedpath } $result2 = [system.windows.messagebox]::show("pleas select save file") if ($result2 = "ok") { add-type -assemblyname system.windows.forms $folderb

SDK 25.1.1 NPE: Attempt to invoke virtual method 'int android.view.View.getVisibility()' on a null object reference -

my code below, fragment popbackstackimmediate when fragmentempty resurface. works in support sdk 25.1.0 , before. class fragmentempty : fragment() { var fragmenttwo : fragment? = null var fragmentone : fragment? = null override fun oncreateview(inflater: layoutinflater, container: viewgroup?, savedinstancestate: bundle?): view? { return inflater.inflate(r.layout.fragment_empty, container, false) } override fun onviewcreated(view: view?, savedinstancestate: bundle?) { super.onviewcreated(view, savedinstancestate) if (childfragmentmanager.findfragmentbytag("fragmentone") == null) { fragmentone = fragmentone() childfragmentmanager.begintransaction().add(r.id.container, fragmentone, "fragmentone").commit() } else { fragmentone = childfragmentmanager.findfragmentbytag("fragmentone") } if (childfragmentmanager.findfragmentbytag("fragmenttwo&

sql - How to look for substring in string where substring is IN a seperate table on Access Query? -

first, here code: select ssiinspectors.inspector, ssiinspectors.date_time_of_inspection ssiinspectors (((ssiinspectors.inspector) in (select [projectmanager].[lastname firstname] [projectmanager]))); essentially, trying find substring "lastname firstname" projectmanager table inside ssiinspector.inspector field. for example, in [lastname first name] field of project manager table have following names smith, jane kenny, mike and in ssiinspector.inspector field have: "doe, johnsmith, janebob, billy" i want able pick "smith, jane" in query. tried using "like" function, not quite sure how use in particular query, or if should using wild cards? you can try using following query: select distinct t1.[lastname firstname] [projectmanager] t1 inner join [ssiinspectors] t2 on t2.[inspector] '*' & t1.[lastname firstname] & '*' however, data appears not normalized @ all. better have names on separat

python - Check if a value is in a list of columns in a pandas.DataFrame -

i working data looks (simplified) in pandas.dataframe: |-----------|-----------|-----------| | feature 1 | feature 2 | feature 3 | |-----------|-----------|-----------| | | b | d | | | | b | | | d | | | | b | | | | | | | | | d | |-----------|-----------|-----------| and want create new column answer question "is value 'd' present in of columns?" so final data like: |-----------|-----------|-----------|-----------| | feature 1 | feature 2 | feature 3 | feature 4 | |-----------|-----------|-----------|-----------| | | b | d | true | | | | b | false | | | d | | true | | | b | | false | | | | | false | | | | d | true | |-----------|-----------|-------

android - Spinner items populated from SimpleCursorAdapter are not showing -

i have spinner populated items simplecursoradapter. problem - aren't visible in spinner, nevertheless can pick 1 , visible selected item: see screenshot here here relevant code: main2activity.java : cursorloader cl = new cursorloader(main2activity.this, contentprovider.createuri(category.class, null), null, null, null, null); cursor cursor = cl.loadinbackground(); final simplecursoradapter cursoradapter = new simplecursoradapter(main2activity.this, android.r.layout.simple_spinner_dropdown_item, cursor, new string[]{"name"},new int[]{android.r.id.text1}, 0); cursoradapter.setdropdownviewresource(r.layout.spinner_item); cursoradapter.notifydatasetchanged(); spinner.setadapter(cursoradapter); content_main.xml : <spinner android:layout_width="wrap_content" android:layout_height="wrap_content" android:spinnermode="dropdown" android:id="@+id/spinner"/> spinner_item.xml : <?xml version=

how to fill php date from javascript keypress event -

i want add automatically dates php array using javascript keypress event. here's part of code: date array: $period = new dateperiod(new datetime("2015-07-03"), new dateinterval('p1m'), new datetime("2018-07-09")); foreach ($period $date) { $dates[] = $date->format("m y"); } text input: <input type="text" id="jumlah" size="3" maxlength="3" onkeyup="myfunction()" onkeypress="return hanyaangka(event)"/> <p id="demo"></p> i want echo july 2015 if input 1, august 2015 if input 2, etc.. how can that? this i've tried, it's not working: <script> function myfunction() { var x = document.getelementbyid("jumlah").value; var i='<?php echo $dates[x];?>'; document.getelementbyid("demo").innerhtml = i; } </script> the problem try mix server side , clie

javascript - Running Python script from HTML and updating DIV with the output -

the project i'm working consists in reading rfid tag using rfid reader connected arduino , sending id via serial port (usb connection). works when click button on html page. this first part operational, have python script sends command arduino, reads serial port , print on screen response. takes 5 10 seconds connect arduino, read rfid tag , send value back. import time import serial import cgi comport = serial.serial('com3', 9600) param_caracter = 'a' time.sleep(1.5) # entre 1.5s 2s comport.write(param_caracter.encode()) value_serial = "" while (len(value_serial) < 9): value_serial = comport.read(11) #f = open("serial_data.txt","w") #f.write(value_serial) #f.close() print "<p>" + value_serial + "</p>" comport.close() my problem is: how run script html page, using php or javascript, append value_serial value div when click button? i've tried codes found on web, none of them

c - What does enter key mean in linux terminal? -

i've got simple c function below: #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int c; while ((c = getchar()) != eof) putchar(c); return exit_success; } use gcc on linux os terminal test it. result is: d d e e f f 5 5 56 56 want know: 1. why every time press enter key, terminal repeats character typed? 2. why put 2 characters (56), , works too, how work? 3. why enter key makes terminal repeat, not other keys? 4. pressing enter key mean in linux terminal or c program this? terminal input managed through kernel specific object known "tty". tty buffers input before (by default) delivering data process. useful because lets (as user) correct command line before sending processes. tty buffering in line-mode, meaning input data delivered either if buffer full or newline inputed. so when type single char, char not available process, inside tty buffer. type new line , both available process

codenameone - Codename One: Getting events from Calendar throws ArrayIndexOutOfBoundException -

i trying events out of users device calendar code: date = new date(); java.util.calendar c = java.util.calendar.getinstance(); c.add(java.util.calendar.month, 1); date = c.gettime(); string calendarid = dc.opencalendar(calendername, false); collection <eventinfo> events = dc.getevents(calendarid, from, to); the last line exception thrown , have absolutely no idea why. i cant deliver exception messages since cn1lib cant debugged within ide or simulator, makes hard find bug here. when getting exception telling me: error internal application error occurred: java.lang.arrayindexoutofboundsexception: null thanks in advance devicecalendar not supported in simulator throw exception. you can events on device , debug code snippet on device, wrap in try-catch , use log.sendlog() stacktrace in email using codename one. remember remove log.sendlog() when you're done, otherwise, may spammed error log emails. try { //devicec

mean stack - passing value from server.js to html page -

function puts(error, stdout, stderr) { console.log(stdout) if(error){ console.log("error") } else{ result="success"; console.log("success"); } } exec("ping localhost", puts); //this ui page <div class="panel panel-default" ng-init="showplatform1()"> <div class="panel-heading"> <p class="panel-title"> platforms detail show 1 information</p> </div> <div class="panel-body"> <form> <div class="form-group"> <!-- <label class="form-control">platformname: {{ platform.platformname }}</label> --> <label class

c# - Delim Tabs in a string -

string s = " 1 16 34"; string[] words = s.split('\t'); foreach (string word in words) { console.writeline(word); } i have string format shown above, when try deliminate using escape tab, outputs exact same string in original format, why not removing tabs? string[] words = s.split(new[] { ' ', '\t' }, stringsplitoptions.removeemptyentries); foreach (string word in words) { console.writeline(word); } i think fixed it. it gives me output. 1 16 34 which checked outputting 3 in array make sure separated.

field-value-query returning unexpected results when used with 'unfiltered' search in MarkLogic -

Image
i getting false results field-value-query when used 'unfiltered' search. i explain problem sample data given below. xml: <book> <name>dixit</name> <age>25</age> <entry> <isbn> <type>hbk</type> <value>1234567</value> </isbn> <isbn> <type>pbk</type> <value>111111</value> </isbn> </entry> <entry> <isbn> <type>hbk</type> <value>1234567</value> </isbn> <isbn> <type>pbk</type> <value>222222</value> </isbn> </entry> </book> above xml can have multiple <entry> elements. 2 or more <entry> can't have same <type> . i want entries having combination of 1 or more isbn t