Posts

Showing posts from January, 2011

Comparing the first columns in two csv files using python and printing matches -

i have 2 csv files each contain ngrams this: drinks while strutting,4,1.435486010883783160220299732e-8 , since that,6,4.306458032651349480660899195e-8 state face,3,2.153229016325674740330449597e-8 it's 3 word phrase followed frequency number followed relative frequency number. i want write script finds ngrams in both csv files, divides relative frequencies, , prints them new csv file. want find match whenever 3 word phrase matches 3 word phrase in other file , divide relative frequency of phrase in first csv file relative frequency of same phrase in second csv file. want print phrase , division of 2 relative frequencies new csv file. below far i've gotten. script comparing lines finds match when entire line (including frequencies , relative frequencies) matches exactly. realize that because i'm finding intersection between 2 entire sets have no idea how differently. please forgive me; i'm new coding. can give me little closer such big help. import csv impo

packages - R Version Compatibility -

are different versions of r belong 3.1 compatible respect packages? that is, under windows , do these versions have same base packages installed in library? does 3.1.0 work package binaries compiled 3.1.1 etc?

javascript - event.preventDefault(); only works some of the time with submit form -

i using mailchimp api submit form. goal prevent default callback provided mailchimp. majority of time event.preventdefault() behaving should. randomly not work: $(function () { var $form = $('#mc-embedded-subscribe-form'); $('#mc-embedded-subscribe').on('click', function(event) { if(event) event.preventdefault(); register($form); }); }); function register($form) { $.ajax({ type: $form.attr('method'), url: $form.attr('action'), data: $form.serialize(), cache : false, datatype : 'json', contenttype: "application/json; charset=utf-8", error : function(err) { alert("could not connect registration server. please try again later."); }, success : function(data) { if (data.result != "success") { // went wrong, notify user. maybe alert(data.msg); var message = data.msg

python - Have Flask-AutoIndex serve the children of the app directory but not "/" itself -

i have flask application , want serve files in subdirectories of folder flask application resides. tried doing flask-autoindex so: autoindex(app, browse_root=os.path.curdir ) @app.route('/') def index(): return render_template('index.html'); this serves static content out of /css , /js nicely, can't / route index function. instead, autoindex routes / , displays files, including application source code file. tried setting add_url_rules false allowed index route / but /css , /js no longer served. how can have subdirectories of application autoindexed still allow application handle / ?

Nested list comprehensions in Haskell -

i following haskell tutorial , on higher order functions section. defines function called chain as: chain :: (integral a) => -> [a] chain 1 = [1] chain n | n = n:chain (n `div` 2) | odd n = n:chain (n * 3 + 1) there exercise find number of "chains" have length longer 15. this: numlongchains :: int numlongchains = length (filter islong (map chain [1..100])) islong xs = length xs > 15 i trying come list comprehension instead of giving me number of chains gives me list of chains longer 15 [1..100]. closest attempt far looks like: [ [ | <- chain b, length > 15] | b <- [1..100]] but get: <interactive>:9:14: no instance (integral [a0]) arising use of `chain' possible fix: add instance declaration (integral [a0]) in expression: chain b in stmt of list comprehension: <- chain b in expression: [a | <- chain b, length > 15] <interactive>:9:45: no instance (enum [a0]) arising arithmetic sequence `1

javascript - Colour-coding points on Google Maps -

i'm developing application page of college project display information house price costs , looking implement colour-coded map different years. idea there dot each house sold located on map (google maps example), , colour-coded green red depending on how expensive was. i'm looking way implement using google maps api, have been unable find solution doesn't slow application loading in ~30k datapoints each year , application had 5 years worth of data. would have suggestions on use. i've looked @ google's geocharts , don't offer looking for. i've looked @ heatmaps, , though colouring effect i'm looking for, points weighted colour dependent on proximity rather specified variable, price. 30k points * 5 years = 150k markers. might much. should looking way show 1 year of history @ time and/or use marker clustering . regarding color markers, use svg markers that. can change color of svg path. little bit of calculation, should able process points

eclipse - Android :: Adding jar in libs vs importing a library -

curious know difference between adding jar file in libs folder vs depending on library project in eclipse. for e.g. google play library can added in libs jar file whereas google doc says import project , require main project depend on play library project. does know difference between two? you want import project library when want use resources project. otherwise, import jar .

When I have the ID of a user in Facebook, how can I have the URL of its profile? -

in our website, when users use facebook connect, take user ids facebook. have url profile each user id. how can that? i couldn't find question here (but on other way url -> id). you can´t access real profile of users, since username not in response of /me anymore , id "app scoped id". protect privacy of user, should never need access profile anyway. if want picture of user, can use picture endpoint: https://graph.facebook.com/[app-scoped-id]/picture

multithreading - JavaFX-8: Can I read (not write) scene graph properties from background thread? -

i'd write background thread automatically saves position of window preferences after waiting 1 second. understand cannot manipulate scene graph background , need call platform.runlater(), accessing property unsafe? i.e. call mywindow.xproperty.get() or mywindow.getx(). have inside platform.runlater()? thanks

ssl - Windows 8 driver signing -

this question has answer here: cheap windows driver signing 64 bit windows 7 3 answers i have windows driver lie unsigned. in need of signed of machines using on. isn't going public application , appreciate wouldn't mind signing .sys driver us. thank time. if can please let me know here or on skype : justin7674 if may have method other test mode terrific too. (anyone may wondering outdated elan usb ic driver) libusb sdk not option (already built driver can't used 3rd party application) the process signing driver well documented signing drivers should not ask random stranger on internet you: doing so, you're inviting potentially malicious 3rd parties modify driver, adding malicious code , signing driver it'll install on machines ... opening gaping hole every machine deploy driver onto. i strongly encourage not accept any off

Newbie- Errors in main_activity.java in Eclipse -

have no experience in java.get error in "r." everywhere in main_activity.java, when make new android project in eclipse setcontentview(r.layout.activity_main); if (id == r.id.action_settings) help appreciated.thanks check if id action_setting in activity_main xml file. if error still there. go projects, try cleaning.

c - store data from a file to a struct array -

i have spent lot of time last 2 day , stuck. cant understand how pointers , structs work function. i pass array of type struct reference , parse file store values. used printf see did word in main values wrong. wonder if have use pointer pointer make work. here function int parse_sightings(char *file, struct sightings_data *recs) { file *fptr; char buf[50]; int lines=0; fptr = fopen(file, "r"); if (fptr == null) { ferror(fptr); exit(1); } else { while (!feof(fptr)) { char ch = fgetc(fptr); if (ch == '\n') { lines++; } } printf("%d\n",lines); rewind(fptr); recs = malloc(lines * sizeof (struct sightings_data)); int index = 0; ///aber/dap/cetaceans/data/sightings_1.txt while (!feof(fptr)) { fscanf(fptr, "%s %c %lf %lf", &(recs + index)->id, &(recs + index)->type, &(recs + index)-&

sql - ORA-01722: invalid number- select, alias -

i can't write complicated select , alias statements because of these errors. what's wrong select statement hr tables select first_name+', '+last_name+' , '+email name employees; let's try : select first_name || ', ' || last_name 'name' employees; yes, mihai mentioned - || concatenation

android - Checkbox, radiobutton doesnt appear properly on JellyBean devices when using appcompat-v21 and Theme.appcompat -

Image
have noticed error when using appcompat-v21 , theme theme.appcompat. styles.xml <style name="myactivitytheme" parent="theme.appcompat"> <item name="colorprimary">@color/primary</item> <item name="colorprimarydark">@color/primarydark</item> <item name="coloraccent">@color/accent</item> </style> manifest.xml <activity android:name=".myactivity" android:label="@string/app_name" android:theme="@style/myactivitytheme"/> the checkbox , radiobutton appearances not correct on 4.1.1 devices , suspect same behavior on 4.0.4 devices well. i not using real device, used genymotion in both cases. ( 4.3 & 4.1.1) appearances fine 4.2.2+ devices. if 1 knows issue , how fix this, please share. also tested on real device samsung galaxy s2 - 4.0.4. doesnt appear correctly. appcompat v21 contained number of issues

Using bash, separate servers into separate file depending on even or odd numbers -

the output comes command run our netscaler. outputs following ... 1 thing note middle 2 numbers change even/odd criteria on last digit. never have more 2 digits, we'll never hit 10. wc-01-web1 wc-01-web4 wc-01-web3 wc-01-web5 wc-01-web8 i need populate file called "even" , "odds." if we're dealing numbers can figure out, having number within string throwing me off. example code i'm missing part need match string. if [ $even_servers -eq 0 ] echo $line >> evenfile else echo $line >> oddfile fi this simple awk command: awk '/[02468]$/{print > "evenfile"}; /[13579]$/{print > "oddfile"}' input.txt there must better way.

c++ - Inserting elements into 2D vector -

so i'm creating class implements adjacency list. in class definition initialized 2 vectors: vector<vector<int>> adjlist; vector<int> neighbors; and declared 2 functions plan use make it: bool constructadjlist(); bool insertintoadjlist(int, int); it's getting difficult wrapping head around 2d vectors. understand vector of vectors, i'm confused how insert new value 1 of "subvectors". example, able create adjacency list in createadjlist empty following loop: for (int = 0; < numofvalues; i++){ neighbors.push_back(0); adjlist.push_back(neighbors); neighbors.clear(); } but how can say, push_back value 5 4th vector in adjlist, represented in insertintoadjlist function insertintoadjlist(4, 5); i know can access specific value in 2d vector saying adjlist[4][1], how can push 1 onto it? thanks! to push on vector element of vector, this adjlist[x].push_back();

javascript - automated file upload selenium ide 2.8 on mac -

i experiencing problem executing automated uploading of file onto website. i'm using selenium ide version 2.8 via firefox 31 on mac test process of web system through browser in work. @ 1 point of process requires me upload excel file. i have searched many forums , blogs solution work on macos x firefox selenium ide none helped. in script, have: command : click target : name=... value : this line click on button have text word 'select file' , 'file upload' dialog window pop out me select file want download command : type target : driver.findelement(by.id("file upload")) value : /users/...../excel.xlsx this line supposed find element id path in 'file upload' , select path of file stated me in value column. problem occured: [error] element driver.findelement(by.id("file upload")) not found as far understand, im not sure if correct read , understand, works others wont work me. missing something? for part:

java - How is constructor chosen in spring for beans defined in xml with parent? -

i working spring 3.1.0. trying understand way spring reading xml files. trying understand how spring deals ambiguous conditions in bean definitions. for example i have alarm.java package com.anshbansal.alarm2; public class alarm { private string type; private int volume; private int hour; public alarm() { } public alarm(string type, int volume, int hour) { this.type = type; this.volume = volume; this.hour = hour; } public alarm(string type, int volume) { this.type = type; this.volume = volume; } public alarm(int volume, string type) { this.type = type; this.volume = volume; } public void settype(string type) { this.type = type; } public void setvolume(int volume) { this.volume = volume; } public void sethour(int hour) { this.hour = hour; } @override public string tostring() { return "alarm{" +

xml - Splitting tables in SQL Server 2008 -

we developing online advert site people buy , sell (similar gumtree) difference being used employees work company, wont reachable people outside company. now have 15 categories have sub categories , sub categories have child categories. we have main table called adverts consists on itemid, title, subtitle, description, createdby, broughtby, startdate, enddate , parentcategoryid, subcategoryid , childcategoryid etc now instead of having 1 massive tables consists of details item selling going create separate table(s) per category details of item. so have advert.vehicle_spec have details car selling i.e itemid (which fk main advert table), make, model, colour, mot, tax etc that way when query main table advert can join onto relevant spec table in way keep tables clean , tidy question approach? there performance issues approach? create relevant fk needed queries etc. i did ask question on sql server forum , 1 individual suggested using xml - each category gets xml schema ,

Sending a file over TCP sockets in Python -

Image
i've been able copy file contents (image) new file. when try same thing on tcp sockets i'm facing issues. server loop not exiting. client loop exits when reaches eof, server unable recognize eof. here's code: server import socket # import socket module s = socket.socket() # create socket object host = socket.gethostname() # local machine name port = 12345 # reserve port service. s.bind((host, port)) # bind port f = open('torecv.png','wb') s.listen(5) # wait client connection. while true: c, addr = s.accept() # establish connection client. print 'got connection from', addr print "receiving..." l = c.recv(1024) while (l): print "receiving..." f.write(l) l = c.recv(1024) f.close() print "done receiving" c.send('thank connecting') c.close() # close connection client

How to find all overlapping phrases between two strings, in Java? -

assume have 2 strings i chicken salad, it's favorite food. this book contains tons of recipes on making sorts of food, including cakes, chicken salad, etc. here overlapping phrases between 2 strings - chicken, salad, chicken salad, food. what's best way find overlapping phrases between 2 strings? assume both syntax , semantics clean, , first 1 quite shorter second one. i tried approach. seems suffice need of salad, chicken, chicken salad, food overlapping phrases. public static void main(string a[]) throws ioexception{ string firstsentence = "i chicken salad, it's favorite food"; string secondsentence = "this book contains tons of recipes on making sorts of food, including cakes, chicken salad, etc"; string[] firstsentencewords = firstsentence.replaceall("[.,]", "").split(" "); set<string> overlappingphrases = new hashset<string>(); string lastphrase = ""

powershell - How to launch multiple instances of cmd prompt -

i launch multiple instances of program called biospwd.exe . i use program typing following cmd prompt: biospwd.exe someinputfile.txt anotherinputfile.txt i following: for ($i = 0; $i -lt 4; $i++) { biospwd.exe someinputfile$i.txt anotherinputfile$i.txt } to run multiple instances of program someinputfile1.txt etc. launches program within powershell ise. i'd launch multiple instances of cmd biospwd.exe program running in each one. something this? 1..4 | % { cmd /c "biospwd.exe someinputfile$($_).txt anotherinputfile$($_).txt" } edit: think above running 1 instance @ time. try start-process instead: 1..4 | % { start-process -filepath "cmd" -argumentlist "/c biospwd.exe someinputfile$($_).txt anotherinputfile$($_).txt" }

r - devtools::document() seems not to work -

devtools not building .rd files in man directory. git clone https://github.com/az0/mlmeta cd mlmeta rscript -e 'require(devtools);devtools::document()' this gives > require(devtools);document('mlmeta') loading required package: devtools updating mlmeta documentation loading mlmeta first time using roxygen2 4.0. upgrading automatically... devtools 1.6.1 (latest cran), r 3.0.2, ubuntu 14.04

ios - How to cancel NSURLSessionDownloadTask with AFURLSessionManager? -

i wanna download pictures afurlsessionmanager in method @selector(collectionaction) : nsurlsessionconfiguration *configuration = [nsurlsessionconfiguration defaultsessionconfiguration]; afurlsessionmanager *manager = [[afurlsessionmanager alloc] initwithsessionconfiguration:configuration]; (int = 0; < _collectionarr.count; ++i) { nsurl *url = [nsurl urlwithstring:url_address(portnumber,_collectionarr[i])]; nsurlrequest *request = [nsurlrequest requestwithurl:url]; nsurlsessiondownloadtask *downloadtask = [manager downloadtaskwithrequest:request progress:nil destination:^nsurl *(nsurl *targetpath, nsurlresponse *response) { nsurl *documentsdirectoryurl = [[nsfilemanager defaultmanager] urlfordirectory:nsdocumentdirectory indomain:nsuserdomainmask appropriateforurl:nil create:no error:nil]; return [documentsdirectoryurl urlbyappendingpathcomponent:[response suggestedfilename]]; } completionhandler:^(nsurlresponse *response, nsurl *filepath, ns

regex - Regular expression in angular gives unmatched parenthesis error -

i trying validate email in angular using regular expression pattern http://www.regular-expressions.info/email.html follows: input.form-control(type="email", placeholder="email", name="email", ng-model='doctor.email', ng-pattern='[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?') which gives error: error: /home/pravin/zyoba/nimbus/nimbus-web/views/adddoc.jade:50 48| .form-group.clearfix 49| .col-xs-7 > 50| input.form-control(type="email", placeholder="email", name="email", ng-model='doctor.email', ng-pattern='[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?') 51| span.font-red.font-23 *

django - Why is the Prefetch object being ignored in prefetch_related? -

using django 1.7: my queryset looks this: return super(employeeviewset, self).get_queryset()\ .filter(status__deleted_flag=false, **filter_kwargs)\ .prefetch_related('phone_number_set', 'email_address_set', 'street_address_set', prefetch('file_set', employeefile.objects.active().select_related('content_type')))\ .order_by('last_name', 'first_name') djdt shows prefetch query executed select ••• "employees_employeefile" inner join "employees_employeefiletype" on ("employees_employeefile"."content_type_id" = "employees_employeefiletype"."id" ) ("employees_employeefile"."deleted_at" null , "employees_employeefile"."owner_id" in (53, 81, ...)) order "employees_employeefile"."created_at" desc then djdt shows each employee getting

mysql - phpbb 3 SQL delete user and all posts -

i want mass remove spam users forum's database. if have uid of account, sql query script delete user , posts option in acp. ssh easier me login. deleting users directly database asking trouble leave sorts of remnants in tables other user table. your best bet if know user names/id's use 'prune users' function in acp under 'users , groups' tab.

c# - XAML custom collection binding async collection update -

i have custom class inheriting observablecollection , inotifypropertychanged (i.e. custom class has properties) serves collection<t> t also inherits inotifypropertychanged : public class customcollection<t> : observablecollection<t>, inotifypropertychanged t: inotifypropertychanged { private string _name; public string name { { return _name; } set { if (_name != value) { _name = value; notifypropertychanged("name"); } } } private int _total; public int total { { return _total; } set { if (_total != value) { _total = value; notifypropertychanged("total"); } } } public event propertychangedeventhandler propertychanged; private void notifypropertychanged(string propertyname) { propertychangedeventhandler handler = propertychanged; if (null != handler) { handler(this, new propertychangedeventargs(p

sql - Sum IF Query for Multiple Tables -

i have table every month has column need add. need make query show in 1 table. first thing did union tables unique countries. how configure ms access query started produce output need? example tables: table 1: january 2014 | country | headcount | | usa | 100 | | china | 50 | | russia | 75 | | usa | 10 | table 2: february 2014 | country | headcount | | usa | 100 | | china | 50 | | mexico | 100 | | china | 75 | table 3: countries | country | | usa | | china | | mexico | | russia | desired output: | country | january | february | | usa | 110 | 100 | | china | 50 | 125 | | russia | 75 | 0 | | mexico | 0 | 100 | this query far doesn't seem work.. select a.[country] country, sum(iif(a.[country] = b.[country], b.[headcount],0)) january sum(iif(a.[country] = c.[country], c.[headcount],0)) febru

visual c++ - to capture the buffer of a microphone -

i creating program record microphone audio , convert mp3 using directshow api in visual c++. there no built in filter convert convert audio mpeg layer 3 i.e. mp3 want send mic buffer external library called lame , convert data in mp3 , can write file using file writer. problem dont know how access buffer of microphone , please me new in directshow programming.. or tell me other way it if want distribute application suggest use sample grabber instead of lame directshow encoder filter. avoid filter registration need handle conversion logic. regarding using lame encoder, what return value of hr = poutputdevice->findpin(). you can give try using graphedit , check pin properties.

php - MYSQL- Displaying data while looping through week ending dates -

for past month of so, have been creating benchmark system allows users add categories & benchmarkitems retain data every week within specific year. having trouble creating mysql statement shows each benchmarkitem results weeks within yr if week there no data or no data year. below queries have been testing , table columns. using codeigniter , plan display results in format mapped out @ bottom. apologize lengthy description attempting clear possible. appreciated. tblbenchmarkitem ================= itemid | itemdescription | itemtarget | itemfreq | fkcategoryid tblbenchmarkdata ================ dataid | fkitemid | resultdate | result | dateadded | datemodified tblcategories =============== categoryid | categoryname | parentid | fkdeptid tblcalendardates - stores 52 weeks year saturday friday ================ id | year | startdate | enddate these mysql statements in model. going set default value in function param year. public function get_data() { $dates = $this->

Hive query - Join or Subquery -

i'm looking performant query. have got 2 tables: productviews(timecol timestamp, user_id string, product_id int, location_city string) productactions(timecol timestamp, user_id string, product_id int, location_city string, action string) action example shopping-cart insert. i need run query grouped location_city or product_id: select *, count(productviews), count(productactions), count(distinct user_id) xxx group xxx has idea?

c# - What benefits does dictionary initializers add over collection initializers? -

in recent past there has been lot of talk whats new in c# 6.0 1 of talked feature using dictionary initializers in c# 6.0 wait have been using collection initializers initialize collections , can initialize dictionary in .net 4.0 , .net 4.5 (don't know old version) like dictionary<int, string> mydict = new dictionary<int, string>() { { 1,"pankaj"}, { 2,"pankaj"}, { 3,"pankaj"} }; so there new in c# 6.0, dictionary initializer talking in c# 6.0 while could initialize dictionary collection initializers, it's quite cumbersome. that's supposed syntactic sugar. dictionary initializers cleaner: var mydict = new dictionary<int, string> { [1] = "pankaj", [2] = "pankaj", [3] = "pankaj" }; more importantly these initializers aren't dictionaries, can used any object supporting indexer , example list<t> : var array = new[] { 1, 2, 3 }; var list =

Android: How to make the text size of Borderless button same as that of TextView -

Image
in following 2 images, there 4 widgets in horizontal linear layout: a textview text results: a borderless button text my cat a view hack "vertical separator" a borderless button text my dog two questions: results: in first 1 bold because used <b> tag around in string resources file. used <strong> tag in second one, not make bold. i did read that strong has semantic meaning, may screen reader blind people read in different tone, blind people. but visually, should bold, isn't it? i want text in button s of same size textview . believe need text size of textview (or default size in android system? or "default size" on user's device? :s ) in sp ( because sp scaled user's font preference) and set text size of button same that? how can that ? can in xml? or possible programatically? , how? use android:textstyle="bold" bold text , android:textsize="12sp" change text size of button

cypher - Neo4J query to join multiple matches to return results -

when run query below query 1 producing result returning categories label document documents. note document can have multiple categories hence collecting them in on go. start doc = node:entities(type = "document-link") match category-[:category]-doc<-[:`document-link`]-id return doc.title title, collect(coalesce(category.category, "")) categories query 2 producing result returning language of document documents. document can have 1 language type. start doc = node:entities(type = "document-link") match lan-[:language]-doc<-[:`document-link`]-id return doc.title title, lan.language language query 3 join of 1 , 2 producing empty result. can highlight doing wrong? start doc = node:entities(type = "document-link") match category-[:category]-lan-[:language]-doc<-[:`document-link`]-id return doc.title title, lan.language language, collect(coalesce(category.category, "")) categories in t

How Can I Compare and Hold Some Value : SQL SERVER 2008 R2 -

Image
i have table looks this: item | date | price | new_price | reduction | pencil | 01/10/14 | 25 | 21 | 4 | pencil | 01/12/14 | 21 | 21 | 0 | pencil | 01/30/14 | 21 | 21 | 0 | pencil | 02/05/14 | 21 | 18 | 3 | pencil | 02/17/14 | 18 | 18 | 0 | pencil | 03/20/14 | 18 | 18 | 0 | pencil | 06/08/14 | 18 | 16 | 2 | pencil | 07/14/14 | 16 | 16 | 0 | pencil | 07/28/14 | 16 | 16 | 0 | how can select can result this: item | date | price | new_price | reduction | reduction_hold | pencil | 01/10/14 | 25 | 21 | 4 | 4 | pencil | 01/12/14 | 21 | 21 | 0 | 4 | pencil | 01/30/14 | 21 | 21 | 0 | 4 | pencil | 02/05/14 | 21 | 18 | 3 | 3 | pencil | 02/17/14 |

Unable to find out reason of error Cross-thread operation not valid from C++ callback to C# -

i'm going implement mvc structure of delegate same in objective-c. functionality bluetooth device return me signal grab in c++ callback , signal message going forward callback of c# lambda function. got following error, cross-thread operation not valid: control 'label1' accessed thread other thread created on. my c# code form1.cs, [unmanagedfunctionpointer(callingconvention.stdcall)] delegate void progresscallback(char thevalue); private void button1_click(object sender, eventargs e) { if (nclwrapper.isnclinitialized()) { nclwrapper.callncldiscovery(); label1.text = nclwrapper.getledpattern(); progresscallback callback = (thevalue) => { //crash here when going assign value lable. this.label1.text = thevalue.tostring(); console.writeline("progress = {0}", t

stdatomic - Accessing uninitialized atomic private variable in c++ -

supposed have following class: class { public: ... ... void incrementn() {++n_;} uint64_t getn() {return n_;} private: std::atomic<uint64_t> n_; ... ... }; assume initialize other variables in class, except n_ , not thread local storage, there no 0 initialization. i create object of class a, , keep calling incrementn() . if @ point want value of n_ , , call getn() , can cause load() routine atomic n_ crash? the load uses memory_order_seq_cst default. see here: http://en.cppreference.com/w/cpp/atomic/memory_order . as mentioned in comments, shouldn't give problems normal ints won't give. concerned overflow if uninitialised initial value large? see here possible consequences: https://www.owasp.org/index.php/integer_overflow

host - How to migrate mysql from localhost to IP address -

i running mysql in localhost under port number 3306. want access mysql database remotely. system has ip address , want use instead of localhost. can please tell me how can achieve one. have written code for accessing remote database. there error?? if need access database remotely need following . mysql :- mysql> grant on *.* root@'localhost' identified 'your-root-password'; mysql> flush privileges; this grant users access database remotely.

javascript - how to activate dropzone on icon click -

i using image . activate dropzone image select box on image click. when user click on <i class="fa fa-image" id="dzopen"></i> user can select file browsing , uploading image preview should display on <div id="media-upload-previews"></div> <i class="fa fa-image" id="dzopen"></i> <div id="media-upload-previews"> </div> <script> dropzone.options.myawesomedropzone = { paramname: "file", maxfilesize: 10, url: 'uploadimages', previewscontainer: "#media-upload-previews", uploadmultiple: true, paralleluploads: 5, maxfiles: 20 } </script> you can wrapp code in jquery click event $(document).on("click", "#dzopen", function(){ //initilize dropzone here . });

c# - WCF Service IIS to build user logged services for external clients -

i'm starting in .net , wcf services, sorry if i'm asking wrong or has nosense. way, sorry english too. i'm trying build several wcf services hosted on iis internet clients can login username / password (info stored in db). when logged, can access info, see private documents, change profile , more actions related account. well, in asp.net if session after success login, can build services "getmydocs" , know "who is", checking session username stored session id when calls login , session don't timed-out. i've noticed wcf services stateless, seems have send in requests username / pwd , check them in db before executing service... always!? later, if want build client desktop / android / ios application, use services. can manage personal , private data through apps after success login. how should handle this? wcf services way go or wcf aren't choice that? how can handle user identification wcf? because services linked user , "ge

php - Redirect loop when using Yii ip access rule -

using yii 1.1.15 . want restrict login , logout actions ip rule. have inside controller: public function accessrules() { return [ [ 'allow', 'actions' => ['index', 'error'], 'users' => ['*'], ], [ 'allow', 'actions' => ['login'], 'users' => ['*'], 'ips' => ['xx.yy.zz.qq'], ], [ 'allow', 'actions' => ['logout'], 'users' => ['@'], 'ips' => ['xx.yy.zz.qq'], ], [ 'deny', // deny users 'users' => ['*'], ], ]; } but when call login action in browser, browser enters redirect loop. if comment out ips rule, works. what wrong above code? this ha

java - Access JFileChooser's TextField to validate path -

is there way access textfield of jfilechooser add event listener? the idea add event listener text field checks path correctness. note file filter not option, since user must able select folders. futhermore, can't filter folders because user must able navigate folder hierarchy. activating , deactivating open button discussed here not valid solution since selection validated when user clicks folder. however, user may enter path directly text field.

javascript - jquery bound event doesn't fire on mobile phones -

heyho, want bind event html tablerow. seems work on common desktop browsers not on mobile phone browsers. tested on iphone 6 , android devices. here's related fiddle , , code: $("body").on("click", "tr", function(){ //do }) i can't use click event on tablerow (which seems work) because table generated after pageload. input. i found solution: adding cursor: pointer; css style tablerow fix problem. don't understand why, because don't have cursor on mobile devices works, what. $("body").on("click", "tr.prim", function(){ $(".sec").fadetoggle(); }) .sec { display: none; } .prim { cursor: pointer; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> <table border="1" cellspacing="0" cellpadding="0" width="300"> <tr height=&quo

process - Background Processes out-living gradle build -

i using gradle-processes manage set of long running services. i basing tasks on javafork, , using main class classpath , arguments. this how looks like: project.procs.javafork { main = "startapp" environment += ["classpath": project.ext.localcp] } on osx, , linux works expectations, on windows, forked processes dying on me after gradle build finished , gradle process exited. :startmainapp build successful total time: 1 mins 53.635 secs c:\projects\git\development\master> any idea ? or settings need set avoid separate process terminated when gradle exists ? as work around using different fork: if (os.isfamily(os.family_windows)) { project.procs.fork { commandline 'cmd', '/c','java.exe com.me.startapp" environment += ["classpath": project.ext.localcp] } } else { project.procs.javafork { main = "com.me.startapp" environment

jquery - window resize function only one time for specific window size -

hi need if window less 768px alert , if window more 768px alert some, have script , else if(){} not work when window size more 768px p.s. need heppend when window less 768px or more 768px var = 0; $(window).resize(function(){ if(width < 768 && == 0){ alert('less 768px'); i++; alert(i); }else if(width > 768){ alert('more 768px'); i==0; } }); instead of i==0; should i=0; inside else if() because assigning value 0 i . although don't know why using i complete code should :- var = 0; $(window).resize(function(){ if(width < 768 && == 0){ alert('less 768px'); = 1; }else if(width > 768 && == 1){ alert('more 768px'); = 0; } });

Android JSON Parsing from URL -

i'm trying json project in android. code. for reason data isn't displayed in textbox runs. i'm not sure made wrong. this url trying grab data: http://cocoalabs.in/demo/ego/index.php/home/read_all_users am trying grab 4 strings , display them textviews this code: mainactivity.java public class mainactivity extends activity { static string cocoainfo="http://cocoalabs.in/demo/ego/index.php/home/read_all_users"; static string clfname = ""; static string cllname = ""; static string cllocation = ""; static string clph1 = ""; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); //to perform background tasks, grabbing info website , write gui new myasynctask().execute(); } public class myasynctask extends asynctask<string, string, string> { @override protected string doinbackground(string... strin

c# - Out of Memory Exception when loading large number of images through a file picker -

windows phone 8.1: foreach (storagefile file in imagefiles) { classforfolderimages cffi = new classforfolderimages(); using(var stream = await file.openasync(windows.storage.fileaccessmode.read)) { var bitmapimage = new windows.ui.xaml.media.imaging.bitmapimage(); bitmapimage.decodepixelwidth = 80; bitmapimage.decodepixelheight = 80; await bitmapimage.setsourceasync(stream); cffi.imageforfolder = bitmapimage; gridviewname.add(cffi); } } in above snippet "imagefiles" contains large number of images , "gridviewname" name of observable collection later bind grid view wish display these images. classforfolderimages class below: public class classforfolderimages : inotifypropertychanged { public event propertychangedeventhandler propertychanged; private bitmapi

c++ - Compare and exchange weak an atomic variable -

i have code (updated correct union-struct ordering): union { struct { short b; short c; }; std::atomic<int> d; } and want swap both b , c (hence atomic d) value zero, using compare_exchange_weak() . have this: a a; . . . std::atomic<int32_t> x = a.d.load(std::memory_order_relaxed); int32_t valtoreplace = 0; return a.d.compare_exchange_weak(valtoreplace, x, std::memory_order_release, std::memory_order_relaxed); how do this? argument compare_exchange_weak(), x , cannot atomic- confused? the local variable x shouldn't atomic. there's no reason be, , can't used argument compare_exchange_weak , expects regular value. i won't comment on whatever you're trying union, since makes no sense me.

sql server - Create Script of database with SQL query -

i have purchased space online on godaddy on sql database stored want copy database local pc cannot take backup of sql database giving error @ taking backup , cannot create script too. so, have idea how create script of database sql query? error : index out of bound array use databasename; go backup database databasename disk = 'c:\sqlserverbackups\databasename.bak' format, medianame = 'c_sqlserverbackups', name = 'full backup of databasename'; go

winforms - Adding a scroll bar to MS Chart control C# -

Image
please understand know there other threads concerning issue, needs different. basically before seen people saying implement scroll bar mschart use .size = ... or .view = ... but, make scroll bar automatically apprear, , scroll bar contains button when clicked causes bar vanish, making chart show data, , no way of bringing scroll bar chart without restarting app. so ask, please, there way incorportate horizontal scroll bar on x-axis of chart? needing on can view chart data on blocks of 100 second blocks. i.e. 0 - 100, click sroll bar bring me 100 - 200 block. thank in advance guys!!!!! im coding in c# also here's example of need: (to try it, create form, add mschart , call following method) private void fillchart() { int blocksize = 100; // generates random data (i.e. 30 * blocksize random numbers) random rand = new random(); var valuesarray = enumerable.range(0, blocksize * 30).select(x => rand.next(1, 10)).toarray(); // cle

.net - How to tell TFS not to conflict for non-checked out files? -

i writing code on big project 200 developers write code on. when apply "get latest" solution, many conflicts appear on local. how can tell tfs not conflict items did not check-out. because files belong modules not interested in , apply "overwrite local file or folder" them. thank you, if files checked out i'd suggest undo changes on files aren't interested in before execute latest operation. however since they're not checked out, yet still changed (which don't quite follow) maybe try shelving changes are interested in, reset entire workspace overwriting changes, , reapply shelveset. p.s. still don't understand why you're changing .cs files you're not interested in, that's separate matter.

mysql - Mysql2::Error: Deadlock found when trying to get lock; try restarting transaction: INSERT INTO -

recently, found lots of deadlock errors in application. mysql2::error: deadlock found when trying lock; try restarting transaction: insert `products`.... the code below: after user has been created, add products user. don't understand why deadlock happened. class user < activerecord::base after_create :add_products has_many :products, :dependent => :destroy def self.create_user user.create!(.......) end def add_products product.add(self, "product_name", 10) end ..... end class product < activerecord::base belongs_to :user def self.add(user, product_name, amount) transaction product = user.products.find_by_product_name(product_name) if product product.increment :amount, amount product.save! else product = self.create! user_id: user.id, product_name: product_name,

javascript - Drag & Drop Magazine Builder -

how can create website builder? want make drag & drop site builder , researching tools. don't know tools necessary that. want make www.joomag.com which tool should use ? html5 provides functionality of drag , drop, need know javascript it. plus making designs need css(possibly css3). save result , generate code, you'll need server side language.