Posts

Showing posts from September, 2011

sql - MySQL: Avoid filesort when using ORDER BY -

create table table1 ( `id` bigint(20) not null auto_increment, `kid` int(10) unsigned not null, `table_group` varchar(100) collate utf8_bin not null) engine=innodb; i got index on following column; primary key (`id`) key `index1` (`kid`,`table_group`); the table has 5million rows matching clause; when explain on below query doing filesort , runtime limit take 10seconds high. mysql> explain select * db1.table1 force index(index1) kid=187 , table_group in ('not_present', 'nothing', 'perror') order id limit 200\g *************************** 1. row *************************** id: 1 select_type: simple table: tabl1 type: range possible_keys: index1 key: index1 key_len: 306 ref: null rows: 1052764 extra: using index condition; using filesort i want avoid filesort; please help

c - qsort() performance issue -

i'm sorting array of structs, each struct contains char string. problem however, struct array of approx. 900,000 elements, qsort taking alot longer expect (qsort takes 2 mins sort array); leading me think there overlooking here. sorting trivial part of assignment working on, , alone on passes time limit have program. below relevant parts of code: struct wordsarray //just struct thath holds *char { char word[25]; }; compare function passed qsort: int cmpfunc(const void *a, const void *b) { const struct wordsarray *a1; a1 = (wordsarray*)malloc(sizeof(wordsarray)); const struct wordsarray *b1; b1 = (wordsarray*)malloc(sizeof(wordsarray)); a1 = (struct wordsarray*)a; b1 = (struct wordsarray*)b; return strcmp(a1->word, b1->word); } my call qsort: wordsarray *allwordsarray; allwordslist = (wordsarray*)malloc(sizeof(wordsarray)*listsize); qsort(allwordslist->word, listsize, sizeof(struct wordsarray), cmpfunc); thanks input. ...

sql - Mysql group by that counts have different logic -

i have table 3 fields:. field1 - field2 - field3 field1 id; field2 date; field3 has 2 possible values ("ac" , "re"). i need know if possible have query group by give me results shown @ end: select field2 , count(total per date) , count(where field3 = "re") mytable group 1; if table is: field1 - field2 - field3 ========================= item1 - date1 - "ac" item2 - date1 - "re" item3 - date1 - "re" item4 - date2 - "re" item5 - date2 - "ac" item6 - date3 - "ac" the result like: - date1 - 3 - 2 - date2 - 2 - 1 - date3 - 1 - 0 select field2, count(*), sum(case when field3='re' 1 else 0 end) re_count table1 group field2

build.gradle - How to refer or link the Java src with test structure in Gradle -

Image
i'm new gradle i'm facing problem while compiling test classes i'm referring java classes in test classes test program couldn't compile. problem wouldn't understand how link or refer java src structure test structure. me how resolve issues. below provided screenshot of src , test package structure , compilation problem. java src , test structure compilation error build.properties apply plugin: 'java' sourcecompatibility = '1.7' [compilejava, compiletestjava]*.options*.encoding = 'utf-8' // netbeans automatically add "run" , "debug" tasks relying on // "mainclass" property. may define property prior executing // tasks passing "-pmainclass=<qualified_class_name>" argument. // // note however, may define own "run" , "debug" task if // prefer. in case netbeans not add these tasks may rely on // own implementation. if (!hasproperty('mainclass')) { ext...

c++ - How to delete botched symbolic links in the registry -

i'm prototyping edits registry create symbolic link 1 area another. i've used following code: hkey hkfs; hkey hksoftware; dword dwdisposition; lstatus result; result = regopenkeyex(hkey_local_machine, _t("software"), 0, key_create_sub_key , &hksoftware); if (result == 0) { result = regopenkeyex(hksoftware, _t("mykey"), reg_option_open_link, key_write | key_create_link | key_wow64_64key, &hkfs); if (result != error_success) { _tprintf(_t("%d\n"), result); result = regcreatekeyex(hksoftware, _t("mykey"), 0, null, reg_option_create_link, key_write | key_create_link | key_wow64_64key, null, &hkfs, &dwdisposition); _tprintf(_t("%d\n"), result); } if (result == error_success) { //result = zwdeletekey(hkfs); tchar target[] = _t("hkey_local_machine\\software\\wow6432node\\mykey"); result = reg...

.net - Display and saving images with WPF -

i decided port winform project wpf encounter problem: software has user space. normally, image selected via openfiledialog, image both stored , used control "image" (roundpb in code). but, winform code not work in wpf because properties not same picturebox "image". here current nonfunctional code : private sub button_click(sender object, e routedeventargs) dim openfiledialog2 new microsoft.win32.openfiledialog() dim imagepath string = nothing if openfiledialog2.showdialog() = vbok imagepath = openfiledialog2.filename my.computer.filesystem.copyfile(imagepath, imagerep & system.environment.getenvironmentvariable("programfiles") & "\mts\profpic.png", overwrite:=true) else : exit sub : end if if roundpb isnot nothing roundpb.source.freeze() roundpb.source = new bitmapimage(new uri(imagepath, urikind.relative)) end sub private sub metrowindow_loaded(sender object, e routedeventargs) if my.comp...

python - 'Font not defined' in Tkinter application freezed by cx_Freeze -

i have freezed tkinter-using gui python 3.4 app cx_freeze , when tried run it, presented following error: nameerror: name 'font' not defined. when remove references font code (i. e., if don't set ttk label fonts anywhere in code), works fine , exe runs nicely. have checked library.zip archive created freeze script , contain font.pyc file in tkinter directory. setup.py file looks like: import cx_freeze import sys import tkinter base = none if sys.platform == 'win32': base = "win32gui" executables = [cx_freeze.executable("rocnikovka.py", base=base)] cx_freeze.setup( name = "number evolution", options = {"build_exe": {"packages":["tkinter", "tkinter.font"], "includes": ["tkinter", "tkinter.font"]}}, version = "0.01", description = "rocnikovka", executables = executables ) any appreciated. update: have tri...

android - NoClassDefFoundError: Failed resolution of: Lorg/apache/http/conn/ssl/DefaultHostnameVerifier; -

i'm trying use exchange web services java api in office365 android app i'm making, keep getting error. relevant stack information below: caused by: java.lang.noclassdeffounderror: failed resolution of: lorg/apache/http/conn/ssl/defaulthostnameverifier; @ microsoft.exchange.webservices.data.core.ewssslprotocolsocketfactory.<clinit>(ewssslprotocolsocketfactory.java:86) @ microsoft.exchange.webservices.data.core.exchangeservicebase.createconnectionsocketfactoryregistry(exchangeservicebase.java:212) @ microsoft.exchange.webservices.data.core.exchangeservicebase.initializehttpclient(exchangeservicebase.java:194) @ microsoft.exchange.webservices.data.core.exchangeservicebase.<init>(exchangeservicebase.java:170) @ microsoft.exchange.webservices.data.core.exchangeservice.<init>(exchangeservice.java:3779) @ com.microsoft.office365.connect.sendmailactivity.onbookmeetingbutton1(sendmailactivity.java:140) ... ...

android - sending location to google map with latitude and longitude -

this how getting current location. question is there way make latitude , longitude link user can click , there current position shown on googlemap . because sending link via text message android , when clicks on link google map install in mobile open or googlemap website open , location lang , lat shown on map. don't know how achieve ? public void onlocationchanged(location location) { mlocationview.settext("location received: "+ location.getlatitude() + location.getlongitude()); for simple url constructed can add sms message, this: string link = "http://maps.google.com/maps?q=loc:" + string.format("%f,%f", location.getlatitude() , location.getlongitude() ); for example, code: double lat = 37.77657; double lon = -122.417506; string link = "http://maps.google.com/maps?q=loc:" + string.format("%f,%f", lat, lon); constructs link this: http://maps.google.com/maps?q=loc:37.776570,-122.417506 f...

AngularJS check if checkbox is unchecked -

i trying show/hide , adjust ng-required status if checkbox checked, doesn't seem managing variables properly. here examples: <input type="checkbox" ng-model="checkboxdmodel.value" ng-true-value="'yes'" ng-false-value="'no'"> input want required unless checkbox checked in case should hidden , not required: <div class="form-group" ng-hide="checked.yes"> <label class="col-sm-3 control-label" for="inputamount"> <font color="red">*</font>expense amount</label> <div class="col-sm-8"> <input type="number" class="form-control" id="inputamount" data-ng-model="itemamount" step="any" ng-required="checked.no"/> </div> </div> http://plnkr.co/edit...

android - Parse JSON file with Gson -

i have method gets strongest wifi acces points signal, avialabe , returns ssid string, these ssid strings stored in raw folder in json file: how can access file in raw folder , parse gson example route_number 6 if ssid "fr wlan" is? ssid_number json file: { "data": [ { "ssid": "kd privat", "route_number": 1 }, { "ssid": "kd wlan hotspot", "route_number": 4 }, { "ssid": "fr wlan", "route_number": 6 } ] } wifijson class: public class wifijson { private string ssid; private int route_number; public wifijson(string ssid, int route_number) { this.ssid = ssid; this.route_number = route_number; } private string getssid() { return ssid; } private void setssid(string ...

ruby - How to retrieve values from a rect html tag using watir -

is there way retrieve values rect tag using watir. can give example url. there rectangular bars on lower part of page. please find it http://www.healthgrades.com/hospital-directory/california-ca-los-angeles/good-samaritan-hospital-hgste2618d46050471?#readmission i have seen couple of sources have not got way details. can 1 me here? yes, can access generic element (example only, not applicable code). data element looking highcharts-data-labels. values = browser.element(:css => "g.highcharts-data-labels") you access element using xpath selector , can in chrome inspecting element , asking xpath selector //*[@id="highcharts-2"]/svg/g[4]/g[2]/text good luck!

java - Maven project for Spring MVC Deploying in GlassFish Error(s) -

i have spring mvc web app created maven project. try deploy/run in glassfish, , receive following error(s). the error(s) below: cannot deploy springmvcjdbctemplate deploy failing=error occurred during deployment: exception while loading app : java.lang.illegalstateexception: containerbase.addchild: start: org.apache.catalina.lifecycleexception: org.apache.catalina.lifecycleexception: java.lang.classnotfoundexception: com.microsoft.sqlserver.jdbc.sqlserverdriver. please see server.log more details. below have in 'pom.xml' file: <dependencies> <dependency> <groupid>aopalliance</groupid> <artifactid>aopalliance</artifactid> <version>1.0</version> </dependency> <dependency> <groupid>com.microsoft.sqlserver</groupid> <artifactid>sqljdbc4</artifactid> <version>4.0</version> <scope>runt...

javascript - AJAX Predictive Search -

i have basic html form want fill in names of states. have of 50 of them (alabama wyoming) stored in following format: <?xml version="1.0"?> <states xml:lang="en"> <item> <label>alabama</label> <value>al</value> </item> <item> <label>alaska</label> <value>ak</value> </item> ... i wrote ajax this: function ajaxfunction(str) { if (str.length==0) { document.getelementbyid("search").innerhtml=""; document.getelementbyid("search").style.border="0px"; return; } var ajaxrequest = new xmlhttprequest(); ajaxrequest.onreadystatechange = function() { if (ajaxrequest.readystate==4 && ajaxrequest.status==200) { document.getelementbyid("search").innerhtml=ajaxrequest.responsetext; document.getelementbyid("search").style.border="1px solid #a5acb2"; } } ajaxrequest.open...

ember.js - How to import non amd library ember-cli -

i using ember-cli , faced problem of importing amplifyjs in project. downloaded amplify using bower library not in es6 format. therefore, when try use in project, can't import it. basically want do: import amplify amplify; //use amplify here brocfile.js app.import('bower_components/amplify/lib/amplify.js'); since lot of libraries no in es6 format yet, question is: "is there way import or use es5 librairies in es6". if not, recommended way of doing in ember? you can't import amplify amplify; because it's not module. you've got don't try import library. need reference global way outside of ember-cli app. from docs: provide asset path first , argument: app.import('bower_components/moment/moment.js'); from here use package specified it’s documentation, global variable. in case be: import ember 'ember'; /* global moment */ // no import moment, it's global called `moment` // ... var day =...

java - Execution of static methods from native c code -

i have call static java methods c. some-c-code (*g_env)->callstaticvoidmethoda(g_env, g_obj, g_mid, val); some-c-code (*g_env)->callstaticvoidmethoda(g_env, g_obj, g_mid, val); some-c-code (*g_env)->callstaticvoidmethoda(g_env, g_obj, g_mid, val); some-c-code i have call java methods several times @ different places. code executes java methods first , comes executing native code. please tell me how can run code in execution sequence required ? p.s. i've cached jvm, jobject , jmethod , attaching them current thread using attachcurrentthread , detachcurrentthread

machine learning - SVM-Light displays corrupted precision/recall results -

i run svm-light classifier recall/precision row outputs seem corrupted: reading model...ok. (20 support vectors read) classifying test examples..100..200..done runtime (without io) in cpu-seconds: 0.00 accuracy on test set: 95.50% (191 correct, 9 incorrect, 200 total) precision/recall on test set: 0.00%/0.00% what should configure valid precision , recall? for example, if classifier predicting "-1" -- negative class; test dataset, however, contains 191 "-1" , 9 "+1" golden labels, 191 of them correctly classified , 9 of them incorrect. true positives : 0 (tp) true negatives : 191 (tn) false negatives: 9 (fn) false positives: 0 (fp) thus: tp 0 precision = ----------- = --------- = undefined tp + fp 0 + 0 tp 0 recall = ----------- = --------- = 0 tp + fn 0 + 9 from formula above, know long tp zero, precision/reca...

html - Can't align thead and tbody in scrollable table -

Image
i have scrollable table isn't full, this: 2 things happening here: background disappears , th columns not aligned. i messing around demo found somewhere , read display: table-header-group aligns tbody header, problem here if use scroll stops working: here's have far: .scroll { /* optional */ /* border-collapse: collapse; */ border-spacing: 0; font-family: raleway; padding-top: 15px; padding-left: 15px; border-collapse: collapse; color: #005693; border-radius: 10px; font-size: 12px; text-align: center; } .scroll tbody, .scroll thead { display:block; } thead tr th { height: 30px; line-height: 30px; /* text-align: left; */ } .scroll tbody { height: 100px; overflow-y: auto; overflow-x: hidden; } .scroll tbody { border-top: 2px solid black; } .scroll tbody td, thead th { /* width: 20%; */ /* optional */ border-right: 1px solid black; /* white-s...

hibernate - error when including dependency within the plugin under execution in maven -

i have following pom.xml works if execute mvn goal mvn hibernate3:hbm2java directly. want make part of execution during generate-entity phase. have few dependencies included in plugin. here working pom. <plugins> <plugin> <groupid>org.codehaus.mojo</groupid> <artifactid>hibernate3-maven-plugin</artifactid> <version>2.2</version> <configuration> <components> <component> <name>hbm2java</name> <implementation>jdbcconfiguration</implementation> <outputdirectory>src/main/java</outputdirectory> </component> </components> <componentproperties> <revengfile>src/main/resources/reveng.xml</revengfile> <propertyfile>src/main/res...

linux - Register Variables in Loop in an Ansible Playbook -

i have 2 ansible tasks follows tasks: - shell: ifconfig -a | sed 's/[ \t].*//;/^\(lo\|\)$/d' register: var1 - debug: var=var1 - shell: ethtool -i {{ item }} | grep bus-info | cut -b 16-22 with_items: var1.stdout_lines register: var2 - debug: var=var2 which used list of interfaces in machine (linux) , bus address each. have 1 more task follows in tha same playbook - name: binding interfaces shell: echo {{ item.item }} with_flattened: var2.results register: var3 which expect iterate on value var2 , print bus numbers. var2.results follows "var2": { "changed": true, "msg": "all items completed", "results": [ { "changed": true, "cmd": "ethtool -i br0: | grep bus-info | cut -b 16-22", "delta": "0:00:00.005778", "end": "2015-04-14 20:29:47.122203", ...

dplyr - Canonical way to select columns in R -

i comparing common "tidying" operations in dplyr , in "plain r" (see output here , source here see mean). i have hard time finding "canonical" and concise way select columns using variable names (by canonical, mean, pure plain r , understandable minimum understanding of r (so no "voodoo trick")). example: ## subset: columns "var_1" "var_2" excluding "var_3" ## dplyr: table %>% select(var_1:var_2, -var_3) ## plain r: r <- sapply(c("var_1", "var_2", "var_3"), function(x) which(names(table)==x)) table[ ,setdiff(r[1]:r[2],r[3]) ] any suggestions improve plain r syntax? edit i implemented suggestions , compared performance on different syntaxes, , noticed use of match , subset lead surprising falls in performance: # plain r, v1 system.time(for (i in 1:100) { r <- sapply(c("size", "country"), function(x) which(names(cran_df)==x)) ...

c++ - Take input in array of bool -

i want take input in array of bool bool bmp[32]; and program interaction. enter binary number : 10101 i want store user input of '10101' in array of bool like. bmp[32]={1,0,1,0,1}; please help!! nothing fancy, read data , store array this: #include <string> #include <cstdio> int main() { std::string str; std::cout << "enter binary number : "; std::cin >> str; bool b[32]; std::size_t size = 0; (auto c : str) { b[size++] = c == '1'; } // set now. return 0; }

c++ - Qt/OO best practices: connecting signals and slots -

i'm relatively light on qt experience, though it. 1 thing i'm uncertain of best place connect signals slots. here's example small device touchscreen: i have class called radiomodel owned qapplication. qapplication owns call viewcontroller. viewcontroller owns view - i.e. of widgets make user interface. there hierarchy ui widgets, of course. top-level widget qhboxlayout, has indicator labels @ top, , qtabwidget @ bottom. qtabwidget has 3 screens, each things qlabels, qgroupboxes, qcomboboxes, etc. the model needs signaled when values in qgroupboxes , qcomboboxes change. initial thought have chain this: qradiobutton (part of qgroupbox) signals clicked(), goes slot of current tab of qtabwidget, looks @ sender determine value (which radio button) clicked, emits own signal radiochanged. radiochanged signal connected viewcontroller's radiochanged signal, in turn connected model's updateradio slot. generally speaking, when widget isolated model emits ...

c# - How to set custom thumbnail for video upload with dailymotion api -

how set custom thumbnail video upload dailymotion api. i'm using https://github.com/cbenard/sodailymotionupload/tree/master/so%20dailymotion%20upload , works else can't able find way add custom thumbnail. appreciated. it's field "thumbnail_url". for exemple in php : $result = $api->call('video.create', array( 'url' => $url, 'title' => 'my awesome video', 'channel' => 'fun', 'thumbnail_url' => 'http://www.website.com/thumb.png', 'description' => 'my awesome description', 'tags' => 'test,tags', 'published' => true ));

gps - Does google SUPL server support LPP protocol? -

i implementing minimal supl 2.0 client . have added supl asn1 specification , lpp asn1 specification application , compiled it. trying implement set initiated immediate services scenario. i have filled fields supl start message lpp protocol information , lte cell id (location id) information. sending message supl.google.com , not able receive response google supl server . does google supl server support lpp? i have tried supl.nokia.com also. not getting response nokia supl server also. the same application code working fine rrlp protocol . please let me know if has come across similar issue or have information regarding lpp protocol usage google supl 2.0 server . yes, supl.google.com supports supl 2.0 , lpp. port number using supl connection? think 7275 encrypted, 7276 not. implement openssl or other encryption, use 7276. are setting lpp capability bit? sure got asn.1 packing , aligning done correctly? rrlp working indicator know doing, think us...

image processing - Python PIL putdata() method not saving the right data -

i want save 10x10 rgb image pil's new, putdata, , save methods. when save, not take in right data , not sure going wrong. the pixel data want save: flat_pixels= [(0, 1, 0), (1, 0, 1), (0, 0, 0), (1, 1, 0), (0, 1, 0), (1, 0, 1), (1, 1, 0), (0, 1, 1), (0, 1, 1), (1, 0, 1), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), ...

php - Target blank opens link in the same tab when inside a modal -

i'm using bootstrap modal show text user. modal has button go "printable version" of content. want link open in new window, i'm using target="_blank" attribute. the problem link opens in same tab. acts _self target. i'm using zend framework. the code a tag is: $this->view->actions = array(array( 'tag' => 'a' , 'label' => 'versão para impressão' , 'attrs' => array( 'href' => base_url. '/corporativo/index/termos?layout=print', 'class' => 'btn btn-primary btn-print', 'target' => '_blank' ) )); it generates following html code: <a href="http://localhost/corporativo/index/termos?layout=print" class="btn btn-primary btn-print" target="_blank">versão para impressão</a> anyone knows why...

php - Full Text Search - Ignore polish letters in search phrase -

is possible ignore polish characters in search phrase using full text search? example, have movie in database. movie's title is: "pięćdziesiąt twarzy greya". if visitor searches phrase: "piecdziesiat", script should find movie contain phrase: "piecdziesiat" (and ignore polish letters). is possible? you can use strtr() convert string diacritics string without diacritics. example, can convert 'pięćdziesiąt' 'piecdziesiat'. there's comment on php documentation page useful function containing translation table. for posterity's sake, is: function normalize ($string) { $table = array( 'Š'=>'s', 'š'=>'s', 'Đ'=>'dj', 'đ'=>'dj', 'Ž'=>'z', 'ž'=>'z', 'Č'=>'c', 'č'=>'c', 'Ć'=>'c', 'ć'=>'c', 'À'=>'a...

python - Django's ManyToManyField automatically adding a symmetric relationship between objects -

i trying code model holds list of references other objects of same class. using manytomanyfield store references. reason when add element many-to-many field of second element reciprocal relation added first one. this test model declared class testmodel(models.model): foo = models.manytomanyfield('self', null=true) then populated database using interactive shell in [1]: m2m.models import testmodel in [2]: m1 = testmodel() in [3]: m1.save() in [4]: m2 = testmodel() in [5]: m2.save() i checked m1's , m2's foo field empty. in [6]: m1.foo.all() out[6]: [] in [7]: m2.foo.all() out[7]: [] then added m2 m1.foo in [8]: m1.foo.add(m2) in [9]: m1.foo.all() out[9]: [<testmodel: testmodel object>] and here lost, reason don't understand when appended m2 m1.foo m1 got appended m2.foo. in [10]: m2.foo.all() out[10]: [<testmodel: testmodel object>] in [11]: m1.id out[11]: 1 in [12]: m1.foo.get().id out[12]: 2 in [13]: m2.foo.get().id out[...

html - Odd gap between CSS containers -

the following css code: .portrait { width: 400px; position: relative; display: inline-block; background-color: #4e5555; } .portrait img { width: 150px; float: left; padding-right: 20px; } .portrait h4 { text-align: left; margin: 0px 0px 0px 0px; color: #fff; } and following relevant html code: <div class="portrait"> <img src="images\filmmakers\aboui, julian\julianaboui-web.jpg"> <h4>julian aboui</h4> </div> <div class="portrait"> <img src="images\filmmakers\alter, aaron\aaronalter-web.jpg"> <h4>aaron alter</h4> </div> <div class="portrait"> <img src="images\filmmakers\abrahams, pia\piaabrahams-web.jpg"> <h4>pia abrahams</h4> <h4>stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff</h4> </div> <div class="portrai...

jquery - Sort text fields based on position javascript -

i have 6 text fields in vertical alignment in form values corresponding it's position. each text field has fruit name associated aren't editable (the editable text fields serial numbers, if may) see jsfiddle url 1 apple 2 banana 3 cranberry 4 date 5 elderberry 6 fennel respectively. user can edit , change (only number, fruit names not editable) values between 1 6 (i have separate javascript function won't let user input other positive integers , not above maximum count). want write javascript/jquery function sort numbers following methodology: suppose user changes value 3 5, means textbox value 3 moved 5th position. means values 4 , 5 pushed values 3 , 4 respectively (like pop , insert in random access array). new values 1 apple 2 banana 5 cranberry <-- user edited 3 5 3 date <-- javascript changed 4 elderberry <-- javascript changed 6 fennel notice value 3 in 4th position , value 4 in 5th position , values 1,2 , 6 remain unaffected. ...

Simple class in Python error -

i error message saying like: typeerror: readfromfile() takes 2 arguments (1 given) this first class in python btw. from numpy import * pycalfem import * pycalfem_utils import * class flowmodel: def __init__(self): self.readfromfile() def readfromfile(self,filename): inputfile=open(filename,'r') ep=readfloat(inputfile) print(str(ep)) inputfile.close() if __name__=="__main__": flowmodel=flowmodel() flowmodel.readfromfile("indata.txt") you call self.readfromfile() without arguments, when create flowmodel instance: def __init__(self): self.readfromfile() this means method passed self , first argument, not second argument filename . remove line; don't have filename pass in there. using method correctly outside of __init__ method after creating instance.

How to count the number of zeros in each position of the sublist using python? -

i have 4 sublist in list below of length 38, want count number of 0 on each position. please how do it? [[01100000100000000001100001001110100000],[01100000100000000001100001001110100000], [01100000100000000001100001001110100000], [01100000100000000001100001001110100000]] the first index of 4 sublist 0000, hence number of 0 4. second index of 4 sublist 1111, hence number of 0 0. how want count 38 positions. it's not clear question if numbers lists or strings. assuming they're strings (otherwise use bin() ), i'd use zip() separate each position count() '0' : numbers = ['01100000100000000001100001001110100000', '01100000100000000001100001001110100000', '01100000100000000001100001001110100000', '01100000100000000001100001001110100000'] [digits.count('0') digits in zip(*numbers)]

Split array into chunks based on timestamp in Haskell -

i have array of records (custom data type) in haskell want aggregate based on each records' timestamp. in general terms each record looks this: data record = record { event :: string, time :: double, :: int, :: int } deriving (show, eq) i used double timestamp since same format used in tracefile. and parse them csv file array of records: [record] now i'm looking approximation of instantaneous events / time. want split array several arrays based on timestamp (say. every 1 seconds) , fold across each smaller array. the problem can't figure out how split array based on value of record. looking on hoogle found several functions splitevery , splitwhen , i'm lost. considered using splitwhen break list when, say, (mod time 0.1) == 0 , if worked remove elements it's splitting on (which don't want do). i should note records not evenly spaced in time. e.g. ...

Laravel custom artisan command and php extension GnuPG not found -

i making own command in laravel , command class call controller method. this: public function fire(\bankemailcontroller $bankemailcontroller) { if($this->option('fetch')){ $this->userinformresluts($bankemailcontroller->checkemails()); } } in checkemails method create new gnupg class: putenv('gnupghome=/var/www/mbiuro/panel/.gnupg'); $gpg = new gnupg(); calling command prompt error: [symfony\component\debug\exception\fatalerrorexception] class 'gnupg' not found php cli uses other php.ini settings unaware. activeting extension in /etc/php5/cli/php.ini solved problem. after issue had problem, creating laravel classes. connected old version of laravel 5. solution , related question can found here: laravel 5: using cache:: or db:: within console kernel's schedule() function

python - np.correlate() and signal.fftconvolve() gave different answers -

i have 10 frames of wcdma complex samples in sigi scrambling code -- matlab gold code (1,1) , "sc" variable. np.correlate() gives clean correlation spikes expected in code below extremely slow. try use fftconvolve() in same code, detected no spikes present. fftconvolve() fast, have work. please tell me why not work? mat=scipy.io.loadmat('011.mat') scr=mat['sc'] o1 = np.correlate(sigi,scr,mode='valid') # o1=signal.fftconvolve(sigi,scr,mode='valid') plot(abs(o1)) cc=max(abs(o1)) print ' max peak = ', cc found answer. if conjugate of scr used both np.correlation() , signal.fftconvolve() give same answer. dont understand reason though?? scr=np.conjugate(scr[0,:]) o1=signal.fftconvolve(sigi,scr[::-1],mode='valid') gave same answer : scr=scr[0,:] o1=np.correlate(sigi,scr,mode='valid') at least, problem solved.

Is there a reference for BigQuery errors? -

i'm getting following error go google api client library (that part doesn't matter appears coming straight through http api): post https://www.googleapis.com/bigquery/v2/projects/[project]/datasets/test/tables/blank2/insertall?alt=json: asn1: structure error: length large i can't find in bigquery docs explaining error message. what mean? , there reference somewhere explaining bigquery error messages? is there reference bigquery errors? yes: https://cloud.google.com/bigquery/troubleshooting-errors it doesn't cover "asn1 error" though: comes different layer. discovered, it's related .pem file parsing.

How to make django querysets with dynamic filters? -

so have website in django storefront , end user has 3 filters use. product type filter (pants, shoes, shirts, etc), delivery filter (yes/no), , location/popularity filter. currently in views.py have method. if request.is_ajax(): if request.get.get('filter') == 'shirts': latest_entries = entry.objects.filter(entrytype="shirts") context = {'latest_entries': latest_entries} return render(request, 'storefrontload.html', context) if request.get.get('filter') == 'pants': latest_entries = entry.objects.filter(entrytype="pants") context = {'latest_entries': latest_entries} return render(request, 'storefrontload.html', context) if request.get.get('filter') == 'shoes': latest_entries = entry.objects.filter(entrytype="shoes") context = {'latest_entries': latest_entries} return render(reque...

angularjs - use the $q promise like the promise returned from $resource -

with angular's $resource promise able assign promise right variable , use out having assign results of promise varible in success function. wondering if can achieve same thing $q? example .service("rest", function($resource){ return { user: $resource( "http://some.com/url") } }) .controller("myctrl", function($scope, rest){ $scope.user = rest.user.get(); <-- want able $q }) short answer: no the $resource interface designed allow kind of 'futures' behaviour. when call .get() returns placeholder object filled data when it's available. because $resource internal angular factory, knows when trigger digest cycles makes seem can use $scope.user beginning. in actuality, won't populated data until there has been http response server. a promise on other hand, general purpose mechanism. doesn't know kind of placeholder object store it's values in when arrive. do...

c# - Convert simple SelectMany into query syntax -

the following simple form of selectmany() . how if @ can convert query syntax? var array = new string[] { "shaun", "luttin" }; array .selectmany( s => s ); the best can produces same output introduces new variable c ... var query = s in array.asqueryable() c in s select c; ...and results in following fluent syntax. array .selectmany ( s => s, (s, c) => c ); re: possible duplication i have read answers is there c# linq syntax queryable.selectmany() method? i'm afraid answers' translation's not compile original fluent syntax . the compiler performs translation turn query syntax method syntax. details specified in section 7.6.12 of c# 5 spec. quick search turns couple translations can result in call selectmany , in section 7.6.12.4: a query expression second clause followed select clause: x1 in e1 x2 in e2 select v translated ( e1 ) . sele...

sql - mysql select all records after certain trigger value in seperate field -

i need select records after specific trigger "bar" item trigger time m1 foo 11:11 m1 foo 11:12 m1 bar 11:13 m1 foo 11:14 m1 bar 11:15 m2 foo 11:11 i need return m1 after , including 11:13 m1 11:13 m1 11:14 m1 11:15 so in pseudo code select records m1 after initial bar?

vbscript - ASP How to get a value from HTML column -

i have asp page displays rows of data in html table, after query sql database. number of returned rows can vary. want add function when click on button, fire off query sql server database update column in particular row. use primary key result set. the part having difficulty getting proper rows id. have wrote far returns same id every time regardless of row click on. sample code below. <table> <tr> <td class="bold" colspan="9"><%=vheading%></td> </tr> <tr> <td class="tablehead">id</td> <td class="tablehead">whenposted</td> <td class="tablehead">whencreated</td> <td class="tablehead">whenupdated</td> <td class="tablehead">source</td> <td></td> </tr> <% while not strs....