Posts

Showing posts from April, 2010

javascript - Keeping created data in AngularJS -

i've general question saving data in angularjs. there opportunities save data in json files , kept them when changed site? mean when change site "persons" "home" , go "persons" created data remain in list of persons? how can resolve this? or possible webapi written in java/c# example? know this? my example @ current push data in list of json data: $scope.additem = function (item) { $scope.list.push(item); $scope.item = null; }; it depends on how long you're looking keep data around, there few options. if want share data between app, while user on website, of angular "services" (factory, service, provider) work singletons. more information on differences, check out answer: angularjs: service vs provider vs factory if looking persist data across user visits, should consider using localstorage. there great angular local storage module here: https://github.com/grevory/angular-local-storage

vb.net - Conversion of SQL Server to Oracle Select query -

i have select query: select sample_number, sample_type, storage_address, external_number systmx2.tm2_samples and need add 2 more columns results of .net syntax code end like" select sample_number, sample_type, storage_address, external_number, somecodearound(storage_address) rowposition, somecodearound(storage_address) columnposition systmx2.tm2_samples the row , column positions based upon fall in 9 x 9 grid. 9 numbers columns across top , 9 numbers rows down side. lab specimen box hold 81 vials. every vial has number 1 81 , last 3 characters of storage_address value similar fr2-s01-r01-001 or fr2-s01-r01-081. vial number 1 in column 1 , row 1; vial 81 in row 9 column 9. .net code row take last 3 character of storage_address , test decimal. tryparse(storage_address.substring(storage_address.length - 3), value) and take value , convert with: cint(decimal.truncate(((value+ 9 - 1) / 9))). and column code is: (value + 9) - (

how allocate attribute for each sensor node in ant colony clustering WSN? -

i working on particle swarm ant colony system wsn clustering in sensor network node gave every sensor node x , y coordinate i dont know, how assign each sensor node attribute according equation calculation centers nodes ,can me please .

printing - How to print specific field that matches with a regex in awk -

it simple question didn't find answer... have tab separated files many rows , different number of fields in each row. this: a1_j a2_f a3_f a10_g a8_t a2_e a2_j a6_h a8_o a9_g i want print fields start a2, not whole line, matched fields.like this: a2_f a2_e a2_j i tried awk, no success. i use grep this: grep -o 'a2_[a-z]' file the -o switch means matches printed, each on separate line.

jsf - Append CSS style from a bean -

is possible append style during @postconstruct of component, example commandbutton. change style class here no way because need dynamic values. i tried following resets style of button uiviewroot root = facescontext.getcurrentinstance().getviewroot(); commandbutton button = (commandbutton)root.findcomponent("form:btn1"); button.setstyle("background-color: red;"); you can assign style commandbutton dynamically using expression language: <p:commandbutton ... style="#{bean.buttonstyle}" ... />

asp.net - noCAPTCHA reCAPTCHA disappearing in UpdatePanel -

i'm implementing nocaptcha recaptcha existing form vb.net. located within updatepanel , uses server side validation verify user has completed captcha (see validating recaptcha 2 (no captcha recaptcha) in asp.net's server side ) if user fails captcha or other of validated fields, captcha fails reload due postback. how resolve , make captcha not disappear after postback? my captcha code: <div id="captcha" class="g-recaptcha" runat="server" data-sitekey="mysitekey"></div> the api.js placed in site.master header. <script src="https://www.google.com/recaptcha/api.js" async defer></script> to expand. i have tried work around failed. added <div id="captcha" class="g-recaptcha" runat="server" data-sitekey="mysitekey"></div> to body of masterpage , threw in updatepanel, gave id, etc. <asp:updatepanel u

c - request for member in something not a structure or union, but its a struct -

this code binary search tree i'm doing school assignment. #include "binary_tree.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #define maxlen 10 node* create_tree() { return null; } void insert_tree(node** root, char* nname, char* number) { if (*root==null){ node* node = (node *)malloc(sizeof(node)); strncpy(node->name , nname, maxlen); strncpy(node->number , number, maxlen); node->left = node->right = null; *root = node; return; } if (strncmp(*root->name, nname, maxlen)) { insert_tree(&(*root)->left, nname, number); } else { insert_tree(&(*root)->right, nname, number); } } void preorder(node* node, int level){ int i; if (node==null){ //printf("null\n"); return; } (i = 0; i<level; i++) { printf(" "); } printf("%s %d\n", node-

c# - Missing an assembly refrence -

in solution working on, in sub project have added reference project. after adding reference, able add using statement , have auto-complete pick right extension looking for. code wrote usual, when compiled, error the type of namespace name 'name1' not exist in namespace 'name2' (are missing assembly reference?) so have searched forums, have added several other system references , have gotten nothing. ran nuget update solution packages, , didn't make difference either. reason, when add reference (using add reference pop-up gui) reference name1 doesn't have dll file in it. if browse dll file directly, still gives me same issue when compiling. ideas appreciated. maybe can copy dll [projectname] / debug / or [projectname] / release /

java - How to do a template class (where the template extends Number) which use number addition? -

hello want simple thing. make template function numbers. want little ability "add". in c++ trivial this: template <typename t> inline t add (t a, t b) { return + b; } int main(int argc, char** argv){ printf("int: %d\n",add(1,2)); printf("float: %f\n",add(1.1,2.1)); } in java got tough lesson. i'm new java believe (and hope) i'm totally wrong , on engineering this. thing come was: public interface intrfcwownumbersadds<t> { t add(number v); } public class supersmartinteger extends number implements intrfcwownumbersadds<supersmartinteger>{ private integer i; public supersmartinteger(int v) { = v; } @override public string tostring(){ return ""+i; } @override public supersmartinteger add(number v) { return new supersmartinteger(this.intvalue()+v.intvalue()); } @override public int intvalue() { return i; // thx god au

Android in-app purchase testing -

Image
i want test in-app purchase implementation. can not configure it. my app has beta version in developer console, there google+ community , google group in beta testers , account added both community , group. added android:debuggable="true" in manifest billing system still wants money. what missing? you have add emails of testers google play console . there field in settings tab, looks this:

android - Which are the dimensions of a Card Item? -

Image
following material design, found cards . unfortunately can't found information dimensions of cards items of picture below. please tell me dimensions of cards need use. want know : what full height , full width of card item? what height of description area in card item(img_4130.jpg,img_4131.jpg,etc.) that's need. according docs in exact page linked, these not cards - represented android.support.v7.widget.cardview - tiles . you have implement own layout tiles , have dimensions wish, because pattern not standardized in docs. main differences between cards , tiles: cards have rounded corners. cards can have multiple actions. cards can dismissible , rearranged. while: tiles have square corners. tiles have no more 2 actions. so use tiles homogeneous content not-so-many actions in it. dimensions depend on images, basically.

opencv - Assertion Failed (Layer_sizes!=0) CvANN_MLP::predict -

i trying classify input image classify function .xml file have made. training artificial neural network(ann) don't know wrong trying code book"practical projects opencv" full code of book available in github: https://github.com/masteringopencv/code/tree/master/chapter5_numberplaterecognition technically used own way extract number segments full picture , created ocr.xlm file. i have no idea why when try classify input segmented image(mat input array) see error : assertion failed (layer_sizes!=0) cvann_mlp::predict here code char const strcharacters[] = { '1', '2', '3', '4', '5', '6', '7', '8', '9' }; int const numcharacters = 9; cvann_mlp ann; void train(mat traindata, mat classes, int nlayers){ filestorage fs; fs.open("ocr.xml", filestorage::read); mat traindata; fs["trainingdata"] >> traindata; fs["classes"] >> classes;

Folder created in Android application appears as binary file when accessed via usb -

i created new folder within app. did via new file(folder-path).mkdirs(); the folder called "albums" , located in /storage/emulated/0/pictures. on android there no problems, folder appears in several filemanagers should. when connect phone computer (fedora 21), folder binary file filesize ~4kb, cant access files inside. checked permissions on folder think okay. can do? have scan file somehow recognized folder? im on android 5.0.2 after creation (or after deletion) run: mediascannerconnection.scanfile(this, new string[]{"/storage/emulated/0/pictures/albums/image1.jpg", "/storage/emulated/0/pictures/albums/image2.jpg", ....} , null, null} every file change (create or delete) should in string array. alternatively, can restart device every time make change. note command not work correctly on empty folders. show 4 kb file instead, seeing now.

Can you pass a typed array to a function within an enum in swift? -

in swift app, i've created enum function takes array of clbeacon objects it's argument (i.e., [clbeacon] ). no clang errors enum, when try use enum, clang complains can't invoke function argument list of ([clbeacon]) . here's code: enum beaconarraystate { case noobjectonscreen, firstobjectonscreen, firstobjectoffscreen mutating func check(beacons: [clbeacon]) -> beaconarraystate { switch self { case firstobjectonscreen: return .firstobjectonscreen case firstobjectoffscreen: return .firstobjectoffscreen case noobjectonscreen: if beacons.count > 0 { println("push screen associated beacon \(beacons[0].minor)") } return .noobjectonscreen } } } var beaconarraystate: beaconarraystate = .noobjectonscreen func beaconmanager(manager: anyobject!, didrangebeacons beacons: [anyobject]!, inreg

python - How to get logged in user modelAdmin callable in django -

i have this: class summaryadmin(admin.modeladmin): list_display = ('date', 'display_user', 'from_till', 'hours_worked', 'productivity_status',) list_filter = ['date', 'user_crm'] def display_user(self, obj): test = "unknown" temp = obj.user_crm #if user.has_perm('crm.list_all_customers'): if temp.user: first_name = temp.user.first_name last_name = temp.user.last_name test = "%s %s" % (first_name, last_name) elif temp.alternate: test = "%s " % temp.alternate else: test = "%s (not linked)" % obj.user #return obj.salesperson if obj.salesperson not none else '' return test is possible logged in user while in display_user function? i think need use threadlocals store request object, not readily available in

java - Inheritance of model class with generic and inner classes -

i have implemented inheritance hierarchy: generic extended insurance witch contains inner (non static) class houseinsurance generic class extended public abstract class generic<t extends generic> { public generic() { entityclass = ((class) ((class) ((parameterizedtype) getclass().getgenericsuperclass()).getactualtypearguments()[0])); } } class extend generic , have nested class extend outer (enclosing) class insurance public class insurance extends generic<insurance> { public class houseinsurance extends insurance { } } unfortunately when trying create instance of inner class getting error: classcastexception: java.lang.class cannot cast java.lang.reflect.parameterizedtype i suppose should add inner class declaration parameter type. not know how. generic class extended many other classes , works. first inheritance inner class, think there problem. please help. far getting compilation error. i not sure when create instanc

AFNetworking : Image is not uploading pre iOS 8 -

i'm using afnetworking in app make possible client-server communication. working great. today, our tester encounter issue, can't upload image server on device having ios 7.0. , 7.1. (note: we're targeting app ios 7.0. >= versions) we've encountered on simulator well. have ever encounter before? i'm not posting code working ios 8 , later versions. i'm sure, there's no issue code. however, think, issue may inside afnetworking framework? ps. we're using latest version of afnetworking framework. all other api calls working fine in both of ios versions. i'm using afhttpsessionmanager call api. (available ios 7.0.) please help! let me know, if want more info. on this. please check code: afhttprequestoperationmanager *manager = [afhttprequestoperationmanager manager]; afhttprequestoperation *op = [manager post:urlstring parameters:params constructingbodywithblock:^(id<afmultipartformdata> formdata) {

java - Display image in mat with jframe (OpenCV 3.00) -

how display mat image in jframe . seticon() not accept mat parameter. image should used in opencv 3.00 before displaying. opencv can open mat images. there way convert image? public void displayimage() { mat image = imgcodecs.imread(getclass().getresource("lena.png").getpath()); jframe frame=new jframe(); frame.setlayout(new flowlayout()); jlabel lbl=new jlabel(); lbl.seticon(image); frame.add(lbl); frame.setvisible(true); frame.setdefaultcloseoperation(jframe.exit_on_close); } i did find code convert has highgui no longer in opencv 3.00. matofbyte bytemat = new matofbyte(); highgui.imencode(".bmp", mat, bytemat); return new image(new bytearrayinputstream(bytemat.toarray())); convert mat bufferedimage, draw on panel, canvas or similar: public static bufferedimage bufferedimage(mat m) { int type = bufferedimage.type_byte_gray; if ( m.channels() > 1 ) { type = b

html - Creating an image border around images of variable size with CSS -

i wish put border frame around image - photo frame image. there easy way this? i.e using css purely, ideally i'd recreate 45 degree joins @ edge , realistic possible. snag here image size variable. i found webpage: http://cssdeck.com/labs/picture-frame-using-box-shadows run snippet below see how works. purely css, no html , no js involved. effect accomplished using box-shadow property. of course, code, need include html , set images' sizes (or keep them in percentage - i.e. 100%) , tweak code bit. effect created , works different sized images, need change inset colour values preferred style. /* pure css picture frame */ html { overflow: hidden; background-color: #653845; background-image: linear-gradient(45deg, hsla(0,0%,0%,.1) 50%, transparent 50%), linear-gradient(-45deg, hsla(0,0%,0%,.1) 50%, transparent 50%); background-size: .25em .25em; box-shadow: inset 0 0 500px hsla(0,0%,0%,.5); height: 100%; padding: 1px; }

HTML5 video not working on mobile phone -

i'm trying html5 video working on web. on desktop works doesn't happen same mobile phone. instead, appears typical video-like image show it's supposed video there wasn't loaded. used easyhtml5video convert video several different formats , according sw, should compatible lots of platforms... after conversion, gives code use, modified adapt paths , style. my mobile phone uses android 4.0. html <video id="video-background" preload="auto" autoplay="autoplay" poster="./images/starry_sky.jpg" loop="loop"> <source src="./videos/time_lapse.m4v" type="video/mp4" /> <source src="./videos/time_lapse.webm" type="video/webm" /> <source src="./videos/time_lapse.ogv" type="video/ogg" /> <source src="./videos/time_lapse.mp4" /> <object type="application/x-shockwave-flash" data="./videos/fl

jquery - Umbraco7 new backoffice section, edit date field, AngularJS -

i'm trying create edit screen new section in office. i've followed various tutorials on how go , working fine normal text fields. however, model has 2 date fields part of , put in date pickers them. cannot life of me them work. i've tried hooking bootstrap , using bootstrap-datepicker turn text input's date time pickers no avail. what's more annoying if use input types of date, create screen works no problem, date pickers. due version of angularjs within umbraco, edit screen not bind correctly hence trying find way around it. i using angularjs approach creating view. any on how can achieve appreciated. links: main tutorial bootstrap-datepicker documents ---- above question posted on our.umbraco.org forum has not had response thought ask helpful folk here. ---- further information, i've tried this: plunker example of possible work around however, doesn't seem work when implemented in umbraco. getting error saying moment not found y

java - ClassNotFoundException with Parse and Facebook -

i hoping can me problem facing. trying integrate facebook login app using parse, , classnotfoundexception error, when call method parsefacebookutils.loginwithreadpermissionsinbackground(loginactivity.this, permissions, new logincallback() the error stack trace: 05-15 10:36:00.749 3936-3936/kstr14.tipper e/androidruntime﹕ fatal exception: main process: kstr14.tipper, pid: 3936 java.lang.illegalstateexception: not execute method of activity @ android.view.view$1.onclick(view.java:4007) @ android.view.view.performclick(view.java:4756) @ android.view.view$performclick.run(view.java:19749) @ android.os.handler.handlecallback(handler.java:739) @ android.os.handler.dispatchmessage(handler.java:95) @ android.os.looper.loop(looper.java:135) @ android.app.activitythread.main(activitythread.java:5221) @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ co

ios - Setting using Content of CALayer's to Image.imageWithRenderingMode Does not work -

i trying set "tinted" version uiimage calayer content property, resulted in original image instead. var imagelayer = calayer(); imagelayer.contentsgravity = kcagravityresizeaspect; imagelayer.contents = image!.imagewithrenderingmode(uiimagerenderingmode.alwaystemplate).cgimage; any idea how use alwaystemplate renderingmode version of uiimage calayer?

php - Magento Magmi how to add custom option color image -

i using magmi product , product custom option import for custom option trying create size , color created through below csv sku,name,description,price,size:drop_down:1,color:drop_down:1 e90451,t-shirt,a t-shirt,5,small|medium|large,red|green now, issue need color image red (red color image) , green(green color image), , i'm not sure how it.

Second File uploading window is not closing using selenium webdriver? -

here code used uploading image via uploading window. on site there 5 uploading button, here try upload 2 images 2 browse buttons. problem that, first window image upload , window closed, second uploading window image url copied uploading window not close. first window code: driver.findelement(by.xpath("//li[@id='upload_1']/input")).click(); stringselection ss = new stringselection("d:\\cars\\audi.jpg"); toolkit.getdefaulttoolkit().getsystemclipboard().setcontents(ss, null); robot robot = new robot(); robot.keypress(keyevent.vk_enter); robot.keyrelease(keyevent.vk_enter); robot.keypress(keyevent.vk_control); robot.keypress(keyevent.vk_v); robot.keyrelease(keyevent.vk_v); robot.keyrelease(keyevent.vk_control); robot.keypress(keyevent.vk_enter); robot.keyrelease(keyevent.vk_enter); second window code: driver.find

excel - Delete Columns Using Date Function -

i apologize if have posted question incorrectly, still getting used stackexchange network. i have created user-form duplicate template workbook, fill in dates of selected month , year, , delete columns because template workbook has 31 pre-formatted columns. the problem having when click on "enter" button in user-form, workbook duplicates , saves, , puts dates across top, but, not execute "delete" line under "duplicate sheet". each sheet in workbook (daily sales, total inventory, deliveries, income statement, profits) when puts in dates across top, supposed delete columns greater "days" , less 31 columns after first date of month. option explicit private sub userform_initialize() initializemonthscombo initializeyearscombo end sub private sub initializemonthscombo() dim months() string months = split("january,february,march,april,may,june,july,august,_ septe

php - Yii 2: Can I access a variable in a view that's rendered by another view? -

in yii 2, following mvc pattern controller passes variables view. however, view renders view in itself. for example in default generated crud views, both create.php , update.php render _form view: <?= $this->render('_form', [ 'model' => $model, ]) ?> is possible me use variable passed controller create.php in _form? say controller renders this: return $this->render( 'create', [ 'model' => $model, 'myvar' => $myvalue, ] ); now can access $myvar in create.php can't in _form (which rendered create.php. there anyway can access this? or need explicitly pass form (in create.php): return $this->render( '_form', [ 'model' => $model, 'myvar' => $myvalue, ] ); the render -function uses extract() convert parameters regular variables in local function context, include of file done. how "receive" values in view. this means if call render (or

c# - Use Expression tree to implement interface by proxying existing implementation -

say have following interface , 2 implementations. public interface iperson { string talk(); void lunch(); } public class dutchperson : iperson { public string talk() { return "ik spreek nederlands."; } public void lunch() { eatbroodjekroket(); } private void eatbroodjekroket() { } } public class englishperson : iperson { public string talk() { return "i speak english."; } public void lunch() { eatfishandchips(); } private void eatfishandchips() { } } public class implementationbuilder<t> { private dictionary<type, iperson> _instances; /// <summary> /// /// </summary> /// <param name="instances">instances used in proxy</param> public implementationbuilder(dictionary<type, iperson> instances) { _instances = instances; } public void setup()

c# - DataGridView button text not appearing despite UseColumnTextForButtonText set to true -

Image
i've added button column datagridview , want display text "compare" on it. i've set text property compare , usecolumntextforbuttonvalue true, no text displays: this true @ runtime, it's not not displaying in designer: how text appear? edit: prosperity's sake, here's code in generated designer.cs file. haven't added any code form myself yet, there's no chance something's resetting further down line. // // compare // datagridviewcellstyle1.alignment = system.windows.forms.datagridviewcontentalignment.middlecenter; datagridviewcellstyle1.font = new system.drawing.font("calibri", 11.25f, system.drawing.fontstyle.regular, system.drawing.graphicsunit.point, ((byte)(0))); this.compare.defaultcellstyle = datagridviewcellstyle1; this.compare.headertext = "compare"; this.compare.name = "compare"; this.compare.text = "compare"; this.compare.tooltiptext = "compare dictionary definition syste

Getting bootstrap modal to show in jquery -

i've created form , goes through jquery validated. question once form has been submitted bootstraps modal popup confirmation message, far i've not been able that. my html <div class="newsletter_email"> <div id="newsletter_modal" class="modal fade" aria-hidden="true" aria-labelledby="mymodallabel" role="dialog" tabindex="-1"> <div class="modal-dialog"> <div class="modal-content col-lg-12"> <div class="modal-header"> <button class="close" aria-label="close" data-dismiss="modal" type="button"> <h4 id="mymodallabel" class="modal-title">form</h4> <p>this header</p> </div> <div class="modal-body">this body<

mysql - How to automate update process between 2 databases -

i'm quite new mysql , in database management in general.... i've solve scenario: in development stage web site has database in local machine , tables dedicated contain information data used application ,during development records of tables grow , when move production want update production server new data... can advise best practice automate update process local production database. thanks in advance the road doing have each database know how far has migrated. you should absolute use liquibase or flyway it. if have simple database environment these 2 work. both of these track changes in version files database keep track of. if need more complexity, in sharded environment, need roll own tool this.

r - Store the summary of kknn into a data.frame -

i have performed kknn operation on data set. want convert summary of operation data.frame. here sample data: x <- data.frame(a=c(4,2,2,5,2,4), b=c("m","f","m","m","m","m"), c=c(53,50,44,47,42,43)) n <- dim(x)[1] samplevalues <- sample(1:n,size=round(n/3),replace=f,prob=rep(1/n,n)) x.train <- x[-samplevalues,] x.test <- x[samplevalues,] x.kknn <- kknn(b~., x.train, x.test, distance=1, kernel="triangular") is possible store summary(x.kknn) in data.frame?

Audio chat using webrtc in safari browser? -

i searching solution audio chat between 2 users in safari browser using webrtc(peer js). have found solutions using temasys plugins , work local streaming. is there someway in safari browser. yes, can use temasys plugin mac osx safari , ie. have used temasys these browsers on live site though there random issues sometimes. , now, think peerjs supports temasys integration also.

jmeter - Performance tool for Web Single Page Application -

please, assist me on one. project web single page application not provide different urls different view. loads clicking within 1 screen. asked find performance tool test such application. i not able hp loadrunner or such tool in same price range. maybe there open source or how use jira project? thanks when click somewhere, if screen doesn't change, browser sends relevant http request (usually or post). jmeter acts on protocol level, doesn't "render" page or execute javascript can send http request. so should able record requests using jmeter's http(s) test script recorder , replay them larger number of threads according load test scenario. you can use view results tree listener visualize request , response details , jmeter assertions ensure test should do.

I can not access phpMyAdmin on XAMPP -

i have xammp installed on windows 8. can access localhost this localhost:800 trying access phpmyadmin xampp when clicking on button or type in http://localhost:800/phpmyadmin/ getting white homepage without on it?! know whats gonig on? worked fine yesterday. try know server's ip address typing ipconfig in cmd, example: 192.168.22.5/phpmyadmin

python - How to check if a number is in a interval -

suppose got: first_var = 1 second_var = 5 interval = 2 i want interval second_var second_var ± interval (from 3 7). wank check if first_var in interval. in specific case want false if first_var = 4 , want true i can this: if (first_var > second_var-interval) , (first_var < second_var+interval): #true is there more pythonic way this? i use class __contains__ represent interval: class interval(object): def __init__(self, middle, deviation): self.lower = middle - abs(deviation) self.upper = middle + abs(deviation) def __contains__(self, item): return self.lower <= item <= self.upper then define function interval simplify syntax: def interval(middle, deviation): return interval(middle, deviation) then can call follows: >>> 8 in interval(middle=6, deviation=2) true >>> 8 in interval(middle=6, deviation=1) false with python 2 solution more efficient using range or xrange don't i

java - How to ignore json property in encapsulated design -

class a{ private b b; //other properties //getter setter } // unable add jsonignore in class due dependency in other module class b { int id; string name; string defname; } i want ignore defname in class a json building codehaus.jackson api. i need {a:{id:value,name:value}} . you can use mixin purpose. first create abstract class jsonignore annotation: abstract class mixin{ @jsonignore abstract string getdefname(); } then use below. (be sure getter name of defname field getdefname() in b class or change in mixin class yours.) objectmapper objectmapper = new objectmapper(); objectmapper.addmixin( b.class, mixin.class ); objectmapper.writevalue( system.out, new a() ); this prints: {"b":{"id":1,"name":"sercan"}}

javascript - Data loss in Node.js child process -

i'm trying send data (as object) child process in node.js, however, of regular expressions lost in transfer. var arguments = { something: { name: 'test', age: 28, active; true }, otherthing: 'some string', regex: /test/i, regex2: new regexp('test') }; var child = cp.fork(path.join(__dirname, 'child.js')); child.on('message', function (data) { console.log(data); }); child.send(arguments); in child.js file have @ top: process.on('message', function () { console.log(arguments); // data has changed }); when log output child process arguments object instead looks this: { something: { name: 'test', age: 28, active: true }, otherthing: 'some string', regex: {}, regex2: {} } so far unable find elsewhere why may happening, ideas? because separate javascript processes, can't send objects. w

javascript - Why does parsing a large number, of string form, give a larger number? -

this question has answer here: why javascript converts number values automatically 4 answers see snippet: var num = "9223372036854775808"; document.write(num); document.write("<br>"); document.write(parseint(num, 10)); on running code snippet, first write yields: 9223372036854775808 and third write yields: 9223372036854776000 but, parsing number in string form number. why give still larger number? i thought might have limits of storage capacity, then, why yield larger number if not store smaller? i read question: why parsing large number integer return 1 , parseint doc did not much. so, why parsing large number, of string form, return larger number? the first result fine treated string. in second one, crosses value of int +/- 9007199254740992 ie, maximum value parseint can parse 9007199254740992

regex - Using Perl to strip everything from a string except HTML Anchor Links -

using perl, how can use regex take string has random html in 1 html link anchor, this: <a href="http://example.com" target="_blank">whatever example</a> and leave , rid of else? no matter inside href attribute <a, title= , or style= , or whatever. , leave anchor: "whatever example" , </a>? you can take advantage of stream parser such html::tokeparser::simple : #!/usr/bin/env perl use strict; use warnings; use html::tokeparser::simple; $html = <<eo_html; using perl, how can use regex take string has random html in 1 html link anchor, this: <a href="http://example.com" target="_blank">whatever <i>interesting</i> example</a> , leave , rid of else? no matter inside href attribute <a, title=, or style=, or whatever. , leave anchor: "whatever example" , </a>? eo_html $parser = html::tokeparser::simple->new(string => $html);

c# - Insert data in LINQ Database -

i wonder why can't insert data database using linq. created serviced-base database. when run program, there no error, still no data appears in database table. private void button1_click(object sender, eventargs e) { dataclasses1datacontext ds = new dataclasses1datacontext(); customer cst = new customer(); cst.custname = textboxnama.text; cst.phone = int.parse(textboxhp.text); cst.custaddress = textboxalamat.text; ds.customers.insertonsubmit(cst); try { ds.submitchanges(); messagebox.show("success"); } catch (exception ) { throw; } } please check if connected correct database(check connection string).

android - Get drawable for different screen density at runtime -

i want print sizes of drawables @ run-time. if on hdpi device can print size of hdpi drawables how access to, lets mdpi , xhdpi well? can access drawables resource ids following code: final class<r.drawable> c = r.drawable.class; final field[] fields = c.getdeclaredfields(); (int = 0, max = fields.length; < max; i++) { final int resourceid; try { resourceid = fields[i].getint(drawableresources); } catch (exception e) { continue; } /* make use of resourceid accessing drawables here */ } ok found it, explicitly ask particular density drawable this: drawable drawable = resources.getdrawablefordensity(id, displaymetrics.density_xhigh); or preferably version drawable drawable = resources.getdrawablefordensity(id, displaymetrics.density_xhigh, theme);

For loop with Python - using ints instead of datetime -

i have datascience task requires getting historical weather data. have looked @ wunderground.com api example structured so: http://api.wunderground.com/api/d23ac65706dbf6dd/history_yyyymmdd/q/ca/san_francisco.json therefore, when attempting build dataset need first day of year last day of year, can't with: 20140101 20140102 20140103 ... 20141229 20141230 20141231 the thing can come is: for m in range(1, 13): d in range(1, 32): r = requests.get("http://api.wunderground.com/api/0def10027afaebb7/history_2014'+str(m)+'/'+str(d)+'/q/mexico/mexico_city.json") data = r.json() but won't work. how go in python? here minimal example demonstrates how iterate on actual dates: >>> import datetime >>> start = datetime.date(2014, 1, 1) >>> end = datetime.date(2014, 1, 5) >>> while start <= end: print start.strftime('%y%m%d') start += date

java - Math Parser - token structure -

i'm implementing own math parser - , have few questions on how proceed. so far parser converting input string tokens: public class token { final public string expression; final public int value; public token(string expression, int value) { this.expression = expression; this.value = value; } } each string, expression, valid entry - number, operator or function. integer type passed enum identify token. when input string separated tokens expression parsed shunting-yard algorithm. my question : want tokens create objects of type. 1 way of doing might be: public abstract class mathcommand { final static hashtable<character, operator> operatortable = new hashtable<character, operator>() {{ put('+', new addition()); put('-', new subtraction()); put('/', new division()); put('*', new multiplication());

ios - Where to store downloaded data in iPhone application? -

i have scenario in application need download mp3, pdf, text files using application. how can download, , store, data using application? nsstring *stringurl = @"http://www.somewhere.com/thefile.png"; nsurl *url = [nsurl urlwithstring:stringurl]; nsdata *urldata = [nsdata datawithcontentsofurl:url]; if ( urldata ) { nsarray*paths=nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentsdirectory = [paths objectatindex:0]; nsstring *filepath = [nsstring stringwithformat:@"%@/%@", documentsdirectory,@"filename.png"]; [urldata writetofile:filepath atomically:yes]; } you can store in document directory,below example store image .below link explained store audio video file how download audio/video files internet , store in iphone app?

c++ - Operator overloading: calling friend function from member function -

i have student class. want overload + operator can add double variable class. here student class: class student { private: std::string firstname; double grade; public: student(const std::string &firstname, double grade); double getgrade() const; friend student operator+(double grade, const student &student); student operator+(double grade) const; }; and implementation: student::student(const std::string &firstname, double grade) { this->firstname = firstname; this->grade = grade; } double student::getgrade() const { return grade; } student operator+(double grade, const student &student) { return student(student.firstname, student.grade + grade); } student student::operator+(double grade) const { return operator+(grade, *this); } double + student done via friend function , student + double goes through member function. when compile this: error: no matching function call ‘student::operator+(double&

unix - Extract tar file without creating folder -

i want extract tar file in unix tar xvf /home/test/group.tar , once extracted got folder group has list of xls,pdf,txt files. how can extract contents of group.tar inside /home/test/list of xls, pdf files without creating group folder. any specific command available or have follow copy , move?? thanks! you may use --strip-components 1 parameter. tar xvf group.tar --strip-components 1

Javascript/Jquery change anchor link using regex -

<ul id="nav"> <li><a href="index.html#section1">natural beauty</a></li> <li><a href="index.html#section2">beginings</a></li> <li><a href="index.html#section3">earth's purity</a></li> <li><a href="index.html#section4">bottling goodness</a></li> <li><a href="index.html#section5">drink health</a></li> <li><a href="index.html#section6">minerals</a></li> <li><a href="#">contact us</a></li> </ul> i looked possible js/jquery on how jump page in href, header print index.html. tried change href this: $(document).ready(function(){ $('a').each(function(){ var value = $(this).attr('href'); var x = 'index.html'+ (#[a-z\d-]+); $(this).attr('href'

how to remove back slashes from json output in php -

the code have used: $val = json_encode(array("test"=>test1,"test2" =>test,"description" => description)); return $val; the result im getting {\"test\":\"test1\",\"test2\":\"test\",\"description\":\"description\"} i need fix api try stripslashes() echo stripslashes('{\"test\":{\"test1\":{\"test1\":[{\"test2\":\"1\",\"test3\": \"foo\",\"test4\":\"bar\",\"test5\":\"test7\"}]}}}'); stripslashes()

How to handle browser javascript confirm navigation alert with ruby watir script -

Image
i'd programmatically handle javascript confirmation alert asking if you'd leave page (see screenshot below). the methods i've tried far have not worked. the browser not recognizing returning value true wanting leave page. this part trying handle alert: if @b.div(:class, "infomessagebox error").present? puts "there error" #@b.execute_script("window.confirm = function() {return true}") @b.execute_script("window.onbeforeunload = function() {};") @b.goto("#{@env}/translatefile.aspx") break end i have read article: " dismiss "confirm navigation" popup watir " method in article not in case. i apreciate because i'm stuck right here. this helped in solving problem. i improved code , works better here might other problems in future (hope not). @b.refresh if @b.alert.exists? @b.alert.text @b.alert.ok end @b.goto("#{@env}/translat