Posts

Showing posts from 2014

sql - Create a table based on a query -

the title may misleading, i'm unsure of way of phrasing it. query below works intended if little slow. however, when try wrapping insert into around query, locks database. table1 contains less 1,000 records , table2 less 1,500 records. the objective of query match records based on date/time groups contained in columns tables 1 , 2. crux of problem getting result set unique table can exported. this query variation of find here , may clarify intentions: https://social.msdn.microsoft.com/forums/office/en-us/1305b3a9-94c9-4e7c-a5fe-7b64a79600ca/select-closest-earlier-date . change rather looking closest date after, i'm retrieving closest day prior. select table1.*, ( select table2.column1 table2 table2.column1 = ( select max(t.column1) table2 t t.column1 <= table1.column1)) tempcol table1 are there alternatives can attempt break sql or option let run until it's complete? example of output: table1.id table1.column1 t.column1 1

Is possible to rewrite all values in array without for loop in javascript? -

let's suppose have array (myarray) data this: 0: myarray content: 'something' date: '15.5.2015' name: 'abc' 1: myarray content: 'text' date: '15.5.2015' name: 'bla' 2: etc ... now rewriting values (into e.g. empty string) of 1 object properties in array (for example: 'content') use loop this: for(var = 0; < myarray.length; i++){ myarray[i].content = ''; } so result of be: 0: myarray content: '' date: '15.5.2015' name: 'abc' 1: myarray content: '' date: '15.5.2015' name: 'bla' 2: etc ... my question is: possible same result without using loop in javascript? this: myarray[all].content.rewriteinto(''); tnx ideas. anything end looping in fashion. however, you don't have loop... because have functional array methods! you're looking map or reduce , perhaps both, since want transform (map)

github - understanding cmd "git version' -

i have git installed on windows 8.1 machine , have installed github windows on machine. when open cmd prompt , type "git version" returns: git version 1.9.5.msysgit.1 when open git shell github windows app same "git version" command returns: git version 1.9.5.github.0 i don't understand why not same or how interpret msygit.1 , github.0 portions. thanks help. seems have 2 different installations of git. first 1 installed mysysgit. second 1 bundled github windows. i have not used either of software (i use linux.); sherlocking based on statements.

python - django - trouble with migrations and modeltranslations -

i trying upgrade app, django v1.6.11 v1.7.8. following instructions upgrade south again , again same error. more precisely: $ python manage.py migrate makemigrations /home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/reversion/admin.py:385: removedindjango18warning: commit_on_success deprecated in favor of atomic. def recover_view(self, request, version_id, extra_context=none): /home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/reversion/admin.py:397: removedindjango18warning: commit_on_success deprecated in favor of atomic. def revision_view(self, request, object_id, version_id, extra_context=none): /home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/django/forms/widgets.py:143: removedindjango18warning: `versionmetaadmin.queryset` method should renamed `get_queryset`. .__new__(mcs, name, bases, attrs)) /home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/cm

multithreading - Android drag ImageView very laggy -

i trying implement touch-draggable imageview in android app. there loads of sample codes on , elsewhere, , seem along lines of this one . i tried similar this, laggy , kept getting warning choreographer﹕ skipped xx frames! application may doing work on main thread. i followed the android documentation advice on , tried work in separate thread, hasn't solved issue. basically register ontouchlistener view, in ontouch() method start new thread try , work (the final update of layout params sent ui thread processing using view.post() ). i can't see how achieve doing less work on main thread. there way fix code? or there perhaps better approach altogether? the code: private void settouchlistener() { final imageview insituart = (imageview)findviewbyid(r.id.insitu2art); insituart.setontouchlistener(new view.ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { final motioneve

python - List comprehension to generate and then sample from array that in turn depends on values in another array (index dependent) -

is there way perform list comprehension each item in list generated sampling randomly list in turn generated depending on values of 2 other lists @ particular index? realize readability suffer, i'm curious if can following list comprehension: def goat_door(guess, correct): doorlist = [] in range(len(guess)): items = [1,2,3] if(guess[i] in items): items.remove(guess[i]) if(correct[i] in items): items.remove(correct[i]) doorlist.append(random.choice(items)) return doorlist (the famous 3 door guessing game problem). the input list guess represents n guesses prize door (independent) , correct actual prize door these n guesses. function goat_door chooses door neither guess nor price door.. i'm new python trying push list comprehension. can done 1 or 2 list comprehensions? def goat_door(guess, correct): return [random.choice(list({1,2,3} - set(gc))) gc in zip(guess, correct)] or

php - Wordpress - Disabling automated resizing system -

i'm having problem wordpress image resizing system. started getting after upgraded 4.2.2. i use 1 page responsive theme , there's photo gallery on portfolio part. when click 1 of thumbnail ajax load show bigger photos, not lightbox. this same theme use: http://visia.themes.pixelentity.com (click "folio" go "our work" section, click 1 of thumbnails open bigger images. bigger image part called "project" in admin area, thumbnails coming "galleries", "our work" section made "page" in admin.) on site, after upload photos on gallery, generates specific size of window, presumably code in php somewhere in theme folder. and if check source code, <img alt="" width="680" height="519" src="http://yourdomain.com/wp-content/uploads/2015/05/yourphoto-680x519.jpg"> it adds "680x519" @ end of image url taken media upload folder. but if see original theme site, ph

java - How to add number of months to a specific date -

i want add number of months specific date based on user selected. instance adding 3 months 15/05/2015. tried showing me same date. code below: calendar aed = calendar.getinstance(); int monthstoadd = 0; if (advertposteddate.equals(1)) { monthstoadd = 1; } if (advertposteddate.equals(2)) { monthstoadd = 2; } if (advertposteddate.equals(3)) { monthstoadd = 3; } aed.add(calendar.month, monthstoadd); date adverted = aed.gettime(); dateformat df = new simpledateformat("dd-mm-yyyy"); string advertexpirydate = df.format(adverted); your code looks fine, exception use if/else if structure instead of if structure. sure advertposteddate has value of 1, 2, or 3? because if doesn't 0 being added months. public static void main(string[] args) { integer advertposteddate = 2; calendar aed = calendar.getinstance(); // 15-5-2015 int monthstoadd = 0; if (advertposteddate.equals(1)) { monthstoadd = 1; } else if (advertpostedda

javascript - Can't get html to check value -

i having webpage value of textbox , check value of "bypass". if stuff in textbox equals value of "bypass", website redirect google. doesn't work, if put in correct values. my code this: <!doctype html> <head> <title>aca2</title> </head> <body> <center> <form> <p><input type="password" name="pass"><br></p> <p><button onclick="bypasscheck()">...</button></p> </form> <p><a href="index.html">back</a></p> </center> <script type="text/javascript"> function bypasscheck() { var aaa = document.getelementbyname('pass')[0].value var bbb = "bypass"; if(aaa == bbb) { window.location.assign("www.google.com") } } </script> </body> </html> use documen

Android/PHP: how to POST/GET JSON data from Android to php -

android/php: how post/get json data android php? currently stuck @ point sending jsonobject data php getting null values in response. what want: i sending 'username' , 'password' android in form of jsonobject , want retrieve same data in jsonobject in php response. here code snippet android_file.java defaulthttpclient httpclient=new defaulthttpclient(); httppost httppost=new httppost(register_user); jsonobject jsonobject=new jsonobject(); httppost.setheader("accept", "application/json"); httppost.setheader("content-type", "application/json"); try { jsonobject.put("username",username.gettext().tostring()); jsonobject.put("password",password.gettext().tostring()); stringentity se=new stringentity("json="+jsonobject.tostring()); //httppost.addheader("content-type", "application/x-www-f

Identify slow query without slow query logs in mysql server -

i wondering there other way to check our slow queries without logging slow query. suppose, have highily busy server can't afford log save memory , i/os. then, there other way available check if have slow query? know, can profiling of query still not sure identify query 1 taking of time , memory. just started mysql administration , not sure how handle this. guidance highly appreciated. i find slow best source of bogging down server. suggest start moderately high value of long_query_time. minimize i/o , disk space. fix queries finds, if can. when have exhausted that, lower setting find more. use pt-query-digest find "worst" queries. keep in mind high value finds long queries, if rare. lower value find fast queries run frequently, , these may real villains. another approach turn on slowlog briefly or during relatively idle time. find may still useful. anecdote: in 1 system there query where misformulated such running 100% cpu. one-line fix d

android - APK Openssl version -

i'm confused. i've receintly created google play app hours later i've recieved mesage in console i'm using wrong openssl version: $ unzip -p yourapp.apk | strings | grep "openssl" gives openssl 1.0.1e 11 feb 2013. but google play supports 1.0.1h , latest. i'm not understand how can update openssl version? sdk? ndk? eclipse? etc... i've downloaded newest version. how can fix it? thanks comments of question. solutions not in libraries in executable added in res/raw/executablefile included openssl. had recompile executable fix alert.

haskell - How to reload updated file in Threepenny-gui 0.6? -

the threepenny-gui changelog ( https://hackage.haskell.org/package/threepenny-gui-0.6.0.1/changelog ) reads: "the functions loadfile , loaddirectory have been removed, felt jsstatic option sufficient use cases." my question is: how can reload image updated during execution without loadfile? with threepenny-gui 0.5 used following code: redraw :: ui.element -> ioref comptree -> (maybe vertex) -> ui () redraw img treeref mcv = tree <- ui.liftio $ readioref treeref ui.liftio $ writefile ".hoed/debugtree.dot" (shw $ summarize tree mcv) ui.liftio $ system $ "dot -tpng -gsize=9,5 -gdpi=100 .hoed/debugtree.dot " ++ "> .hoed/wwwroot/debugtree.png" url <- ui.loadfile "image/png" ".hoed/wwwroot/debugtree.png" ui.element img # ui.set ui.src url when, threepenny-gui 0.6, set jsstatic just "./.hoed/wwwroot" , following code (obviously) results i

regex - XSD regular expression restriction on xsd:string -

what regular expression if want sequence of integers separated @ least 1 blank? something "123 098". here's how use regular expression 2 sequences of digits separated @ least 1 whitespace character: <xs:simpletype name="twosequencesofdigitstype"> <xs:restriction base="xs:string"> <xsd:pattern value="\d+\s+\d+"/> </xs:restriction> </xs:simpletype>

php - Select Data by check box click next and unselect the selected row -

i want create crf form university project . created course table select data course student click completed course , next click .then next page show same data base table not courses, student selected.and student can subset applied courses. when select course , click next, show previous row in course table. want selected course row not select when click . cause completed course not want select applying course. i want select row database when aply show same databases row except selected row i add same line in problem line.. <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html> <head> <title> crf form </title> <link rel="stylesheet" href="css/admin_style.css" > </head> <body> <div id="header"> <a href="index.php"> <h1>

javascript - Change all text on page with innerHTML -

i want change text on page, got value "yes".how can change "yes"-value on page? i want if value of text = "yes", must replaced <span class='ic ic-normal ic-icon-yes'></span> this current code: <?php $_helper = $this->helper('catalog/output'); $_product = $this->getproduct() ?> <?php if($_additionalgroup = $this->getadditionaldata()): ?> <section id="additional"> <div class="box-collateral box-additional"> <h2><?php echo $this->__('additional information') ?></h2> <?php $i=0; foreach ($_additionalgroup $_additional): $i++; ?> <h3><?php echo $this->__( $_additional['title'] )?></h3> <table class="data-table" id="product-attribute-specs-table-<?php echo $i?>"> <col width="25%" /> <col />

initialization - Rails - initialize object instance variable -

i have 2 arrays initialise [] in prediction model's object. if try: def initialize @first_estimation = [] @last_estimation = [] end then many of unit tests fail. failure/error: assign(:prediction, prediction.new( argumenterror: wrong number of arguments (1 0) however, if try: def after_initialize @first_estimation = [] @last_estimation = [] end then arrays not instantiated. how can instantiate arrays when object constructed without altering else? since see parenthesis here prediction.new( deduce try pass params. but initialize doesnt accept => boom but wait, activerecord model? if so, have use: after_initialize :set_arrays def set_arrays @first_estimation = [] @last_estimation = [] end and maybe use attr_accessor too, dont know expect

jstree with default cheked attribute and find node by mask -

i integrated jstree site, problem that, have no idea how give jstree node element checked attribute default, jstree - precheck checkboxes not case. data-jstree='{"selected":true}' working don't want element selected. , 1 more thing, not find anywhere: possible nodes id (even if not selected), or can node id mask? in advance the latest commit fixes , enables use (i guess need): <div id="jstree"> <ul> <li data-jstree='{"selected":true}'>root 1</li> <li data-jstree='{"state":{"checked":true}}'>root 1</li> </ul> </div> you can download latest code here: https://github.com/vakata/jstree/archive/master.zip

html - Flexbox not working inside table? -

Image
i'm using flexbox display text label along numeric value in narrow column, text truncated ellipsis if doesn't fit. it worked fine, until had need place entire column in table-cell - @ point browser (chrome) ignored column width , made table wide enough fit text. here's label layout: <div class="line"> <span>very long label text</span> <span>12345</span> </div> .line { display: flex; width: 100%; } .line span:first-child { white-space: nowrap; flex-grow: 1; overflow: hidden; text-overflow: ellipsis; } .line span:last-child { flex-shrink: 0; margin-left: 5px; } placing in regular div fixed width works expected. placing in table-cell doesn't: fiddle: http://jsfiddle.net/98o7m7am/ .wrapper { width: 150px; } .table { display: table; } .table > div { display: table-cell; } .line { display: flex; width: 100%; } .line span:first-child { whit

class - Simple program [HELP] c++ -

hey guys please tell me wrong program. doesn't output desired output. glad if explain me why doesn't show errors doesn't show output. #include<iostream> using namespace std; class danielclass { public: string namefunction(string first_name, string last_name) { return fullname = first_name + " " + last_name; } private: string fullname; }; int main() { string namefirst; string namelast; danielclass nameobj; cout<<"enter first name: "; cin>>namefirst; cout<<"enter last name: "; cin>>namelast; cout<<"your full name is: "; cout<<nameobj.namefunction("" , ""); return 0; } you need pass strings function work: cout<<nameobj.namefunction(namefirst ,namelast); here example

c++ - Error LNK2028: unresolved token -

this question has answer here: 'unresolved external symbol' errors 2 answers hi have seen type of question have been asked before none of them worked me. thats why asking again. i have written code using opencv 2.4 , have added files needed code. still getting error. error 1 error lnk2028: unresolved token (0a00000c) "extern "c" unsigned long __stdcall ibwrt(int,void const *,unsigned int)" (?ibwrt@@$$j212ygkhpbxi@z) referenced in function "int __cdecl writedata(void const *,unsigned int)" (?writedata@@$$fyahpbxi@z) d:\f1nh-tester-2014-08-04\puma_led_tester\puma_led_tester\ni_gpib.obj puma_led_tester i tried solving adding header file related function nothing worked. please me resolving this. that's linker error , says missing implementation of function ibwrt . adding header files not help, need find

sql - Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding -

i calling stored procedure when getting error: "timeout expired. timeout period elapsed prior completion of operation or server not responding." public static dataset copywebsite(int oldsiteid, int newsiteid, int16 ispagecopyflag, string modulescommaseperated) { return sqlhelper.executedataset(sqlhelper.connectionstring, "usp_copysite", oldsiteid, newsiteid, ispagecopyflag, modulescommaseperated); } how remove error?

Reflecting Oracle Global Temp Tables Using Pythons SQLAlchemy -

i using sqlalchemy , want reflect table structure of global temp tables. from sqlalchemy import metadata ... meta = metadata() meta.reflect(bind = engine, = ['tt_employees'], schema = schema) i enable 'echo=true' when establishing connection: db_engine = create_engine(engine.url.url(**params), echo=self._echo) i can reflect tables except global temp tables. because of way sqlalchemy looks tables in reflect(): info sqlalchemy.engine.base.engine select table_name all_tables nvl(tablespace_name, 'no tablespace') not in ('system', 'sysaux') , owner = :owner , iot_name null , duration null the duration of oracle global temp tables 'sys$session' why no global temp tables reflect. version info sqlalchemy 1.0.4 py27_0 oracle database 11g enterprise edition release 11.2.0.4.0 - 64bit is there can this? appending metadata via metadata.tables() appears work guessing there better solution: test = [sqlalch

primefaces - While selecting values in selectOneMenu, values are not getting selected -

i use selectonemenu component. using primefaces 5.2. reduced body size zoom="95%". first time selected value , once again selecting other value-->value not getting selected, still older value getting displayed. xhtml code: <h:body style="zoom:95%;"> <p:selectonemenu id="id" value="#{managebean.summarysearch.status}" style="width:180px;"> <f:selectitem itemlabel="pending" itemvalue="pending"/> <f:selectitem itemlabel="approved" itemvalue="approved" /> <f:selectitem itemlabel="rejected" itemvalue="rejected" /> <f:selectitem itemlabel="all" itemvalue="all" /> </p:selectonemenu> <p:commandbutton value="search" actionlistener="#{managebean.search}" update

c++ - pipe can not read/write all the chars -

i trying send array of char 1 process using pipe, characters passing not of them! part of beginning. code: int p1[2], p2[2]; int main() { pipe(p1); int f1= fork(); if(f1 == 0) { char ar[100]; int n = 38; for(int i=0;i<n;i++) { ar[i] = 'f'; } close(p1[0]); //close read write(p1[1],ar,n+1); } else if (f1 > 0) { wait(null); int f2 = fork(); if(f2 == 0) { char arr2[100]; close(p1[1]); //close write int m = read(p1[0],arr2,strlen(arr2)); cout << arr2 << " " << m << endl; } else if (f2 > 0) {wait(null);} } return 0; } you invoke std::strlen() on uninitialized char array, mistake. std::strlen() looks first occurence of null byte in array , returns position. array uninitialized , making first occurence of null byte undefi

java - JPA Optimizing using custom queries -

i using jpa/hibernate orm , want optimize queries load necessary data specific endpoint. what's best way load subset of attributes of specific class , convert json? endpoints use spring mvc , jackson json mapper. approaches figured out, haven't tested yet. create pojo objects include necessary attributes , map query fields attributes using @sqlresultsetmapping . this approach requires adding lot of additional classes, other seem good. ignore overhead in database queries , limit response data jsonviews. this can messy real fast, putting different jsonviews seems tedious. queries overhead insignificant curious how map larger more complex queries. use java.sql.preparedstatements , map resultset manually. additionally use @jsoninclude(include.non_null) use non null values. seems best solution me, ignores jpa entirely , not sure if should go solution. know lose every advantage of orm, seems every other solution needs similar or more complex work. ??? the last coup

c++ - piping stockfish misbehaves in fedora -

somewhere in project use fork , pipe execute process , pipe i/o communicate (i'm writing in c++). there no problem when compile in ubuntu 14.04, work fine, compiled in fedora on wmware virtual machine , strange things began happen. if run binary in terminal, there no error nothing written in pipe (but getting streams of characters work). tried debug code in fedora, put break point in code, broken pipe signal given when process tried read pipe (there no signals when executing in terminal). so, have of encountered such problems before? there difference in piping between debian , red hat linux? or because i'm running fedora on virtual machine? code: int mfd_p2c [2]; int mfd_c2p [2]; int menginepid; if (pipe(mfd_p2c) != 0 || pipe(mfd_c2p) != 0) { cout << "failed pipe"; exit(1); } menginepid = fork(); if (menginepid < 0) { cout << "fork failed"; exit(-1); } else if (menginepid == 0) { if (dup2(mfd_p2c[0], 0) != 0 || close(

c# - Using the name data annotation vs hard coding in view -

i have following in entityframework domain models: [required] [display(name = "first name")] public string firstname { get; set; } [required] [display(name = "last name")] public string lastname { get; set; } and in view following: @html.labelfor(model => model.firstname) but wondering, why preferred specify "display name" in model instead of writing label manually in view page? i can see causing more problems, if in 6 months time comes me , says "we don't want first name anymore, want "your first name" either have revert hard coding in view or recompile model project change take effect.. is there benefits not aware of using data annotations? the benefit of displayattribute localization code below. [required] [display(name = "first name", resourcetype = typeof(yourresources)))] public string firstname { get; set; } asp.net mvc 3 localization displayattribute , custom resource provider has answ

ios - view considers navigation bar only after rotation -

Image
i have simple uiscrollview uiscrollview *mainscrollview = [[uiscrollview alloc] initwithframe:cgrectzero]; [self.view addsubview:mainscrollview]; [mainscrollview mas_makeconstraints:^(masconstraintmaker *make) { make.edges.equalto(self.view); }]; when view loaded , shown, part of uiscrollview appears under navigation bar. after rotation view considers navigation bar , pins view bottom. how can make view consider navigation bar beginning? to start uiscrollview @ bottom of uinavigationbar suggest set adjust scroll view insets property , setting extend edges property well. needful changes of below property per requirement.

python - out of memory error when reading csv file in chunk -

i processing csv -file 2.5 gb big. 2.5 gb table looks this: columns=[ka,kb_1,kb_2,timeofevent,timeinterval] 0:'3m' '2345' '2345' '2014-10-5',3000 1:'3m' '2958' '2152' '2015-3-22',5000 2:'ge' '2183' '2183' '2012-12-31',515 3:'3m' '2958' '2958' '2015-3-10',395 4:'ge' '2183' '2285' '2015-4-19',1925 5:'ge' '2598' '2598' '2015-3-17',1915 and want groupby ka , kb_1 result this: columns=[ka,kb,errornum,errorrate,totalnum of records] '3m','2345',0,0%,1 '3m','2958',1,50%,2 'ge','2183',1,50%,2 'ge','2598',0,0%,1 (definition of error record: when kb_1 != kb_2 , corresponding record treated abnormal record ) my computer, ubuntu 12.04, has 16 gb memory , free -m returns total used free shared buf