Posts

Showing posts from June, 2014

javascript - Dynamically Add Form Fields and Update Field Value -

i have form can add fields: http://jsfiddle.net/ytrkqr6a/2/ $(document).ready(function() { var max_fields = 32; //maximum input boxes allowed var wrapper = $(".cameras"); //fields wrapper var add_button = $(".add-camera"); //add button id var x = 1; //initlal text box count $(add_button).click(function(e){ //on add input button click e.preventdefault(); if(x < max_fields){ //max input box allowed x++; //text box increment $(wrapper).append('<div class="form-group"><input type="text" name="camera '+ x +'" value="camera '+ x +'" placeholder="camera '+ x +'" class="form-control cameras" readonly /> <a href="#" class="remove-camera">remove</a></div>'); //add input box } }); $(wrapper).on("click",".remove-came

encryption - When is key signing necessary? -

if you've validated persons public key think verifying fingerprint in person/over phone, signing public key still necessary? especially if plan on not decrypting messages yourself, plan on encrypting message valid public key, key signing still necessary? i find useful sign key couple of reasons: to reassure me in future key hasn't changed. to key owner prove key others via web-of-trust. on point 1), it's easy enough verify fingerprint now going every time send person encrypted mail or check signature? signing key means can forget fingerprint. on point 2), owner of public key may appreciate signature on key convince others key belongs them. example if sign alice's key , bob has verified key, bob can choose trust alice's key virtue of signature. in practice, believe proper etiquette sign alice's key export ( gpg --export --armor <alice's key id> ) , send alice in encrypted email. allows choose how use signature on key - might

Access 2010 calculating the number of workdays -

i new access 2010 , need number of days in workweek excluding holidays twist. have been able use standard vb code workdays appears on internet , works great simple monday – friday or monday - saturday calculation. question is, how can or possible manipulate code calculate number of days if friday, saturday , sunday count 1 day? example: calculate number of days tuesday 11/25/14 today. -today's date = monday, december 01, 2014; -monday, december 01, 2014 = 0; -sunday, november 30, 2014 = 3; -saturday, november 29, 2014 = 3; -friday, november 28, 2014 = 3; -thursday, november 27, 2014(holiday) = 2; -wednesday, november 26, 2014 = 2; -tuesday, november 25, 2014 = 1 so in example above, number of days 3. if need account statutory holidays you'll need use kind of table. purely algorithmic approaches problem difficult manage , prone failure, because holidays fall on fixed date may observed on other date. example, if christmas falls on saturday em

javascript - Stuck on Converting a JS function to Perl -

im trying convert this: (js function) perl. decrypt3 = function (strin, strkey) { var strout = new string(); var lenin = strin.length; var lenkey = strkey.length; var = 0; var numin; var numkey; while (i < lenin) { numin = parseint(strin.substr(i, 2), 32); numkey = strkey.charcodeat(i / 2 % lenkey); strout += string.fromcharcode(numin - numkey); += 2; } return strout; }; this far have come: im not sure how strout , correct numkey. while (<>) { chomp; print decrypt3($_, $key),"\n"; } sub decrypt3 { @str_in = unpack 'c*', shift; @str_key = unpack 'c*', shift; @str_out; $i (0 .. $str_in) { $numin = int[$str_in[ord[$i 2], 32] $sum = $str_in[$i] + $str_key[$i / 2% @str_key]; use list::util 1.29 qw( pairmap ); @base32_syms = (0..9, 'a'..'v'); %base32_sym_vals = map { lc($base32_syms[$_]) => $_, uc($base32_syms[$_]) => $_,

c# - Need help print list of strings -

i trying print innertext values class xyz, printed "system.collections.generic.list`1[system.string] public list<string> getl1names() { uitestcontrol document = browinx.currentdocumentwindow; htmlcontrol control = new htmlcontrol(document); control.searchproperties.add(htmlcontrol.propertynames.class, "xyz"); uitestcontrolcollection controlcollection = control.findmatchingcontrols(); list<string> names = new list<string>(); foreach (htmlcontrol link in controlcollection) { if (link htmlhyperlink) names.add(control.innertext); } return names; } using print console.writeline(sitehome.getl1names()); "system.collections.generic.list`1[system.string] that because system.collections.generic.list<t> not overload tostring(). default implementation (inherited system.object) prints name of object's type, seeing.

tinymce - How to Cut, Copy and Paste from JavaScript to a User's Clipboard -

there multiple similar questions in stackoverflow deal how cut, copy, , paste javascript (in response button press, instance) without user having use ctrl+x, c, or v. all these answers suggest either insane wanting , users should never have clipboards violated in such profane manner, or use hack of invisible flash movie (which has questionable support). however, google docs this, , not use flash movie. can open google document, go edit menu, choose "paste" (or cut or copy) , not browser window tells "your browser security settings don't permit editor automatically execute copying operations." however, go rich text editor ( ckeditor or tinymce instance, common among them all) , try same command. message reads: "your browser security settings don't permit editor automatically execute copying operations." so question simply: google docs doing allow users cut, copy, , paste via menu button doesn't run in security issues?

c# - IsDBNull throws an exception -

i'm reading mysql database 1 columns of datetime type. of these dates null. can't seem figure out how check if value null or not. thought isdbnull solve problem, makes no difference @ all if (!reader.isdbnull(4)) { service.servicedate = reader.getdatetime("servicedate"); } this exception i'm getting: "additional information: unable convert mysql date/time value system.datetime" i tried if (system.dbnull.value == reader.isdbnull(4)) as as reader.isdbnull(4).tostring() and convert.toboolean(reader.isdbnull(4)) how check without using try catch? the error not seem have isdbnull - mentions datetime conversion. have tried passing column index getdatetime , doing isdbnull ? if (!reader.isdbnull(4)) { service.servicedate = reader.getdatetime(4); } . another possibility: convert 0 datetime=true additionally, after reading other info on error, sounds may need add convert 0 datetime=true connection string, enab

jsp - Java Login Servlet getting a internal error request HTTP 500 java.lang.NullPointerException -

i'm working on java web application uses login servlet jsp login page. login page action set go servlet won't load , i'm getting http 500 error. had arraylist stored username , password locally in java class worked fine without error until changed pull login data local mysql database using jdbc. database setup table "user" has string data user class. i ran seperate java class test database , seemed run fine when tried implement web application gave errors within loginservlet. setup authenicationservice class pull user login data database , store them objects in arraylist. not sure if there better way didn't want mess previous code seemed work ok prior changes. i'm sure there better way i'm kind of lost change appreciated thanks. here user class have setup business logic layer: public class user { private string username; private string password; private string firstname; private string lastname; private string email; private string phon

windows - How to make batch file that will swap typed characters (A=T to T=A) -

i want make simple batch file can type in letters dna bases (a, t, g, c) , change text type opposite base pairs. please me make code. examples: a=t t=a c=g g=c these changes want batch file make. want typing within batch file. most obvious solution (quite straight forward): set x=atatatccgcatcgatcgaa set x=%x:a=x% set x=%x:t=a% set x=%x:x=t% set x=%x:g=x% set x=%x:c=g% set x=%x:x=c% echo %x% replace "a"s "x", replace "t"s "a", replace "x"s "t". same "g"-"c".

php cURL doesn't follow redirect -

i use following code http-status code of final url (after following redirects): $handle = curl_init($url); curl_setopt($handle, curlopt_followlocation, true); curl_setopt($handle, curlopt_returntransfer, true); curl_setopt($handle, curlopt_header, true); // want headers //curl_setopt($handle, curlopt_nobody, true); curl_setopt($handle, curlopt_timeout, 5); curl_setopt($handle, curlopt_ssl_verifypeer, false); curl_setopt($handle, curlopt_useragent, 'my bot'); $response = curl_exec($handle); $httpcode = curl_getinfo($handle, curlinfo_http_code); curl_close($handle); however, curl doesn't follow redirects. f.e. if use www.raffiniert.biz/kunden, shows plain 301, instead of following www.raffiniert.biz/kunden/ what's wrong? thanks raphael i got expected response using same code. http/1.1 301 moved permanently server: nginx

vba - Populating Word Tables from Access -

i trying create tables in ms word , fill them data ms access. of code have written below in basmain , basutilities. having trouble private sub fillcells in basmain. used sub fill tables text fields, table needs allow other formats. data listed in basutilites text except tblemployees.[notes] , tblemployees.[photo]. notes memo , on limit of characters text , photo bmp picture. also, tables should not have form fields. appreciated. thank you!! here link source files: https://jumpshare.com/b/sy6mxurdtdpssdcqkluj basmain option explicit public const cstrpath string = "\source\243src_final.accdb" public connemp adodb.connection public rstemps adodb.recordset sub listemps() dim strask string strask = inputbox("which country?", "county request") if strask = "uk" call basutilities.connect("uk") elseif strask = "usa" call basutilities.connect("usa") else msgbox "this name not recognized!&qu

javascript - asynchronous node.js concepts with IO -

var net = require ('net'), local_port = 8000, local_ip = '127.0.0.1', remote_port = 80, remote_ip = 'xxx.xx.xx.x', server = net.createserver (function (socket){ var servicesocket = new net.socket (); servicesocket.connect (parseint (remote_port), remote_ip, function () { socket.on ('data', function (msg){ servicesocket.write (msg); }); }); }).listen (local_port, local_ip); there server, runs code, , client, connects server , sends 2 blocks of data 1 after another, d1 , d2. is true, d2 arrive before d1 remote_ip ? wouldn't case possible: let's client sends d1 of size x asynchronously, , d2 of size y , y smaller x, wouldn't socket.on('data'...) fire first reception of d2 on 'data' listener? net.createserver , net.socket both create tcp sockets. this has few implications: data write first received first. boundaries not fixed, single write on 1 side may split multiple data eve

string - Lua: RegEx to Pattern -

simple problem...i need turn regex pattern... "\[\"([0-9]+)\"\]" into lua pattern. i doing replace bunch ["x"] lines [x] in string x number -∞ or +∞...so that's limitation. need port lua patterns can use in string.gsub. find: "\[\"([0-9]+)\"\]" also, how remove " " around number? need pattern that. if me out, appreciate it. you try this. > f = "foo [\"12\"] bar" > x = string.gsub(f, "%[\"(%d+)\"%]", "[%1]") > print(f) foo ["12"] bar > print(x) foo [12] bar \d matches digits represented %d in lua .

Cannot convert string to int in PHP -

i'm having tough time converting value read socket connection integer. it's value tells me how many bytes going received next. $ar = fread($client, 4); $binaryint = unpack('n', $ar); debug_to_console($binaryint); //displays 16 (as expected) $bred = fread($client, intval($binaryint)); //intval returns 1 for reason intval evaluates 1 , can't figure out why. btw $ar variable sent integer java server have running via code sample dout.writeint(data.length); thanks edit i got it. user2587326 below helped instead of using intval(binaryint[1]) binaryint[1]. i think reading 4-byte integer sent java program on dataoutputstream php program on socket. first, fread($client, 4) call reads 4 bytes string, convert them array unpack(), taking 4-bytes @ time (format specifier 'n') resulting array 1 element, use: intval( $binaryint[1] ) instead of intval($binaryint) obtain number. edit: works intval too, won't hurt it.

Python: How to efficiently implement large symmetric array with many empty entries -

i using large 2-dimensional square array entries lists of integers. not written in stone, it's w w array, w=15000, , each entry list of integers, random size 0 400. has 2 characteristics: it symmetric many of entries empty lists, including ones on diagonal right now, taking advantage of first part , implement pseudocode: f=[ [ [] in range(w)] j in range(w) ] # initiate blank w x w array in range(w): j in range(i): if (condition): f[i][j] = [a list of integers] then in end, assign rest of values follows: for in range(w): j in range(w): f[i][j]=f[i][j] # reference, size of f not increase i not experienced programmer, , i'm feeling approach not efficient. in particular, feel not taking advantage of fact many entries empty. can have more efficient list f such doesn't occupy space entries end being empty? mind still important have "coordinates" x, y assigned correctly. there variety of ways store sparse matr

php - Mark all methods as "safe" -

i want create class full of html helper methods: class formhelper { public function text() { return 'hello <b>world</b>'; } } which register global: $twig->addglobal('fh',new formhelper); then can call methods twig: {{ fh.text }} but they're escaped (e.g. hello &lt;b&gt;world&lt;/b&gt; ). i know can prevent escaping |raw , want bypass this, same way can designate function safe . is possible class methods? twig globals storage can put variable available in context. no logic applied, if variables stored in local context. but can iterate class's methods , register them safe functions: $object = new formhelper(); foreach (get_class_methods($object) $method) { $function = new twig_simplefunction("fh_{$method}", array($object, $method), array('is_safe' => array('html'))); $twig->addfunction($function); } note can't use dot ( . ) in function

android - how to disable setOnItemSelectedListener(listener) Toast message -

i have listener show toast message when user clicks on spinner , selects item. but when set value of spinner programatically want disable toast message. how do it. i have tried setonitemselectedlistener(null) before programmatically setting value of spinner setonitemselectedlistener(listener) after toast message still shows no matter do. thanks in advance. this done inside oncreate btw. want disable toast messaging when oncreate sets default values spinner. here's listener private onitemselectedlistener listener = new onitemselectedlistener() { public void onitemselected(adapterview<?> parent, view view, int position, long id) { string item = (string) parent.getitematposition(position); toast = toast.maketext(getbasecontext(), weather.temp_description.get(item), toast.length_short); if (mtemp.getonitemselectedlistener() != null) { toast.show(); } }; public void onnothingsel

Close, open new magnific popup window via API -

via function, trying close open magnific popup window , open new one. what have image gallery custom title includes links. link closes magnific gallery of images , open ajax window. script uses lightbox show images , have "add cart" link opens form (to select various options) via ajax add current image cart. function sunshine_add_to_cart(image) { var image_url = jquery(image).attr('href'); jquery.magnificpopup.close(); jquery.magnificpopup.open({ items: { src: image_url+'?sunshine_lightbox_cart=1' }, type: 'ajax' }, 0); console.log(image_url); } the magnific gallery closes, ajax never does. console logging proper url value exist. same url opened via standard link works fine. http://screencast.com/t/yodiy2j76t - standard link opens - http://screencast.com/t/ee18cl19tusi - add cart ajax window fine http://screencast.com/t/whgseoyijn6g - link in image view closes current gallery not open new a

sql - Moodle schema changes? -

with recent upgrade moodle 2.7, customer of ours reporting customsql reports failing. example, this query used report gradeable items, fails now: select u.firstname "first", u.lastname "last", c.fullname "course", a.name "assignment" prefix_assignment_submissions asb join prefix_assignment on a.id = asb.assignment join prefix_user u on u.id = asb.userid join prefix_course c on c.id = a.course join prefix_course_modules cm on c.id = cm.course asb.grade < 0 , cm.instance = a.id , cm.module = 1 order c.fullname, a.name, u.lastname a quick query or 2 db shows there 0 rows in prefix_assignment_submissions , prefix_assignment. suggestions? the assignment module replaced assign module in moodle 2.2. the old assignment module disabled default in moodle 2.5 (i think) , removed in moodle 2.7. the query need rewriting use assign_submissions table (and other assign_* tables relevant).

android - Lollipop shared element transition for mapView? -

i have mapview takes small portion of screen, when touched opens full screen view. i accomplish switching between 2 fragments. i'd love use new lollipop animation framework expand small mapview seamlessly larger mapview (from fragment1 fragment2). unfortunately, haven't been able work -- , wondering if has been able mapview work new animation framework. my code: @suppresslint("newapi") public void launchmapfullscreenfragment(fragment previousfragment, mapview mapview) { // launch fragment view google maps fragmentmapfullscreen fragment = new fragmentmapfullscreen(); if (build.version.sdk_int >= build.version_codes.lollipop) { previousfragment.setsharedelementreturntransition(transitioninflater.from(this).inflatetransition(r.transition.change_image_transform)); previousfragment.setexittransition(transitioninflater.from(this).inflatetransition(android.r.transition.explode)); // create new fragment add (fragment b)

Why does my skrollr parallax effect not work properly when the height of my window gets longer? -

i got parallax effect work on laptop screen size. viewed site on larger screen noticed parallax effect not finishing because there not enough room scroll down. how fix issue? below snippet of code showing 2 of elements moving scroll down. using data attributes transform. should using else? can view site here http://nsohail.github.io/project3-html/ <div id="slide-1" class="slide" data-0="transform:translate(-770px,0px);" data-10p="transform:translate(-770px,0px);" data-100p="transform:translate(185px,0px);"> </div> <div id="slide-1" class="slide" data-0="transform:translate(770px,0px);" data-10p="transform:translate(770px,0px);" data-100p="transform:translate(-220px,0px);"> </div> instead of using 100p (pe

port scanning - How should I do to check if the service running on a remote host? -

i'm writing port scanner , want verify if specific port running standard service expected on port, such ssh , http . know 1 of methods send query port , analyze returned information. example, ssh sends me version information upon connection. however, when did connect() port 22 on ip address, got error number: 110. error message: connection timed out . idea appreciated. the whole code long story. paste excerpt here. struct sockaddr_in dest_addr; dest_addr.sin_family = af_inet; dest_addr.sin_port = htons(22); dest_addr.sin_addr.s_addr = inet_addr("8.8.8.8"); int service_sock = socket(af_inet, sock_stream, ipproto_tcp); if (service_sock < 0) { printf("error creating service socket. error number: %d. error message: %s\n", errno, strerror(errno)); exit(0); } int dest_addr_len = sizeof(dest_addr); if (connect(service_sock, (struct sockaddr *)&dest_addr, dest_addr_len) < 0) { // stuck here printf("error connection. error number: %

Applying dynamic arguments to JavaScript function but deferring invocation -

consider javascript code: var somearg = "hello"; elem1.onclick = function() { foo(somearg); }; somearg = "bye"; elem2.onclick = function() { foo(somearg); }; i invoke foo argument "hello" when click on elem1, however, way above code works, foo invoked "bye" every time. basically, i'd apply somearg foo not invoke foo until later. the usual way builder function: var somearg = "hello"; elem1.onclick = buildhandler(somearg); somearg = "bye"; elem2.onclick = buildhandler(somearg); function buildhandler(arg) { return function() { foo(arg); };; } ...or function#bind : var somearg = "hello"; elem1.onclick = foo.bind(null, somearg); somearg = "bye"; elem2.onclick = foo.bind(null, somearg); either way, you're doing creating new function that, when called, calls foo value pass it. reason original code doesn't work functions close on variable somearg , not value of when th

scala implicit parameter type inference -

running following script under scala 2.10.4. expecting result of a.classop should mypage. why nothing? scala> trait pagemodel { | def classop[t](implicit manifest: manifest[t]) { | println("class: " + manifest.runtimeclass.getname) | } | } defined trait pagemodel scala> class mypage extends pagemodel defined class mypage scala> val = new mypage a: mypage = mypage@1f2f992 scala> a.classop class: scala.runtime.nothing$ edited: i think answer. thanks! however, interesting same code running on 2.9.3 gives me java.lang.object. should behave same? see nomanifest in 2.9.3 well. scala> trait pagemodel{ | def classop[t](implicit m: manifest[t]) { | println("class: " + manifest[t].erasure.getname) | } | } defined trait pagemodel scala> class mypage extends pagemodel defined class mypage scala> val = new mypage a: mypage = mypage@f7bf869 scala> a.classop class: java.lang.object when define method def classop[t](.

ios - iPhone 6 simulator doesn't work properly -

my code ball going end of bottom of screen , regenerate @ top of screen... if(ball.center.y >666){ ball.center=cgpointmake(one.center.x, -30); in iphone 6 simulator, farthest ball goes down ball.center.y >585 , regenerates. how come doesn't go way down ball.center.y >666? i have retina 4.7hd , retina 5.5hd launch images placed. whether use auto layout , size classes or no auto layout , no size classes ball doesn't go lower ball.center.y >585. please help, don't know how solve problem.

javascript - Why must I use browser.sleep while writing protractor tests -

my first run @ e2e tests. i'm trying digest else's protractor tests. problem: there lot of browser.driver.sleep , seems fragile. goal: not use browser.driver.sleep question: better approach browser.driver.sleep ? less fragile promise or dont know lol? var config = require('../../protractor.conf.js').config; describe('this homepage body tests', function(){ browser.driver.get(config.homepageurl); it("should open find clinic page", function(){ // page loads :: want fix random wait interval browser.driver.sleep(2000); browser.ignoresynchronization = true; var string = 'clinic'; var main = '.search-large-text'; var link = element(by.csscontainingtext('.submenu li a', string)); link.click().then(function() { // page reloads :: want fix random wait interval browser.driver.sleep(3000); var title = element(by.csscontainingtext(main, string)); expect(title.gettext()).tobe(string); }

ios - Simulating a resizeable airplay display -

im working on ios application supports external displays on airplay, of testing external display option in simulator, , on ios devices connected macs running various airplay receiver apps. im attempting support external display size changes, , don't have access the device test with(and can't device is). i've noticed in documentation uiscreen uiscreenmodedidchangenotification: clients can use notification detect changes in screen resolution. this notification supposedly gets triggered device i'm trying support, , seems should handle resizing ui respond change. are there ways simulate airplay display can resized, , on resize post uiscreenmodedidchangenotification notification? many displays support multiple resolutions. when resolution changes on display re-negotiate new resolution ipad , notification triggered. try changing display's resolution while ipad plugged in via video adaptor.

operating system - why 2D hashmap is memory inefficient? -

i told friends using 2d hashmap discouraged due fragmentation problem? tell if that's case , why? personally don't see reason discourage use if there legitimate need 2d hashmap. what may referring how system deals collisions. if 2 different values end same hash value position, do? still need store them both. there few different techniques used handle issue , 1 of them aim start large set of possible hash value positions potentially lead lot of wasted space. better method check next available position until finds free spot. it has been while since studied storage of these types, seems may talking about. not major issue , not reason never use hashmaps (including 2d ones). i'm not sure on think issues above compound when used in more dimensions (hence more of issue 2d hashmap).

nginx - Phpbrew on ubuntu – how to change version? -

i have ubuntu 12.04 lts "precise", php 5.3.10 (from apt-get), fresh phpbrew 1.17.2, , php 5.4.35 installed phpbrew. works cli. $ php -v # 5.3.10-1ubuntu3.11 $ phpbrew install 5.4.35 +default +fpm $ phpbrew switch 5.4.35 $ nginx -s reload $ service php5-fpm restart $ php -v // php 5.4.35 $ curl -il example.com | grep powered # still 5.3.10-1ubuntu3.11 ! why? than i've tried new fpm brew bind pid /var/run/php54-fpm.pid , reconfigure servers fastcgi_pass unix:/var/run/php54-fpm.pid; . $ phpbrew fpm start works correclty, example page phpinfo(); returns 5.3 version. how really switch php version in case? thanks in advance! this issue explained here: https://github.com/phpbrew/phpbrew/issues/226 basically have link php *.so files within apache config hand.

C - What library (.so file) is the c function open() in, and how would I find that out for an arbitrary function? -

how can find library function open() is? like, name of actual "xxxxxx.so" file contains function? also, there place typically information other functions? i didn't know how find library given function in, required dlopen knowing library not required dlopen() : if file null pointer, dlopen () shall return global symbol table handle running process image. symbol table handle shall provide access symbols ordered set of executable object files consisting of original program image file, executable object files loaded @ program start-up specified process file (for example, shared libraries), , set of executable object files loaded using dlopen () operations rtld_global flag. … but if want know: #define _gnu_source #include <stdio.h> #include <stdlib.h> #include <dlfcn.h> int main() { // don't need know library dlopen(): void *handle = dlopen(null, rtld_now); if (!handle) puts(dlerror()), exit(1);

java - PermGen thrashing at 99%, but nowhere near MaxPermSize -

i have repeatable situation jvm undergoing heavy gc load. when request jvm stats using jmap -heap , info below (this oracle jdk 1.7.0_25 on linux) note while says maxpermsize 256m, says permgen sitting @ 136mb @ 99.9% capacity. that explain gc thrashing, question why isn't jvm expanding permgen full available 256m? there parameter can prevent pool expansion happening, , stopping jvm making full use of 256m? note tenured pool getting bit tight, near as permgen. using thread-local object allocation. mark sweep compact gc heap configuration: minheapfreeratio = 5 maxheapfreeratio = 10 maxheapsize = 805306368 (768.0mb) newsize = 1048576 (1.0mb) maxnewsize = 4294901760 (4095.9375mb) oldsize = 4194304 (4.0mb) newratio = 8 survivorratio = 8 permsize = 50331648 (48.0mb) maxpermsize = 268435456 (256.0mb) g1heapregionsize = 0 (0.0mb) heap usage: new generation (eden + 1 survivor space): cap

android - How to create folder in internal storage with I add more bitmaps inside the folder? -

i want create folder in internal storage number of images inside folder. can do? to create folder inside internal storage use getfilesdirectory(); consider example: for creating folder named myfolder in external storage: file myfolder = new file(environment.getexternalstoragedirectory()+"/myfolder"); if(!myfolder.isexists) myfolder.mkdirs(); for creating same in internal storage use: file myfolder = new file(context.**getfilesdirectory()**+"/myfolder"); if(!myfolder.isexists) myfolder.mkdirs(); now can add files folder wish! refer myfolder folder object. hopes clear..

why Netty doesn't bind with public IP address & it binds with 127.0.0.1? -

i got in weird situation , can bind serverbootstrap local ip address when tried public ip address throws exception : exception in thread "main" org.jboss.netty.channel.channelexception: failed bind to: /57.88.173.132:5055 can explain me wrong??? btw im using netty 3.6.1 i changed address not real random numbers port real one here code private static final string bind_address = "57.88.173.132"; private static final int port = 5055; public server() { try { startup(); } catch (ioexception e) { e.printstacktrace(); } } private void startup() throws ioexception { serverbootstrap serbootstrap = new serverbootstrap(new nioserversocketchannelfactory(executors.newcachedthreadpool(),executors.newcachedthreadpool())); serbootstrap.setpipelinefactory(new pipelinefactory()); serbootstrap.bind(new inetsocketaddress(bind_address,port)); here exception thrown exception in thread "main"

javascript - How to find coordinates of mouse in HTML -

i need place img (image1.png) @ specific coordinates on html page. how can find coordinates of mouse when click? please write javascript (no jquery) function find x , y coordinates of mouse? note: should mouse coordinates on html page, , not screen. try this: function getmousecoordinates(event) { var x, y; x = event.clientx + document.body.scrollleft + document.documentelement.scrollleft; y = event.clienty + document.body.scrolltop + document.documentelement.scrolltop + 1; return [x,y]; }

string - Java, Calculate the number of days between two dates -

this question has answer here: calculating difference between 2 java date instances 43 answers possible duplicate: calculating difference between 2 java date instances in java, want calculate number of days between 2 dates. in database stored date datatype, in code strings. i want calculate no of days between 2 strings. well start with, should only deal them strings when have to. of time should work them in data type describes data you're working with. i recommend use joda time , better api date / calendar . sounds should use localdate type in case. can use: int days = days.daysbetween(date1, date2).getdays();

c# - How to show large icons when using axSymbologyControl? -

Image
i'm using arcgis axsymbologycontrol. how show large icons? public istylegalleryitem getitem() { m_stylegalleryitem = null; axsymbologycontrol1.styleclass = esrisymbologystyleclass.esristyleclassscalebars; this.showdialog() return m_stylegalleryitem; } my desktop application arcgis window is there size property can set? like public istylegalleryitem getitem() { m_stylegalleryitem = null; axsymbologycontrol1.styleclass = esrisymbologystyleclass.esristyleclassscalebars; //try different x , y values here various sizes axsymbologycontrol1.size = new system.drawing.size(94, 264); this.showdialog() return m_stylegalleryitem; } i have no experience esri/arcgis libraries, controls deriving system.windows.forms.control have property, , seems similar. i found sample code buried in arcobjects sdk 10 .net api reference , pulled line above from. not sure if exact library using, perhaps docs provide better information i.

javascript - Disable JQuery datepicker dates by picking a date from another datepicker -

2 datepickers fromdate , todate my requirement select fromdate , todate should not more 30 days selected fromdate , when pick fromdate should enable next 30 days in todate datepicker. i tried implement facility these datepickers not working //from date $("#txttfromdateteacherdailyreport").datepicker( { changemonth : true, changeyear : true, dateformat : "dd/mm/yy", maxdate : '0', beforeshow : function() { jquery(this).datepicker( 'option', 'maxdate',jquery('#txtttodateteacherdailyreport').val()); }, }).datepicker("setdate", "0"); //to date $("#txtttodateteacherdailyreport").datepicker( { changemonth : true, changeyear : true, dateformat : "dd/mm/yy", maxdate :'0', beforeshow : fun

testing - colorizing golang test run output -

i when terminal/console test runs show output in either red or green text. seems lot of testing libraries available go have this. however, i'd use default testing package comes go. there way colorize it's output red , green? you can create wrapper shell script , color using color escape sequence. here's simple example on linux (i'm not sure how on windows, guess there way.. :) ) go test -v . | sed ''/pass/s//$(printf "\033[32mpass\033[0m")/'' | sed ''/fail/s//$(printf "\033[31mfail\033[0m")/''

How To Read Data Into A List Structure in C#? -

i writing program uses studentstruct (structure) consists of: studentid, studentname, , grades (which separate list). program supposed read in sequential text file , contains methods allow user to: add student, add grades (to particular student), change student name, , delete student. @ end of program supposed overwrite previous file new changes made current program session. my question how read in data text file separate structure variables within lists? my text file looks this: 00000,mimzi dagger,100,50,75,70,45,10,98,83 00001,alexander druaga,89,45,80,90,15,73,99,100,61 00002,nicholas zarcoffsky,100,50,80,50,75,100,100 00003,kantmiss evershot,50,100 once structure variables within list filled, how overwrite file contents of list structure in same format above file? since have multiple , varying amounts of grades, how achieve looping through , adding each grade grades list? as can maybe tell, new c# , first project. appreciated! class program { stati

php - How to import an XML feed with UTF-8 characters? -

here example of utf-8 characters in lastfm api xml response: <artist>psy</artist> <name>강남스타일</name> <album>gangnam style (강남스타일)</album> i'm using domdocument::load load xml: $doc->load('http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&[parameters]') foreach ($doc->getelementsbytagname('track') $node) { 'name' => $node->getelementsbytagname('name')->item(0)->nodevalue, etc... this result: [artist] => psy [name] => ê°•ë‚¨ìŠ¤íƒ€ì¼ [album] => gangnam style (강남스타ì¼) what need differently?

class - What's the proper way to declare a field holding a function in dart? -

imagine silly class this: class conditionalworker{ var validitychecker= (inputs)=>true; conditionalworker(this.validitychecker) ... now question is, proper way of declaring validitychecker field? this tutorial suggests using typedefs . that's not practical. firstly it's chore write lot of typedefs used once. , secondly these typedefs show , pollute autocompletion of ide. the var works best, custom setters/constructor arguments keep of specific kind, know it's discouraged style guide. i function<bool> more glorified var , amount of work same. it's shame because it's legal have function this: bool every(bool test(e element)); where parameter defined function, can't have field declared same way: bool test(e element); but there didn't figure out. right?d if function<bool> not specific enough (you want specify number , type of arguments have use typedefs. there no other ways. i'm not sure why thi

c# - Where can I find System.Web.HttpContext.Current.Server dll? -

Image
where can find system.web.httpcontext.current.server dll. want use server.mappath() in code , requires system.web.httpcontext.current.server namespace. references couldn't find , add system.web.httpcontext.current.server solution. help? right click references >> click add reference , under assemblies click framework , search system.web , check checkbox , click ok button add it's reference in project: you have reference of system.web , can use types , methods under system.web namespace/assembly it, in case httpcontext : system.web.httpcontext

Windows Phone 8.1: MessageDialog Text Style -

i want style messagedialog text , align text right instead of left. how can style messagedialog text in windows phone 8.1 ? use contentdialog instead. can build using visual studio template (project -> add -> new item -> content dialog)

ios - Page Slide animation with CATransition -

how can set page slide animation catransition. have uitextview inside uiview. uitextview page. both having 500 in width. effect should as, when swipe left, x value of frame of textview should change 0 -500. can uiview's animation properties. here need , when textview disappear -500 (origin.x) simultaneously textview should appear 500 0 (frame.x). how can it? in advance. i have found solution myself. used catrasition kcatransitionpush type follows: animation.type = kcatransitionpush;

apache - mod rewrite urls for search page parameters -

i rewriting search page variables with: rewriterule ^search/([^/]*)/([^/]*)$ /search.php?search=$1&cat=$2 [l] which works if go /search/test/members however if on home page , use search box, url shows as: /search?search=test&cat=members how rewrite url when user uses search form url shows as: /search/test/members add these rules: rewritecond %{the_request} \ /+search\.php\?search=([^&]+)&cat=([^&\ ]+) rewriterule ^ /search/%1/%2? [l,r] in order redirect browser new url. cleaner url requested , rule have internally rewrite back it's supposed be.

recursion - Implementing next_permutation in sml? -

how implement in sml? possible change inner for-loop recursive inner function? void recursivepermute(char str[], int k) { int j; // base-case: fixed, print str. if (k == strlen(str)) printf("%s\n", str); else { // try each letter in spot j. (j=k; j<strlen(str); j++) { // place next letter in spot k. exchangecharacters(str, k, j); // print spot k fixed. recursivepermute(str, k+1); // put old char back. exchangecharacters(str, j, k); } } } you write like val rec recursivepermute = fn (str, k) => ... or fun recursivepermute (str, k) = ... you can check k , length of str like if (string.size str = k) ... else ... as inner-loop function, work in poor way, better else concerns representation of string. if want swap characters, work o(n) @ worst n - length of string (due need remove characters between them , put them back). generally, need use o(n^2) time quite in

Spring XD - Event delivery guarantees -

when create stream composed of multiple modules, there guarantees provided on event delivery each module. there possibility of events being replayed? what if processor module takes long time process 1 event crashes in middle of processing. happens event when module restarted in container? see the documentation re: message bus configuration , error handling (message delivery failures) . the retry configuration can modified @ bus or individual module/stream level.

javascript - Parse.com relations count -

i want query object parse db through javascript, has 1 of specific relation object. how can criteria achieved? tried this, equalto() acts "contains" , it's not i'm looking for, code far, doesn't work: var query = new parse.query("item"); query.equalto("relateditems", someitem); query.lessthan("relateditems", 2); it seems parse not provide easy way this. without other fields, if know items following: var innerquery = new parse.query('item'); innerquery.containedin('relateditems', [all items except someitem]); var query = new parse.query('item'); query.equalto('relateditems', someitem); query.doesnotmatchkeyinquery('objectid', 'objectid', innerquery); ... otherwise, might need records , filtering. update because of data type relation , there no ways include relation content results, need query relation content. the workaround might add itemcount column , kee

node.js - Getting a validation error in mongoose even though files are provided -

i getting validation error following message on saving database though have provided fields, { [validationerror: validation failed] message: 'validation failed', name: 'validationerror', errors: { name: { [validatorerror: path `name` required.] message: 'path `name` required.', name: 'validatorerror', path: 'name', type: 'required', value: undefined } } } this how object trying save looks { name: 'nobody singh', phone: '+919177121364', address: 'flat no 306 koratala apartments\nstreet no 3 ,himayatnagar, near siraj plaza', start: '2014-12-03t13:00:00.000z', end: '2014-12-03t15:00:00.000z', details: 'flat no 306 koratala apartments\nstreet no 3 ,himayatnagar, near siraj plaza' } an here schema // load things need var mongoose = require('mongoose'); // define schema our user model var appointments

Unable to set Hebrew Keyboard on android lockscreen for unlock phone? -

Image
so extending reference question . able set hebrew password on android based motorola phone. after setting password hebrew based, wanted unlock same using "choose input method" , selecting hebrew phone not shown me key pad after selecting hebrew. attaching screen shot setting system language english , trying choose input method hebrew , unlocking password unable hebrew key pad. setting system language hebrew , choose input method hebrew , unlocking password unable hebrew key pad so, got answer own question : move framework/base/packages/keyguard/res/layout , modify keyguard_password_view.xml node edittext removing/commenting android:imeoptions="flagforceascii|actiondone" <edittext android:id="@+id/passwordentry" android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_hori

android - Xamarin Fragment Switching in Adapter -

replacing fragment in xamarin android on click of button i'm not able switch fragment other fragment in adapter class. swagbtn.click += delegate(object sender, eventargs e) { var events = new events(); var basefragments = new basefragments(); basefragments.fragmentreplacewithoutbackstak( "", resource.id.main_container, events, resource.animator.enter, resource.animator.exit, resource.animator.pop_enter, resource.animator.pop_exit ); }; here fragmentreplacewithoutbackstak method public void fragmentreplacewithoutbackstak( string str, int continer, android.support.v4.app.fragment class, int anim_first, int anim_second, int anim_third, int anim_fourth ) { activity.supportfragmentmanager .begintransaction() .setcustomanimations(anim_first, anim_second, anim_third, anim_fourth) .replace(continer, class) .commit(); }

Groups in TestNG are not following the sequential order -

im trying use groups features in testng , , trying automate application . i have written 3 tests . package com.sonata.testng; import org.openqa.selenium.by; //import org.openqa.selenium.webelement; //import org.openqa.selenium.interactions.actions; import org.openqa.selenium.support.ui.select; import org.testng.annotations.aftermethod; import org.testng.annotations.aftersuite; import org.testng.annotations.beforemethod; import org.testng.annotations.beforesuite; import org.testng.annotations.test; public class bugzilla_groups extends bugzilla_baseclass{ @beforesuite(groups = {"functional test"}) public void initializetest() throws exception{ super.setup(); } @test(groups = {"functional test"}) public void testlogin() throws exception { driver.get(baseurl); system.out.println("login test start"); driver.findelement(by.id("login_link_top")).click(); driver.findelement(by.id(&

regex - readlines() error in python -

i'm new scapy , python, , have modelled below code on code example violent python: hacker's cookbook. after running program on wlan0 interface error attributeerror: readlines my understanding readlines() converts capture list, findall() able operate on string line. can help? cheers. #!/usr/bin/python import optparse import logging import re # provides support regular expressions logging.getlogger("scapy.runtime").setlevel(logging.error) # suppresses messages have lower level of seriousness error messages scapy.all import * def findguest(capture): line in capture.splitlines(): ipaddr = re.findall("(?:\d{1,3}\.){3}\d{1,3}",line) # findall returns list # must use ,raw if ipaddr: print 'found ip addr '+ipaddr[0] def main(): parser = optparse.optionparser() # create parser object parser.add_option('-i