Posts

Showing posts from February, 2012

codeigniter - Using Code Igniter active record in Wordpress -

need move code code igniter wordpress. heavily using codeigniter's db classes handle database. use them this, instead of translating wp's wpdb. is there way of using code igniter active record/db classes , keep nice ci db usage in wordpress? thanks if using wordpress 3.3 , above, can make use of following library wordpressigniter usually, it's not straight forward think, because both of them have own code structure. many have tried , successful. depends on features want use , depth. following links may come handy you: so - ci wodrepress integration http://www.marketingadept.com/blog/integrating-codeigniter-and-wordpress/

Bamboo plan branching with different JDK version -

i'm working on bamboo, in plan configuration there task build maven project (maven 3.x configuration). when configuring plan branching there way change build jdk version specific branch? sadly, not possible of now. (see https://answers.atlassian.com/questions/67887/run-branchplan-with-different-build-configurations ) no, it's not possible. branches inherit build configuration master, there few things can modified or overridden. cannot create new jobs or tasks in branches. this shame imagine not uncommon use bamboo various versions of software might have build different jdks. simple (but unsatisfactory) workaround clone build plan , modify tasks accordingly :(

Quick help on Uncaught SyntaxError: Unexpected token ILLEGAL javascript Function -

i have following piece of code, <script type="text/javascript"> $(document).ready(function(){ $(".slidingdiv_rm").hide(); $(".show_hide_rm").show(); $('.show_hide_rm).click(function(){ $(".slidingdiv_rm").slidetoggle(); }); }); </script> however don't understand why i'm having following error: uncaught syntaxerror: unexpected token illegal index.php:222 line 222 $('.show_hide_rm).click(function(){ i'll appreciate help, thank much! you forgot closing quotes ' $('.show_hide_rm').click(function(){...

go - Undefined Error in Golang -

i have following structure: /*gotime.go*/ package gotime type struct { dnow int ynow int mnow time.month } and there function like: /*gotime.go*/ func (n now) daynow() int { n.dnow = time.now().day() return n.dnow } i'm getting following error when want call package: /*main.go*/ package main import ( "fmt" "./gotime" ) blah := fmt.println(blah.daynow()) i errors: # command-line-arguments .\main.go:5: imported , not used: "_/c_/users/ali/desktop/test/gotime" .\main.go:10: undefined: you can @ of package on github: link package how can solve problem? since now struct, need struct composite literal create value of type. also since package, need qualified name : blan := gotime.now{} also since modifying it, should / need use pointer receiver: func (n *now) daynow() int { n.dnow = time.now().day() return n.dnow }

sql server - Birt filter data set -

i have sql code select id1, ' ' id2, balance1, 0 balance2 table 1 union select ' ' id1, id2, 0 balance1, balance2 table 2 table 1 , table 2 have no relations, cannot use join. in report template have created table binded data set columns sql code outputs. i have put 2 detail rows in table this head: id balance detail1: [id1] [balance1] detail2: [id2] [balance2] i need filter out data table2 in detail1 , filter out data table1 in detail2. how do this? also table report results crossing data this: [id1] [balance1] [id2] [balance2] [id1] [balance1] [id2] [balance2] and need 1 detail reuslt on top , 1 on bottom : [id1] [balance1] [id1] [balance1] [id2] [balance2] [id2] [balance2] how should set report template? i think need query...

sql - use of outer joins in where clause if the value is defaulted -

in clause used column_name(+)=some value , use of right outer join column ex: deptno(+)=30 please explain thanks ex: deptno(+)=30 without other table join meaningless. the join against constant involves join event in constant being compared 1 of columns. error outer-join must include outer-join construct in constant test. without it, join can fail complete row. pervasive miscoding of outer-join because behavior of constant test when considered part of join event of outer-join different behavior when stands alone. have included sample of behavior difference 2 seemingly semantically equivalent queries not equivalent because 1 uses true join , 1 not. point being outer-join constructs give meaning when being used in join. solution have seen, code missing outer-join constructs. see common errors seen when using outer-join your query valid this: select <column_list> t1, t2 t1.c1 = t2.c1(+) , t1.c2(+) = ‘y’;

java - EntityManager becomes null -

i have curious error when using entitymanager. here extract of code. @persistenceunit entitymanagerfactory factory; @resource usertransaction transaction; entitymanager em; inside method: try{ datos.creardatos(docentrada); ctx.setdatosmensajes(datos); factory=persistence.createentitymanagerfactory("ealia"); transaction = (usertransaction)new initialcontext().lookup("java:comp/usertransaction"); entitymanager em = factory.createentitymanager(); //do whatever does, works fine. // here entity manager not null } catch (exception e){ } finally{ // here entity manager null try { svcsmensajes.grabarmensajesalida(datos, constantes.mensaje_salida_ws_usuarios_gestion, constantes.nombre_servicio_ws_usuarios_gestion, constantes.mensaje_entrada_ws_usuarios_gestion, em, ctx,transaction); } catch (cecaexception e) { // no devolvemos error en este caso } em.close(); factory.close(); } i don't ...

java - How to dynamically resize a Canvas inside a BorderPane with JavaFX -

i've been using swing long time , starting javafx . i'm having trouble figuring out how create resizable painting area. what i'd equivalent swing code: jpanel parent = new jpanel(new borderlayout()); jpanel drawarea = new jpanel(){ protected void paintcomponent(graphics g) { g.setcolor(color.white); g.fillrect(0, 0, getwidth(), getheight()); g.setcolor(color.red); g.drawline(0, 0, getwidth(), getheight()); g.drawline(getwidth(), 0, 0, getheight()); } }; parent.add(drawarea, borderlayout.center); this nicely scale fit parent container whenever change size. i'm trying same in javafx using borderpane parent , canvas inner control, based on code here: http://www.javacodegeeks.com/2014/04/javafx-tip-1-resizable-canvas.html this works setting canvas dimensions of parent component whenever change - however, prevents canvas shrinking when the parent ought shrink since parent size includes child canvas size...

jsf 2 - How to display bean validation message in modal dialog? -

for modal dialog bean followed link: automatically show validation messages in p:dialog on validation failure but @ same time want show data-table record also. if used action event in button, showing modal message, no data table records. in case of using string function in button, shows record, not validation message. how fix one?

asp.net - Condition in ASP Repeater Control -

this situation, wanted check whether datatable contains value particular column, if wanted display image. here code, <%if (databinder.eval(container.dataitem, "videoid") != "") {%> <img src="<%#configurationmanager.appsettings["baseurlimages"] %>videoicon.png" class="relatednewsicon" /> <%}%> it not working, correct me i'm wrong! thanks in advance, rajesh. check using condition in c# if (table.columns.contains("columnname")) { foreach(datarow row in table.rows ) { if(row["column"]!=null || row["column"]!="") { // disable or enable image desire } } } and bind repeater

javascript - Efficient way to change object key names -

i trying change object key names different. "name => text, _id => value" i tried following works fine. wondering whether there better ways that? var = { name: "foo", _id: "1234" }; var b = { name: "bar", _id: "222" }; var map = { name: "text", _id: "value", }; var arr = [a, b]; var arr2 = []; _.each(arr, function (obj) { obj = _.reduce(a, function (result, value, key) { key = map[key] || key; result[key] = value; return result; }, {}); arr2.push(obj); }); console.log(arr2); jsfiddle if number of properties two, can map them manually. var arr2 = _.map(arr, function (e) { var o = {}; o[map.name] = e.name; o[map._id] = e._id; return o; }); sometimes, manually cleaner. if want iterate on properties of given objects, then: var arr2 = _.map(arr, function (e) { var o = {}; (k in e) { o[k] = e[k]; } return o...

css - Create Image Button in Oracle Apex 5 -

Image
how can create image button in oracle apex 5 ? using universal theme in application. i have set button attributes below. but display this. update after using style="background-image:url(#app_images#holidays.png);background-repeat:no-repeat;" in button attributes field, image display this. instead of full image displays cropped image. how can fix issue ? the button templates of universal theme in apex 5.0 css icons only. if need image button small number of buttons, use "text" button template , enter <img src="#app_images#holidays.png"> into "label" attribute of button. if want have own image button template, go shared components -> templates , copy existing "icon , text" button template , name "image , text" , use following html markup <button class="t-button t-button--icon #button_css_classes#" #button_attributes# onclick="#javascript#" type="butto...

java - Remove ASCII Question Mark -

i have following string passed application. 2&#65533;4&#65533;9&#65533; (2�4�9�) i remove question mark ascii characters above string. how this? according unicode code table , &#65533; (or \ufffd ) is character �. you can remove unicode character string : str = str.replaceall("&#65533;", ""); but should try understand why there.

java - Disable the tabswipe -

i having 3 tabs have created using android.support.v4.view.viewpager want stop swipe horizontally fingers should working when user taps on name of tab. caloriebsearchheading.java public class caloriebsearchheading extends fragmentactivity implements actionbar.tablistener { private string[] tabs = { "recent","frequent","my foods" }; private string[] tabss = { "recent","frequent","my drinks" }; private viewpager viewpager; private actionbar actionbar; private tabscaloriebpageadapter madapter; private string foodtype; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_caloriebsearchheading); bundle bundle = getintent().getextras(); if(bundle != null){ foodtype = bundle.getstring("foodtype"); } viewpager = (viewpager) findviewbyid(r.id...

java - Maven - xmlbeans : working with multiple schema files to generate a single jar file -

i have different service schema files(more 5), wanted generate jar file using xmlbeans. i using xmlbean plugin follows <plugins> <plugin> <groupid>org.codehaus.mojo</groupid> <artifactid>xmlbeans-maven-plugin</artifactid> <version>${xmlbeans.version}</version> <executions> <execution> <goals> <goal>xmlbeans</goal> </goals> <phase>compile</phase> </execution> </executions> <inherited>true</inherited> <configuration> <download>true</download> <javasource>${java.version}</javasource> <schemadirectory>src/main/xsd</schemadirectory> <xmlconfigs> <xmlconfig implementation="java.io.file">src/...

Create ftp user in Windows server 2008 using php -

i have site provides option upload user's files using ftp. when working in cpanel, used cpanel api gave option create ftp users. on windows server, , have no idea how same - create ftp user using php. server running iis 7 if matters. found solution! there awesome tool called xlight ftp , can manage ftp users through mysql, , it's easy make sql queries in php. here full guide: http://www.xlightftpd.com/tutorial/usersodbc.html

performance - Access SQL-Server slow when opening multiple queries -

i upsizing access 2010 database ms sql-server , have strange problem occurs if open more 1 query. discovered problem because had form 3 sub forms opened slowly. removed 1 sub form after or opened queries testing. following description end of testing. to describe problem lets concentrate on 3 queries call qa, qb , qc. each query based on each 1 table on sql-server few records. tables linked tables connected sql server connection string (later found out connection string wrong , problem. keep here question , answer still makes sense.): odbc;driver=sql server native client 11.0;server=server01;trusted_connection=yes;database=aatest001; currently access , sql-server both run on single high performance pc. if open qa or qb or qc each query opens instantly. if open qa , qb , qc whole procedure becomes slow. first query starts fast, next (most of time) still fast. third query needs 10 seconds or more open. it not matter if open them in order a, b, c or c, b, or other order. last...

css - margin-top issue on HTML -

Image
i have following html <body> <div class="template"> <div class="box"></div> </div> </body> my css .template{ height:500px; width:1000px; background-color:#e1bfbe; margin:0 auto; } .box{ height:420px; width:165px; background-color:#ffffff; margin-left:416px; margin-right:417px; margin-top:37px; margin-bottom:38px; } now following output but when add float:left; in .box class following image only margin-top not working without float:left; why should add float:left top margin element .box ? here's thread describes same problem: css margin terror; margin adds space outside parent element it's common issue non-collapsing margins. an alternative adding float: left overflow: auto

ios - Trying to place a UIView over top of a UIImageView to highlight a section of UIImage -

Image
i building app displays text book on screen. text of page a uiimage , , contained inside of a uiimageview on screen. highlight each line of page, using a uiiview placed on top each line. here similar trying achieve, except in uiimage , have multiple lines highlighted, whereas in case, plan highlight 1 line @ time: each line covered a uiview of same dimensions line, want this uiview transparent, , colour yellow, red, or blue, not clear. opacity, , alpha values use achieve effect similar uiimage ? thanks in advance reply. set backgroundcolor of uiview desired color. set alpha of uiview 0.5 however, effect somehow different picture posted uiview on top , text color affected.

python - XSLT select from a nested element -

i'm sure i'm missing simple here... i can't select nested xml element using xlst transform. here xml <collection> <record> <leader>01814nam a2200205ia 4500</leader> <controlfield tag="003">psca</controlfield> <controlfield tag="005">20141201150951.0</controlfield> <controlfield tag="008">131110s9999 xx 000 0 und d</controlfield> <datafield tag="040" ind1=" " ind2=" "> <subfield code="a">psca</subfield> <subfield code="c">calyx</subfield> </datafield> <datafield tag="110" ind1=" " ind2=" "> <subfield code="9">76</subfield> <subfield code="a">children's services central</subfield> </datafield> <datafield tag="245" ind1="0" ind2="0...

amazon web services - Spring Boot with Embedded Tomcat behind AWS ELB - HTTPS redirect -

running spring boot application port 8080 on ec2 instance. aws elb configured redirect 80 -> 8080 443 (ssl termination happens here) -> 8080 application uses spring security , if user arrives http://example.com redirect . login page use ssl. spring security snippet: http.requireschannel().antmatchers("/login", "/logout").requiressecure(); we running redirect loop makes sense. to spring boot application looks requests made non-secured port 8080, redirects https://example.com , goes through elb , again gets request on 8080 any ideas on how run aws elb ??? looks did trick: @component public class tomcatcustomizer implements embeddedservletcontainercustomizer { @override public void customize(configurableembeddedservletcontainer container) { tomcatembeddedservletcontainerfactory tomcat = (tomcatembeddedservletcontainerfactory) container; tomcat.addconnectorcustomizers(new tomcatconnectorcustomizer() { @ov...

Bash script: variable output to rm with single quotes -

i'm trying pass parameter rm in bash script clean system automatically. example, want remove except *.doc files. wrote following codes. #!/bin/bash remove_target="!*.txt" rm $remove_target however, output say rm: cannot remove ‘!*.txt’: no such file or directory it bash script add single quotes me when passing variable rm. how can remove single quotes? using bash suppose have directory 3 files $ ls a.py b.py c.doc to delete except *.doc : $ shopt -s extglob $ rm !(*.doc) $ ls c.doc !(*.doc) extended shell glob, or extglob , matches files except ending in .doc . the extglob feature requires modern bash . using find alternatively: find . -maxdepth 1 -type f ! -name '*.doc' -delete

ios - Instantiate a *game scene* view Swift -

so, trying instantiate view controller. issue is, view trying to instantiate gamescene view controller (sprite kit). also, view instituting from gamescene view. if instantiating normal uiviewcontroller, this: let vc : anyobject! = self.storyboard!.instantiateviewcontrollerwithidentifier("main") self.showviewcontroller(vc as! uiviewcontroller, sender: vc) //the view instantiating's class name "gamescene" when try run this, 2 errors: gamescene not have member named "storyboard" 'gamescene' not have member named 'showviewcontroller' can please explain why not work, , please post working solution? thanks in advance! this because game scene not have property called storyboard or showviewcontroller . these part of uiviewcontroller class. . access them inside gamescene can create property inside gamescene pointing current uiviewcontroller . class gamescene: skscene { var gameviewcontroller : uiviewcontroller! ...

Python Help: Write the definition of a class WeatherForecast -

write definition of class weatherforecast provides following behavior (methods): a method called set_skies has 1 parameter, string. method called set_high has 1 parameter, int. method called set_low has 1 parameter, int. method called get_skies has no parameters , returns value last used argument in set_skies . method called get_high has no parameters , returns value last used argument in set_high . method called get_low has no parameters , returns value last used argument in set_low . no constructor need defined. sure define instance variables needed "get"/"set" methods. class weatherforecast(object): def __init__ (self, skies, value): self.skies = "" value = 0 def get_skies(): return self.set_skies def set_skies(self, value) self.skies = value def get_high(): return self.set_high def set_high(self, value): self.high = value def get_low(): return self.se...

angularjs - how to debug an angular for loop -

Image
i trying batch upload of multiple pdfs. each file named in specific format 02-2015 hip bs32 date / pipeline abbreviation / location abbreviation. i running files through loop compare abbreviations list in database. assign properties object before passed api controller. pipeline , location tables setup same. issue having pipeline. problem is, $scope.pip = $scope.pipelookup[matches[1]]; $scope.loc = $scope.locationlookup[matches[2]]; the locationlookup matching location abbreviation , placing in $scope.loc variable. pipelookup not working. of course throwing error because pipeline properties undefined. not sure if on looking something. if more information needed let me know $scope.companies = company.query(function () { }); $scope.locations = location.query(function () { }); $scope.pipes = pipe.query(function () { }); $scope.selectcompany = function () { var id = $scope.companyid.companyid $http.get('/api/apicompany/' + id) .success(function...

google spreadsheet - Conditional formatting based on validation errors -

i have drop down box , old data in sheet doesn't match drop down box list needs added conditional formatting cell stands out bit better. is possible set conditional formatting of cell based on whether or not cell has validation error? it impossible way want, there workaround. you can use conditional formatting custom formula. if data validation range, use range. if list, create range list. for example range on sheet2 a1:a10 has values used in data validation. want format range sheet1 b:b based on values found in range. first, select column in table(or whole table) , colour red . use conditional formatting following custom formula colour matches white =countif(indirect("sheet2!$a$1:$a$10"),"="&b1) you can add conditional formatting colour empty cells white if have empty space after table

javascript - service method does not recognize variable defined outside -

here service: angular.module('core').factory('servererroralert', ['toaster', function(toaster) { return function(errorresponse) { toaster.pop('error', 'error', errorresponse); if (deferred) { deferred.reject(errorresponse); } } } ]); here how call : function update(updatedtransaction, originaltransaction, updatelocal) { var deferred = $q.defer(); updatedtransaction.$update(function() { if (updatelocal) {angular.extend(originaltransaction, updatedtransaction);} deferred.resolve(updatelocal ? originaltransaction : false); } , servererroralert); return deferred.promise; }; the second update function calling servererroralert service. return promise can chained. as can see servererroralert merely convenience function. not define deferred in service, instead hoping recognize ...

java - Count Number of Users in Cassandra column family? -

i have table in cassandra- create table data_holder (user_id text, record_name text, record_value blob, primary key (user_id, record_name)); i want count distinct user_id in above table? there way can that? my cassandra version is: [cqlsh 4.1.1 | cassandra 2.0.10.71 | dse 4.5.2 | cql spec 3.1.1 | thrift protocol 19.39.0] the select expression defined as: selection_list | distinct selection_list so can: select distinct user_id data_holder;

c# - How to use WebClient with .NetCore? -

is there way use webclient in .net core application? if build application following error: severity code description project file line error cs0246 type or namespace name 'webclient' not found (are missing using directive or assembly reference?) i think webclient not part of .net core, there alternative? as @mike z says in comments, webclient isn't in core repo , won't ported. stack overflow question " need deciding between httpclient , webclient " has answers why should using httpclient instead. one of drawbacks mentioned there no built-in progress reporting in httpclient . however, because using streams, possible write own. answers " how implement progress reporting portable httpclient " provides example reporting progress of response stream.

css - Show hidden rect with text on hover of another poly -

i need use pure svg project. know how effect divs dont know how make work svg, dont know im doing wrong. i want show hidden black rect white text when hover on polygon (and polygon 0.1 of opacity normal , changes 0.8 of opacity on same hover) tooltip opacity , nice smooth transition, pure svg. .showme { opacity: 0.3; } .showme:hover { opacity: 0.8; } .desc { visibility: hidden; } .showme:hover + .desc { visibility: visible; } <svg width="200" height="200" viewbox="0 0 1000 300" xmlns="http://www.w3.org/2000/svg" version="1.1" > <rect x="1" y="1" width="998" height="298" fill="blue" class="showme"/> </svg> <svg width="200" height="200" viewbox="0 0 1000 300" xmlns="http://www.w3.org/2000/svg" version="1.1" class="desc" > ...

java - How can I make this JButton work -

i working on code generate random number when press button , output number. have wrote code , compiles when press button nothing works. can please help. here of code. public class slotmachine extends japplet { jbutton b1 = new jbutton("start"); jpanel p; int int1; public slotmachine() { init(); } public void init() { this.setlayout(null); this.setsize(1000, 1000); jbutton b1 = new jbutton("start"); b1.setbounds(100, 100, 100, 100); getcontentpane().add(b1); repaint(); } public void run() { b1.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { random random1 = new random(); int int1 = random1.nextint(11); } }); } public void paint(graphics g) { g.drawstring("your number is" + int1, 30, 30); } } avoid using null lay...

syntax - How to do an update + join in PostgreSQL? -

basically, want this: update vehicles_vehicle v join shipments_shipment s on v.shipment_id=s.id set v.price=s.price_per_vehicle; i'm pretty sure work in mysql (my background), doesn't seem work in postgres. error is: error: syntax error @ or near "join" line 1: update vehicles_vehicle v join shipments_shipment s on v.shi... ^ surely there's easy way this, can't find proper syntax. so, how write in postgresql? the update syntax is: [ [ recursive ] with_query [, ...] ] update [ ] table [ [ ] alias ] set { column = { expression | default } | ( column [, ...] ) = ( { expression | default } [, ...] ) } [, ...] [ from_list ] [ condition | current of cursor_name ] [ returning * | output_expression [ [ ] output_name ] [, ...] ] in case think want this: update vehicles_vehicle v set price = s.price_per_vehicle shipments_shipment s v.shipment_id = s.id

debugging - Can't step over when using GoClipse -

this duplicate question how debug go programs using goclipse? , thread answered 1 of 2 questions posed poster. when debug program goclipse, "step over" command functioning same "step into" command. has else seen issue?

python - Why getting invalid literal when running this script? -

when run following script, valueerror: invalid literal int() base 10: '2-' when date contains 1 digit (ie 02-02-2011). works fine when date has 2 digits (ie 11-11-2011). reason this, , how can fix it? from __future__ import division easygui import * import ystockquote import datetime import math def main(): stock = 'nflx' name = ystockquote.get_company_name(stock) start_date = create_date(02,13,2009) end_date = create_date(10,21,2014) start_price = get_price_on_date(stock,start_date) end_price = get_price_on_date(stock,end_date) if not isinstance(start_price,str): print "please enter different start date, market closed on day chose!" quit() else: start_price = float(start_price) if not isinstance(end_price,str): print "please enter different end date, market closed on day chose!" quit() else: end_price = float(end_price) no_of_shares = mat...

JavaScript function chaining using the singleton pattern -

i have small piece of code written in below. var = || {}; my.farm = (function () { var add = function(x){ console.log(x) return + this; }; return { add: function(x){ return add(x); } } }); on separate file create sheep instance of my.farm var sheep = new my.farm() i want able call function following output 6 sheep.add(3).add(2).add(1) any ideas how can achieve this? changes required my.farm snippet accommodate this? thanks in advance. something this var = || {}; my.farm = (function () { var x=0; return { add: function(newx){ if(typeof(newx) !="undefined") { x+=newx; return this; } return x; } } }); var sheep = my.farm(); console.log( sheep.add(2).add(4).add()); http://jsfiddle.net/7q0143er/

html - Chrome extension sending message from iFrame to event page then to content script -

i have inserted iframe content script. works fine. if want display parent's html content on iframe, have use messaging communicate between iframe , content script, doesn't work. tries send message iframe "event page" "content script". once content script receives message, query html content , reply. doesn't work either. how can make work? content script: var iframe = document.createelement('iframe'); iframe.id = "popup"; iframe.src = chrome.runtime.geturl('frame.html'); document.body.appendchild(iframe); chrome.runtime.onmessage.addlistener(function(msg, sender, sendresponse) { if (msg.from === 'event' && msg.method == 'ping') { sendresponse({ data: 'pong' }); } }); event page: chrome.runtime.onmessage.addlistener(function(msg, sender, sendresponse) { if (msg.from === 'popup' && msg.method === 'ping') { chrome.tabs.query({active: true, currentwind...

python - How do I decompose a number into powers of 2? -

i'm trying create function receives number argument , performs actions on number find out closest powers of 2 add number. example, if user enters 4, function append 4 because power of 2. if user enters 14 function should see 14 not power of 2 , closest powers of 2 make 14 2,4, , 8. key notes: going 2^9. what have far: def powers_finder(n): powers=[] i=0 total=0 while i<10: value=2**i total=total+value i=i+1 #this if statement if user enters power of 2 n #then number appended right away powers list. if value==n: powers.append(value) the problem here being if user enters in lets 5 (n) 5 made of power 2^2=4 , 2^0=1 4+1=5. how can extend function include process? thank you! most efficient way of doing this: def myfunc(x): powers = [] = 1 while <= x: if & x: powers.append(i) <<= 1 return powers

c++ - Why does printing a string array output hexadecimal? -

why following program print "0x2ffee4" console? #include <string> #include <iostream> using namespace std; int main() { string city1[] = "toronto"; cout << city1; return 0; } the answer given t.c. correct, mention if expecting print out "toronto" console using cout want this: include <string> include <iostream> int main() { using namespace std; // string city1[] = "toronto"; // compiler error - next line instead string city1[] = { "toronto" }; cout << city1[0]; return 0; } any time want initialize array of type during declaration need use = { }; set each array's element separated commas. @ code sample: #include <string> #include <iostream> int main() { using namespace std; string cities[] = { "new york", "philadelphia", "chicago", "boston" }; // same above except size of ar...

Scons Explicit Dependency -

i have simple .cpp file depends on jsoncpp . part of build process want scons untar jsoncpp (if isn't already) , build (if isn't already) before attempting compile app.cpp since app.cpp depends on .h files zipped inside of jsoncpp.tar.gz . this i've tried far: env = environment() env.program('app', 'app.cpp') env.depends('app.cpp', 'jsoncpp') def build_jsoncpp(target, source, env): shutil.rmtree("jsoncpp", ignore_errors=true) mytar = tarfile.open(str(source[0])) mytar.extractall() print("extracted jsoncpp") env.command("jsoncpp", ['jsoncpp.tar.gz'], build_jsoncpp) however, scons never prints "extracted jsoncpp"... attempts compile app.cpp , promptly fails. if using make , like: app: jsoncpp.tar.gz # build app jsoncpp.tar.gz: # extract , build here and order guaranteed. you should take @ untarbuilder , means extract tarfile , have of extract...

Jenkins - How do I pass Email-ext plugin's "Culprits" email list variable to a build step? -

culprits list of users committed change since last non-broken build till now. jenkins email-ext plugin able send email culprits during post-build action. i want use list of emails defined culprits in python script build step inside of jenkins job. can suggest how can this? the 'culprits' list comes scm plugin in jenkins , includes users have committed since last successful build. email-ext plugin sourcing list scm , generating email addresses based on following heuristic the plugin generate email address based on committer's id , appended "default email suffix" jenkins's global configuration page. instance, if change committed id "first.last", , default email suffix "@somewhere.com", email sent "first.last@somewhere.com" if email addresses have sort of pattern (and must do, otherwise email-ext plugin not generating correct addresses) can generate them inside groovy script eg: import hudson.model.* def...

java - JTextField deletes String at newline instead of appending -

i trying create gui client application. bufferedreader's .readline() acting input stream. problem prints newlines , carriage-returns in console, once try append in textarea seems rewrite previous string. here's example code public class airlinesclient extends jframe implements actionlistener { public static bufferedreader socketin = null; public static printwriter socketout = null; public static socket connection = null; public static string breakline; public static string command; public airlinesclient() throws unknownhostexception, ioexception{ jpanel schpanel = new jpanel(); jbutton schedules = new jbutton ("flight schedules"); jbutton pilots = new jbutton ("pilots' shifts"); //mainframe super.setsize(300, 400); setlocationbyplatform(true); setdefaultcloseoperation(exit_on_close); setvisible(true); //adding schedulebutton's panel root frame s...

Update / Add Navigation Properties with Entity framework -

i using repository , unit of work pattern entity framework 6. my entities (model classes) have following relationship: article ______________ __________|__________ _______________ | | | | tags images references authors reviewers whenever article created, data inserted tables (i.e. article , tags , images , references , authors , reviewers . there one-to-many relationship between article , other child tables. add method passed article object following: public class article { public int articleid {get;set;} icollection tags {get;set;} icollection images {get;set;} icollection authors {get;set;} icollection reviewers {get;set;} } adding database simple , doing following: public void add (article arc) { this.context.article.add(arc); } for update, not getting best way of doing this. user can pass on object of article amended navigation prope...

oracle - Oracle11g: Improve performance of sum function and group by -

i have query: select case when to_char(a.data_posicao_carteira, 'yyyymmdd') <= '20110513' a.codigo_favorecido else a.codigo_favorecido_original end codigo_favorecido, '13/05/11' posicao_carteira, b.banco, b.agencia, b.conta, sum(nvl(case when tv.valor_parcela = 0 tv.valor_venda else tv.valor_parcela end, 0)) + sum(nvl(case when tav.valor_parcela = 0 tav.valor_anulacao else tav.valor_parcela end, 0)) valor_bruto, sum(nvl(case when tv.valor_parcela = 0 tv.valor_desconto else tv.valor_parcela_desconto end, 0)) + sum(nvl(case when tav.valor_parcela = 0 tav.valor_desconto else tav.valor_parcela_desconto end, 0)) valor_comissao, sum(nvl(case when tv.valor_parcela = 0 tv.valor_venda else tv.valor_parcela end, 0)) + sum(nvl(case when tav.valor_parcela = 0 tav.valor_anulacao else tav.valor_parcela end, 0)) + sum(nvl(case when tv.valor_parcela = 0 tv.valor_desconto else tv.valor_parcela_desconto end, 0)) + sum(nvl(case when tav.valor_parcela = 0 ta...

python 3.4 - What is the preferred way to add many fields to all documents in a MongoDB collection? -

i have have python application iteratively going through every document in mongodb (3.0.2) collection (typically between 10k , 1m documents), , adding new fields (probably doubling/tripling number of fields in document). my initial thought use upsert entire of revised documents (using pymongo) - i'm questioning that: given revised documents bigger should inserting new fields, or replacing document? also, better perform write collection on document document basis or in bulk? this great question can solved few different ways depending on how managing data. if upserting additional fields mean data appending additional fields @ later point in time changes being addition of additional fields? if set ttl on documents old ones drop off on time . keep in mind if want set index sorts results descending _id recent additions selected before older ones. the benefit of of doing way continually writing data opposed seeking , updating data faster. in regards upserts ...

python - How do I write a csv file from a dictionary with multiple values per key? -

i posted question part of question. need write csv file in gives me name of technician, date worked on tract, , number of tracts on date. found way needed data dictionary key being name of technician , value being date , count using cursor through arcmap find data, using code so: desc = arcpy.describe(inlayer) fields = desc.fields field in fields: srow in cursor: tech = srow.getvalue("technician") moddate = srow.getvalue("modifieddate") formdate = moddate.strftime("%m-%d-%y") if tech == "elizabeth": escontract = escontract + 1 eslist = [] eslist.append(formdate) estech.update(eslist) date in estech.iteritems(): if tech in listedtech: listedtech[tech].append(date) else: listedtech[tech] = [date] where estech counter dictionary defined earlier , listedtech empty ...

JSON find in JavaScript -

is there better way other looping find data in json ? it's edit , delete. for(var k in objjsonresp) { if (objjsonresp[k].txtid == id) { if (action == 'delete') { objjsonresp.splice(k,1); } else { objjsonresp[k] = newval; } break; } } the data arranged list of maps. like: [ {id:value, pid:value, cid:value,...}, {id:value, pid:value, cid:value,...}, ... ] (you're not searching through "json", you're searching through array -- json string has been deserialized object graph, in case array.) some options: use object instead of array if you're in control of generation of thing, have array? because if not, there's simpler way. say original data: [ {"id": "one", "pid": "foo1", "cid": "bar1"}, {"id": "two", "pid": "foo2", "cid": "bar2"}, {"id": ...

java - How would i apply inheritance to very similar classes, like BlueScrollBar and RedScrollBar? -

i'm beginner inheritance in programming, i'm trying desgin rgb colour mixer here using inheritance design, have 3 classes, redscrollbar, greenscrollbar , bluescrollbar. tried create parent class first, called scrollbar , tried extend 3 classes. realised each class, need change variable names too, example: class bluescrollbar { //establish line x1 y1 , x2 y2 float bluelx1; float bluely1; float bluelx2; float bluely2; //establish box, x, y, width , height; float bluebx; float blueby; float bw = 20; float bh = 20; boolean bluemouseover = false; boolean blueboxlocked = false; float blueyoffset = 0.0; bluescrollbar(int lx1, int ly1, int lx2, int ly2) { bluelx1 = lx1; bluely1 = ly1; bluelx2 = lx2; bluely2 = ly2; bluebx = lx1; blueby = ly2/2; } void draw(){ if(mousex >=bluebx-bw/2 && mousex <=bluebx+bw/2 && mousey >=blueby-bh/2 && mousey <=blueby+bh/2 ){ fill(0); ...

regex - shell sed to replace a special character in a text file but unable to replace it -

i trying replace sam_18 sam in text file doesnt produce correct result. sed -i -e 's/sam_18/sam/g' it doesnt produce output. bit confused if considering '_' in between special character. help?thanks option -i requires file (at least) perform in-place substitution: sed -i -e 's/sam_18/sam/g' myfile if no file provided, sed reads standard input (or input pipe). cannot use -i in case. like: cat myfile | sed -e 's/sam_18/sam/g' > newfile

xcode - Adding a build variant and running it on iOS 8 -

Image
when create new ios project have 2 build variants, debug , release (or @ least that's called in android, build variant). is possible create build variant? let's say, "staging". then, how run app on different build variant, example how run in release mode on emulator/development device? yes, here's how. to add build configuration in menu left, select project. to right, you'll see "project" , "targets". select project. go info tab , click '+' under configurations , choose "duplicate "debug"/"release" configuration" , name whatever you'd like. to choose build type use click "nameofmyproject" next device you're building (upper left of screen) , choose "edit scheme". choose run -> build configuration -> nameofyourbuildconfiguration. hope helps.

java - > vs. >= causes significant performance difference -

i stumbled upon something. @ first thought might case of branch misprediction in case , cannot explain why branch misprediction should cause phenomenon. implemented 2 versions of bubble sort in java , did performance tests: import java.util.random; public class bubblesortannomaly { public static void main(string... args) { final int array_size = integer.parseint(args[0]); final int limit = integer.parseint(args[1]); final int runs = integer.parseint(args[2]); int[] = new int[array_size]; int[] b = new int[array_size]; random r = new random(); (int run = 0; runs > run; ++run) { (int = 0; < array_size; i++) { a[i] = r.nextint(limit); b[i] = a[i]; } system.out.print("sorting sorta: "); long start = system.nanotime(); int swaps = bubblesorta(a); system.out.println( (system.nanotime() - start) + "...