Posts

Showing posts from September, 2012

PHP Symfony request stack not found on bundle extension load -

i'm trying create reusable logging bundle can have custom formatter log messages. formatter set in main app's config file that: custom_logger: formatter: appbundle\services\messageformatter then in loggerbundle/dependencyinjection/customloggerextension.php after receive configuration i'm trying logger service , set formatter class customloggerextension extends configurableextension { public function loadinternal(array $mergedconfig, containerbuilder $container) { $loader = new yamlfileloader($container, new filelocator(__dir__ . '/../resources/config')); $loader->load('services.yml'); $class = $mergedconfig['formatter']; $obj = new $class; $container->get('custom.logger')->setformatter($obj); but problem logger uses request stack services: custom.logger: class: loggerbundle\services\logger arguments: ['@request_stack'] and when try servi...

In PhantomJS how can I pass URI parameters to an HTML file loaded with the file:// protocol? -

i using phantomjs 2.1.1. i'd open html file on local file system in phantom, , pass uri parameters. if open page without uri parameters, e.g: page.open("product.html"); then page opens fine if pass in uri parameters path: page.open("product.html?id=cheese"); then error "product.html?id=cheese: no such file or directory" (in phantomjs debugging environment product.html), if phantom including uri parameters part of file name. supported examining network requests in phantom debugger. i've experienced after upgrading past phantomjs 2.0. using phantomjs 1.9, , able pass uri parameters in manner , worked fine. there new phantom api passing uri parameters?

css - Chrome: SVG container not rescaling responsively -

i have svg being used 'mask'; it's displayed on top of div background image image peeks through unfilled areas of svg. svg responsive height of document (rather width). works fine far. however, i've been made aware if resize (chrome) browser, background image overflows out of bounds of masking svg; however, if refresh resized page, appears expected - only occurs on resize, , in chrome (oh, , opera too, apparently). works expected in ff , safari. i've included demo here (and jsfiddle ) inline svg, doesn't seem matter if it's inline or <img /> tag - results same. it seems somehow related containing element; if open inspector , set containing element's padding 0 after goes screwy, seems figure out , appear expected; if include rule in loaded css makes no difference. tried triggering similar css properties on page resize via javascript, hasn't made difference. am missing something, or have stumbled across bug? #splash { pos...

sql - Left Join table giving uncessary extra rows -

good day. i writing query against 2 tables, table , table b. table has 57 rows. resultant should same row count table a. table b has 44 rows. script ;with ss (select distinct * tablea), ss2 (select distinct * tableb) select distinct a.lotid, a.name, b.machine_id ss left join ss2 b on b.recipe_id = a.id b.machine_id = 1 table a id lotid name 62 fr 3 2000w - 200w/ms 63 fr 3 2000w - 180w/ms 85 fr 2 2000w - 173w/ms 87 fr 2 1200w - 173w/ms 197 fr 2 1100w - 185w/ms 200 fr 2 2000w - 185w/ms 204 fr 2 1200w - 41w/ms 218 fr 5 kst / test 220 fr 5 2000w - 29w/ms 221 fr 4 2000w - 185w/ms 222 fr 5 2000w - 185w/ms 223 fr 2 n2000w - 200w/ms 224 fr 3 2000w - 185w/ms ...

python - How to send photo on telegram bot -

i'm implementing simple bot should send photos , videos chat_id . well, i'm using python, script import sys import time import random import datetime import telepot def handle(msg): chat_id = msg['chat']['id'] command = msg['text'] print 'got command: %s' % command if command == 'command1': bot.sendmessage(chat_id, *******) elif command == 'command2': bot.sendmessage(chat_id, ******) elif command == 'photo': bot.sendphoto(...) bot = telepot.bot('*** insert token ***') bot.message_loop(handle) print 'i listening ...' while 1: time.sleep(10) in line bot.sendphoto insert path , chat_id of image nothing happens. where wrong? thanks you need pass 2 params bot.sendphoto(chat_id, 'url')

java - How long does it take for an android application to be placed in "standby" mode in M? -

does know timing this? alternatively know part of aosp source code concerns app standby? i found equivalent timing doze (30 minutes, btw) perusing source code deviceidlecontroller.java , looking same standby. what "standby" mode? afaik, app can either active,background or dead(killed). how describe state think "standby"?

Group objects by a series of common IDs and select a grouping based on the sum of a different key in LINQ -

so have bit of academic question. able solve using brute force approach, believe solvable more elegantly in linq - however, can't find way so. solution can c# or vb, it's linq giving me trouble. i have following object: public class foo { public int fooid {get; set; } public int bar {get; set; } /// <summary> /// contains list of fooid /// </summary> public int[] stackability } what need find possible groupings of foo s based on stackability (i.e.: common fooid in stackability list), select grouping has highest sum of bar . so, example: have foos ids of 1, 2 , 3. +-------+-----+--------------+ | fooid | bar | stackability | +-------+-----+--------------+ | 1 | 5 | 2, 3 | +-------+-----+--------------+ | 2 | 2 | 1, 3 | +-------+-----+--------------+ | 3 | 6 | 1 | +-------+-----+--------------+ foo 1's stackability contains values of 2 , 3 , has bar of 5. f...

ios - How to implement 2 UITableViews in 1 ViewController? The tableViews each have their own custom cell -

i have 2 tableviews each own custom cell. how can implement these tableviews in 1 viewcontroller? here code. xcode can't cast custom cell standard uitableviewcell func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int { // let accountsize = int(accounts.count()) // return accountsize; var count:int? if tableview == self.tableview { count = int(accounts.count()) } if tableview == self.tableviewloan { count = int(loans.count()) } return count! } func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { // return uitableviewcell() var cell:uitableviewcell? if tableview == self.tableview { //cell = tableview.dequeuereusablecellwithidentifier("accountstableviewcell", forindexpath: indexpath) as! accountstableviewcell var cell1 = tableview.dequeuereusablecellwithidentifier("accountst...

java - How can I connect to a database in Spring using configuration files? -

i tried connect mysql database using spring mvc don't know why datasource properties not saved. gives me exception authentification failed i've saved connection details in properties file. this web.xml : <?xml version="1.0" encoding="utf-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> <context-param> <param-name>contextconfiglocation</param-name> <param-value> classpath:main/java/containers/dao-context.xml classpath:main/java/containers/service-context.xml </param-value> </context-param> <listener> <listener-class>org.springframework.web.context.contextloaderlistener</list...

"Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1" -

this question has answer here: what causes java.lang.arrayindexoutofboundsexception , how prevent it? 14 answers i've got simple question i've got complete tomorrow. code compiles , runs exception error. sorta kinda new java , have feeling related multidimensional array. package question12; import java.security.securerandom; import java.util.scanner; public class question12 { scanner sc = new scanner(system.in); string first_name, last_name, id, seat_no; char seatch; string[][] passengerlist = new string[1][4]; void setfname() { system.out.printf("passenger first name: "); first_name = sc.nextline(); } void setlname() { system.out.printf("passenger last name: "); last_name = sc.nextline(); } void setid() { system.out.printf("passenger id: "); id = sc.nextline(); } void setseatnumber (...

windows - Trying to prevent a security group from applying to other folders/files -

i'm trying make $adnamero , $adnamerw (that i've created below) don't applied folders below let rest of permissions inherited. i've tried change propagation flag 2 strings applied folder , files added to, still get's added sub files , folders... i thought might need change inheritanceflags object both of strings, when changed manually (through windows gui) didn't seem work correctly... any appreciated. function new-ace { [cmdletbinding()] param( [parameter(mandatory=$true, position=0)] [security.principal.ntaccount]$account, [parameter(mandatory=$false, position=1)] [security.accesscontrol.filesystemrights]$permissions = 'readandexecute', [parameter(mandatory=$false, position=2)] [security.accesscontrol.inheritanceflags]$inheritanceflags = 'containerinherit,objectinherit', [parameter(mandatory=$false, position=3)] [security.accesscontrol.propagationflags]$propagationflags = 'none', [p...

c++ - Placement new using void* bits as storage -

assuming sizeof(t) <= sizeof(void*) , following defined / portable? ... void* storage = 0; new (&storage) t(t); this seems used sensible small-object optimisation, if so. you passing valid address, , if memory pointed big enough contain object, , alignment compatible object, it's fine code. the alignment should implicitly correct if sizeof(t) <= sizeof(storage) . can paranoid , explicitly set with: alignas(t) void* storage = 0; although think manually setting alignment isn't needed, , sizeof(t) <= sizeof(storage) mean correct alignment guaranteed, i'm not 100% sure. note because type of storage void* doesn't mean anything. particular placement new defined standard as: void* operator new(std::size_t count, void* ptr); the address parameter void* , meaning type pointed can anything. requirement it's address valid memory. however, if storage ever goes out of scope, you're busted if object contained within needs destr...

css - Absolutely positioned element positions relatively to transformed element -

i recreated issue encountering in template. there nav has position: relative; . inside nav there div 2 lists nested. 1 of lists position absolutely stick bottom of nav . problem occurs when div has transformation applied it. when div in between absolutely , relatively positioned elements get's transform property, absolute list positions relatively div instead of nav . mdn docs state following position:absolute do not leave space element. instead, position @ specified position relative closest positioned ancestor if any, or otherwise relative containing block. absolutely positioned boxes can have margins, , not collapse other margins. does mean transformed element positioned element? why this? tested in edge, ff, , chrome. act same. you can run recreated snippet below. applying transform on div on hover of nav. *{ margin: 0; padding: 0; box-sizing: border-box; } html, body{ min-height: 100%; height: 100%; } nav{ background:...

linux - unable to reach ssh remote host using ansible using aws key -

i trying ping server using ansible, getting error messages [ec2-user@ip-172-30-0-64 kafka-scripts]$ ansible zook1 -m ping -vvv using /home/ec2-user/kafka-scripts/ansible.cfg config file <172.30.0.113> establish ssh connection user: none <172.30.0.113> ssh: exec ssh -c -q -o controlmaster=auto -o controlpersist=60s -o 'identityfile="/home/ec2-user/kafka-scripts/keys/kafka_broker.pem"' -o kbdinteractiveauthentication=no -o preferredauthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o passwordauthentication=no -o connecttimeout=10 -o controlpath=/home/ec2-user/.ansible/cp/ansible-ssh-%h-%p-%r -tt 172.30.0.113 '/bin/sh -c '"'"'( umask 22 && mkdir -p "` echo $home/.ansible/tmp/ansible-tmp-1461268838.85-234429685988133 `" && echo "` echo $home/.ansible/tmp/ansible-tmp-1461268838.85-234429685988133 `" )'"'"'' zook1 | unreachable! => { "change...

extjs4.2 - actioncolumn xtype column header is showing Actions in column hide/show list -

Image
in ext js grid, column xtype: actioncolumn, column header not showing in show/hide column list. comes 'actions' default actioncolumn column. can override actual column header in list of columns show/hide actioncolumn columns? image shows screenshow of examples sencha examples. if want change label in columns, need use config called menutext actioncolumn example: ( https://fiddle.sencha.com/#fiddle/1944 ) { xtype:'actioncolumn', width:50, menutext: 'my actions', items: [{ icon: 'extjs-build/examples/shared/icons/fam/cog_edit.png', // use url in icon config tooltip: 'edit', handler: function(grid, rowindex, colindex) { var rec = grid.getstore().getat(rowindex); alert("edit " + rec.get('firstname')); } },{ icon: 'extjs-bu...

sql server - RangeS-U and U locks at the same time and on the same resource -

i'm working stored procedure , deadlock situation. i've been using sql server profiler , information deadlock 'deadlock graph' event in form of .xdl file. below content of file. i've cleared informations statement.the statement marked <executionstack> in .xdl (for both processes same statement): select somecolumn, somecolumn2 sometable (updlock) inner join sometable2 on sometable.sometable2id = sometable2.sometable2id inner join sometable3 on sometable2.sometable3id = sometable3.sometable3id somecolumn = @something , somecolumn2 = @something2 and content of .xdl file: <deadlock-list> <deadlock victim="processc19dc8"> <process-list> <process id="processc19dc8" taskpriority="0" logused="0" waitresource="key: 5:72057594042646528 (8194443284a0)" waittime="1541" ownerid="21923027" transactionname="user_transaction" lasttranstarted="2013-0...

python - Shuffling combinations without converting iterable (itertools.combinations) to list -

the following simple code gives me possible combinations of length 3 of 200 elements. from itertools import combinations comb = combinations( range(200), 3 ) i want combinations in random order in order pick first n combinations. however, if convert comb list , shuffle following, may memory error because list might contain many elements: comb = list(comb) # might huge , give memory error random.shuffle(comb) n = 10 comb = comb[:10] # first n random combinations is there other way n random combinations ? (i.e., not in order generated itertools.combinations). there c(200, 3) = 1313400 possible combinations. mentioned, number can out of hand due combinatorial explosion . example, if choose 4 instead of 3 elements, number of combinations approximately 50 times larger (64684950). instead of randomly selecting these combinations, can randomly build possible combinations. to build combinations, can use random.sample random library. random.sample(range(200), 3) rando...

c# - return a multidimensional json array using json.net -

i have code: var all_books = db.books; var result = all_books.select(a => new { a.bookid, a.booktitle, a.bookisbn}).take(4).tolist(); var jsondata = new { secho = param.secho, itotalrecords = all_assets.count(), itotaldisplayrecords = all_assets.count(), aadata = result }; return json(jsondata,jsonrequestbehavior.allowget); and json returned in form of: {"secho":null,"itotalrecords":2764,"itotaldisplayrecords":2764,"aadata":[{"bookid":"m-711745","booktitle":"20844","bookisbn":"hp la2205wg"},{"bookid":null,"booktitle":"n/a","bookisbn":"n/a"},{"bookid":"m-710587","booktitle":"20707","bookisbn":"hp la2205wg"},{"bookid":"735129","booktitle":"21272","b...

jquery - Dynamic variable names javascript MVC -

i'm running bit of javascript code in loop, creating chart (using google visualization). after code run, need access these objects somewhere else. problem can't call "chart" again, since has been over-written. i've managed figure out hacky solution involves using mvc @ thing dynamically generate @ run-time, force variable name. works, don't think it's right way approach problem. there way me dynamically change name of variable each time it's run? the following code run multiple times. @{ var mychart = "cdata" + model.chartid.tostring(); } ... function () { @mychart = new google visualization.chartwrapper({ ... }); dashboard.bind(slider, @mychart); dashboard.draw(data); } mychart changes every single time code run, giving me hacky string. putting without ' marks, becomes variable @ runtime. after run, have resize function run following: @mychart .setoption('width', width); @mychart .setoption('heig...

command line - Create IIS 6 application pool -

can let me know how (or point me right direction) can create application pool , set application use newly created pool using commandline? application has been added iis need create new pool , use new application. this gathered, in case else looking same thing: rem // creates new application pool called myapppool cscript %systemdrive%\inetpub\adminscripts\adsutil.vbs create w3svc/apppools/myapppool iisapplicationpool rem // if running under different user name , password rem cscript %systemdrive%\inetpub\adminscripts\adsutil.vbs set w3svc/apppools/myapppool/wamusername "domain\username" rem cscript %systemdrive%\inetpub\adminscripts\adsutil.vbs set w3svc/apppools/myapppool/wamuserpass "pass" rem cscript %systemdrive%\inetpub\adminscripts\adsutil.vbs set w3svc/apppools/myapppool/apppoolidentitytype 3 ======================================== rem // create new virtual directory (creates vdir "test" , set d:\websites\mywebsite cscript %systemro...

arrays - What is the difference between Lua tables and classes? -

i'm beginner programming in general , have been trying few different languages. in lua, there tables seem super lists (arrays, dictionaries, lists in one) in lua possible this: player = { health = 100, attack = 50, mana = 54 } print(player.health) and return 100. in other programming languages, need make class same output. understanding, lua has classes tables? tables seem act similar same? if not, makes them different , pros , cons of using either? but understanding, lua has classes tables? no, not. lua (ignoring c api stuff) has 1 complex data structure: tables. you can create class using table. can create kinds of things using table. lua tables flexible, precisely because only data structure lua has. in lua, every complex thing @ base level table. or if it's c api, userdata. a class prototype creating objects. declare class has x, y, , z members in it, create object of class type have x, y , z members in it. you can create lua tables mimic ...

python - How to get latest record per user whilst filtering on another (annotate?) -

i have model baz. want list of latest baz (descending order) each user_bar, filtering on single user_foo. class baz(models.model): foo = models.foreignkey(user, db_index=true, related_name='user_foo') bar = models.foreignkey(user, db_index=true, related_name='user_bar') content = models.charfield(max_length=32) created = models.datetimefield(db_index=true, auto_now_add=true) so example there baz records, , filter "tom": id foo bar content -- --- --- ------- 1 tom dick text 2 tom harry more text 3 dick tom more text 4 tom dick last text ever in case query return: id foo bar content -- --- --- ------- 4 tom dick last text ever 2 tom harry more text ...assuming records created in order. this records, there multiple records each user_bar (i want latest each user_bar): baz.objects.filter(foo=request.user).order_by('-created') (upda...

node.js - Rethinkdb audit trail with field timestamp and status when update/insert -

i trying create rethinkdb database audit trail in node.js. my table contains following fields: order-id quantity price status timestamp i have file upload following data example: order-id......quantity.....price 1....................'1000'..........100 2....................'500'............100 3....................'1575'..........100 when upload in empty table these rows inserted along time&date , status set 'active'. let's assume upload file again updated data (the quantity of order-id 1 changed), example: order-id......quantity.....price 1....................' 1010 '..........100 2....................'500'............100 3....................'1575'..........100 the rethinkdb query should set status of row order-id 1 'replaced' , update timestamp. next should insert new row updated data, set status 'active' , timestamp it. so table new updated data should this:...