Posts

Showing posts from May, 2014

actionscript 3 - Can't move object of class in AS3 -

i'm making game in need hero shoot, can't realize why bullets aren't moving. appear on stage stay in place appear , don't move. can't find mistake. thanks!! so class has make appear , move bullets when press space. public class nivel_1 { public var mc:mainchar = new mainchar(); public var ene:enemigo = new enemigo(); public var bullet:bullet = new bullet(); public var back:mc_nivel_1 = new mc_nivel_1() public var spawn_boss:boolean =false; public var boss:boss = new boss(); public static var balavector:vector.<bullet> = new vector.<bullet>(); public var disparo:boolean = false; public function nivel_1() { } public function iniciar():void { main.escenario.addeventlistener(event.enter_frame, update); main.escenario.addchild(back); ene.init(600,630); mc.init(100,150); main.escenario.addeventlistener(keyboardevent.key_up, onkeyuplv1); main.e...

first order logic - How does 'elim' in Coq work on existential quantifier? -

i'm confused coq on way dealing existential quantification. i have predicate p , assumption h p : nat -> prop h : exists n, p n while current goal (whatever) (some goal) if want instantiate n in h, do elim h. however after elimination, current goal becomes forall n, p n -> (some goal) it looks coq converts existential quantifier universal one. know (forall a, p -> q a) -> ((exists a, p a) -> q a) out of limited knowledge on first-order logic. reverse proposition seems incorrect. if 'forall' 1 , 'exists' 1 not equivalent, why coq such conversion? does 'elim' in coq replace goal harder prove one? or please show why ((exists a, p a) -> q a) -> (forall a, p -> q a) holds in first-order logic? maybe missing key goal: forall n, p n -> (some goal) is read as: forall n, (p n -> (some goal)) and not as: (forall n, p n) -> (some goal) that is, goal given gives arbitrary n , proof p n , in...

jquery - How to insert Null value to database if the user do not pick a date? -

i using bootstrap datepicker allow user select date input date. 1 thing wondering, when user not select date datepicker. not show null value in database, show date format 0000-00-00. here html: <div class="form-group"> <label class="control-label col-sm-3">date of birth</label> <div data-date-viewmode="years" data-initialize="datepicker" data-value="null" data-date-format="dd/mm/yyyy" data-date="{{date('y-m-d')}}" class="input-append date dpyears col-md-8"> <input type="text" name="birth_date" placeholder="{{date('y-m-d')}}" size="16" class="form-control"> <span class="add-on birhtdatedatepicker"> <button class="btn btn-primary" type="button"><i class="fa fa-calendar"></i></button> </span> </div>...

javascript - how can I test logic under the condition of "'ontouchstart' in window" in JS -

we have logic under "ontouchstart in window". use popup form desktop website, rest of cases show normal form. var isdesktopdevice = !('ontouchstart' in window); if (isdesktopdevice) { //popup form } else { //normal form } i wonder how can test in javascript many in advance

asp.net - Can't stop child web application from inheriting parent's web.config -

i've looked @ related questions , followed solutions, it's still isn't working me. appreciated, thank you. i have web application added virtual directory (under parent site) , converted application. has own application pool. parent .net 2.0 , child .net 4.0. the parent's web.config: <configuration> <configsections> <sectiongroup name="system.web.extensions" ...> <sectiongroup name="scripting" ...> <section name="scriptresourcehandler" ... /> <sectiongroup name="webservices" ...> <section name="jsonserialization" ... /> <section name="profileservice" ... /> <section name="authenticationservice" ... /> </sectiongroup> </sectiongroup> </sectiongroup> </configsections...

Reading the decimal value of little endian in PHP -

i'm reading 6 bytes in little endian binary file using $data = fread($fp, 6); unpack("v", $data); the result 1152664389 , in hex 0x44b44345 now result in little endian , has decimal number. in delphi, able decimal number using function: var myint:integer; s:single; begin myint:= 1152664389; // same myint:= $44b44345; s:= psingle(@myint)^; and output of s 1442.102.. number im looking for... i searched way in php got lost. please help, thanks okay, bit confused. wanted retrieve little endian number binary file convert float. so steps were: 1) read bytes , unpack using $number = unpack("v", $data); 2) convert $number decimal using dechex. 3) use following function convert hex float: function hexto32float($strhex) { $v = hexdec($strhex); $x = ($v & ((1 << 23) - 1)) + (1 << 23) * ($v >> 31 | 1); $exp = ($v >> 23 & 0xff) - 127; return $x * pow(2, $exp - 23); } thanks again.

objective c - Auto-refresh upon launch ios -

i'm going through bloc bootcamp ios development , i'm looking solution reload "new images" upon launch. needs automatically refresh , fetch new images without user having pull refresh. building out replica of instagram if helps. it sounds you've got method created accomplish task, it's question of calling method. i don't know code looks like, i'll attempt "physics poets" example: - (void)pulltorefreshmethod { // there might code configuring view, etc. in here // code refresh } the simplest way when loads in viewdidload on initial viewcontroller . let's pulltorefreshmethod other things in addition refreshing. take code refreshes , put in own method. - (void)refreshinstagram { // code refresh } then, within pulltorefreshmethod , you'd call with: [self refreshinstagram]; and in viewdidload , call there, too. without specific code, can't give specific answer, though.

Finding SQL Users who satisfy two different conditions -

i have table following: user id || quality_a 200; 1 15; 3 35; 7 76; 6 200; 5 if want find users such exists row users quality 1, , exists row users quality 5, how do so. instance, in table above, user 200 has 2 rows, , qualities respectively 1 , 5. counted. also, should titled appreciated. you can try this select user_id table1 quality_a in (1,5) group user_id having count(distinct quality_a) >= 2

actionscript 3 - Which is faster: (i == 0) or (i < 1) -

i heard that: //this: val1 * 0.5; //is faster this: val1 / 2; so wonder if there else that, , ask: var val1:uint = 0; //is this: if (val1 == 0) //faster this?: if (val1 < 1) why? whichever do, compiler optimise on whatever platform compiling on. if need check if it's 0, use (i == 0) , if want know if it's less zero, use 1 instead. write read out loud. tiny things won't make faster, , should worried readability , clean design rather tiny operation faster. and if doesn't logical changes, chances on platform, both perform in 1 cpu cycle.

Connection failed socket in C -

i'm trying create program connect itself. trigger thread client , thread server , create socket each thread. use same port. when thread client tries connect thread server, connection fails. why? can't understanding. me! the full code it's complicated, because it's big. i'll generalize. #define addr "127.0.0.1" struct threaddata{ int portnum; int sockid; int lastid; unsigned int lastcheck; }; // ----------- ----- connection ------ ------------- // void dieerror(char *message, int socket){ printf("%s\n", message); if(socket != 0) close(socket); exit(1); } int createsocket(int portnum, struct sockaddr_in* netw){ int sockid; sockid = socket(af_inet, sock_stream, 0); if(sockid == -1) dieerror("socket() failed", sockid); struct in_addr addrr; if(inet_pton(af_inet, addr, &addrr) < 1) dieerror("pton() failed", sockid); netw->sin_fami...

verbosity - How do you determine within Ant whether verbose is enabled? -

within ant build.xml, want influence child process's verbose flag based on whether ant run verbose enabled. there variable set determine this? or otherwise, can parse raw ant command line somehow check whether -v passed? the property sun.java.command contains command line options <project > <echo message="${sun.java.command}" /> <condition property="verbose.is.set"> <contains string="${sun.java.command}" substring="-v" /> </condition> <echo message="${verbose.is.set}" /> </project>

swing - Java: SwingPropertyChangeSupport -

i trying make mvc java swing program makes use of swingpropertychangesupport notify view whenever model gets updated. problem having notifications not seem happening. i have prepared sscce below. in sscce, there swing gui has button , text field. when click button, counter in model gets incremented, , view supposed notified can update itself. however, appears notifications not sent/received (i not sure -- both) though have checked make sure oldvalue , newvalue different each other. appreciate assistance in understanding i've gone wrong. thanks! import java.awt.gridbagconstraints; import java.awt.gridbaglayout; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.beans.propertychangeevent; import java.beans.propertychangelistener; import javax.swing.jbutton; import javax.swing.jframe; import javax.swing.jpanel; import javax.swing.jtextfield; import javax.swing.swingutilities; import javax.swing.event.swingpropertychangesupport; publi...

javascript - iMacro's !LOOP from command line -

This summary is not available. Please click here to view the post.

linux - SCP first line of a file to another system -

i think should possible use combination of scp command , head command copy first line of file remote system, haven't been able come right command make happen. given scp command this: scp /shared/myfolder/myfile.txt myuser@myserver:/newlocation/myotherfolder/myfile.txt i'd send first line of myfile.txt remote system. use command first: head -1 myfile.txt >> myfile2.txt and scp myfile2.txt, helpful have in single command. scp doesn't read stdin or work bash process substitution, can try hacks like: head -1 myfile.txt | ssh myuser@myserver "cat > /shared/myfolder/myfile.txt"

sharepoint 2013 - Can I create an Azure AD registered multi-tenant application that can access OneDrive for Business data on both cloud only tenants and on-prem farms? -

i'm creating multi-tenant application on azure ad needs access onedrive business both cloud tenants , on-prem farms. here scenario: my application makes rest calls using sharepoint 2013 rest api. the scenario or class of app " daemon/server application web api ". my app needs needs app-only permissions since application runs @ scheduled time without user interaction. based on class of app i'm building , permissions need, i'm using client credentials oauth 2.0 flow allow app-only authentication. admin running app gives consent tenant once app, , app allowed run on it's own thereafter. everything works fine accessing data on cloud-only tenants, i'm not sure if it's possible access data on-prem farms don't have tenancy in azure ad. note, able make sharepoint app able access both, sharepoint apps don't allow apps app-only permissions grant full-control tenant on fly, have go azure ad application route because full control can grante...

c++11 - How can I push back onto a vector an instance of a class in C++ -

bear me please, first time posting. have 3 classes. class suppliers has set of class parent. class parent has vector of class location , class location has data memebers. ex (this pseudo code, not actual code. i've shown simplicity sake): class suppliers{ set<parent> setter; }; class parent{ vector<location> loc; }; ` the following constructor of location class created. run no problems until lines hit 2 lines iterators. trying find specific parent , push new location onto parent 'loc' vector. pass in iterator i've found reference. try push new instance of location class following error. data.cpp:139:33: error: passing 'const std::vector' 'this' argument of 'void std::vector<_tp, _alloc>::push_back(const value_type&) [with _tp = location; _alloc = std::allocator; std::vector<_tp, _alloc>::value_type = location]' discards qualifiers [-fpermissive] the last line gives error says cannot alter read-only...

csv - Grouping Data first by frequency, then by category in python -

Image
i have large csv file, log of caller data. an example of file: companyname high priority qualityissue customer1 yes user customer1 yes user customer2 no user customer3 no equipment customer1 no neither customer3 no user customer3 yes user customer3 yes equipment customer4 no user my code can sort data can top caller. however, need next find caller count of types of calls. format csv below: top calling customers, equipment, user, neither, customer 3, 2, 2, 0, customer 1, 0, 2, 1, customer 2, 0, 1, 0, customer 4, 0, 1, 0, i've tried sorts of combinations of groupby, counters, , loops cannot life of me past first colu...

java - how to run evalb in stanford corNLP? -

i'm not familiar stanford corenlp. want use 1 of classes evalb . i've imported packages (although many of them have errors). class evalb doesn't have error. when run got exception : exception in thread "main" java.lang.exceptionininitializererror @ edu.stanford.nlp.international.language.<clinit>(language.java:15) @ edu.stanford.nlp.parser.metrics.evalb.usage(evalb.java:136) @ edu.stanford.nlp.parser.metrics.evalb.main(evalb.java:163) caused by: java.lang.runtimeexception: uncompilable source code - package java.util.function not exist @ edu.stanford.nlp.parser.lexparser.abstracttreebankparserparams.<clinit>(abstracttreebankparserparams.java:13) ... 3 more java result: 1 i have installed jdk 1.8 how can fix this?

Auto-Build TypeScript Project in Visual Studios Code 2015 -

i starting out in type script, , using new visual studios code ide. facing issue can either use visual studios type script plug-in, , run javascript files using node. won't build js file automatically when ts file saved. uninstalled plugin, , installed typescript according video: https://egghead.io/lessons/typescript-typescript-up-and-running-in-seconds now can have 1 ts file built using --watch option, how accomplish auto building multiple .ts files when move on more complex projects require it? also best way write typescript using visual studios code ide? i'm not huge fan of set because have have terminal open watch single ts file (which can mean bunch of windows required watch each file, , terminal open run program. i'm not sure whether use visual studio code or visual studio 2013 . assume it's vs code (if it's not, consider switching. vs code good!). now i'll quote myself another answer . you can build commands: create simple tsconf...

How do I format result of Excel formula to take currency format? -

Image
i have 2 columns, each numeric value. third column product of first 2 columns numbers. want in format of $xxxx.00 rather xxxx . what can achieve this? right click on column header , choose format cells

algorithm - How to Memoize the solution to Unique Paths in Python -

Image
i've been trying solve problem while. m x n grid given , we've find number paths top left corner bottom right corner. simple problem though; there many solutions well. here're details. http://www.interviewbit.com/courses/programming/topics/math/problems/paths/ http://articles.leetcode.com/2010/11/unique-paths.html i solved problem in java, , wrote 1 more solution in python. want modify previous solution memoized table final answer gets collected @ bottom right cell. value of cell sum of right , left adjacent cells. here's code can't debug:- class solution: #actual recursive function def paths(self,row,col): if row == 0 or col == 0: self.mat[row][col] = 1 return 1 self.mat[row][col-1] = self.paths(row, col-1) self.mat[row-1][col] = self.paths(row-1, col) self.mat[row][col] = self.mat[row][col-1] + self.mat[row-1][col] return self.mat[row][col] # driver function. called de...

python - Getting User Identity from a POST Request in ASP.NET -

so asp.net site being hosted on intranet. 1 of things need able active directory username of person if trying post request through simple api have set up. currently confused settings. in web.config have following: <authentication mode="windows" /> and in applicationhost.config have this: <authentication> <anonymousauthentication enabled="true" username="" /> <basicauthentication enabled="false" /> <clientcertificatemappingauthentication enabled="false" /> <digestauthentication enabled="false" /> <windowsauthentication enabled="true"> <providers> <add value="negotiate" /> <add value="ntlm" /> </providers> </windowsauthentication> <iisclientcert...

Logging in to a site using Python Requests -

i trying programmatically log site using python requests library: login_url='https://login.drexel.edu/cas/login?service=https://one.drexel.edu/c/portal/login' login_payload = { 'username':'lk12', 'password':'1q2w3e4r5t6y' } s = requests.post(login_url, data=login_payload) print s.text note, username , password key retrieved page source's username , password id field. upon running script , looking @ output of s.text , appears never logged in despite login credentials being valid. output of s.text login page. using firefox, checked curl request looks like: curl 'https://login.drexel.edu/cas/login?service=https%3a%2f%2fone.drexel.edu%2fc%2fportal%2flogin' -h 'host: login.drexel.edu' -h 'user-agent: mozilla/5.0 (macintosh; intel mac os x 1...

php - Laravel Eager Load and Group Multiple Joins on Pivot -

i have pivot table thats used join 2 other tables have many relations per hotel_id. there way can eagerload relationship pulls results both tables in 1 relationship? raw sql query, works correctly when using belongstomany order off. amenities pivot table id hotel_id distance_id type_id distance table id name type table id name raw query (this works fine) select * amenities left join distance d on a.distance_id = d.id left join type t on a.type_id = t.id a.hotel_id = ? my "hotels" model using belongstomany so public function distance() { return $this->belongstomany('distance', 'amenities', 'hotel_id', 'distance_id'); } public function type() { return $this->belongstomany('type', 'amenities', 'hotel_id', 'type_id'); } this outputs collection, not grouped correctly. need loop these select fields side side entered in pivot table, user can select "type" , "dist...

backbone.js - JointJS Element with ports and tool items (delete, settings etc.) -

Image
i managed enhance svg-shape ports via: joint.shapes.devs.element = joint.shapes.basic.generic.extend(_.extend({}, joint.shapes.basic.portsmodelinterface, { // svg markup ports }); with output: i want enhance shape delete button. have: joint.shapes.devs.toolelement = joint.shapes.basic.generic.extend({ // markup delete button }); based on mike goodwin´s solution in how give jointjs elements remove tool? my question: how can combine portmodelinterface delete tool? solution should this: thanks helping me out. solution the key this plugin . author extended portsmodelinterface own code move-, resize- , ports-tool. extended further implementing delete functionality. way devs-model open extension in case of functionality. how it´s done in tooledviewplugin.js there joint.plugins.tooledmodelinterface = {} . in there added: deletetoolmarkup: '<circle fill="red" r="11"/><path transform="scale(.8) translate...

python library 'json' prints everything twice -

i decided make simple program started json in python 3.4.3 however, seemed write 2 lines before encountered weird; prints twice. program this: import json jsonfile = open('todo.json','r').read() print(jsonfile) this prints string twice. if remove 'import json' works fine. suggestions? thanks in advance okay, named py file json.py. did not think through

Rails controller update record by copying field -

i have rails 3.2 app copy contents of 1 field in controller action. costprojects contains these 2 columns: original_year project_year i want copy contents of project_year original_year . i tried doing this: update = costproject.where(:id => @costprojects).update_all(:original_year => :project_year) i error: pg::error: error: invalid input syntax integer: "project_year" line 1: update "costprojects" set "original_year" = 'project_year' w... ^ thanks help! please try : costproject.where(:id => @costprojects) .update_all("original_year = project_year") with former code: update_all(:original_year => :project_year) it trying update integer field original_year string value project_year . that's why got error.

In-House Enterprise Distribution: iOS 7 device "Unable to Download App", iOS 8 device has no issue -

i have been developing/distributing ios ipad app on year, have encountered problem. when run code on both ios 8 ipad , ios 7 ipad, there no issues. switch enterprise dist provisioning profile , create archive. update manifest.plist, correctly update version number, md5 values, etc. upload usual , when download app on ios 8 device, installs fine. when try , download on ios 7 device, says "waiting..." few seconds, error message, "unable download app "myappname" not downloaded @ time". i don't understand why i've never had issue in past, , makes no sense me why installs fine on other device. any ideas or appreciated! ios 7 ipad version: 7.0.4 ios 8 ipad version: 8.3 xcode version: 6.3.2 ios 7 ipad console logs: jun 2 12:37:47 kats-ipad wifid[70] <notice>: wifi:[454966667.548617]: client itunesstored set type background application jun 2 12:37:47 kats-ipad wifid[70] <notice>: wifi:[454966667.550120]: bg application: not ...

MS ACCESS, VB Import External MS Access table into SQL server table -

i have access database acting user interface. have linked sql server 2008 table in access database. on user interface there various filters/criteria user selects (such date, external ms access database, etc. these utilized in importing database. right importing external ms access database user selects internal table on user interface. goal import data directly sql server table. possible? here how doing now. dim select_file string dim varfile variant dim dbmonth string dbmonth = me.month.value '<-- month either default current month of user selects in combobox on user interface ' there code here has user select external access database , varfile = .selecteditems select_file = varfile docmd.transferdatabase acimport, "microsoft access", select_file, actable, "table_" & dbmonth & "_all", "table" so table "table" has data external ms access database user selected. wondering if there simple way imp...

powershell - Run function with Start-process within script -

i trying initialize ton of powershell windows complete scan quickly. each window needs different input , have array variable giving input. start-process function seems work, gives me unknown function error if use " , gives me absolutely no response when use ' foreach($search in $partlist){ start-process powershell.exe -argumentlist '-nologo -noprofile -executionpolicy bypass -command .\get-data -search $search -department $pndept -accuracy $accuracy; pause' start-sleep -s 5 } i not understand why unknown function error, believe no response because variables not global, i've declared variables global , still no luck. maybe i'm missing something. thanks. to add ansgar wiechars' answer, there following differentiator: jobs start new processes under hood give lot of framework running multiple instances, queuing , getting data back. however, starting new process each job expensive in windows. starting new powershell window going @ l...

android - Use adb over wi-fi with device that can't connect to computer -

my nexus x has gone haywire , refuses connect computer. uninstalling , reinstalling drivers did nothing. factory reset of tablet failed help. so, looking use wi-fi debug but, of course, can't connect set debug port 5555. there way of setting device rather computer? i've developed plugin connect device computer on wifi device has connected @ least once. take https://github.com/pedrovgs/androidwifiadb . phone hasn't rooted.

apply - Using lapply to list percentage of null variables in every column in R -

i given large csv 115 columns across , 1000 rows. columns have variety of data, character-based, integer, etc. however, data has lot of null variables of varying types (na, -999, null, etc.). what want write script generate list of columns on 30% of data in column null of type. to this, wrote script give me null percentage (as decimal) 1 column. this script works fine me. length(which(indata$observationyear == "" | is.na(indata$observationyear) | indata$observationyear == "na" | indata$observationyear == "-999" | indata$observationyear == "0"))/nrow(indata) i want write script columns. believe need use lapply function. i attempted here, however, can't seem script work @ all: null_counter <- lapply(indata, 2, length(x), length(which(indata == "" | is.na(indata) | indata == "na" | indata == "-999" | indata == "0"))) names(indata(which(0.3>=null_c...

ruby on rails - TimeWithZone & Time.zone.now integration test fails -

in controller method set user's variable activation_sent_at equal time.zone.now when activation email sent user. on development server seems work (although time expressions in application 2 hours behind on local time of computer). i want include integration test tests whether activation_sent_at indeed gets set properly. included line: assert_equal @user.activation_sent_at, time.zone.now however, produces error: no visible difference in activesupport::timewithzone#inspect output. should @ implementation of #== on activesupport::timewithzone or members. i think it's suggesting use expression time.zone.now in test. i've looked @ different sources, including http://api.rubyonrails.org/classes/activesupport/timewithzone.html , not sure here. suggestions causing error? additional info: adding puts time.zone.now , puts @stakeholder.activation_sent_at confirms 2 equal. not sure generates failure/error. the issue 2 dates close each other not same. can...

c# - Designing a WCF Service properly -

i need create wcf service @ work handle request different clients on same machine , optionally clients different machine on company's network (from programmer computer - debugging purposes). need suggestions on how create service because quite beginner when comes wcf. the service requests clients perform different operations on h/w devices located on host machine. service need contain several modules support kinds of h/w devices. programmers writing client code use modules objects perform operations. each module needs support events towards clients , exception throwing. i wanted know several things: is possible somehow export methods documentation clients? because best, when client code being written, programmer able see method does, exceptions being thrown , on. saw there way share api dll clients (keep in mind of clients run (and coded) on same machine using .net. is possible throw exceptions in service implementation methods? want use of .net abilities , exceptions ...

c# - Additional information: Failed to establish a connection to 'Server' -

i'm trying create service update postgresql database using topshelf, npgsql , c# following error when trying connect database. a first chance exception of type 'npgsql.npgsqlexception' occurred in npgsql.dll an exception of type 'npgsql.npgsqlexception' occurred in npgsql.dll not handled in user code additional information: failed establish connection 'hostname' this connection string. conn = new npgsqlconnection("server=hostname;port=5432;user id=uid;password=pass; database=dbname;"); i use the same connection line asp.net c# webapp working fine. pg_hba.conf file has line host all 0.0.0.0/0 md5 , postgresql.conf file has line listen_addresses = '*' . able connect database through pgadmin same log in credentials. have added rule firewall on computer port 5432 , host server not have firewall enabled. i tried run same code on same system postgresql server hosted using localhost server , receiv...

jquery - Getting the correct event.target for parent elements in Javascript? -

first off using vanilla javascript (no frameworks). trying click event listener on element doesn't exist yet doing (where parentelement exists already): parentelement.addeventlistener( "click", function(e){ console.log(e.target) } ) the thing clicking looks this: <a href="#" class="modal-close"> <i class="fa fa-times"></i> </a> i trying e.target match a tag matches i tag since being clicked. therefore if try , match a tag won't match. console.log(e.target.tagname == "a") //false how can match a tag instead of it's child (the i tag). i know if used jquery do: $("parentelementthatexists").on("click","a.modal-close",function(e){... that work fine. not using jquery. this works me window.onload=function(){ var x = document.getelementbyid("x"); x.addeventlistener( "click", function(e){ console.l...

drjava - Java not realizing Int inside if has changed -

my code supposed show slot machine type background there images in each lane not activated , when press spin randomizes ones visible , if not supposed visible set invisible. problem when press spin images not show up. when set them visible show up. believe when try set them visible in if/else statements. import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; import java.awt.dimension; import javax.swing.imageicon; public class slots1 extends jframe implements actionlistener { jpanel panel; jbutton spin; int wheelone = 0; jlabel imgslot1; jlabel imgslot12; jlabel imgslot13; jlabel imgslot14; jlabel imgslot15; jlabel imgslot16; jlabel imgslot17; public slots1() { dimension screensize = toolkit.getdefaulttoolkit().getscreensize(); double width = screensize.getwidth(); double height = screensize.getheight(); int wid = (int) width; int hgt = (int) height; jframe frame = new jframe("sesame chicken...

java - How to improve performance of Updating data using JPA -

i using ejb , container managed em ( local testing creating em here). have requirement need update database based on condition, issue update taking long time , how reduce ? i tried 2 approach 1> update query 2> update in entity please let me know if doing mistake, or other approach exist. note : code update below public class test { private static final int oaonaccount = 0; private static final int arraylist = 0; private static entitymanagerfactory emf; private static entitymanager em; static int test_size = 20000/4; public static void main(string[] args) { // createbulk(); createupdatequery(); // update(); } private static void createupdatequery() { long st = system.currenttimemillis(); emf = persistence.createentitymanagerfactory("jpa"); em = emf.createentitymanager(); system.out.println("---- createupdatequery ---"); entitytransaction tx = em.gettr...

Django/Python unorderable types: complex() < complex() -

'm learning django , python tutorial, , of time there bugs between different version of django or python. i ran problem "unorderable types: complex() < complex()" because of : def top_stories(top=180, consider=1000): latest_stories = story.objects.all().order_by('-created_at')[:consider] ranked_stories = sorted([(score(story), story) story in latest_stories], reverse=true) return [story score, story in ranked_stories][:top] i found solution said: use key function give stores score: ranked_stories = sorted(latest_stories, key=score, reverse=true) return ranked_stories[:top] but, wasn't working because of older version, told me try "yes, has changed bit. have specify lambda sorting because key has callable. using lambda makes callable on every item of iterable object using - ensuring key can used across kind of object instances own classes. try following: ranked_stories = sorted(latest_stories, key=lambda story: stor...

Is Python 3.4 backwards compatible for 2.7 programs/libraries? -

i deciding whether install python 3.4 or 2.7 on home server running ubuntu server 14.04.2. want ensure has support used python libraries (scipy, numpy, requests, etc) not sure how many of these packages support 3.4. do 2.7 packages work on 3.4? if no, differences between 2 causes errors? minor versions of python backwards compatible, major versions not maintain backwards compatibility. there many libraries work both, language not make guarantee.

python - How can I copy CMS pages from a development site to a live site? -

i've been integrating django cms django project has been in production on year. part of development activities, i've converted cms pages pages used static content before added django cms. development database contains pages copy live site rather require project staff recreate these pages on live site. i have searched django cms documentation did not find command this. i've searched issues on github, questions on , django cms google groups. thing i've found this discussion 3 years ago. discussion mentions using dumpdata dump cms models. i've tried it. dump contains information about pages (for instance, created page , when) not contain contents of pages. the live site has data must preserved. cannot perform database level dump on development site , restore on live site, erase or overwrite data exists on live site. i'm using django 1.7 , django cms 3.1.0. the discussion refer predates 3.x series. perhaps doing dumpdata models associated cm...

python - How to extract from a multi-indexed pandas.Series object based on secondary level criterion? -

i have pandas dataframe sample object below on perform group-by correlation calculation. @ end view time-series correlation between value1 , value2 data = [ (1, 'alpha', 3, 101, 2), (1, 'beta', 2, 102, 3), (1, 'gamma', 5, 103, 4), (2, 'alpha', 2.5, 101, 1), (2, 'beta', 2.2, 105, 2), (2, 'gamma', 5, 100, 0), (3, 'alpha', 2.1, 102, 0), (3, 'beta', 2.0, 102, 3.3), (3, 'gamma', 5, 100, 2), ] datapd = pandas.dataframe(data, columns=('time', 'id', 'value1', 'value2', 'value3')) corrvals = datapd.groupby('time').corr() so when @ corrvals['value1'] , select value2 items. they're on level after time . e.g. corrvals['value1'].index.values shows: array([(1, 'value1'), (1, 'value2'), (1, 'value3'), (2, 'value1'), (2, 'value2'), (2, 'value3'), (3, 'value1'), (3, 'value2'), ...