Posts

Showing posts from April, 2011

amazon s3 - Getting access denied when uploading an s3 file using Ink (FilePicker) -

we're using ink filepicker, works great us, except 1 specific use case. when uploading via url, , specifying link s3 file - access denied error. other links work fine, other https links work fine well. bucket policy set make uploads public, per filepicker documentation. thanks help. have created iam permissions per filepicker recommendations: https://developers.inkfilepicker.com/docs/web/#custom-s3 and need set credentials correctly in filepicker. you need permission. filepicker has more detailed page , video on how set s3 correctly.

php - Shared hosting - catch user ip -

i hosting 1 site @ ccihosting.com , tried catch user ip with $_server['remote_addr'] and got ip of server located in panama not ip. told me because of shared hosting. webhostings have shared servers don't ? , got no problems of catching ip addresses. know whther because of shared hosting or no. thanks ip address of website differ on shared hosting . many websites on shared hosting may have different dns names same ip addresses. you same ip address when on dedicated hosting server . edit : try alternative code <?php function get_client_ip() { $ipaddress = ''; if (getenv('http_client_ip')) $ipaddress = getenv('http_client_ip'); else if(getenv('http_x_forwarded_for')) $ipaddress = getenv('http_x_forwarded_for'); else if(getenv('http_x_forwarded')) $ipaddress = getenv('http_x_forwarded'); else if(getenv('http_forwarded_for')) $ipaddre...

jquery - Orbiting <img> elements work but not <div> elements, why? -

i'm trying create effect elements orbit around center element jquery. have altered existing code , partially works. my html code: <div class="orbit-carousel" data-speed="30" data-explode-distance="0" data-vary-size="50" data-start-position="90" data-rewind="false" style="width: 700px; height: 350px;"> <img src="sun.png" class="thesun" /> <img src="planet1.png" class="planet" /> <img src="planet2.png" class="planet" /> <img src="planet3.png" class="planet" /> <img src="planet4.png" class="planet" /> <img src="planet5.png" class="planet" /> </div> <script> $(window).load(function(){ $(".orbit-carousel").orbit(); }); ...

twitter bootstrap - Enable (CSS) Stylesheet for only one div and it's contents -

i was looking (simple) wysiwyg editor jquery plugin that's compatible bootstrap 3. i've seen lot wysiwyg editors jquery plugin compatible previous bootstrap, website uses bootstrap 3, each time implemented such jquery plugin, bootstrap 3 ruin buttons , mess whole editor up. so i'm asking whether there option enable bootstrap 2 stylesheet 1 div , contents. i assume iframe work, then, need wysiwyg editor's contents (which in iframe then), along text inputs on 'non-iframe'. one way might able solve scope css div. have implemented content management system have created. let example give wysiwyg div id of htmleditable. you target div css , css within div. #htmleditable .wysiwyg{ ....css goes here } #htmleditable p{ ....css goes here } the above css apply div. case of finding correct css need in div. note may need override/reset css div stop bootstrap3 applying it. here example of reset css. (you need scope make sure don't r...

Formatting input from excel to mysql using command line client -

i want import data excel mysql database using command line client. example of how csv-file built: name 1 | 1 | 2 | 3 | name 2 | 1 | 2 | 3 | name 3 | 1 | 2 | 3 | i'm using code: load data local infile 'path file.csv' table table_name fields terminated ',' lines terminated '\n'; i "query ok" , code formatting on table should csv-file result: | null | null | null | | null | null | null | | null | null | null | what wrong? seems u have used '|' in csv file delimiters instead of comma, try code `load data local infile 'path file.csv' table table_name fields terminated '|'lines terminated '\n';`

ejb 3.0 - Difference between creating dao object with constructor and by EJB injection -

i know difference between creating dao object constructor : mydaoobject = new mydaoobject(); and creating ejb injection : @ejb mydaoobject mydaoobject; is there difference in running and/or performance ? thanks. well...you can't create ejbs constructor because lose functionality offered container (dependency injection, pooling, calling of @postconstruct, transactions, ...). correct way @ejb mydaoobject mydaoobject; p.s. or, in case using cdi , @inject instead of @ejb

android - How to create Emulator for new Nexus 7 2 in eclipse -

google has launched nexus 7-2 resolution 1200x1920 , other features. want test android app on same don't have device test. kindly let me know how create emulator new nexus 7 in eclipse using avd manger. i have updated sdk tool , platform latest , able see old nexus 7 (800x1280 res) in avd manager. creating new avd device. in android virtual device manager select "device definitions" @ top. select "new device..." name it: "nexus 7 2" or "nexus 7 (2013)" or whatever like. nexus 7 2 (2013) settings: screen size (in): 7.02 resolution (px): 1920 x 1200 sensors: accelerometer gyroscope gps proximity sensor cameras: front rear input: no nav ram: 2048 mib size: large screen ratio: long density: xhdip buttons: software device states: portrait: enabled landscape: enabled

alias for python class in another module -

for example: i have module contains class class, have module b uses class class parameter in methods , have module c uses module b. should import a.class make possible pass class parameter methods module b. if i'll put module packages d.e.f... i'll long import string what best way make alias class in module b, using b.somemethod(b.class) , module c knows nothing module a. now import a.class in module b, , use import b.class in module c .# file: a.py class klass(object): pass .# file b.py from import klass def somemethod(foo): pass .# file c.py from b import somemethod b import klass somemethod(klass.field) i assume trying describe situation, , don't see issue here: i have module contains class class # file: a.py class klass(object): pass i have module b uses class class parameter in methods # file b.py import klass def somemethod(foo): pass somemethod(klass) i have module c uses module b. should impor...

shell - Multiple modes for line-oriented command interpreters with Python Cmd class -

i trying build cli (line-oriented command interpreters) using python cmd class support 2 or more modes, each mode have different set of commands, commands switch between them. currently implemented 2 modes using 2 separate classes each mode, set next class execute in state variable: class opmode(cmd): def do_show(self, line): : def do_configure(self, line): # switch configmode ctx.state = 'config' return true class configmode(cmd): def do_set(self, line): : def do_exit(self, line): # go opmode ctx.state = 'op' return true # in main ... while 1: if ctx.state == 'op': opcli.cmdloop() elif ctx.state == 'conf': confcli.cmdloop() else: break is there way achieve same thing single cmd class? using single cmd instance not improve code. keep track of state inside cmd class , each command action adjust respone accordingly. however, want cle...

c# - Singleton implementation check -

hi interested in implementing method returns singleton object.i have created implementation based on example found on msdn not sure if implementation corect. the code runs fine not sure how check if it's same object instance. here code: public class fileshareaccessfactory : ifileshareaccessfactory { private volatile static ifileshareaccess m_fileshareaccess; private static object m_syncroot = new object(); public ifileshareaccess getfileshareaccessinstance(icontextfactory contextfactory, ilogger logger) { if (m_fileshareaccess == null) { lock (m_syncroot) { if (m_fileshareaccess == null) { m_fileshareaccess = new fileshareaccess(contextfactory, logger); } } } return m_fileshareaccess; } } as double-checked implementations go, yes - that'll work ok. doesn't need volatile , since synchronized double-ch...

css - Align image to bottom of responsive container -

i'm trying align images bottom of container. however, site responsive, when change window size image moves up/down container seems fixed a point on page. is there way fix baseline of image baseline of container indefinitely? essentially, image aligned bottom begin with, window contacts, text forces container expand , end white space below image. my css image div follows: .floatbottom { height: 100%; position: absolute; bottom:0; width: 500px; } css parent container: #box{ height: auto; padding-top: 90px; padding-bottom: 90px; position: relative; } html image in container: <div id="box"> <div class="floatbottom"> <img src="/images/bottom.png"> </div> </div> any ideas massively appreciated! <div class="container"> <div class="content"></div> <div class="floatbottom"></div> </div> and set css cont...

xml - How do I markup a word document with template directives? -

i have unenviable task of writing template system sits on top of word 2007/10/13 allows people inject simple logic document end data store (tbd exported xml document of form) in following forms: direct binding data element (for example paragraph/heading/section title) repeating data element number of times (for example table body or list) providing in-line logic (for example if-block checks business rule result value). rather providing program on case case basis, want put in hands of client means need use authoring tools provided word. can use add-in we're writing markup document, upload document template our solution above directives in , execute them there. i've looked @ following ideas of have big holes in them unfortunately. xml schema. gone in word 2007+ unfortunately though. adding xml namespace content.xml file , writing directives in using attributes in namespace (easy post-process then!). can't work out how edit these or display them on document v...

Tile notification for windows phone - invalid XML payload - -

i send 2 push notifications toast , tile (just count) the toast gets received: <?xml version="1.0" encoding="utf-8"?><wp:notification xmlns:wp="wpnotification"><wp:toast><wp:text1></wp:text1><wp:text2>asdf</wp:text2><wp:param></wp:param></wp:toast></wp:notification> the tile not: <?xml version="1.0" encoding="utf-8"?><wp:notification xmlns:wp="wpnotification"><wp:tile><wp:backgroundimage></wp:backgroundimage><wp:count>122</wp:count><wp:title></wp:title><wp:backbackgroundimage></wp:backbackgroundimage><wp:backtitle></wp:backtitle><wp:backcontent></wp:backcontent></wp:tile></wp:notification> this xml provide , keep getting format errors . there wrong in format? your tile format should like string tilemessage = "<?xml version=\...

c# - How to insert datalist value into another databse tables? -

assumes have 2 tables, table 1 , table 2 . table 1 contains information such pictures, name , price. table 2 contains information order list,table number,quantity , price. if used datalist display data table 1 , , added quantity(name) drop down list, table number(name) drop downlist , submit button, how can add selected data table 2 ? *i'm trying create ordering menu using asp.net, shows food menu table 1 using datalist , waiter submit quantity,table number , food name kitchen side (kitchen.aspx) has gridview order list,quantity , table number on it.

actionscript 3 - Print data from json response to AS3 label -

this json response i'm getting api, used. trace(loader.data); httpstatushandler:200 {"status":"success","data": [{"cab_id":"101","rating_up":"4","rating_down":"4"}],"errors":""} i need decode , print in as3 .can show mew how so. tried this, var mydata:object = json.decode(loader.data); trace(mydata[1]); trace(mydata->rating_up); trace(mydata.tostring()); none working!!! help? why don't try like trace(mydata.data[0].cab_id); trace(mydata.data[0].rating_up); trace(mydata.data[0].rating_down);

c# - Connection pooling and Appdomain -

this question related old question . 1) have vb.net application requires connections databases.so if open multiple instance of same application(exe files) uses different connection or uses multiple connection. can make use single connection? 2) heard appdomain(an appdomain provides layer of isolation within process) . in making connection drawn same pool , make optimal use of resources? article has related it. different processes (your case #1) not (and cannot) share database connections, each connection unique process. i not know whether connection pools per process or per-appdomain. 1 unlikely make difference. model should aiming create, use , close connections around each functional database operation. not try , keep them open, rather try , keep them closed. maximises re-use opportunities re-use. unless have particular few excess connections on theoretically needed default pooling while avoiding holding connections open work. 1 connections reset before b...

c - GCC: __attribute__((malloc)) -

quoting gcc documentation (emphasis mine): the malloc attribute used tell compiler function may treated if non-null pointer returns cannot alias other pointer valid when function returns and memory has undefined content . improves optimization. standard functions property include malloc , calloc . realloc -like functions not have property memory pointed not have undefined content. i have following code: struct buffer { size_t alloc; // allocated memory in bytes size_t size; // actual data size in bytes char data[]; // flexible array member }; #define array_size <initial_value> buffer *buffer_new(void) __attribute__((malloc)) { struct buffer *ret; ret = malloc(sizeof(struct buffer) + array_size); if (!ret) fatal(e_out_of_memory); ret->alloc = array_size; ret->size = 0; return ret; } now i'm bit puzzled here: though didn't initialize data member, still set alloc , size fields resp...

django-admin.py startproject doesn't work, why? FIXED -

the command django-admin.py startproject mysite doesn't work. also more information, here screenshot of happens: http://i.imgur.com/xqsy4zy.png . i tried using full path django: c:\python27\scripts\django-admin.py startproject mysite . neither of these commands create anything. fixed: here answer: django-admin.py not working himmip try django-admin.py startproject mysite in directory want project. plus, make sure have django installed calling python -c "import django; print(django.get_version())" command line. should print out django's version if correctly installed. just in docs .

javascript - Highcharts - change column stacking on click -

i have lovely highcharts plot stacked columns. i'd button can toggle whether stacking 'normal' or 'percent'. i'm trying following (which doesn't work): $('#button').click(function () { var chart = $('#container').highcharts(); chart.options.plotoptions.column.stacking = 'percent'; chart.redraw(); }); fiddle here: http://jsfiddle.net/crkcj/2/ any appreciated! it's not possible change plotoptions in real time. instead can update options each series instead, example: $('#button').click(function () { var chart = $('#container').highcharts(), s = chart.series, slen = s.length; for(var =0; < slen; i++){ s[i].update({ stacking: 'percent' }, false); } chart.redraw(); }); jsfiddle demo here .

java - Display datepickers value in a textview -

i developing android application... in there datepicker date of birth selected... when date displayed... example date january 0 displayed instead of 1 , february 1 displayed instead of 2.. , need value of date in 3 textviews... example if date 04/02/1984 ... need take 04 1 textview , 2 , 1984 one.... pls help.. @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); final datepicker date = (datepicker) findviewbyid(r.id.datepicker1); final textview tvdate = (textview) findviewbyid(r.id.textview2); date.init(date.getyear(), date.getmonth(), date.getdayofmonth(),new ondatechangedlistener() { @override public void ondatechanged(datepicker arg0,int arg1, int arg2, int arg3) { // todo auto-generated method stub string date=integer.tostring(arg1); string month=integer.tostring(arg2); string year=integer.tostri...

javascript - Json not able to access via dot operator -

i using a4j jsfunction send data server , receive json server <a4j:jsfunction name="submitdata" action="#{imageretrivebean.savedata}" data="#{responsenodespathsbean}" oncomplete="processdata(event.data)"> <a4j:param name="param1" noescape="true" value="myfunction()" assignto="#{imageretrivebean.requestjsonmsg}" /> <a4j:param name="param2" noescape="true" value="getfloorno()" assignto="#{imageretrivebean.floorno}" /> </a4j:jsfunction> in processdata function below function processdata(data) { console.log(data); var dataobj = data.responsejsonmsg; } the console.log prints data correctly. following output. ({responsejsonmsg:"{//my data}"}) but not able access data using data.responsejsonmsg the console gives error typeerror: data undefined images of code error occurs , error output on chrome ...

C - How to add a float variable to a string -

i've got variable contains floating number, how do adding string? something this: int main() { char postdata[] = "field1="; float mynumber = 123.12; postdata = postdata + mynumber; return 0; } i want end result "field1=123.1" it doesnt seem easy postdata + mynumber :( use sprintf : char buffer[32]; sprintf(buffer, "%s%f", postdata, mynumber); if need one-digit precision: char buffer[32]; sprintf(buffer, "%s%.1f", postdata, mynumber); here working example.

php - Zend framework - form method valid not work -

i have come problem zend form valid not work? can tell me how can fix problem? code - form setup: <?php class application_form_register extends zend_form { public function init() { /* form elements & other definitions here ... */ $this->setmethod('post'); $this->setattrib('class', 'register'); $this->setattrib('id', 'register_form'); //add email field $this->addelement('text', 'register_email', array( 'label' => 'your email address:', 'required' => true, 'filters' => array('stringtrim'), 'validators' => array('emailaddress',) ) ); $email_field = $this->getelement('register_email'); $email_field->setdecorators(array( 'viewhelper', 'label', new zend_form_decorator_htmltag(array('tag' => 'div'...

String has box like value which is not able to parse by java -

i having problem read file has box in 1 place, when see box in hex mode display 00 01 don`t know how remove character. , problem is, in same file. of records has double quote inside double quote see below string. input one- "i " time values " input one- "i " "time i" values " output - "i time values "

SQL Server: How to check if the value of returned field is not null -

i have sql statement follows: select returndate <joins> <conditions> how check if returndate not null? you can use case is null (or is not null ): select case when returndate null 'it null' else 'it not null' end isitnull dbo.tablename .... if need filter null/not null values can use is not null : where returndate not null ...

android imagebutton can not show ,layout file is following -

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingleft="16dp" android:paddingright="16dp" android:orientation="vertical" > <textview android:layout_width="wrap_content" android:layout_height="220dp" android:text="@string/hello_world" /> <relativelayout android:layout_width="match_parent" android:layout_height="50dp" android:paddingleft="16dp" android:paddingright="16dp" android:paddingtop="500dp"> <imagebutton android:id="@+id/id_button_previous" android:layout_width="wrap_content" android:layout_height="wrap_content" android:backgr...

Golang: storing/caching values to be served in following http requests -

i writing go webservices (also implementing webserver in go http.listenandserve). have map of structs keep in memory (with approximate data size of 100kb) used different http requests. which best way achieve in go? in experience, better use global package variables or caching systems (like memcache/groupcache)? in addition answers you've received, consider making use of receiver-curried method values , http.handlerfunc . if data data loaded before process starts, go this: type common struct { data map[string]*data } func newcommon() (*common, error) { // load data return c, err } func (c *common) root(w http.responsewriter, r *http.request) { // handler } func (c *common) page(w http.responsewriter, r *http.request) { // handler } func main() { common, err := newcommon() if err != nil { ... } http.handlefunc("/", common.root) http.handlefunc("/page", common.page) http.listenandserve(...) } this ...

php - Paypal Direct pay not working -

i have api paypal dodirect method on nvp [direct credit card payment], , i'm using php base language. i'm getting success transaction or response says so. not updating in sandbox account. include_once(drupal_get_path('module','payment_details').'/paypal_do_direct.php'); $paypaldodirect = new paypaldodirect(); $paypaldodirect->setapiusername('crazyheartram_api1.gmail.com'); $paypaldodirect->setapipassword('1377690526'); $paypaldodirect->setapisignature('afm3wtxoe0l1wd2urjztljzhc-wnawhtswj-b7-rw3qpclgamslinqp8'); $paypaldodirect->setcreditcardtype($cardtype); $paypaldodirect->setenvironment('sandbox'); $paypaldodirect->setamount($amount); $paypaldodirect->setcardexpmonth($expirationdate); $paypaldodirect->setcardexpyear($expirationyear); $paypaldodirect->setcardverificationvalue($cvv); $paypaldodirect->setfirstname($firstname); $paypal...

NHibernate QueryOver restrict by string length -

how restrict query length of string property? eg. like: nhsession.queryover<customer>() .where(p => p.registrycode.length == 8) something may trick nhsession.queryover<customer>() .where( restrictions.eq( projections.sqlfunction("length", nhibernateutil.string, projections.property<customer>(x => x.registrycode)), 8 ) )

gwt - RequestFactory's Entity Relationships -

the details of request 's with() implementation of requestfactory in gwt bit unclear me. see here the official documentation . question 1: when querying server, requestfactory not automatically populate relations in object graph. this, use with() method on request , specify related property name string. does mean if entity @ server uses lazy fetching , returned entityproxy have requested objects specified in with()? seems bit odd instantiate whole object graph of object server side, send small piece client. question 2: does req.with("foo").with("foo"); same req.with("foo"); ? question 3: does req.with("foo").with("bar"); same req.with("foo","bar"); ? note: i'm having hard time finding implementation details of with() in source code , api doesn't me either. question 1: it depends on server side implemenation. with invocation make sure corresponding getter ( get...

grid - image to grow outside Javafx gridpane cell -

i add image javafx2 gridpane per code below, image not restricted inside cell. image flow outside cell. gridpane moon_pane = new gridpane(); moon_pane.setid("prayertime_pane"); moon_pane.setgridlinesvisible(true); moon_pane.setpadding(new insets(10, 10, 10, 10)); moon_pane.setalignment(pos.baseline_center); moon_pane.setvgap(10); moon_pane.sethgap(10); text moon_phase_text = new text("60% full"); moon_phase_text.setid("prayer-text-english"); moon_pane.sethalignment(moon_phase_text,hpos.left); moon_pane.setvalignment(moon_phase_text,vpos.center); moon_pane.setconstraints(moon_phase_text, 0, 0); moon_pane.getchildren().add(moon_phase_text); imageview moon_img = new imageview(new image(getclass().getresourceasstream("/images/full_moon.png"))); // moon_pane.sethalignment(moon_img,hpos.center); // moon_pane.setvalignment(...

php - Change web app locale with url routing -

i'm developing web app zend framework 2. how can change application locale based on current url? i match urls domain/locale/controller/action/etc. don't know put code analyse current url , change locale accordingly! thanks help! i solved in way: ../config/autoload/local.php $_server['request_uri_path'] = parse_url($_server['request_uri'], php_url_path); $segment = explode('/', $_server['request_uri_path']); $locale = $segment[1]; if($locale == '') $locale = 'en_us'; // default locale return array( 'translator' => array( 'locale' => $locale, ), );

How to run Maven surefire without printing out test results to the command line? -

i running maven 3.1.0 surefire plugin already --quiet option, still prints out results of unit tests out command line, if pass. is there way print failures? the output i'd suppress if fine looks like: ------------------------------------------------------- t e s t s ------------------------------------------------------- running net.initech.project.dawgs.actionfactory.interfaceactionfactorytest tests run: 14, failures: 0, errors: 0, skipped: 0, time elapsed: 0.425 sec running net.initech.project.dawgs.actionfactory.valuescopetest tests run: 8, failures: 0, errors: 0, skipped: 0, time elapsed: 0.001 sec running net.initech.project.dawgs.assertion.assertcontainstest tests run: 7, failures: 0, errors: 0, skipped: 0, time elapsed: 0.011 sec running net.initech.project.assertion.assertendswithtest tests run: 6, failures: 0, errors: 0, skipped: 0, time elapsed: 0.012 sec running net.initech.project.assertion.assertisequaltest tests run: 5, failures: 0, errors: 0, skipped: 0, ...

linux - grep exact word match (-w) does not work with file paths in a text file -

im trying grep filename fullpath in file contains 'ls -l' output, fails match correctly. line in shell script string search pcline=`grep -w "$file1" $file2` # grep file1 in file2 contents if echo command, output of command looks below grep -w run /home/rajesh/rootfs.layout expected lrwxrwxrwx 1 root root 3 aug 28 run actual lrwxrwxrwx 1 root root 7 aug 28 bin/run-parts lrwxrwxrwx 1 root root 3 aug 28 run -rwxr-xr-x 1 root root 303 aug 28 tests/aes/run.sh -rwxr-xr-x 1 root root 445 aug 28 tests/auto_ui/run.sh -rwxr-xr-x 1 root root 320 aug 28 tests/available_memory/run.sh -rwxr-xr-x 1 root root 308 aug 28 tests/fonts/run.sh -rwxr-xr-x 1 root root 309 aug 28 tests/html_config_page/run.sh -rwxr-xr-x 1 root root 361 aug 28 tests/ipc/run.sh -rwxr-xr-x 1 root root 304 aug 28 tests/json/run.sh -rwxr-xr-x 1 root root 303 aug 28 tests/log4cplus_cpp/run.sh -rwxr-xr-x 1 root root 301 aug 28 tests/log4cplus_c/run.sh -rwxr-xr-x 1 root root 751 aug 28 tests/msm_basic/...

java - maven h2 lucene classnotfound -

i use in project h2 , enable lucene search index. added following deps. pom.xml: <dependency> <groupid>org.apache.lucene</groupid> <artifactid>lucene-core</artifactid> <version>4.4.0</version> </dependency> <dependency> <groupid>org.apache.lucene</groupid> <artifactid>lucene-analyzers-common</artifactid> <version>4.4.0</version> </dependency> i still java.lang.classnotfoundexception: org.apache.lucene.search.searcher h2. problem occours when launch program. use lucene < 4.0.0; org.apache.lucene.search.searcher abstract class has been deprecated in version 3.6.0, , included since 4.0.0 as/inside org.apache.lucene.search.indexsearcher . http://lucene.apache.org/core/3_6_0/api/core/deprecated-list.html

ios - Multisampling for drawing app -

i'm creating drawing ios application, , in need of smoothing lines being drawn user. i'm using multisampling normal. for each time user moves finger, code : create points make line , draw these points sampling buffer. resolve sampling buffer. the result buffer drawn canvas. the problem when user have big canvas (e.g: 2048x2048), resolve process takes quite time it's causing drawing lag/choppy. resolve process resolve pixels in buffer, regardless whether pixels needs resolved or not. i saw drawing app procreate, , draws smoothly no lag big canvas. so, possible, don't know how that. does have idea solution? thanks. just in case has same problem me, found decent solution : create smaller sampling fbo purpose of drawing lines last point current point. use 256x256 buffer. when drawing last point current point, use sampling buffer , resolve. draw sampling buffer current layer. the result not bad, no more lag. problem setting appropriate ...

javascript - How to detect scroll event on a ListView? -

does know of way detect vertical scroll/swipe gesture on listview? tried listening swipe event fires on left-to-right , right-to-left gestures, not or down. tried listening on parent view resulted in same behavior. in advance tips or tricks! :) it doesn't seem supported, 1 way set list views height ti.ui.size not scroll, , put inside scrollview. listen scroll event on scrollview. try this: // vertical scroll view var parentscrollview = ti.ui.createscrollview({ height : 'auto' }); // make list view not scroll var listview = ti.ui.createlistview({ height : ti.ui.size, ... other initialization here ... }); parentscrollview.add(listview); parentscrollview.addeventlistener('scroll', function(e) { // lets know scrolled var scrollx = e.x; var scrolly = e.y; // alternatively use contentoffset var contentoffsetscoped = e.source.contentoffset; var contentoffsetsame = parentscrollview.contentoffset; }); this minimalist exa...

javascript - Firefox extension: how to fill an input text field -

i have custom toolbar button created in accordance tutorial . javascript code button following: custombutton = { 1: function () { alert("just testing") }, } and works. when click on button, alert happens. i'm trying make changes, namely, fill input field on clicking button, piece of code doesn't work: custombutton = { 1: function () { document.getelementbyid("loginusername").value = "aaaa"; }, } the element id "loginusername" exists on page. can fill selenium webdriver: driver.findelement(by.id("loginusername")).sendkeys(user). so question why doesn't work in firefox extension? thanks, racoon your toolbar button , input field (assuming latter part of web page) live in separate documents. it's easy cross boundary. change code to gbrowser.contentdocument.getelementbyid("loginusername").value = "aaaa";

how to POST list of objects in django? -

sorry i'm new django, need transfer list post in django, problem list elements need complex objects, dictionaries every list entry should have first name , last name parameters. know how make list of simple values : <input type="hidden" name="alist" value="1" /> <input type="hidden" name="alist" value="2" /> <input type="hidden" name="alist" value="3" /> and : alist = request.post.getlist('alist') what best practice of doing this? thanks it's not @ clear want do, perhaps list json , post that.

python - Is there a way to have a dictionary key be a range? -

forgive me if obvious, i'm very, new python. i've found ways multiple keys dictionary, that's not i'm trying do. basically i'm looking this: my_dict = { "1-10" : "foo", "11-20" : "bar", # ... "91-100" : "baz" } ... keys aren't strings , number in given range maps value. example, my_dict[9] ought return foo , my_dict[3] should. thought of using explicit array, following, didn't work: my_dict = { [1, 2, 3, ..., 10] : "foo", i'm unsure if valid use-case dictionary, or if there data structure should using. python has way of surprising me. know python magic make work? how this: def fancy_dict(*args): 'pass in list of tuples, key/value pairs' ret = {} k,v in args: in k: ret[i] = v return ret then, can: >>> dic = fancy_dict((range(10), 'hello'), (range(100,125),...

ios - swipe and pan gesture overlap -

is possible let specific gesture fail next possible gesture recognized? to more specific, @ sample snippet: uiswipegesturerecognizer *swipeleft = [initialize uiswipegesturerecognizer... @selector(handleswipe:)] swipeleft = uiswipegesturerecognizerdirectionleft; swipeleft.delegate = self; uipangesturerecognizer *pan = [initialize uipangesturerecognizer... @selector(handlepan:)] pan.delegate = self; [pan requiregesturerecognizertofail:swipeleft]; the above code states if swipe left not recognized device, pan gesture handler used. so question: possible let swipeleft intentionally fail (after being recognized swipe left touch device) based on criteria checked on handleswipe, , let pan gesture handle touch input instead? thanks. check out uigesturerecognizerdelegate protocol here: https://developer.apple.com/library/ios/documentation/uikit/reference/uigesturerecognizerdelegate_protocol/reference/reference.html specifically, the gesturerecognizer:shouldreco...

c# 4.0 - Accumulating Lexer errors in ANTLR 4 -

i trying accumulate lexer errors when lexing in run time. have followed exact way of achieving parser errors in this answer . when try lexer. class class2 : iantlrerrorlistener<itoken> { public void syntaxerror(irecognizer recognizer, itoken offendingsymbol, int line, int charpositioninline, string msg, recognitionexception e) { console.writeline("error in lexer @ line " + ":" + e.offendingtoken.column + e.offendingtoken.line + e.message); } } and register listener below. class2 z = new class2(); lexer.adderrorlistener(z); but gives error unexpected. argument 1: cannot convert 'cssparserantlr.class2' 'antlr4.runtime.iantlrerrorlistener<int>' and the best overloaded method match 'antlr4.runtime.recognizer<int,antlr4.runtime.atn.lexeratnsimulator>.adderrorlistener(antlr4.runtime.iantlrerrorlistener<int>)' has invalid arguments please give me reason why happeni...

javascript - How to impersonate JS enabled browser? -

i need download webpage using script (php, python, bash) , not using gui browser. problem web page checks front deals js enabled browser. got using naive downloading given url initial page (in case think coursera courses page: http://pastebin.com/4tjjrmtu ). how can download "real" content using script? far can think such solutions (some crazy ones): figuring out js on startup pages does, , mimic in script, loading page scan network traffic using wireshark , find pattern request page abc1.html ends fetching page abc1body.html instead of native (for given language) download feature launch external browser download page ( exec firefox --dump http://foo.bar/x.html -- making up, don't know if there browser scripting capability). and other ideas? grateful tested ones. dropping script , instead writing browser plugin 1 of options, since put time write scripts seems quicker fix them, instead writing them scratch. have @ phantomjs . headless browser, mi...

Wordpress: is it possible to create a sticky post that is at the top of the search results no matter the terms searched for? -

title pretty says all. i'd post appear @ top of every search results page. google , support forums turned nothing. any pro's on here want shed light if possible or not? one method include custom field on posts checkbox allows mark post sticky. then, in search.php file, write wp_query retrieve sticky posts ( http://codex.wordpress.org/class_reference/wp_query#custom_field_parameters ). then after displayed, include search results loop. you're calling sticky posts prior displaying of search results.

c++ - How to initialize std::array<T, n> elegantly if T is not default constructible? -

how initialize std::array<t, n> if t not default constructible ? i know it's possible initialize that: t t{args}; std::array<t, 5> a{t, t, t, t, t}; but n me template parameter: template<typename t, int n> void f(t value) { std::array<t, n> items = ??? } and if wasn't template, it's quite ugly repeat value hand if n large. given n, generate sequence-type called seq<0,1,2,3,...n-1> using generator called genseq_t<> , this: template<typename t, int n> void f(t value) { //genseq_t<n> seq<0,1,...n-1> std::array<t, n> items = repeat(value, genseq_t<n>{}); } where repeat defined as: template<typename t, int...n> auto repeat(t value, seq<n...>) -> std::array<t, sizeof...(n)> { //unpack n, repeating `value` sizeof...(n) times //note (x, value) evaluates value return {(n, value)...}; } and rest defined as: template<int ... n> st...

ruby on rails - How to let a non-signed in user access a restricted page only once? -

i have rails 3.2 app requires user signed in (current_user) in order access event pages, subdomains. i'm using devise authentication. is there way allow user one-time access event page if supplied direct link it? want them prompted sign in (or sign up) if try access different event pages, or if leave , come @ future date same event page. i've watched guest account episode on railscasts , seems user continue logging in guest without ever signing approach. here events controller code: def show @event = event.find_by_name(request.subdomain) if params[:id].present? @event = event.find(params[:id]) end # if @event.present? , @event.videos.present? @video = video.find_by_id(params[:video]) || @event.videos.first # else # @video = @event.videos.first # end # @json = event.all.to_gmaps4rails if @user = current_user else flash[:alert] = "please sign in first" redirect_to sign_up_url(:subdomain =...

Simplyfy HTML Table code using PHP -

i have webpage (created within php files) needs display table 30 rows long , allows user enter values each of 30 rows , press button let php process have entered. anyway instead of having write out normal html form table has 30 rows wonder if way create table in php less code. so looks like <form name="createtable" action="?page=createtable" method="post" autocomplete="off"> <table border='1'> <tr> <th> weight </th> <th> cbm min </th> <th> cbm max </th> <th> min </th> </tr> <tr> <th> 1000 </th> <th> 0.1 </th> <th> 2.3 </th> <th> <input type=text name=min1> </th> </tr> <tr> <th> 1500 </th> <th> 2.31 </th...

c++ - How to share code between two classes having same parent? -

although using mfc, believe c++ question. i have cresizingdialog derived cdialog base class dialogs in application. gives them ability automatically (you guessed it) resize according target screen size. cresizingdialog achieves overrides cdialog's several virtual functions including onsize() , oninitdialog() , onpaint() . far , good. now adding property sheet/page needs same resizing functionality can't use cresizingdialog base class property page. means need new base class cresizingpage derived cpropertypage contain same functionality cresizingdialog. however code resizes dialogs , controls same. there way can reuse cresizingdialog somehow? have never used multiple inheritance, here? i have 2 suggestions how solve this, you'll have decide easier/nicer situation. if possible can move resizing code standalone function appropriate parameters can call 2 virtual functions. the other way make base class template. this: template< typename base > ...

ruby - Re-enable Rails 4 auto-EXPLAIN -

automatic explain on slow-running sql queries. feature has been removed rails 4. config.active_record.auto_explain_threshold_in_seconds = 0.5 we find useful, in controlled circumstances. came short in searching answers following questions. what underlying rationale removing auto-explain? (i'm sure reasons sound, can't find are.) is there way reintroduce auto-explain in rails 4 codebase? (couldn't find gem, nor online information) here commit removed auto_explain . looks reasoning used , problematic w/ asset pipeline. commit notes can still use activerecord::relation#explain generate explain queries, if want have automatically called have implement yourself. looking on removed code in commit should on right path.

java - What happens when a File is not created for a file input stream? -

what happens when file not created file input stream? happens if want retrieve file hasn't been created yet? equal null? you ioexception. best bet test file.exists() first. since possible file deleted between time call file.exists() , time start reading it, have handle exceptional case anyway.

jquery - Search regular expression in JavaScript -

the search regular expression in array jquery autocomplete not working correctly. i have array: var names = [ "jorn zaefferer", "scott gonzalez", "john resig" ]; here autocomplete function of jquery: $( "#developer" ).autocomplete({ source: function( request, response ) { var matcher = new regexp('^'+request.term,'g'); var arr=new array(); for(var i=0;i<names.length;i++) { var index=0; if(matcher.test(names[i])===true) //not returning true { console.log("it true"); arr.push(names[i]); } else { console.log("not done"); } } response(arr); } }); the conditional statement: if(matcher.test(names[i])===true) in code not returning true. why? you need remove g flag on regular expression can leave regular expression object state 1 search next , can m...

xml - Unexpected behavior with XSLT when trying to select first matching element -

i have data want serialize xml in specific format. have array of testclass , consists of 2 string properties: a , b . i know doesn't sound practice, in case, expect values of a identical instances of testclass . i want create xml file contains common a value , b values. i've written following code: using system; using system.collections.generic; using system.linq; using system.text; using system.xml.serialization; using system.xml.xsl; using system.io; namespace test { public class program { public class testclass { public string { get; set; } public string b { get; set; } } static void main(string[] args) { testclass[] array = new testclass[] { new testclass() { = "a1", b="b1"}, new testclass() { = "a2", b="b2"} }; xmlserializer serializer = new xmlserializer(typeof(tes...

css - Change Background Row Color when Press a Button -

i want change default background color of grid row after had been selected , when press button. i'm using sencha extjs 4.2. anyone me please? thank in advance task can solved using column renderer: http://jsfiddle.net/blgsa/10/ var button = ext.create('ext.button.button', { text: 'btn', listeners: { click: function() { var sm = grid.getselectionmodel(); if (sm.hasselection()) { var rec = sm.getselection()[0]; if (rec.get("color") == "black") rec.set("color", "red"); else rec.set("color", "black"); } } } }); var renderer = function(value, metadata, record) { metadata.style = 'color:'+record.get("color"); return value; } var grid = ext.create('ext.grid.panel', { height: 300, width: 400, title: ...

selenium - Is there a way to preserve the order of tests in TestNG without a TestSuite.xml file? -

i'm doing selenium tests in testng. not have maintenance annoyance of keeping of test methods in separate file , rather include package scan @tests. given scenario, there way preserve order of test methods within test file , have testng consume 1 test class @ time. currently, maintaining method order within tests @test(dependson={}) works; however, i'm seeing situation testclassa test_method_1 test_method_2 test_method_3 test_method_4 testclassb test_method_1 test_method_2 test_method_3 test_method_4 run tests , order like: classb, method 1 classa, method 1 classb, method 2 classb, method 3 classa, method 2 classa, method 3 classb, method 4 classa, method 4 i don't care class order, care methods of 1 test class run entirely before moving on next test class. anyone? it great see testng.xml file. seems similar situation described here: http://testng.org/doc/documentation-main.html#testng-xml . think in case should have ...

eclipse - WebApplicationInitializer container.addServlet() returns null -

i creating basic web app maven, importing eclipse 4.2. have tomcat 7 setup server. trying configure spring data mongodb web app. i following code-based configuration approach found here: webapplicationinitializer when run project on server, null pointer exception in webapplicationinitializer class have created. line: container.addservlet("dispatcher", new dispatcherservlet(dispatchercontext)); returning null. what heck missing? bit new creating web-apps scratch using annotations. here class in question: public class atwwebappinitializer implements webapplicationinitializer { @override public void onstartup(servletcontext container) throws servletexception { // create 'root' spring application context annotationconfigwebapplicationcontext rootcontext = new annotationconfigwebapplicationcontext(); rootcontext.register(springmongoconfig.class); // manage lifecycle of root application context container.addl...