Posts

Showing posts from January, 2011

python 2.7 - Why is '5' passed into warriors_game when it is called instead of 'win' -

why '5' in line 4 passed warriors_game when called instead of 'win'? shouldn't python pass argument argv1 last thing assigned (which 'win')? def warriors_game(*args): arg1, arg2, arg3 = args arg1 = 5 print "if warriors %s i'll happy." % arg1 print "if warriors %s i'll sad." % arg2 print "just kidding, don't care %s, %s, or %s." % (arg1, arg2, arg3) warriors_game('win', 'lose', 'draw') # why doesn't pass 'win'

wordpress - positioning background image with CSS -

i building wordpress site. on homepage, trying position ball without affecting other divs under slider, theme maker has given same class name. want make ball small , place under writing. theme not allow me assign class image. i've tried affects other images in row. me please? thinking may able use first child not sure. thanks! .cg-strip .cg-strip-bg { background-size: contain !important; background-position-y: 90%; background-size: 50%; } use: <div class="cg-strip-bg " style="background:url(http://adasportsandrackets.com/wordpress/wp-content/uploads/2014/10/ada-460-mole150x146hp.png) no-repeat center bottom / 80%!important; "></div> note!! don't use: background-image: background: stuff: url(blabla.png) no-repeat center bottom / 80%!important 80% size, might bit below text, you're free fix till desired result.

ruby - How to merge hash of arrays? -

i have array: [ {a => 1, b => { c => 1, d => 1}}, {a => 1, b => { c => 1, d => 2}}, {a => 1, b => { c => 2, d => 2}}, {a => 2, b => { c => 1, d => 1}}, ] i want change this: [ {a => 1, b => [{ c => 1, d => [1, 2]}, { c => 2, d => [2]}]}, {a => 2, b=> [ { c=> 1, d => [1] } ]} ] rules/requirements: hashes of same value of a go 1 hash b should array of {c => , d =>} d should array d same value of c go same array here solution. explicit, not generalize other hash structures. hashes = [ {:a => 1, :b => { :c => 1, :d => 1}}, {:a => 1, :b => { :c => 1, :d => 2}}, {:a => 1, :b => { :c => 2, :d => 2}}, {:a => 2, :b => { :c => 1, :d => 1}}, ] a_values = {} hashes.each |hash| a_value = hash[:a] a_values[a_value] ||= {} c_value = hash[:b][:c] a_values[a_value][c_value] ||= { :c => c_value, :d => [] } d_va...

java - Android Studio 'Run app' dialogue doesn't appear in one project but will in another -

Image
i'm toying android studio making simple stupid app learn saving key preferences , ran weird obstacle. i'll try provide as can since may hard reproduce bug both apps i'm running super basic , there no compile errors . specs: no emulator, i'm running samsung galaxy tablet . windows 7, android studio 1.2, gradle 2.2.1. in question title, mean have project named kitty (pretty hello world , button). click run->'run app'->(dialogue box opens)->ok->within moments app launches on tablet. ^^^this beautiful screen want see on sharedpreferences , it's on kitty . now started project called sharedpreferences (gist: 2 checkboxes ask "do chocolate" , "do luigi" , check 1 none or both , press save. 2 textviews underneath update if things , later if reopen app textviews remember chocolate luigi preferences). main_activity. i don't think changed settings or project preferences between 2 , neither give me error. mainactivi...

python - ProgrammingError Django 1.7 (1146 error, marketing slider does not exist) -

i have managed ecommerce page working fine on local host, however, when trying working on webfaction admin page working , static files working .com/admin main page error in browser. have suggestions? programmingerror @ / (1146, "table 'mycommerceapp_db.marketing_slider' doesn't exist")) i managed around removing mysql database , starting new postgresql 1 on webfaction , updating settings.py postgres. hope of use.

powershell - How to reset the max file size which Office Web apps supports -

Image
i have office web apps server run on windows server 2008 r2 me transforming office files(word, ppt, excel). error when file size exceed 10mb. have searched internet, got no answer. the closest aticle http://blogs.technet.com/b/sammykailini/archive/2014/06/25/office-web-apps-2013-increase-excel-workbook-size-from-the-10-mb-limit.aspx , still not work. has did work before ? need help. must support @ least 20mb file's transformation. and there configuration:

nokogiri - Using the Ruby Mechanize "links_with" to grab text but getting extra content -

when grab group of links using mechanize links_with method want text showing link i'm getting series of characters: links = @some_page.links_with(text: /v\s.*(bench|earcx)|(bench|earcx).*v/) links.each |link| link.text end the links shown in browser " 23409bench092834 " , " 20193bench092339 " want when go save them in database saved \r\n\t\t\t\t\r\n\t\t\t\t\t 23409bench092834\r\n\t\t\t\t\r\n\t\t\t\t where did these characters come , represent? i've tried using text , to_s on them isn't getting rid of these random characters. i think may escape codes if how remove them? you failed give example html showing markup you're working against. makes difficult you. don't that; you. mechanize uses nokogiri internally , can return nokogiri document, you'll want that. there you're in nokogiri's domain give more control on searching. using mechanize's links_with finds matching links in document , returns th...

Java label irregularity (possible bug?) -

if @ java standard §14.7, see statements may have label prefixes, e.g.: labeledstatement:       identifier : statement in theory, label should able label succeeding statement. so, example, following compiles accordingly: public class test { public static void main(string[] args) { hello: return; } } intuitively, compiles: public class test { int i; public static void main(string[] args) { test t = new test(); label: t.i = 2; } } but following not compile: public class test { public static void main(string[] args) { oops: int k = 3; } } even though (note scoped brackets): public class test { public static void main(string[] args) { oops: { int k = 3; } } } so question hinges on whether or not declarations statements. according standard (and online documentation ): in addition expression statements, there 2 other kinds of stat...

How do I use a SP in SQL Server 2014 to call a external XML source? -

i attempting retrieve currency exchange rates http://www.floatrates.com/daily/usd.xml using sp in sql server 2014. result in xml. created following sproc: --drop procedure [dbo].[proc_callwebservice] create procedure [dbo].[proc_callwebservice] declare @obj int declare @surl varchar(200) declare @response varchar(max) set @surl = 'http://www.floatrates.com/daily/usd.xml' exec sys.sp_oacreate 'msxml2.serverxmlhttp', @obj out exec sys.sp_oamethod @obj, 'open', null, 'get', @surl, false exec sys.sp_oamethod @obj, 'send' exec sys.sp_oagetproperty @obj, 'responsetext', @response out select @response [response] exec sys.sp_oadestroy @obj return and when run sproc null in return instead of xml. what need change in proc xml response site mentioned above? ok tested following sp pulls xml data: drop procedure [dbo].[proc_callwebservice] go create procedure [dbo].[proc_callwebservice]...

Laravel 5 app keeps using old database connection -

pdoexceptionvendor/laravel/framework/src/illuminate/database/connectors/connector.php:47 sqlstate[hy000] [1045] access denied user 'forge'@'localhost' (using password: yes) i have updated .env file correct credentials (its not localhost anymore, ip address) keep getting error message. have run php artisan config:clear too. how can force production app use new credentials in .env file? my config/database.php standard: 'connections' => [ 'mysql' => [ 'driver' => 'mysql', 'host' => env('db_host', 'localhost'), 'database' => env('db_database'), 'username' => env('db_username'), 'password' => env('db_password'), 'port' => env('db_port', '3306'), 'charset' => 'utf8', 'collation...

php - How to set posts_per_page in order to increment search display results? -

first of working on theme created developer , having few problems understanding @ how theme works or dev did. so, need increment search display results 10 25. using debug plugin able see query being executed wp: select sql_calc_found_rows wp_posts.id wp_posts 1=1 , (((wp_posts.post_title '%noticias%') or (wp_posts.post_content '%noticias%'))) , wp_posts.post_type in ('post', 'page', 'attachment', 'esp-publicitarios', 'opinion', 'especiales', 'portadadeldia', 'clasificados', 'anunciantes', 'logos') , (wp_posts.post_status = 'publish' or wp_posts.post_author = 4 , wp_posts.post_status = 'private') order wp_posts.post_date desc limit 0, 10 what want change limit 10 25 tried add @ functions.php file @ end: function change_wp_search_size($query) { if ($query->is_search) $query->query_vars['posts_per_page'] = 25; // change 25 number of post...

javascript - Why inline function doesn't catch a variable -

this question has answer here: google maps js api v3 - simple multiple marker example 11 answers i want callback called when user clicks on marker. i've figured out if use inline defined function, variable want use has value corresponding last used value. in code below it's last value of data array. <!doctype html> <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> <meta charset="utf-8"> <title>simple markers</title> <style> html, body, #map-canvas { height: 100%; margin: 0px; padding: 0px } </style> <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script> <script> var data = [ {name: 'limanowskiego 1', la...

c++ - Building boost::python module with SCons under Windows -

i'm trying build boost::python module using scons. i've managed find code snippets on web , stitch them builds correctly on linux. have major problems on windows (using visual studio 2013 compiler). here's code: import distutils.sysconfig, os,sys def tool_boost_distutils(env): vars = distutils.sysconfig.get_config_vars('cc', 'cxx', 'opt', 'basecflags', 'ccshared', 'ldshared', 'so') in range(len(vars)): if vars[i] none: vars[i] = "" (cc, cxx, opt, basecflags, ccshared, ldshared, so_ext) = vars env.appendunique(cpppath=[distutils.sysconfig.get_python_inc(), "d:/boost-vs2013/include/boost-1_57"]) if sys.platform == "win32": print "configuring windows" env.appendunique(cxxflags=["/md","/ehsc"]) else: env.appendunique(libs="boost_python") env.appendunique(cxxflags =["-std=c++11"]) env['shl...

actionscript 3 - as3 array of objects - movement with constant speed -

ok, have experience as3 , of basics. problem has been stumping me long. tried workaround based on know as3. somehow either error message or doesn't @ all. here code i'm trying solve. var zombiecount:array = new array(); var helltime:timer = new timer(1500); helltime.addeventlistener(timerevent.timer, spawnzombies) helltime.start(); function spawnzombies(happened:timerevent){ var zombie1:zombie = new zombie(); zombiecount.push(zombie1); stage.addchild(zombiecount[zombiecount.length - 1]); zombie1.x = 135 + (330*math.random()) zombie1.y = -29 stage.addeventlistener(event.enter_frame, move_zombie) function move_zombie(happened:event){ for(var i:int; < zombiecount.length; i++){ zombiecount[i].y = zombiecount[i].y + 1; if(zombiecount[i].hittestobject(border)){ stage.removechild(zombiecount[i]); zombiecount.shi...

sorting - Comb_sort doesn't work in Perl -

i wrote comb sort in perl. looks good, program doesn't work , compiler doesn't show errors. ask help. code is: @tab = (1,3,5,22,2,12,1); $gap = scalar(@tab); $replace = 1; while ($gap>1 || $replace) { $gap = ($gap * 10) / 13; if ($gap == 0) { $gap = 1; } $replace = 0; ($i=0; $i+$gap < $n ; $i++) { if ($tab[$i]>$tab[$i+$gap]) { ($tab[$i], $tab[$i+$gap]) = ($tab[$i+$gap],$tab[$i]); $replace = 1; } } } print "sorted array: @tab"; the revised code uses $n never sets it. if used use warnings; , use strict; , have known problem. directives, get: $ perl comb.pl global symbol "$n" requires explicit package name @ comb.pl line 20. execution of comb.pl aborted due compilation errors. $ there 5 variables in code, including $n , there's need my appear 5 times. with $n set initial value of $gap (aka scalar(@tab) ), code sorts data se...

c# - How to insert a HTML character into this Html.ActionLink? -

Image
i'm using following code generate this: <p>@html.actionlink("read", "index", "news", null, new { @class = "btn btn-default" })</p> but want make button looks (with use of html character &raquo; ): however when following: <p>@html.actionlink("read &raquo;", "index", "news", null, new { @class = "btn btn-default" })</p> i this: how fix this? the text encoded actionlink() implementation, don't need it. use char in string.

Split strings to sentences and save punctuation mark at the end by regex java -

so, have text string s = "the if-then-else statement provides secondary path of execution when "if" clause evaluates false. use if-then-else statement in applybrakes method take action if brakes applied when bicycle not in motion. in case, action print error message stating bicycle has stopped." i need split string in sentences save punctuation mark @ end of sentence, cant use this: s.split("[\\.|!|\\?|:] "); because if use receive this: the if-then statement basic of control flow statements tells program execute section of code if particular test evaluates true example, bicycle class allow brakes decrease bicycle's speed if bicycle in motion 1 possible implementation of applybrakes method follows: and i'm loosing punctuation mark @ end, how can it? first of regex [\\.|!|\\?|:] represents . or | or ! or | or ? or | or : because used character class [...] . wanted use (\\.|!|\\?|:) or better [.!?:] (i not sure why...

node.js - InternalOAuthError when using passport-linkedin strategy -

i'm working passport-linkedin , i'm getting error. internaloautherror: failed obtain request token @ /users/davey/code/node/appify-frontend/node_modules/passport-linkedin/node_modules/passport-oauth/lib/passport-oauth/strategies/oauth.js:196:36 @ /users/davey/code/node/appify-frontend/node_modules/passport-linkedin/lib/passport-linkedin/strategy.js:80:19 @ passbackcontrol (/users/davey/code/node/appify-frontend/node_modules/passport-linkedin/node_modules/passport-oauth/node_modules/oauth/lib/oauth.js:397:13) @ incomingmessage.<anonymous> (/users/davey/code/node/appify-frontend/node_modules/passport-linkedin/node_modules/passport-oauth/node_modules/oauth/lib/oauth.js:409:9) @ incomingmessage.emit (events.js:129:20) @ _stream_readable.js:908:16 @ process._tickcallback (node.js:355:11) /oauth/linkedin 500 1074ms - 786b here's setup looks like exports.setup = function (config) { var passport = require('passport'); var link...

c++ - MPI multiple send and receive in loop -

i have big problem code , maybe conceptually. need work done in 2 different functions. 1 function has 1 instance , main thread, , second function has many instances on many other nodes. one of functions (function a) sending 3 parts of data nodes, , other function, b, should receive @ each node. next, function should wait results. when ready functions b in each of nodes should send 1 part of data function a, , starts again. it should work in sample code: void preparedata() { //function for(int = 1 ; < threads;i++) { mpi_send(...); //first part of data mpi_send(...); //second part of data mpi_send(...); //third part of dat } //here function (a) should wait because second function (b) computing data for(int i=1;i<threads;i++) { mpi_recv(...); //receiving data function b } } void computedata() { //function b while(isdone) { mpi_recv(...); //first part of data mpi_recv(...); //second part of data mpi_recv(...); //third part of data ...

I'm new to Java Swing, and coding in general and a code I wrote today is having an odd glitch involving the button.doClick() method. -

if review code me, give me pointers etc, grateful! in game in case you've never played mastermind, 3 colours hidden in specific order , user has guess out of 4 possible colours. code appears work well, though unfinished, odd glitch occurs once user wins. when player guesses 3 hidden colours, prompted press "play again" button, supposed reset game, appears do, once user inputs colour jtextfields designated so, words last entered in fields revealed. have implemented small line displays word "working" on nearby jlabel show doclick() methods activating, reset button doesn't work intended, though newgame button does. odd glitch, if has fix or reason glitch or other general improvements make day! import java.awt.color; import java.awt.componentorientation; import java.awt.dimension; import java.awt.gridbagconstraints; import java.awt.gridbaglayout; import java.awt.insets; import java.awt.event.actionevent; import java.awt.event.actionlistener; import javax....

Where does default USER PROFILE for the Internet Explorer lives and how do I access it from Selenium? -

each time run test, new instance of ie, ignore settings. solve same problem in firefox , chrome setting option browsers specific user profile . firefoxprofile profile = new firefoxprofile(path/to/profile"); public static readonly iwebdriver webdriver = new firefoxdriver(profile); this how path user profile looks in firefox : @"c:\users\<user_name>\appdata\roaming\mozilla\firefox\profiles\t1hjw29h.watirwebdriver" i'd in folder user profile lives in internet explorer , how access selenium . thanks helping after straggling problem days, i've found solution on youtube helped me solve it, @ least when comes internet explorer. i'm still looking appropriate solution in chrome. one need download autoit said in video write autoit script, save it, , compile produce executable file shown in video add command execute autoit in context of automation. the last step in critical of all. in case, i've put in open method because i...

MongoDB - Using Aggregate to get more than one Matching Object in an Array -

Image
i'm trying poster in this link trying accomplish. have documents same structure poster; in documents there array of objects, each many keys. want bring objects (not first, can $elemmatch ) in array key's value matches query. want query's result array of objects, there key in each object matches query. example, in case of linked question, want return array of objects "class":"s2" . want returned: "filtermetric" : [ { "min" : "0.00", "max" : "16.83", "avg" : "0.00", "class" : "s2" }, { "min" : "0.00", "max" : "16.83", "avg" : "0.00", "class" : "s2" } ] i tried queries in answer. f...

Obtaining the "default" mockup TinyMCE configuration on Plone 5 -

i'm trying configure tinymce inside plone 5 template (so: not z3c.form widget type). using tinymce mockup patter learn how display rudimentary tinymce configuration (without i18n support). how can "default" configuration applied tinymce when it's loaded default content types plone page? what i'm looking way right value data-pat-tinymce html attribute. i think you're asking this... first, default tinymce pattern configuration: from zope.component import getmultiadapter import json pattern_options = getmultiadapter( (context, request, none), name="plone_settings").tinymce()['data-pat-tinymce'] tiny_options = json.loads(pattern_options) then, manipulate tiny_options dictionary , customize needs , provide data-pat-tinymce attribute json.dumps.

IntelliJ fails to open FTP conection -

Image
i configured ftp on 1 of servers , , running. able open using windows explorer : but when try test connection in intellij , get: has had happen? appreciated. ftp log file: #software: microsoft internet information services 7.0 #version: 1.0 #date: 2015-06-03 13:08:54 #fields: time c-ip cs-method cs-uri-stem sc-status sc-win32-status 13:41:07 192.168.4.78 [8]user firestorm\highlander 331 0 13:41:07 192.168.4.78 [8]pass - 230 0 13:41:19 192.168.4.78 [5]closed - 421 121 13:44:11 192.168.4.78 [9]user firestorm\highlander 331 0 13:44:11 192.168.4.78 [9]pass - 230 0 13:44:41 192.168.4.78 [10]user firestorm\highlander 331 0 13:44:41 192.168.4.78 [10]pass - 230 0 13:45:28 192.168.4.78 [11]user firestorm\highlander 331 0 13:45:28 192.168.4.78 [11]pass - 230 0 13:45:28 192.168.4.78 [11]cwd / 250 0 13:45:58 192.168.4.78 [12]user firestorm\highlander 331 0 13:45:58 192.168.4.78 [12]pass - 230 0 13:45:58 192.168.4.78 [12]cwd / 250 0 13:46:40 192.168.4.78 [13]user anonymous 331 0 ...

assembly - How to improve the disassembler view in IAR Embedded Workbench for ARM v7.30 -

i'm using iar embedded workbench arm v7.30, , jlink jtag debugger connect arm development board. write in assembler, not c. while of disassembly view in iar debugger project correct, of isn't: ; original source code bl setup_starting_address tsts r4, #err_address_setup bne error_while_reading send_command mov r3, #command_read bl cf_send_command tsts r4, #err_command bne error_while_reading wait_for_flag_to_be_set bl get_status tsts r4, #status_bit3 beq wait_for_flag_to_be_set renders this: ;disassembly view 0x204: 0xf7ff 0xffc4 bl setup_starting_address ; 0x190 epidmatxcnt: 0x208: 0xf414 0x2f00 tst.w r4, #524288 ; 0x80000 0x20c: 0xd113 bne.n error_while_reading ; 0x236 send_command: 0x20e: 0xf04f dc16 61519 ; 'oð' epiim: 0x210: 0x0320 lsls r0, r4, #12 0x212: 0xf7ff dc16 ...

javascript - Binding an array of objects to template containing google-map-marker elements -

i have <dom-module> property locations of type array updated externally every once in while: <dom-module id="my-map"> <template> <google-map api-key="my_api_key" id="map" libraries="visualization,geometry,drawing"> <template is="dom-repeat" items="{{locations}}" as="user"> <template is="dom-repeat" items="{{user.trace}}"> <google-map-marker latitude="{{item.latitude}}" longitude="{{item.longitude}}"> </google-map-marker> </template> </template> </google-map> </template> </dom-module> <script> polymer({ : 'my-map', properties : { locations : { type : array, value : [], observer : '_locationschanged' ...

php - How to use variables in mailgun API? -

how can use variables in mailgun? in test email (test@example.com) added following variable {"age": 20} but not go used when creating mail. here goes code when mail sent. $mailformat = "code html :d"; $result = $mgclient->sendmessage($domain, array( 'from' => 'example <example@example.com>', 'to' => 'test@example.com', 'subject' => '%recipient_fname%, testing mail', 'html' => $mailformat )); from documentation : v: prefix followed arbitrary name allows attach custom json data message. see attaching data messages more information.

Python Requests Get XML -

if go http://boxinsider.cratejoy.com/feed/ can see xml fine. when try access using python requests, 403 error. blog_url = 'http://boxinsider.cratejoy.com/feed/' headers = {'accepts': 'text/html,application/xml'} blog_request = requests.get(blog_url, timeout=10, headers=headers) any ideas on why? because it's hosted wpengine , filter user agents. try this: user_agent = "mozilla/5.0 (macintosh; intel mac os x 10_10_3) applewebkit/537.36 (khtml, gecko) chrome/42.0.2311.152 safari/537.36" requests.get('http://boxinsider.cratejoy.com/feed/', headers={'user-agent': user_agent})

ios - PHPhotoLibrary get album names -

i've been trying find alternative getting album names photos api in ios 8. alassets, can use: valueforproperty:alassetsgrouppropertyname photos api, can't seem find alternative. there is: localizedtitle under phassetcollection isn't right either, gives me city names. i'm looking can return actual names of groups, including ones synced itunes. i'd appreciate see how in apps. apple encouraging use photos api apps linked 8.0, i'd rather not use both alassetlibrary , photos. code: - (nsstring *)nameforalbumincollection:(id)collection { nsstring *title = nil; if ([phasset class]) { title = [collection localizedtitle]; } else { title = [collection valueforproperty:alassetsgrouppropertyname]; } return title; } - (void)setup { self.recentscollectiondatasource = [[nsmutableorderedset alloc]init]; self.favoritescollectiondatasource = [[nsmutableorderedset alloc]init]; self.albumstabledatasource = ...

Algorithm to pick a single value from a vector in matlab? -

i have vector of equiprobable values. let's say: [ 12.62 22.856 22.983 23.111 24.295] i have pick single value among these values. in case, in opinion, exclude 12.62. mean value among remaining (22.856 22.983 23.111 24.295) 23.311. think 23.111 should choice between these equiprobable values. when considering general vector of arbitrary values , dimension criterion/algorithm should use pick single value inside considered vector? i'm trying read (i.e., guess) question , comments far criteria you're implicitly applying. came these: the vector shall mapped 1 of elements. outliers amongst elements shall neither candidates nor influence of other elements chosen. the mean of candidates shall in way relevant candidate chosen. with these criteria, 1 can come following algorithm: identify outliers (criteria of constitutes outlier determined) remove outliers compute mean of remaining values choose 1 of remaining values closest m...