Posts

Showing posts from February, 2012

Does fixing the Checkstyle INFOs improve performance of the Java code -

i wondering while fixing checkstyle infos if leads performance improvement. understand info cannot taken still comment appreciated. i not think offer such improvement can wrong hence better seek expert advice :) assuming refer standard checkstyle checks: http://checkstyle.sourceforge.net/availablechecks.html refer style of source code, not "style of programming". example, code formatting ("arraytrailingcomma", "genericwhitespace"...) not affect actual bytecode generated class. there may class causes hundreds of warnings, , anothe class free of warnings, , in end, may compile identical bytecode. some of checks may influence code in way changes bytecode, , thus, influences performance @ least theoretically . example, "equalshashcode" check: if causes insert equals/hashcode method, may of course affect performance (but more importantly: behavior of program!). "booleanexpressioncomplexity" might cause split complex expre

javascript - Column of Kendo Grid is not resizable in IE 10 and IE 11 -

i using kendo grid in web app , including kendo.all.min.js file. version of js file 2012.1.515. in grid, columns not resizeable in ie 10 , ie 11 though works fine in other browsers. i have created sample of grid , included same file grid columns not resizeable in ie 10 , ie 11. here sample code: <!doctype html> <html> <head> <title></title> <link href="http://cdn.kendostatic.com/2013.3.1324/styles/kendo.common.min.css" rel="stylesheet" /> <link href="http://cdn.kendostatic.com/2013.3.1324/styles/kendo.rtl.min.css" rel="stylesheet" /> <link href="http://cdn.kendostatic.com/2013.3.1324/styles/kendo.silver.min.css" rel="stylesheet" /> <link href="http://cdn.kendostatic.com/2013.3.1324/styles/kendo.dataviz.min.css" rel="stylesheet" /> <link href="http://cdn.kendostatic.com/2013.3.1324/styles/kendo.dataviz.silver.min.cs

wordpress - Woocommerce- Reset product thumbnail size on product page -

i having interesting problem. thumbnail size product pages set 175 x 169 , catalog product 362 x 257 pixels. displaying product in header of shop using code: <?php echo do_shortcode( '[product sku="62-1166"]' ); wp_reset_postdata(); ?> this working fine. on shop pages when particular product displayed (one displayed in header) thumbnail appears 362 x 257 pixels rather 175 x 169 pixels. how fix issue?, here demo link: http://restaurantapplianceparts.com/dev/ ahmar. edit: actually, on further inspection due #product .woocommerce .products li being set width:90%. change field , sort issue. #product .woocommerce .products li { width: 175px; } this being set "image-wrap quickview" div class. has max width of 362px. if edit css give .image-wrap.quickview max-width of 175px, product thumbnail display correct width. .image-wrap.quickview { max-width: 175px; } this reduce size of thumbnails in related products below. altern

regex - Regular Expression in Google Analytics for two parts of string -

i need filter data in google analytics based on regular expression. i need "if string contains "/secure//secure/common/callback" and, further down string contains words "true" include it. i tried this: ^/secure//secure/common/callback*true i added start there bunch of text in between "callback" , "true" returns 0 when should return thousands of records. what regular expression use here? use this: ^/secure//secure/common/callback.*?true . means character .* means character repeated o or more times .*? has same meaning except not greedy, matches less amount of characters possible, usefull if have more 1 matching ( true in case) in string.

javascript - How to test with cross-origin data in node-webkit? -

i've been testing of cross-origin data through node success. however, ran situation node couldn't solve request data. i'm using getimagedata() function, throws cross-origin problem. on other cross-origin problems, node can handle requests, function seems give trouble. also, if package node-webkit , run stand-alone, works great. i'm sure there explanation, cannot find it. why node-webkit work, running node.js server not? without pouring code on page, let me try explain i'm doing. have axis camera i'm getting data from. it's motion jpeg, , stored in img tag i've got id'd. data coming http://ip , etc, etc. i think problem getimagedata() function requesting img tag id rather somewhere external, in-turn throw cross-origin flag. am correct? how can solve this? also, know of way test node-webkit apps without packaging them? essentially, node-webkit simulator? i have solved problem adding package.json: "chromium-args&quo

wordpress - Redirect with .htaccess without changing URL in address bar -

this question has been asked before, i'm not getting expected results following solutions in there. i need make redirect .htaccess without changing url in address bar. is, www.mydomain.com/en-uk should redirect www.mydomain.com/en but address bar should still display www.mydomain.com/en-uk i've tried few things no matter how url changes redirected path. of now, have this: redirectmatch 301 /en-uk/(.*) http://www.mydomain.com/en//$1/ also, should noted site uses wordpress. ideas? try: rewriteengine on rewriterule ^en-uk(/.*)?$ /en$1 [l]

php - Can't pass variable from routes to view in laravel 4 -

i'm trying learn laravel 4 , reading book called laravel: code bright i'm trying pass array data routes view error errorexception undefined variable: squirrel codes these. same in book. url localhost/test routes.php <?php route::get('/{squirrel}', function() { $data['squirrel'] = $squirrel; return view::make('simple', $data); }); ?> simple.php <!doctype html> <html lang="eng"> <head> <meta charset="utf-8"> <title>views!</title> </head> <body> <p>i wish <?php echo $squirrel; ?> squirrel!</p> </body> </html> you have variable this: <?php route::get('/{squirrel}', function($squirrel) { $data['squirrel'] = $squirrel; return view::make('simple', $data); });

c++ - memory allocation for static singleton class object -

this question has answer here: where static variables stored (in c/c++)? 15 answers for below singleton class memory taken (stack or global memroy) class singleton { public: static singleton* get() { static singleton instance; return &instance; } }; instance located in static storage (or global call it).

Making new array whose elements are every second element of another array.(Pascal) -

i've been trying make program ask user input elements of array , use array make new 1 elements every 2nd element of inputted array. writing: program keanu; uses crt; type arr=array of integer; var n,i:integer; a,c:arr; begin writeln('--enter desired length of array--'); readln(n); setlength(a,n); setlength(c,n); writeln('elements of array a:'); i:=1 n readln(a[i]); writeln('elements of array c are:'); i:=1; while (i<=n) begin c[i]:=a[i]; i:=i+2; end; write('c = {'); i:=1 n begin if c[i]=0 continue else begin write(c[i],' '); end; end; write('}'); readln; end. but can notice far efficient way make program job. first, because new array contain blank/empty elements(zeros) ignored continue statement , dont want if possible. second,i have problem when inputting number array length.last element of new array in output window small,negative number , shouldn't there @ all.i know has counter "i&q

c# - Slide-down animation for ItemsControl -

overview in wpf/xaml, best way implement slide-down animation when inserting item itemscontrol ? background at first glance, seems can use fluidmovebehavior blend expression interactions namespace. add itemspaneltemplate itemscontrol : <itemspaneltemplate x:key="easein"> <stackpanel isitemshost="true"> <i:interaction.behaviors> <ei:fluidmovebehavior initialtag="datacontext" duration="0:0:0.25" appliesto="children"/> </i:interaction.behaviors> </stackpanel> </itemspaneltemplate> this nicely slides other items in list down when new item added, doesn't animate newly added item. can add loaded animation in itemscontrol itemtemplate translate item offscreen offset 0: <datatemplate x:key="datatemplate1"> <grid background="white"> <grid.triggers&

pandas - python: slice according to an irregular pattern -

below, can find excerpt pandas timeseries. slice rows set apart white space. there recurring pattern, i.e. 21 times value x, 4 different values abcd, 21 times value y, 4 different values efgh, 21 times value z etc. in case, i'm interested in obtaining bcdy, fghz , on. the problem pattern interrupted due missing data. any ideas? thanks. 2014-01-20 00:00:00 197021 2014-01-20 00:01:00 197021 2014-01-20 00:02:00 197021 2014-01-20 00:03:00 197021 2014-01-20 00:04:00 197021 2014-01-20 00:05:00 197021 2014-01-20 00:06:00 197021 2014-01-20 00:07:00 197021 2014-01-20 00:08:00 197021 2014-01-20 00:09:00 197021 2014-01-20 00:10:00 197021 2014-01-20 00:11:00 197021 2014-01-20 00:12:00 197021 2014-01-20 00:13:00 197021 2014-01-20 00:14:00 197021 2014-01-20 00:15:00 197021 2014-01-20 00:16:00 196836 2014-01-20 00:17:00 196865 2014-01-20 00:18:00 196787 2014-01-20 00:19:00 196915 2014-01-20 00:20:00 196902 2014-01-20 00:21

Nginx automated /tmp cleanup? -

i've installed nginx on vps i found message inside nginx admin to automated /tmp cleanup add bellow cron 0 */1 * * * /usr/sbin/tmpwatch -am 1 /tmp/nginx_client via crontab -e command where should execute line ? 0 */1 * * * /usr/sbin/tmpwatch -am 1 /tmp/nginx_client my vps centos 5 32 cpanel go console of vps , following: $ crontab -e then, in cron file (which schedules jobs using * * * * * syntax can read more on wikipedia ) enter line: 0 */1 * * * /usr/sbin/tmpwatch -am 1 /tmp/nginx_client this execute command tmpwatch every hour, on hour. tmpwatch remove files modified file time greater 1 hour in /tmp/nginx_client directory.

javascript - Change Div and Body Class on Refresh -

i'm using backstretch plugin apply stretched background image body element. $("body.apples").backstretch("/apples.jpg"); $("body.oranges").backstretch("/oranges.jpg"); $("body.pears").backstretch("/pears.jpg"); i want body class change on refresh, shows different background images on refresh. i'm trying work out how show related .wrapper div below when page refreshed. <body class="apples"> <div class="wrapper apples"> <h1>something apples</h1> <p>some content</p> </div> <div class="wrapper oranges"> <h1>something oranges</h1> <p>some content</p> </div> <div class="wrapper pears"> <h1>something pears</h1> <p>some content</p> </div> </body> i've managed .wrapper div change

Parse Push notification not working if app is killed (Android) -

i have implemented parse notification in app. have put initialization call in app.oncreate(). when app running, works perfectly. however, if app killed, find notifications not coming through. has seen this? if app force stopped, google cloud messaging won't work until app launched again user. that's behavior since android 3+ (don't remember exact version). if app runs in background or stopped implicitly os (to free memory), gcm work. parse push notifications behave same, since use gcm.

php - MATCH AGAINST unknown column -

Image
i have problems searching method, i'm using match against because it's better like. example have database full of cities , when type city name (for example moscow) in input field, there error "unknown column 'moscow' in 'where clause'". have 2 columns in database, city_id , city_name my sql query looks this "select city_name default_cities match(city_name) against($city)" if have suggestions i'll appreciated :) "select city_name default_cities match(city_name) against('$city')" use quotes $city edit don't forget escape it. (for ex. "l'amour")

mysql only compares first numerical part of string to int column in where -

this more "why" or "any pointers documentations" question. today realised comparison in clause takes first numerical part of string if compared int column. (my own conclusion) for example: select * companies c id = '817m5' will still return companies id = 817. it make sense i'm failing find documented anywhere see if conclusion correct , if there additional things know exact behaviour. where , int type, comparison documentation? where? how called? thanks! this comparison: where id = '817m5' and id integer. so, mysql has compare integer string. well, can't directly. either has convert string number or number string. mysql converts string number, converting leading numeric characters. so, '817m5' becomes 817 . here exact quote: to cast string numeric value in numeric context, not have other use string value though number: mysql> select 1+'1'; -> 2

c# - How to give a call to more than two Get method using mvc4 web api controller -

i'm working on mvc4 web api project. i have created new controller groupvaluescontroller , have following methods public groupviewmodel get() public list<groupmodel> get(guid id) public list<groupmodel> getdetails(guid id) first 2 methods working fine i'm calling them group.cshtml view following $.getjson( "api/groupvalues", function (data) { and $.getjson( "api/groupvalues/" + id, function (data) { for third controller method public list<groupmodel> getdetails(guid id) i'm executing details.cshtml view following not working. i'm mismatching calling ? function getgroupdatabyid(id, ctrl) { $.getjson( "api/groupvalues/getdetails/" + id, function (data) { is related route? public static void register(httpconfiguration config) { config.routes.maphttproute(

objective c - CHCSVParsing an unusual csv file -

i'm having difficulties how should parse kind of csv file. for example: 06:16 pm,7,299,http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0026_heavy_rain_showers_night.png,moderate rain @ times,14,22,180,s,3.1,81,10,993,75 2014-01-31,9,48,3,38,22,35,176,s,119,http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0003_white_cloud.png,cloudy,6.0 2014-02-01,7,45,3,37,19,30,220,sw,113,http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0001_sunny.png,sunny,2.2 2014-02-02,9,47,3,37,17,27,236,sw,113,http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0001_sunny.png,sunny,0.0 2014-02-03,8,46,3,37,21,34,152,sse,116,http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0002_sunny_intervals.png,partly cloudy,1.8 2014-02-04,9,48,3,38,20,32,191,ssw,263,http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0009_light_rain_showers.png,patchy light drizzle,1.4 "london","united kingdom"

Always java.lang.NullPointerException with android device (Lenovo and NEC and all devices running android 2.3.x) -

Image
always java.lang.nullpointerexception android device (lenovo , nec , devices running android 2.3.x) i wondering why game error @ java.lang.nullpointerexception android device(lenovo , nec , devices running android 2.3.x). it's working very samsung device tested. please see attached print screen captured crashes & anrs in play store, , game link in play store: https://play.google.com/store/apps/details?id=kids.iq.kidsiqpicturesquestionfull here full code(color_q_easy_1.java) package kids.iq.kidsiqpicturesquestionfull; import java.sql.date; import java.text.simpledateformat; import java.util.calendar; import java.util.random; import java.util.timer; import java.util.timertask; import android.annotation.suppresslint; import android.annotation.targetapi; import android.app.activity; import android.app.dialog; import android.content.clipdata; import android.content.intent; import android.graphics.color; import android.graphics.typeface; import android.graphics.drawa

php - Showing different content based on $_SESSION UserLevel -

i having problem trying show different menu options based on userlevel. have mysql database users table. users table contains userlevel either set 0 or 1. reason php isn't working. in fact, when add php menu, not display on site below menu. advice appreciated. code starts session <?php if(!empty($_session['loggedin']) && !empty($_session['username'])) { ?> <?php include "mainnav.php"; ?> <center> <h2> campaign updates</h2> </center> <div id="campaignpostwrap"> <div id="campaignscrollbox"> <?php $con=mysqli_connect("localhost","dorians","ds2953!b67p$","aldentec"); // check connection if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } $result = mysqli_query($con,"select * campaigns order postdate desc"); while($row = mysqli_fetch_array($result)) {

c# - How to Add text in current RichTextBox text WPF -

i want add text richtextbox. example consider have 1 richtextbox , text "uzair" , want add "ali". string mytext = "ali" richtextbox.text += mytext i don't know why there isn't text property of richtextbox in wpf there alternative richtextbox.text property? use appendtext add text richtextbox . richtextbox.appendtext("ali");

excel - How to select a value given a set of criteria -

i have following table , select $ products when index = max: id product $ max? 1 1 no 2 b 2 no 3 2 no 4 c 4 no 5 d 5 no 6 3 yes 7 b 6 yes 8 c 8 yes how results in column identified max? regards. upd: the results should based on max id , not max $. sorry confusion if need formula max column based on max id, try next one: =if(max(if(b:b=b2,a:a))=a2,"yes","no") where b:b column products, a:a - column id. just select d2 , enter formula in formula bar, , press ctrl + shift + enter evaluate , drag down. note, if know exact ranges of data, can change b:b , a:a e.g. $b$2:$b$100 , $a$2:$a$100

javascript - move blocks between two divs -

so have 2 divs , inside there gona blocks: <div class="list-block 01"> <span>21@epos.com</span> <span class="movesym" id="01">+</span> </div> if 1 clicks on + whole block moves other div. works move ech block div once, need them go both ways as .movesym clicked. my js //remove block on click $('.del-block').on('click', function() { var block = $(this).attr('id'); $('.' + block).remove(); }) //move form list blocks different fields $('.leftside01 .movesym').click(function() { console.log($(this).attr('id')); var id = $(this).attr('id'); $(this).text("-"); $('.leftside01 .list-block.' + id).appendto('.rightside01'); }) $('.rightside01 .movesym').click(function() { console.log($(this).attr('id')); var id = $(this).attr('id'); $(this).text("+");

osx - Mac OS X: How to handle iflt_detach() not completing in KEXT stop function -

in kext's stop() function, call iflt_detach() detach registered iff filter. however, appears (for whatever reasons), filter's detach() function may called outside of stop() function. in case, should in stop function? can't return kern_success since cause kext unloaded obvious side-effects delayed call detach() function. the following snippet enetlognke.c , shows stop() function: kern_return_t com_dts_apple_kext_enetlognke_stop (kmod_info_t * ki, void * d) { kern_return_t retval = kern_failure; // default result, unless know are // detached interface. if (gfilterregistered == false) return kern_success; if (gunregisterproc_started == false) { // want start detach process once. iflt_detach(genetfilter); gunregisterproc_started = true; } if (gunregisterproc_complete) { retval = kern_success; } else { el_printf("enetlognke_stop: incomplete\n"); } if (retv

ios - Decrementing app badge when push notification received outside of app -

i'm trying make sure push notifications in app date, reflect current data on server. so example scenario: i'm making email app the user receives push new email then user deletes email on pc, before looking @ device. how can remove push device , decrement badge count? i've tried sending new push decremented badge count popup new notification when don't want new notification popped up.

angularjs - Facebook login callback not called -

i'm trying use fb api login on app built angularjs. i'm using angular-facebook library. works, issue once user authorized app, callback not called. popup window not closed, , solution user reload page. how can fix this? $scope.login = function() { facebook.login(function(response) { // never called ;_; if (response.status == 'connected') { // need stuff here } }, {scope: 'email,user_birthday,user_likes'}); }; if want more detail information on how use angularjs facebookapi, might helpful: http://www.boynux.com/angularjs-facebook-integration/ regards,

ios - Magical Record saveWithBlock: not saving -

i'm having trouble getting objects save using method [magicalrecord savewithblock:completion]. when switch on using normal blocks works fine. using version 2.2develop. the code below works, , have commented out savewithblock: specific parts. executeblock...: methods wrap dispatch_async , executeblockonmainthread: replaces completion: block. [card.managedobjectcontext mr_savetopersistentstoreandwait]; //[magicalrecord savewithblock:^(nsmanagedobjectcontext *localcontext) { // replace this... [nsobject executeblockinbackground:^{ // this... card *localcard = [card mr_incontext:[nsmanagedobjectcontext mr_contextforcurrentthread]]; // mr_incontext:localcontext]; nsrange range = [localcard.fragment rangeofstring:localcard.term options:nscaseinsensitivesearch]; if (range.location == nsnotfound){ return; } nsstring *fragmentstring = [localcard.fragment stringbyreplacingoccurrencesofstring:@" " withstring:@"+"]; nsstring *url

sql server - Bulk Insert from sqlcmd not firing trigger -

i'm using sqlcmd in batch file weekly imports. sqlcmd -u xxxx -p xxxx -i e:\data\importtc.sql the command executing, bulk insert [xxxx].[dbo].[stage] 'e:\acct\timecards\timecard.txt' (fieldterminator = ',', rowterminator = '\n', fire_triggers) go from inside sql server management studio, works fine. when exec sqlcmd won't fire trigger manipulates of data. anyone encountered before? thank you.

grails - import groovyx.net.http.RESTClient in Groovy class -

i try import groovyx.net.http.restclient in groovy class. groovy class this: void getrest() { def r = new restclient(url) def response = r.get(path:'test',headers:['authorization': "auth"] ) println "response" println response.headers response.headers.each { -> println } } in class, import restclient this: import groovyx.net.http.restclient however, got "unable resolve class groovyx.net.http.restclient" error. using netbeans ide 7.4. i have config buildconfig.groovy following code: compile ":rest:0.8" and add maven repo: mavenrepo "http://repository.codehaus.org/" but still can't import restclient. should that? fix it. add 1 more repo buildconfig: mavenrepo "http://grails.org/plugins"

javascript - d3 grid lines, have done some research but still stuck -

Image
i teaching myself d3. have read through tutorials scott murray , reading through d3 tips , tricks , have looked through stackoverflow. read "proper way draw gridlines, among others. when have question answer here. stuck, due inexperience, , have fiddle: fiddle demo here snippet copied "proper way draw gridlines": svg.selectall("circle") .data(yscale.ticks()) .enter() .append("circle") .attr("x1", margin.right) .attr("x2", width) .attr("y1", function(d){ return yscale(d[2]); }) .attr("y2", function(d){ return yscale(d[2]); }) .attr("fill", "none") .attr("shape-rendering", "crispedges") .attr("stroke", "black") .attr("stroke-width", "1px"); i love draw grid lines across y axis , x axis, figured i'd 1 thing @

web - What are the different ways you can communicate with USB port through Browser -

i want create webpage access usb port of client. intent configure hardware connected usb port. can desktop application because configuration option different different hardware. connected , need pull code dynamically server. not web programmer. great find best way this. it ends attempting write app performs similar. doing, instead writing both web server , web page. use simple, dlib web server, serve data end user. this how works: web server handles usb connection. if written in c++ or other native language, have more control on device. web page loaded web server have written. in web page, can have sort of javascript worker, etc. pull new data server , push data web interface usb device. adds layer of protection because can ensure user has not made modifications web page. the main drawback possibility required install server on client's machine. however, can circumvented writing applet can embedded within page!

java - Maven configuration: pass file inside a classpath jar as an argument -

several maven plugins need/support passing java.io.file configuration parameter, wherein specify relative/absolute location of file plugin locate , use. is there way can specify property file in plugin configuration file has found inside jar in classpath? i'm particularly wanting know , use aspectj-maven-plugin , can specify xlintfile value custom xlinkdefault.properties file location. file, in case, found inside classpath jar. i use maven-2.2.1 way. no, not in general; there's no magic turn that's not file on disk java.io.file . many maven plugins (e.g., maven-checkstyle-plugin 's configlocation designed allow more flexible input these cases: this parameter resolved resource, url, file. if resolved, contents of configuration copied ${project.build.directory}/checkstyle-configuration.xml file before being passed checkstyle configuration. as workaround, if plugin cannot changed, dependency:unpack may way classpath resource local file (see ma

flash - Security sandbox violation in Windows Server 2008 -

i experiencing security violation error when make http requests webserver. error #2044: unhandled securityerror:. text=error #2170: security sandbox violation: i have following crossdomain file in root of server, , using same configuration in server host in machine. however, webserver unable connect windows server 2008 r2 this crossdomain.xml file: <?xml version="1.0"?> <!doctype cross-domain-policy system "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"> <cross-domain-policy> <site-control permitted-cross-domain-policies="all"/> <allow-access-from domain="*" to-ports="*" secure="false"/> <allow-http-request-headers-from domain="*" headers="*" secure="false" /> </cross-domain-policy> and .as file security.loadpolicyfile("http://123.456.789.123:8000/crossdomain.xml"); security.allowdomain("*");

html - Full Example of Coinbase API? -

i realize may asking lot api provide few lines. want see how put , call in html. think seeing full example me lot! what know need: need request url $.getjson("https://coinbase.com/api/v1/prices/spot_rate?api_key=xxx" that provides validation need, accessing api( think). rest of code provide on site methods. # reponse { "amount": "10.00", "currency": "usd" } so call in html use <div id="call"></div> i'd appreciate help! you can add &callback=? url shown in jsfiddle. http://jsfiddle.net/8n7an/ $.getjson("https://coinbase.com/api/v1/prices/spot_rate?currency=usd&callback=?", function( data ) { //do want response here }); otherwise, you'll run cross origin request issue require server side access fix. so in case url be: https://coinbase.com/api/v1/prices/spot_rate?currency=usd&callback= ? i don't think need api key call. in fact, if you&#

dynamic programming - Set partitioning with constraints java -

the what i'm attempting produce optimum set of brackets (optimum defined constraints) tournament. the problem i don't know how approach problem. this paper pretty high level discusses possibility of solving set partitioning problems constraint programming. states majority of set partitioning problems solved via integer programming. looking example emulate. question similar so question . majority of constraint examples i've seen defined specific partition total. possible model system partitions determined dynamically constraints , participant set? link examples limited 2 due reputation. a more concrete example known values the number of participants n. each participant has weight w associated them. constraints a bracket (set) made of 2,3,4,6,7, or 8 participants. each participant in single bracket. the must not more 15% difference between lowest weighted participant , highest weighted participant in bracket. favor creating brackets of size

arrays - How to rotate a binary vector to minimum in Python -

if have arbitrary binary vector (numpy array) in python, e.g. import numpy np vector = np.zeros((8,1)) vector[2,1] = 1 vector[3,1] = 1 this give me binary array 00001100. have 00000000 or 00010100 etc. how make such script when give binary vector input, script gives minimum right-rotated binary numpy array output? few examples: 00010000 --> 00000001 10100000 --> 00000101 11000001 --> 00000111 00000000 --> 00000000 11111111 --> 11111111 10101010 --> 01010101 11110000 --> 00001111 00111000 --> 00000111 10001111 --> 00011111 etc. suggestions / optimized python implementations in mind? =) thank assistance. need local binary pattern implementation =) the fastest way create table first , can use ndarray indexing result, here code: you need create table yourself, code here demo import numpy np np.random.seed(0) #create table def rotated(s): in range(len(s)): s2 = s[i:] + s[:i] if s2[-1] == "1": yi

php - I can't update a SQL table with right concatenation -

could me concatenate in way ? tried wasn't able make it! here's code : include('config.php'); $base="recettes"; $sql="insert into". $base." (username, titre) select '$username', '$output[0]' "; $request = mysqli_query($con,$sql); thank you! about concatenation... you're missing space behind , before ($username when have query error, echo query see looks like.

c++ - Regexp with flex -

i trying write flex rule this: %% [0-9]+ yylval=atoi(yytext); return number; [<] return langle; [/>] return closerangle; [>] return rangle; [/] return slash; [ a-za-z0-9] yylval=strdup(yytext); return anything; \n /* ignore end of line */; [ \t]+ /* ignore whitespace */; %% when run flex program against file, says: example4.l:19: warning, rule cannot matched example4.l:20: warning, rule cannot matched i guess because in rule [/>] matches either / or > . question how write rule matches / and > together? i tried documentation: says that: ‘rs’ regular expression ‘r’ followed regular expression ‘s’; called concatenation am not doing same? what's wrong? , how cope this? i guess because in rule [/>] matches either / or > . exactly. but question how write rule matches / , >

Routing Errors on attempts to delete all records in a table using Rails 4 through a link_to -

i using rails 4, , trying delete assessments using link_to helper. pertinent code below: routes.rb resources :assessments collection delete :remove_all end end assessment index.html.erb <p>to delete assessments in 1 swoop, click <%= link_to 'remove assessments', remove_all_assessments_path, method: :destroy, data: { confirm: 'are sure?' } %> assessments_controller.rb def remove_all @assessments = assessment.all @assessments.each |assessment| assessment.destroy(assessment.id) end flash[:notice] = "all assessments have been deleted." redirect_to assessments_url end i run rake routes , prefix verb uri pattern controller#action remove_all_assessments delete /assessments/remove_all(.:format) assessments#remove_all the html source generated link: <p>to delete assessments in 1 swoop, click <a data-confirm="are sure?"

selenium webdriver - Dealing with elements that are not visible due to zoom level -

we have automation processes have been scraping website months. discovered our scraper isn't working. turns out, website has been changed have table 9 columns placed inside frame. however, either frame or table styled improperly , first 6 columns on screen @ 100% zoom because table big. when zoom out 50%, rest of columns manage fit in view. unfortunately, there button on last column need click, selenium doesn't , says element not in view @ 100% zoom. when use following check whether it's in view or not while (!elmt.isdisplayed()) { // wait } and manually zoom page out column button comes view, clicks button. how can zoom page out? yes had similar issue while testing in safari. the work around zoom out page programmatically before perform operation on page. with of js can this: document.body.style.zoom = "30%" or whatever value required. in selenium make use of javascript engine execute script. this worked work around worked me.

optimization - is there a "best way" to short circuit a mysql query -

i have situation i'm assembling query based on user provided criteria , want figure out efficient way this. if have table looks this: int id | varchar phone | varchar email | varchar rfid and user pass in array defines order (and items) they'd user *could this: ["id","email","phone"] or this: ["email"] or this: ["phone","rfid"] or other possible combination of 4 fields. based on receive need user in order in these fields arrived , if find match, don't want keep looking. in other words if input is ["email","rfid","phone"] and db , find user provided email, don't want keep looking see if rfid matches, want return said user. however, if don't find such email, want move on rfid. so, in various tests i've done (mostly playing case statement in where clause) results have been terrible. taking second return value, opposed taking <50ms when sim

c# - Issue with D&D from list box to the screen -

i'm using following code drag & drop listbox textbox working great, got problem. when drag item listbox , mistake drop screen, not in textbox . cant take item drag screen , noting. need pick new item list , drag textbox , can drag again. there way to check if item drag drop in textbox? this code use , calling dodragdrop method. if drag wrong place in screen (not textbox), idea? private void listbox_selectionchanged(object sender, routedeventargs routedeventargs) { if (sender listbox) { var listbox = sender listbox; if (listbox.selecteditem != null) { var myselecteditem = listbox.selecteditem user; if (myselecteditem != null) { dragdrop.dodragdrop(listbox, myselecteditem, dragdropeffects.copy | dragdropeffects.move); } } } }

bash - avconv : flac to ogg conversion with metadata kept -

i'm writing command line tool convert input music library various formats (flac / ogg / mp3 / ...) output music library of given format (flac / ogg / mp3). i've based on avconv (or ffmpeg if avconv not available) since complete command line converter i've found. script available @ url (github): https://github.com/biapy/howto.biapy.com/blob/master/various/mussync-tools i'm trying pass metadata input library files output/converted library files. i've come code: local map_metadata=' 0:g' # specific needs input formats/ case "${input_file_mimetype}" in 'application/ogg' ) # input metadata first audio stream , direct global. map_metadata=' 0:s:0' ;; * ) # nothing. # map_metadata=' 0:g' ;; esac # specific needs output formats/ local output_options="" case "${output_format}" in 'flac' ) # no encoding options needed. en

python - Installing PyQuery Via Pip -

i'm attempting install pyquery via pip i'm getting error not understand. command used was: sudo pip install pyquery i output below: requirement satisfied (use --upgrade upgrade): pyquery in /usr/local/lib/python2.7/dist-packages downloading/unpacking lxml>=2.1 (from pyquery) running setup.py egg_info package lxml /usr/lib/python2.7/distutils/dist.py:267: userwarning: unknown distribution option: 'bugtrack_url' warnings.warn(msg) building lxml version 3.3.0. building without cython. error: /bin/sh: 1: xslt-config: not found ** make sure development packages of libxml2 , libxslt installed ** using build configuration of libxslt downloading/unpacking cssselect (from pyquery) running setup.py egg_info package cssselect no previously-included directories found matching 'docs/_build' installing collected packages: lxml, cssselect running setup.py install lxml /usr/lib/python2.7/distutils/dist.py:267: userwarning: unknown distribution option: '