Posts

Showing posts from March, 2015

nltk - TypeError - Translate takes one argument.(2 given) Python -

i have following code import nltk, os, json, csv, string, cpickle scipy.stats import scoreatpercentile lmtzr = nltk.stem.wordnet.wordnetlemmatizer() def sanitize(wordlist): answer = [word.translate(none, string.punctuation) word in wordlist] answer = [lmtzr.lemmatize(word.lower()) word in answer] return answer words = [] filename in json_list: words.extend([sanitize(nltk.word_tokenize(' '.join([tweet['text'] tweet in json.load(open(filename,read))])))]) i've tested lines 2-4 in separate testing.py file when wrote import nltk, os, json, csv, string, cpickle scipy.stats import scoreatpercentile wordlist= ['\'the', 'the', '"the'] print wordlist wordlist2 = [word.translate(none, string.punctuation) word in wordlist] print wordlist2 answer = [lmtzr.lemmatize(word.lower()) word in wordlist2] print answer freq = nltk.freqdist(wordlist2) print freq and command prompt returns ['the','the&

git - Heroku does not seem to run most recent version of deployed play application -

yesterday pushed update heroku application online version not seem execute recent code. specifically, new route added results in "action not found" error visible here , akka job schedule in global.onstart not started. not writing log @ least. my conf/routes file contains line get /json/matches controllers.feeddaemon.matches() the corresponding controller exists , implements action def matches = action { implicit request => ok(cache.get(keymatches) match { case some(o) => o.asinstanceof[string] case none => "" }) } needless say, works locally. heroku build did not report errors , went through. i'm using play 2.2.2. application contains git submodule , sbt multi project build. heroku detects git submodule though. if multi project problem, i'd expect build errors or classnotfoundexceptions though. the answer pretty simple. in versions before 2.2, play framework created startup script

java - Download list of pages from some domain with URL constraint -

i need download list of pages on domain have specific url endings. for example, have webpage, http://brnensky.denik.cz/ , czech webpage news. every article has url ending post date, http://brnensky.denik.cz/zpravy_region/ruzova-kola-usnadni-presun-po-brne-20140418.html . so find list of urls begin http://brnensky.denik.cz/ , whatever, , example -20140418.html . possible achieve? i'm trying solve in java, other way help. regex be ^http://brnensky\.denik\.cz.*[0-9]{8}\.html logic beginning url , ending date.html , date 8 digit string. you may have escape '/' according tool or lang used implement expression

Lists of term-frequency pairs into a matrix in R -

i have large data set in following format, on each line there document, encoded word:freqency-in-the-document, separated space; lines can of variable length: aword:3 bword:2 cword:15 dword:2 bword:4 cword:20 fword:1 etc... e.g., in first document, "aword" occurs 3 times. want create little search engine, documents (in same format) matching query ranked; though using tfidf , tm package (based on tutorial, requires data in format of termdocumentmatrix: http://anythingbutrbitrary.blogspot.be/2013/03/build-search-engine-in-20-minutes-or.html ). otherwise, use tm's termdocumentmatrix function on corpus of text, catch here have these data indexed in format (and i'd rather use these data, unless format alien , cannot converted). what i've tried far import lines , split them: docs <- scan("data.txt", what="", sep="\n") doclist <- strsplit(docs, "[[:space:]]+") i figured put in loop: doclist2 <- strsplit(docl

javascript - ArmCharts makechart with click events -

i'm new here bear question i'm going ask. i want create click event armcharts piechart. example, when user click pie chart, open new popup window. my code follow chart = amcharts.makechart("piechart-placeholder2", { "type": "pie", "fontsize": 9.5, "labeltext": "[[percents]]%", "theme": "light", "legend": { "markertype": "circle", "position": "right", "marginright": 80, "automargins": false }, "dataprovider": [{ "perkara": "xxx1", "amaun(rm)": 4444 }, { "perkara": "xxx2", "amaun(rm)": 5555 }, { "perkara": "xxx3", "amaun(rm)": 73344 }, { "perkara": "xxx4", "amaun(rm)": 3322

ios - Why setClipsToBounds:NO disables setCornerRadius: for UItableview? -

Image
i'm creating uiitableview. first cell want have user image button allow him change image. (not complicated). somehow have strange problem: when set setmaskstobounds:no [self.usertable.layer setcornerradius:20.0]; disabled. attaching code output example: //initiate usertable //[self.usertable setclipstobounds:no];//from documentation line set default [self.usertable.layer setcornerradius:20.0]; [self.view addsubview:self.usertable]; later in cellforrowatindexpath: add: [mycellview.contentview addsubview:photo]; //my photo uimageview if uncomment line [self.usertable setclipstobounds:no] get: but corners not rounded more...... read following questions this , this , still cant figure out? did had problem , can provide fix not force me change code? , how 2 options related each other? lot. calling setcornerradius applies mask calayer, used mask bounds , create rounded corner effect. calling setmaskstobounds:no , disabling mechanism used round corners. in

WSDL/SOAP support on Go? -

i looked around , find support xml. are there packages support soap/wsdl on go? nope. soap sucks, had implement server of already-defined protocol uses soap, listened net/http , decoded/encoded envelopes encoding/xml . in few minutes, served first envelope go.

linux - Meaning of declarations in /etc/init.d/functions on EL 5 -

i'm of amateur when comes bash shell scripting , baffled first line in killproc() function in /etc/init.d/functions on centos 5.10 system: local rc killlevel= base pid pid_file= delay try what meaning of line? believe declaration of local variables perhaps, meaning of = after couple of items? have included complete killproc() function below reference: # function stop program. killproc() { local rc killlevel= base pid pid_file= delay try rc=0; delay=3; try=0 # test syntax. if [ "$#" -eq 0 ]; echo $"usage: killproc [-p pidfile] [ -d delay] {program} [-signal]" return 1 fi if [ "$1" = "-p" ]; pid_file=$2 shift 2 fi if [ "$1" = "-d" ]; delay=$(echo $2 | awk -v rs=' ' -v ignorecase=1 '{if($1!~/^[0-9.]+[smhd]?$/) exit 1;d=$1~/s$|^[0-9.]*$/?1:$1~/m$/?60:$1~/h$/?60*60:$1~/d$/?24*60*60:-1;if(d==-1) exit 1;delay+=d*$1} end {printf("%d

jQuery Parsley/Laravel - Password Validation not working -

i developing app laravel , doing form validation parsley ( http://parsleyjs.org/ ) instead of laravel forms checked before send. this works without issues except password validation. have 2 password fields , want validate them against each other "parsley-equalto" still can type different values in each field , gets validated. equalto functions seems not work. <form method="post" action="http://127.0.0.1/laravel/register" accept-charset="utf-8" class="form-horizontal" id="parsleyform"> <div class="form-group"> <div class="col-sm-6"> <input type="password" class="form-control" required placeholder="password" parsley-trigger="change" id="password"> </div> <div class="col-sm-6"> <input type="password" class="form-control" required pa

MySQL: joins, The used SELECT statements have a different number of columns -

i know there more questions can`t find right answer me. this query: $query = $mysql->query("( select questions.*, tags.tagdata questions left join tags on questions.id = tags.questid ) union ( select users.username users left join questions on users.id = questions.ownerid ) "); i select questions in table questions, tags save ownerid id of owner , want username display. error: the used select statements have different number of columns what doing wrong? why need union ? question table linked user , can use in join select questions.*, tags.tagdata, users.username questions left join tags on tags.questid = questions.id left join users on users.id = questions.owner

alfresco - Create document when create new folder -

i wonder how create pdf or word document automatically repository when create new folder in document library. thanks in advance. i don't understand mean. buy guess can done rule or behaviour. create rule on root folder folders created. set incoming type folder. action execute javascript. if @ javascript api cookbook , there samples on how create file. creating pdf's or word scratch bit difficult hence binary content isn't plain text.

javascript - The show event is not fired using bootbox dialog -

i'd catch show event bootbox.confirm dialog css adjustments dialog before showing that. i tried things followings didn't succeed: $(document).on("show", function (event) {...}); $(document).on("show", ".bootbox", function (event) {...}); $(document).on("show.bs.modal", function (event) {...}); they aren't global events. restricted plugin. so should use them within context. like: $('div').modal({ show: function(){ // } });

PHP5 + MongoDB 2.6 + PHP driver 1.5.1 - C10k Apache worker/prefork -

we're moving production environment (mongodb + php) , while testing concurrency (using loader.io) face difficulties reaching 10k concurrent connections. my test script basic, simple mongoclient::construct connect database , static echo. i tried both mpms in apache without success: 1. prefork + mod_php - bottleneck not connections, rather memory - each php process used ~200m - not scalable @ all. 2. worker + php-fpm - after ~2000-3000 connections start seeing many errors both on php machine regarding no candidate servers db stating many connections. i'm kinda stuck here. thought giving nginx shot, seems it'll fall short same option #2 above did. could achieved @ all? allowing more 10k connections in configuration (php+mongodb) any ideas?

joomla - Issue with router.php and send parameters via URL in joomla3 component -

i designed joomla3 component... i want send parameters component via url. i linked menu component..so access component address: http://examle.com/tag i have 3 parameters: years month day example: http://examle.com/tag/2014/12/19 this router.php <?php defined('_jexec') or die ; function bahaedinibuildroute(&$query) { $segments = array(); $app = jfactory::getapplication(); $menu = $app->getmenu(); $params = jcomponenthelper::getparams('com_bahaedini'); $advanced = $params->get('sef_advanced_link', 0); if(isset($query['year'])) { $segments[] = $query['year']; unset( $query['year'] ); } if(isset($query['month'])) { $segments[] = $query['month']; unset( $query['month'] ); } if(isset($query['day'])) {

java - How to use multiple configuration files for log4j2 -

i writing java code tests java library. library includes own log4j2 configuration part of distribution. i use log4j2 in test code without modifying library's configuration. is there way have separate log4j2 configuration test code? this running command-line java, no servers or web involvement @ all. edit try more clear: want able configure loggers, appenders, etc test code use , , at same time have library code use its own separate configuration file logging. idea use log4j2 in test code, without having change library's configuration file. since library configuration file part of library's distribution, don't want change testing. this may helpful: log4j2 first log4j2-test.xml in classpath if file not found, log4j2.xml in classpath so 1 option copy library's configuration (log4j2.xml) log4j2-test.xml , add own configuration log4j2-test.xml. furthermore, log4j2 supports xinclude in xml configuration , use feature avoid duplicating libra

windows - Hiding the process name to avoid DLL injection. How feasible is it? -

the idea quite simple, i.e try not follow standard. example inject thing firefox, malware need know name of process 'firefox.exe' or inject thing in internet explorer, malware need know process 'iexplorer.exe'. if firefox or internet explorer not follow convention hard. idea put logic change name of process. real 'firefox.exe' replaced our 'firefox.exe' file. duplicate file startup , real firefox executable renamed `random string.exe'. when system triggers 'firefox.exe', open our 'firefox.exe' executable. executable in-turn open real firefox exectable 'random string.exe' , set dummy process information using 'setprocessinformation' api. using 'setprocessinformation' set false location of executable malware not able find real process based on location. can body suggest how feasible (provided setprocessinformation can set false process location)? its not worth trouble. an attacker needs handle p

Android Google Plus Circles Birthday -

i've been searching explanation on why can't gather birthdays or taglines people in user's circle on google plus. i've played oauth 2.0 playground , retrieved birthday , tagline info people in circles have security set "visible circles" can't figure out why isn't available in google+ api android. the user logged in google plus using apiclient: mgoogleapiclient = new googleapiclient.builder(gathergoogle.this) .addconnectioncallbacks(this) .addonconnectionfailedlistener(this) .addapi(plus.api, null) .addscope(plus.scope_plus_login) .addscope(plus.scope_plus_profile) .build(); then in onconnected(bundle connectionhint) method, after gathering current user's info populate header, call peopleapi load visible connections: plus.peopleapi.loadvisible(mgoogleapiclient, null).setresultcallback(this); this calls onresult(loadpeopleresult peopledata) method supposed return list of people, does. gives me display name, id, thumbnail, etc... basi

Java key store is not found when default SSL context is redefined -

suppose, want connections via ssl in java application ask user permission, when untrusted or expired server certificate encountered (like of web browsers do). it seemed, natural way substitute default ssl context on application startup. here minimal working example: public class clientauthentication { public static final string server_url = "https://my.test.server"; public static void main(string[] args) throws exception { sslcontext defaultcontext = sslcontext.getinstance("tls"); defaultcontext.init(null, new trustmanager[]{new myx509trustmanager()}, null); // defaultcontext.init(null, null, null); sslcontext.setdefault(defaultcontext); httpurlconnection connection = (httpurlconnection) new url(server_url).openconnection(); system.out.println(connection.getresponsecode()); } private static class myx509trustmanager implements x509trustmanager { @override public void checkclie

Including HTML/PHP in JQuery -

i developing website manufacturing company using combination of php html css , jquery. want user able click on "contact us" button open modal window table of sales reps can contact quotes , other such contact information. have written php file generate , format of information interested in displaying, there way can include jquery .modalwindow() call? jquery: <script type="text/javascript"> $(document).ready(function(){ $('.modallink').modalwindow(); $('#contactus').modalwindow({ height: '750', width: '750',title: 'does work?',description: 'i want include php here'});}); </script> the modalwindow "class": (function($){ // defining our jquery plugin $.fn.modalwindow = function(prop){ // default parameters var options = $.extend({ height : "250", width : "500", title:"hey james isn't slick?", description: &qu

bash - Getting URL from javascript webpage -

i need semi-automatize getting links page wget , bash line editors. source code not contain these url's. possible url's way or similar one? the webpage example http://uloz.to/hledej?protected=notpassword&redir=0&q=picture&media=image , want direct url's found items (in case 52). i noticed in web browser running in windows not able open in next tab, on linux am. there connection?

multithreading - switch / create desktop C# opening form inside -

hi there have been working on program long time goal have lock system switch between desktops login form on 2nd screen allow login have run problem can not login from2 close second desktop can destroyed have manually close have tried invoking close , hide have tried destroy process not close not close. if use method .showdialog open form if use .show . close form parts of work show blank windows form1 main form process request public form1() { initializecomponent(); // create thread object. not start thread. worker workerobject = new worker(); thread workerthread = new thread(workerobject.dowork); workerthread.start(); system.threading.thread.sleep(3000); workerobject.requeststop(); } } public partial class worker { static desctop mdesktop = new desctop(); // method called when thread started. public void dowork() {

Google Font License -

i designed new website , need fonts this. have found google fonts. don't know in form can use these. have give credits or other things that? as far know, google fonts free , open-source, can use them freely without further references google fonts or google. on google fonts site state: all of fonts open source. means free share favorites friends , colleagues. can customize them own use, or collaborate original designer improve them. , can use them in every way want, privately or commercially — in print, on computer, or in websites. https://www.google.com/fonts#aboutplace:about

python - MySQL Query to fuzzy(?) search a software database -

i have software names database need search ,now trying find query select right software name . software name field varchar example software list in db: adobe flash professional mozilla firefox browser 20.0 adobe photoshop lightroom netbeans ide winrar 5.10 beta 2 query firefox be: firefox or mozilla firefox query lightroom be: lightroom or adobe lightroom or photoshop lightroom query winrar be: winrar or winrar archiver i have tried work soundex or levenshtein distance , not return desired result . you looking fulltext searching: https://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html note need create fulltext index on searched column, , may want consider adding relevant keywords (so abovementioned "archiver" matches on something)

c++ - c++11 equivalent of c# Interlocked.Increment -

i'm rewriting c# code c++: public class lightorder { private static int internalidcounter; public int internalid { get; private set; } // control myself call method once each order public void assigninternalid(int ordersexecutorid) { // if internalid assigned, i.e. != 0, can print error or internalid = interlocked.increment(ref internalidcounter); // more } // more } this works fine - each order has sequential id if assigninternalid called different threads parallel. what closest c++ equavalent code? should declare internalid std::atomic<int> , use ++ ? or should declare internalid int , use std::atomic_fetch_add ? should declare internalid std::atomic<int> , use ++ ? yes. or should declare internalid int , use std::atomic_fetch_add ? no. functions atomic_fetch_add work on atomic types (specialisations of atomic , or types atomic_int ), you'd still need atomic type.

c# - How to show a picture box inside a panel on hover programmatically? -

i have following problem, because quite new don't know if asking right questions...hope can put me in right direction, in advance. i have panel. inside there textbox(same size panel(140*40) , picturebox(smaller , in right top corner, 15*15).at moment able when mousehover panel(and textbox) show picturebox image deleting in it. if pass mouse on picturebox himself dissapears, , want happens when mouseleave textbox or panel. a college told me must use parent property, have no idea how can that. i don't know if explanation good, leave code here, can point me solution. textbox tbrole , panel pnrole , picturebox pbdeletex : tbrole.mousemove += (senderl, el) => { if (mousehover) { pbdeletex.visible = true; mousehover = true; } else { pbdeletex.visible = true; mousehover = false; } tbrole.backcolor = col

c - How does preprocessor make that expansion (define macro found in included header file ) -

i have header file contain constant f_cpu , use macro guard header.h #ifndef f_cpu #define f_cpu 1000000ul #endif and source.c file #define f_cpu 16000000ul #include "header.h" how first macro(in c file ) expand value not included yet? use -e option of preprocessor follow happens. define f_cpu macro in first line of source.c , after when header file included, macro definition in header not takes place because of #ifndef guard. note there no macro expansion in code. expansion takes place when use macro.

mysql - Calculating average from 2 database table colums -

i trying calculate average based on values 2 table columns in mysql . lets have table structure: id | user_id | first_score | last_score 1 | 1 | 10 | 60 2 | 1 | 70 | 10 3 | 1 | 100 | null what trying achieve here, calculating avg of highest value (i.e. 60, 70, 100). seeing in different colums, not sure how go it.. you solve greatest function. unfortunately results in null when 1 or both values null. so: select avg( greatest( coalesce(first_score,last_score) , coalesce(last_score,first_score) ) ) mytable;

grep command to match only request url of access log -

i need find accessed urls having keywords config,tmp,backup or dump. grep '/config/\|/tmp/\|/backup/\|/dump/' access.log when grep access log getting unwanted logs below 106.221.160.250 - - [11/apr/2014:12:07:13 -0400] "get url.com/perfect http/1.1" 200 43 "file:///something/tmp/579928.html" "htc_smart_f3188 mozilla/5.0 (like gecko) obigo/q7" 0 20675 it's unwanted get url.com/perfect http/1.1" 200 43 "file:///something/tmp/579928.html doesn't contain desired keyword. how should change grep command? try this: grep 'tmp\|config\|backup\|dump' accessl.log

linux - "cannot write to log file pg_upgrade_internal.log" when upgrading from Postgresql 9.1 to 9.3 -

i keep on getting above error whenever run following command via postgres user. /usr/lib/postgresql/9.3/bin/pg_upgrade \ -b /usr/lib/postgresql/9.1/bin/ \ -b /usr/lib/postgresql/9.3/bin/ \ -d /var/lib/postgresql/9.1/main \ -d /var/lib/postgresql/9.3/main cannot write log file pg_upgrade_internal.log failure, exiting i'm using ubuntu 13.10. both postgresql 9.1 , 9.3 running properly. make sure run command directory writable postgres user, /tmp or /var/lib/postgresql : $ cd /tmp $ usr/lib/postgresql/9.3/bin/pg_upgrade ...

php - simplexml-load-file -- remote or local loading? -

simple question apache+php: if use simplexml-load-file make http request or load file filesystem in case have: option a: simplexml_load_file('test.xml'); option b: simplexml_load_file('http://my.website.com/test.xml'); moreover in second option, php perform dns resolution of my.website.com or there bypass mechanism? thanks lot! option load straight disk, option b perform http request, including dns lookup. there no bypass dns lookup, other modifying hosts file or putting in ip directly.

Android: Sharing app content to a web page -

i want app users able share 1 of app pages others external web link marketing strategy, people don't have app can view page , excited download , register although no 1 can view app without signed in, have app , web domain didn't build website yet, efficient way ? you can write code on server receive data, store , serve (php/mysql or java or else). easiest way make form , send request android app simulate filled-in form. publish facebook or google+, there apis , android app.

c++ - Linker Error using g++ with Qt 4.5.1 -

i'm trying test out new dev environment , having problems referencing of required qt libraries. first ran this: $ g++ helloworld.c -o helloworld -i /usr/local/trolltech/qt-4.5.1/include/qtcore/ -i /usr/local/trolltech/qt-4.5.1/include/ and got error: /tmp/ccmsm4kz.o: in function `qstring::qstring(char const*)': helloworld.c:(.text._zn7qstringc2epkc[_zn7qstringc5epkc]+0x1d): undefined reference `qstring::fromascii_helper(char const*, int)' /tmp/ccmsm4kz.o: in function `qstring::~qstring()': helloworld.c:(.text._zn7qstringd2ev[_zn7qstringd5ev]+0x2d): undefined reference `qstring::free(qstring::data*)' collect2: ld returned 1 exit status so added reference qtcore library via: $ g++ helloworld.c -o helloworld -i /usr/local/trolltech/qt-4.5.1/include/qtcore/ -i /usr/local/trolltech/qt-4.5.1/include/ -l /usr/local/trolltech/qt-4.5.1/lib -lqtcore which removed compile errors, when try run program error: ./helloworld: error while loading shared libr

moment() function works in html but not in separate javascript file -

i have included moment.min.js in page <script src="js/jquery.js"></script> <script src="js/modernizr.js"></script> <script src="js/moment.min.js"></script> <script src="js/fatcalc.js"></script> i can call <script>document.write(moment());</script> and displays date fine on page. but, when call within fatcalc.js var date = moment(); i error: 'moment' not defined. why can html page see it, not fatcalc.js file? well, figured out. seems issue jshint don't understand adding top of script fixed it. /*global moment:true */

c# - Getting XML elements textboxes from search string -

i've got xml file has multiple entries, each looking this: -<crq> <id>crq000000003314</id> <status>1</status> <summary>complete</summary> <service>server</service> <impact>3000</impact> <risk>2</risk> <urgency>4000</urgency> <class>4000</class> <environment>1000</environment> <trigger/> <triggerid>cp_00</triggerid> <coordinator>user name</coordinator> <desc>ticket description.</desc> </crq> i have string in c# app matches id, eg crq000000003314. how able load xml , return elements underneath id (status summary etc) separate text boxes when string matched on event? you can element using linq xml this: var xmldocument = xdocument.load("path"); var element = xmldocument .descendants("crq") .firstordefault(x => (string) x.el

If the prototype of `Object` in JavaScript is null, why can I do Object.toString()? -

all newly created objects (with exception of objects created using object.create(null)) contain object object.prototype in prototype chain. these newly created objects can call newobject.tostring() because tostring defined on object.prototype . however, internal prototype of object said null . if that's case, why heck can this: object.tostring(); // prints: "function object() { [native code] }" perhaps i've answered own question. tostring defined on object constructor function? why?! > var obj = object.create(null); undefined > obj.tostring(); typeerror: undefined not function > object.tostring(); "function object() { [native code] }" see, obj created null prototype, when call .tostring() on it, error happen. but object self function, , prototype function object, has .tostring() method.

networking - WCF consume web service and network architecture -

Image
i'm getting start wcf soap web service. trying implement flexible, hot-plug featured, interoperable web service. a device consumes server service (predefined ip address) means registering server, , service asks device returning configuration information of device. service remotely control registered devices later. network architecture please see diagram below. server-side service listening on 80 port. had router (router b) connects server, , set nat table 220.120.20.209:80 mapping 192.168.0.3:80. 220.120.20.209 public ip. two clients connect router (router a) , have private ip addresses relatively(170.15.40.1/ 170.15.40.2) . clients host service (called deviceservice) listening on 80 port. , didn't set nat on router a. 68.250.250.1 public ip. operation (request registration) client sends (request) message service. (response) service response message. (get config devices) service consumes client through calling http: //clientsip:80/deviceservice. operatio

java - ResultSetMetaData getting default value of column -

i using oracle database. i want default value assign column using java jdbc. but using resultsetmetadata not provide method default value of column. so please tell me idea. in advance. you can run query select data_default user_tab_columns table_name ='mytable' , column_name = 'mycolumn'

Javascript confirm multiple changes -

i want alert user changes made in 4 fields. script works 1 @ time. if 1 or 4 changes have been made, alerts first 1 , skips others. displayed in 1 confirm box. <script> function validateform() { var w = document.getelementbyid("item_name"); if (w.value != w.defaultvalue) { return confirm('update item name. continue?'); } var x = document.getelementbyid("item_brand"); if (x.value != x.defaultvalue) { return confirm('update item brand. continue?'); } var y = document.getelementbyid("department_id"); if (!y.options[y.selectedindex].defaultselected) { return confirm('update item department. continue?'); } var z = document.getelementbyid("vendor_part_num"); if (z.value != z.defaultvalue) { return confirm('update vendor part number. continue?'); } } </script> you don't want ask each field individually, first check them all, ask user, this <script

rust - How to define and use macro in module? -

when i'm trying define macro in code, compiler says this: refix/mod.rs:12:1: 12:12 error: macro definitions not stable enough use , subject change refix/mod.rs:12 macro_rules! re_fix( ^~~~~~~~~~~ refix/mod.rs:12:1: 12:12 note: add #[feature(macro_rules)] crate attributes enable refix/mod.rs:12 macro_rules! re_fix( i've added lot of #[feature(macro_rules)] , didn't help. source code: https://gist.github.com/suhr/11207656 ps: yes, they're lot of other errors there, interested one. i think error message misleading. have add #![feature(macro_rules)] main crate module (note exclamation sign), along #![crate_id=...] , others. #![crate_id="rsfix#0.0"] #![feature(macro_rules)] macro_rules! example( ... ) fn main() { example!(...); } this should work on latest compiler version.

actionscript 3 - How to drag and drop multiple objects to specific targets? -

i new as3. of course ignore reset button now. know code big , clunky don't mind understood me. i trying match yellow ball yellow goal , green green , on. however every time try drag second object can't, object stuck, hear problem as3/flash , simple way solve drag off screen don't want do. yellowball.addeventlistener(mouseevent.mouse_down, mousedowny) redball.addeventlistener(mouseevent.mouse_down, mousedownr) blueball.addeventlistener(mouseevent.mouse_down, mousedownb) greenball.addeventlistener(mouseevent.mouse_down, mousedowng) yellowball.addeventlistener(mouseevent.mouse_up, mouseupy) redball.addeventlistener(mouseevent.mouse_up, mouseupr) blueball.addeventlistener(mouseevent.mouse_up, mouseupb) greenball.addeventlistener(mouseevent.mouse_up, mouseupg) resetbutton.addeventlistener(mouseevent.click, reset); addeventlistener(event.enter_frame,enterframehandlerr); function mousedowny(event:mouseevent):void { yellowball.startdrag(); } function mousedownr(e

css3 - Bootstrap 3 Change display:block to another value -

when looking @ checkbox based on bootstrap 3 class "checkbox" in ie development tools display set block, as: display:block; when uncheck box in front of display:block has cross-over line. checkbox looks how want. need specify in inline style value display equal crossed on display:block being unchecked. tried different values display in inline style nothing works. suggest set value display in inline style? here segment of code: <div class="checkbox" style="min-height:20px;padding-top:3px"> <asp:checkbox id="chkclosewo" runat="server" cssclass="checkbox" /> </div> here html code: <div class="checkbox" style="min-height:20px;padding-top:3px;display:inherit"> <span class="checkbox"><input id="maincontent_chkclosewo" type="checkbox" name="ctl00 $maincontent$chkclosewo" /></span> </div>

java - Interface methods - implementation vs. definition -

please explain why following isn't valid in java (1.7). having interface: interface foo { mymethod(argument arg) } where argument interface: interface argument{} an implementation of argument : class someargument implements argument{} and implementation of foo : class bar implements foo { mymethod(someargument arg) {} } the class bar results in compilation errors, since mymethod isn't implemented. there anyway accomplish above out need of casting? thanks! the mymethod() signature has exact defined in foo interface. suppose have class ( baz ) implements argument . then, mymethod(argument arg) signature allow passing parameters of baz type. but if keep this: class bar implements foo { mymethod(someargument arg) {} } you not able pass baz instances mymethod , because you've broken contract. as side note, should follow naming conventions when developing!

ios - Reminder App using Core Data and TableView -

how can create table each section there titles such dates , dates duplicate different times included in section same date? ios calendar. i not use eventstore , calendar, , reason work using core data , have created data model inside created date attribute. let me give example, sample output: reminder 04/23/2014 17:33:32.502 [2654:60 b] (      "4/22/2014 16:45:42 +0000",      "4/22/2014 16:50:25 +0000",      "4/23/2014 17:50:03 +0000",      "24/4/2014 15:45:43 +0000" ) my thought is: the sections of tableview should 3, takes dates of 22, 23 , 24 , in section 22, there must 2 dates of 22 different times. any advice on how move?

mongodb - Mongo db aggregation multiple conditions -

i want project collection applying exporting value if field inside range. sort of: db.workouts.aggregate({ $match: { user_id: objectid(".....") } }, { $project: { '20': { $cond: [ {$gt: [ "$avg_intensity", 20]} , '$total_volume', 0] } } }) i need value if avg_intensity inside range. group , sum on projection result. what trying applying $gt , $lt filter no success. db.workouts.aggregate( { $match: { user_id: objectid("....") } }, { $project: { '20': { $cond: [ [{$gt: [ "$avg_intensity", 20]}, {$lt: [ "$avg_intensity", 25]}] , '$total_volume', 0] } } }) how may apply both $gt , $lt conditions? to combine logical conditions under $cond operator wrap conditions $and operator: db.workouts.aggregate([ { "$match": { "user_id": objectid("....") }}, { "$project": { "20": { &q

javascript - Why do JS Promise A+ create/fulfill/reject not part of the spec? -

http://promisesaplus.com/ finally, core promises/a+ specification not deal how create, fulfill, or reject promises, choosing instead focus on providing interoperable method. future work in companion specifications may touch on these subjects. as functional developer, deal monads , operators point bind map or flatmap chain calls wrapped inside monad box. according question js deferred/promise/future compared functional languages scala , map , flatmap operators seems melted under then in js spec, because not make sense provide both in dynamically typed language js (?) , more convenient use , remember single operator. so far good, there's then operator ( that doesn't seem implemented ) but why promise create / fulfill / reject not part of spec? it's having half monad :( it seems i'm not 1 complain typically, problem is: i want create js library i want expose promise-based api i want client choose promise implementation wants use

Create PostgreSQL 9.3 index on json column through python, django, south? -

i have json column , need add index that: create unique index index_name on table ((column->'nest1'->'nest2'->'nest3'->>'data_to_index')); this works if execute sql lets pgadmin iii. problem need create index on django south migration. so, i'm doing in migration file is: def forwards(self, orm): ... db.execute("""create unique index index_name on table ((xml->'nest1'->'nest2'->'nest3'->>'data_to_index'))""") but index not created after migration. i tried in lot of different ways using psycopg2 directly, loading , executing sql file... nothing works! can me? thank you!

C++/Qt perform mouse click -

i've started qt5 / c++ project , wish control mouse (outside application window) in platform independent way. i've figured out, there nice method: qcursor::setpos(int x, int y) which allows, move cursor. is there api performing clicks?

Android Add Yes/No box to listView.setOnItemClickListener -

i've been trying lot of things try working, have list view displaying sqlitedb. each row of database clickable want able copy table in database. function working fine. problem want yes/no box appear confirm before gets copied in. have gone through numerous tutorials , been on here searching solution, none can fit in. here code have sitting inside displaylistview() method. in advance! listview.setonitemclicklistener(new onitemclicklistener() { public void onitemclick(adapterview<?> listview, view view, int position, long id) { // cursor, positioned corresponding row in // result set cursor cursor = (cursor) listview.getitematposition(position); dbhelper.addtoplanner( cursor.getstring(cursor.getcolumnindexorthrow("band")), cursor.getstring(cursor.getcolumnindexorthrow("day")), cursor.getstring(cursor.getcolumnindexo

In Android system, how many intents can system handle per second? -

roughly how many intents can android system handle per second/minute? i refer http://developer.android.com/guide/components/intents-filters.html seems loaded question , not seem answerable, sorry.

binary - Bitwise rotation with AND, OR, XOR gates -

how 1 rotate 4 bit binary number 4 places using and, or, xor gates? the inputs called x_0 , x_1 , x_2 , x_3 x_3 msb , x_0 lsb. for example 1010 rotated right 4 places 0101 . i can't seem find sources this. a 4-bit number rotated 4 bits in either direction same number started with. think playing joke on you. actually showed bit-reversing number, not rotating it. to implement bit-reverser combinatorial function, need 4 pieces of wire. connect input[i] output[3-i]. to implement state machine, use gates implement 4 clocked d-type flip flops (see the wikipedia page diagram . connect input[i] output[3-i].

mod rewrite - How to redirect from magento site to wordpress blog using .htaccess? -

i have magento main site , wordpress in blog folder. i want redirect blog when types http://www.example.com/blog/ however not redirecting blog. tried om magento's .htaccess (root) ... rewriteengine on rewriterule ^blog/(.*)$ http://example.com/blog/$1 [l,r=301] please if wrong.

python - Two-way ssl authentication for flask -

i have implemented ssl communication client application verifies identity of ssl server application using flask. want ssl server application verify identity of ssl-client application. possible flask ? how verify client certificate ? during first handshake client sending csr , in response sending certificate signed self signed ca certificate. but not yet clear how client verified server while next communication. there callback cert verification. link on google groups says not possible have ssl authentication on flask. in order 1 need use webserver apache,ngnix. way authenticate client ? there 1 more thing want achieve need identify each client based on certificate. possible flask. my question naive not yet familiar flask disclaimer before start note @emanuel ey's comment. want consider if being done on production or development server first. example; if using apache webserver https component can done apache. thing differently pass through certificate details

XML/PHP: XML doesnt get written properly by my script -

Image
i seem have small problem, whenever insert information via form xml file, adds information directly in previous's entry's child, instead of creating new child, entry, this: <people> <person> <name>lighty</name> <age>17</age> <sex>m</sex> <comment>iets</comment> <name>darky</name><age>22</age><sex>f</sex><comment>things</comment></person> while need have something, this: <people> <person> <name>lighty</name> <age>17</age> <sex>m</sex> <comment>iets</comment> </person> <person> <name>darky</name> <age>22</age> <sex>f</sex> <comment>iets</comment> </people> i tried using "$xml->formatoutput = true;" line, add child formatoutput 1 filled in, complete fail. an

CodeIgniter store session data in variable and pass it to another function -

i want store information of user if submits form, in order display in function able know did action. here 1st function public function view() { $page = 'listevisiteurs'; $comptable = array(); $compt= array(); $message = array(); if ($this->input->post()) { $mois = $this->input->post("mois"); $nom = $this->input->post("nom"); $session_data = $this->session->userdata('logged_in'); $data['nom'] = $session_data['nom']; $comptable = array($data['nom'] => $mois); ........ } $compt = array('fields' => array()); foreach ($comptable $key => $label) { $compt['fields'][] = array( 'key' => $key, 'label' => $label ); } ...... here second one public function get_visiteursmep() { $

plugins - Android DDMS is already installed so an update will be performed instead -

i had same problem many people had in updating adt plugin. used procedure described here: error message : android sdk requires android developer toolkit version 22.6.1 or above so, checked developer tools , hit next button. , says 'your original request has been modified. "android ddms" update performed instead.' but doesn't update, nor give me way one. (tried post screencap stackoverflow says need rep of @ least 10) here solution follow steps here: start eclipse, select > install new software. click add, in top-right corner. in add repository dialog appears, enter "adt plugin" name , following url location: https://dl-ssl.google.com/android/eclipse/ click ok. if have trouble acquiring plugin, try using "http" in location url, instead of "https" (https preferred security reasons). in available software dialog, select checkbox next developer tools , click next. in next window, you'll see list o

creating accumulator function (python) -

how create accumulator function called repeatedly single numeric argument , accumulate argument sum. each time called, returns accumulated sum. example given below. a=make_accumulator() a(10) -> 10 a(20) -> 30 a(-15) -> 15 class myaccumulator: def __init__(self): self.sum = 0 def add(self, number): self.sum += number return self.sum = myaccumulator().add print(a(10)) # => 10 print(a(20)) # => 30 print(a(-15)) # => 15 something ?

serial port - Using inbuilt Fingerprint Scanner .NET -

i making application , wanted ask if can interface inbuilt fingerprint scanner (of hp laptop) in .net application there's no reason why couldn't, if it's connected serial port device (as implied tags used on question). however, that's not end of it. need know how communicate device, , need know how make sense of data sends you. now, devices give functioning activex component can import project , handles you. otherwise, you're going want consult documentation of particular device on computer, , see if it's workable. there's sdks work .net (like http://www.griaulebiometrics.com/page/en-us/grfinger_sdk , http://www.digitalpersona.com/developer-tools/sdks/software-development-kits/ ), , c sdks quite easy interface .net well.