Posts

Showing posts from June, 2010

javascript - Paste function in jquery/java script on button click -

i have textbox write website url.and place button beside that. i want if user copy url place , click on button copied url paste in textbox. now can use ctrl+v paste url in text box.but mobile user not able use that. need on click on button copied url paste in textbox. any highly appreciable , in advance. based upon many questions past... javascript clipboard data on paste event (cross browser) get current clipboard content? is possible read clipboard in firefox, safari , chrome using javascript? how copy clipboard in javascript? ... answer "no, it's impossible." i suggest, though, you've skipped important step in development process. problem face want allow mobile users painlessly enter text (in particular, urls, pain type) other sources textbox on site. take step , @ other possible solutions problem don't involve javascript access user's clipboard. in fact, 'solution' you're trying implement doesn't user, becaus

java - Line Number Reader -

i got problems code window.videoinfo.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { try { url url = new url(window.videoinput.gettext()); urlconnection con = url.openconnection(); linenumberreader in = new linenumberreader(new inputstreamreader(con.getinputstream())); in.setlinenumber(1523); in.getlinenumber(); system.out.print(in.readline()); } catch (ioexception ex) { ex.printstacktrace(); } i trying display specific line website. if press button displays first line. when set line number 1523. setlinenumber(1523) makes line number returned getlinenumber() starts 1523 . won't skip 1523 lines. skip 1523 lines, need do: for(int = 0; < 1523; i++) in.readline();

How to iterate day in php? -

i need next 7 (or more) dates except sunday. firstly did $end_date = new datetime(); $end_date->add(new dateinterval('p7d')); $period = new dateperiod( new datetime(), new dateinterval('p1d'), $end_date ); and after checked $period in foreach . noticed if remove sunday need add 1 more day end , each time when sunday is... there way it? $start = new datetime(''); $end = new datetime('+7 days'); $interval = new dateinterval('p1d'); $period = new dateperiod($start, $interval, $end); foreach ($period $dt) { if ($dt->format("n") === 7) { $end->add(new dateinterval('p1d')); } else { echo $dt->format("l y-m-d") . php_eol; } } see in action

default to index.html but allow user to type to index.php and get the php page -

i'm busy building wordpress website client. i've developed site off-line , upload live server show client i've done far. want keep "under construction" html page i've create default when browsing site if type in www.sitename.com/index.php want actual site displayed. i don't want use "under construction" plugin don't want user have enter form of username or password gain access site. i have tried: directoryindex index.htm browse index.php flips me index.htm page. i've had here: make index.html default, allow index.php visited if typed in unless i'm missing it, there's no real conclusion. my development machine runs windows 8 xampp. use in .htaccess file redirect user index.html when types domain name, if types index.php , able on page rewriterule ^$ index.html [r=301,l]

linux - what is the meaning of key size of cipher -

what key size or key length of cipher , , heard 128 bit key, 1024 bit rsa key , mean? for suppose there 1024 bit key , thought 1024 means number of bits required store key , right? and have public , private keys ( ssl keys ) , how can find key size of certs ( public key , private key). there linux tool find key size? all explained here: http://en.wikipedia.org/wiki/key_size . to check key size of cert can use example openssl : openssl x509 -in your_cert_in_pem_format.crt.pem -noout -text

javascript - multiple arguments with PySide QtCore.Slot decorator -

how define multiple arguments? types supported? , why fail when combine decorator? i couldn't find real documentation on went source -- pysideslot.cpp . slot takes 2 keyword args, name (a string name slot) , result (a python type object or string naming qt type, used specify return type of function). if name isn't supplied, try read function you're decorating, careful: other decorators ruin name of function, if you're combining slot decorator may want explicitly specify name arg. any positional arguments feed slot converted strings pyside::signal::gettypename , joined comma-separated string. become signature of slot , used routing calls. for example, given decorator: @qtcore.slot(int,str,result=float) def func(a,b): assert len(b)==a; upload(b); return 2.5 the pyside internals create call signature string of 'int,qstring' , resulttype string of 'double'. i hope helps next person struggling debug slots.

java - How do I get started with JFreeChart? -

i've never used third party library before. should after downloaded jfreechart-1.0.14.tar.gz ? i don't know if i'm doing these things right: 1. put jcommon-1.0.17.jar , jfreechart-1.0.14.jar @ same directory source code. 2. import needed class in source code (e.g. import org.jfree.util.rotation; ) many articles tell how in ides. instead of ides, i'm writing codes vim , compile myself. so, assume didn't thing wrong, how should compile source code javac , run code java ? edit: here's file layout: ./src | - test.java ./lib | - jcommon-1.0.17.jar | - jfreechart-1.0.14.jar i compile by javac -cp "lib/*" -d classes/ src/test.java run by java -cp classes:lib/jcommon-1.0.17.jar:jfreechart-1.0.14.jar test however, error occurs: exception in thread "main" java.lang.noclassdeffounderror: org/jfree/data/general/piedataset how can resolve problem? exception in thread "main" java.lang.noclassdeffounderror

javascript - Mouse Event Handling for an Element -

i made search box , coding this <table id="searchbox" style="border:1px solid #555;"> <tr> <td> <input type="text" style="border:none" id="mytextbox" onclick="makeactive();" /> </td> <td> <select onclick="makeactive();"> <option>option 1</option> <option>option 2</option> <option>option 3</option> </select> </td> <td> <input type="submit" value="submit" /> </td> </tr> </table> functions function makeactive() { document.getelementbyid("searchbox").style.border="1px solid #ff0000"; } function makeunactive() { document.getelementbyid("searchbox").style.border="1px solid #555"; } my requirement : code says when user either click textbox or selectbox table border changes shows searchbox acti

Entity Framework Migrations with a different Database -

i stuck trying figure out how set database run migration on. i have created new empty project , set entity framework using code first. have classes built. i want add new database , run migrations on this. have migrations working can't figure out database running on. is possible set database want use migrations? multiple dbs same context gets little tricky. possible: essence of problem how ef decides connection use. access instantiate context without no params during migration. depending on how behaves influences outcome , success. start here: entityframework code-first custom connection string , migrations

scripting - Python: checking if point is inside a polygon -

i have class describing point (has 2 coordinates x , y) , class describing polygon has list of points correspond corners (self.corners) need check if point in polygon here function supposed check if point in in polygon. using ray casting method def in_me(self, point): result = false n = len(self.corners) p1x = int(self.corners[0].x) p1y = int(self.corners[0].y) in range(n+1): p2x = int(self.corners[i % n].x) p2y = int(self.corners[i % n].y) if point.y > min(p1y,p2y): if point.x <= max(p1x,p2x): if p1y != p2y: xinters = (point.y-p1y)*(p2x-p1x)/(p2y-p1y)+p1x print xinters if p1x == p2x or point.x <= xinters: result = not result p1x,p1y = p2x,p2y return result i run test following shape , point: pg1 = (0,0), (0,2), (2,2), (2,0) point = (1,1)

c# - Dependency injection in long-running Windows service - Composition root the right idea? -

i writing windows service (if goes according plan) run months @ time. throughout lifetime of service, maintain several wcf services (named pipes communicating other local apps), run embedded data store (ravendb probably, more or less irrelevant question), , use third-party software maintain sip service (voip functionality). of challenges facing means having react events , create new business objects handle these events represent. now, i've read mark seemann's book (at least relevant parts discussion), , understand why service locator bad, , why handling in composition root (service starting point in case) - in general case. however, don't understand how can apply every situation. see how perfect in cases can compose whole root @ start of application, or in mvc ioc engine used per request framework. however, long-running service, imagine inefficient in best case, , impossible in cases, create objects front. can't imagine being able write non-trivial service gets

gruntjs - Using grunt in Symfony project with different bundles -

i'm looking advice & tips on how deal grunt tasks in symfony project containing different bundles. for example: created "backendbundle" contains basic login system , basic ui general web applications. ui uses twitter bootstrap, parts of jquery ui , contains of own js , css. bundle in private git repo. i created second bundle (cmsbundle) imports inherits backendbundle , adds cms functionalities backend. cmsbundle uses ui of backendbundle, has css/js of own. a website project symfony project includes both bundles using composer, bundles downloaded vendor folder. the problem gruntfile.js resides in root folder of project (aka website), , has no knowledge of the imported bundles' requirements. is there way include/import tasks provided specific bundle in seperate gruntfile.js file ? i don't having direct experience making describe work across multiple bundles, seems grunt hub may accomplish you're after. you'd need ensure (grunt hu

perl - How can I use HTML::Template without creating separate files for each template? -

the normal way of using html::template follows: main file: my $template = html::template->new(filename => 'secret.tmpl'); $template->param(secret_message => $bar); print $template->output; secret.tmpl: <h1>hello <tmpl_var name=secret_message></h1> the question is, can use template engine without creating separate files - i.e., generating template's content on fly? or maybe it's possible other modules? yes, possible html::template : constructor works templates stored either in scalar (as whole block of text) or in array (line line). this: my $t_from_scalar = html::template->new( scalarref => $ref_to_template_text, option => 'value', ); $t_from_array_of_lines = html::template->new( arrayref => $ref_to_array_of_lines, option => 'value', ); in fact, there 2 specific constructor methods these cases: my $t_from_scalar = html::template->new_scalar_ref(

Using Integer And Char Pointers in C++ or C? -

int *ab = (int *)5656; cout << *ab; //here appcrash. int *ab; *ab = 5656; cout << *ab; //these block crashes app too. but can hex value of content of pointer if write this: int *ab = (int *)5656; cout << ab; //output hex value of 5656. so want ask: * operator brings contents of pointer(?) why in this(these) example(s) app crashes? and can use operator if change code this: int = 5656; int *aptr = &a; cout << *aptr; //no crash. and why dereference operator(*) brings first character of char: char *cptr = "this test"; cout << *cptr; // here output = 't' cout << cptr; // here output = 'this test' int *ab = (int *)5656; cout << *ab; //here appcrash. in case, setting pointer ab point @ address 5656. know what's @ address? no don't. telling compiler trust there int there. then, when dereference pointer *ab , find there isn't int there , undefined behaviour. in case, program

c++ - Creating Toolbox objects (e.g. Labels etc.) in code -

i'm new @ using microsoft visual studio, have knowledge c++ language. i'd create object can found in toolbox, such labels, button, etc., without putting them onto window hand. how can it? objects/controls labels , buttons special type of window, associated window class , window procedure. such, call createwindowex , supply second parameter, lpclassname, class name of object/control want create (eg. label use class name static ). check out following tutorial complete example, using button class to create button: hwnd hwndbutton=createwindowex(null, "button", "ok", ws_tabstop|ws_visible|ws_child|bs_defpushbutton, 50, 220, 100, 24, hwnd, (hmenu)idc_main_button, getmodulehandle(null), null);`

jquery - Textillate-effect displays all unordered list items when combined with <a href="#"></a> -

i using textillate apply effect on unordered list. this works far well. unfortunately when combine hyperlinks within < ul > - element, displays < li >'s of unordered list when starting effect. i made quick jsfiddle: http://jsfiddle.net/deschroe/9hske/ does have idea why hicks in first line? goal is, displays 1 @ time. here's code: <div id="white_box"> <div class="container white"> <div class="row"> <div class="span12"> <h1>recent works:</h1> <h2 class="tlt"> <ul class="texts"> <li><a href="#">1 link</a></li> <li><a href="#">2 link</a></li> <li><a href="#">3 link</a></li> </ul> </h2> </div> </div> </div> </div>

vb.net - Clicking the button it select all my page (working on browser not on mobile) -

first of all, 2 days old using jquery mobile, work done trial , error , reading. i have added aspx button , enhance jquery, looks fine except 2 behavior 1- when assign icon button, tried click in browser, code write in btn_search_click not fire, after many checking , and testing notice code fire if clicked icon "search image" itself. 2- when tried button on mobile "galaxy note" seem whole page write getting selected light orange in image below, later on discovered pressing button give effect, pressing "search icon on button" works well is normal behavior? https://plus.google.com/u/0/115817137660799291682/posts/7tn5kxdfobt here html/jquery page (without table movies) <%@ page language="vb" autoeventwireup="false" codefile="default2.aspx.vb" inherits="default2" %> <!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" c

java - Adding list to a list of lists doesn't work -

i can not code work. .txt file reading here: urls.txt the problem code not @ add lines. whenever try @ "lists" gives me indexoutofboundsexception. the code gets executed each 30 seconds, have call lists.clear(); method. note: "lists" defined earlier: public static arraylist<arraylist<string>> lists = new arraylist<arraylist<string>>(); this code: try { url urls = new url("https://dl.dropboxusercontent.com/u/22001728/server%20creator/urls.txt"); bufferedreader br = new bufferedreader(new inputstreamreader(urls.openstream())); lists.clear(); string line; arraylist<string> list = new arraylist<string>(); lists.add(list); int y = 0, z = 0; while ((line = br.readline()) != null) { y++; if(line.equalsignorecase(">

java - While loop stack overflow -

i use method, , while loop stack overflow. no error message or crash. got in log cat: 05-18 20:17:16.528: w/inputeventreceiver(19831): attempted finish input event input event receiver has been disposed. when put code in while boolean: data.numberofsamedaterows(selectedday) != 0 the loop fine. when use below got stack overflow. if(data.numberofsamedaterows(selectedday) != 0) i=0; else i++; thank helping :) here code: databasemain data = new databasemain(this); data.open(); simpledateformat dateformatter = new simpledateformat("d-mmmm-yyyy"); string datewanted = getcorrectdate(removespinner); date wanteddate = new date(); int = 0; try { wanteddate = dateformatter.parse(datewanted); } catch (parseexception e) { e.printstacktrace(); } calendar mycal = new gregoriancalendar(); mycal.settime(wanteddate); date newdate = mycal.gettime(); string

android - 3 layouts - middle is flexible -

Image
i need following thing: 3 layouts: header content footer header must on top footer must sticked bottom ( android:layout_alignparentbottom="true" ). but how make middle occupy whole other screen? thanks. here solution (with android:layout_weight , scrollview): <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:background="#dddddd" android:gravity="center" android:orientation="vertical" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content"

java - Method overrding passing null object -

this question has answer here: how overloaded method chosen when parameter literal null value? 7 answers i unable understand why program prints string class aa { void m1(object o) { system.out.println("object "); } void m1(string o) { system.out.println("string "); } } public class stringorobject { public static void main(string[] args) { aa = new aa(); a.m1(null); } } please me understand how works print sting rather object dave newton's comment correct. call method goes specific possible implementation. example be: class foo {} class bar extends foo {} class biz extends bar {} public class main { private static void meth(foo f) { system.out.println("foo"); } private static void meth(bar b) { system.out.println("bar")

hibernate - Grails query cache is not used -

i'm trying cache following query called controller: def approvedcount = book.countbyapproved(true, [cache: true]) i have enabled 2nd-level cache book class, adding static mapping = { cache true } to book.groovy . have following configured in datasource.groovy hibernate { cache.use_second_level_cache = true cache.use_query_cache = true cache.region.factory_class = 'net.sf.ehcache.hibernate.ehcacheregionfactory' } in same file i've enabled query logging adding logsql=true in datasource block. every time load page, book.countbyapproved(true) query logged, assume means results not being retrieved query cache? i'm running locally, there's no possibility cache being missed because cached query result has been invalidated (by actions of user). i'll @ jira issue filed, looks problem dynamic finders, since hql works: book.executequery( 'select count(*) book name=:name', [name: 'foo'], [cache: true])

javascript - google extension popup doesn't appear using OnClick -

here site source code: <!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"> </script> <meta name="robots" content="all"> <meta name="revisit-after" content="2 hours"> <meta name="distribution" content="global"> <meta name="viewport" content="width=728"> <link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/myextensionid"> <title> </title> </head> <body bgcolor="#ffffff" background="bg.png" topmargin="0" leftmargin="0"> <center>

ColdFusion 9 - Top n random query results -

i've got series of queries 5 results @ random, problem is taking while through them, because involves loop assign rand value can order (which railo can in-query) i wondering if has dealt , knows of way of speeding up. i'm below 200ms, isn't bad i'm sure can sped up. you don't need use qoq @ all. one option might write original query as: select top 5 whatever,you,need table order rand() update syntax depending on database server you're using. another option, done both regular queries , qoq, be: select primary keys shuffle array (i.e. createobject("java","java.util.collections").shuffle(array) ) use first 5 items in array select fields need. no looping or updating, 2 simple selects. of course if primary key auto-incrementing integer, might away select max(id) use randrange pick 5 items.

loops - Resuming a Java program when the computer sleeps? -

i have java program has loop in checks new messages every twenty seconds. example: while (true) { thread.sleep(20000); newmessages(); } this works when computer being run. however, if user put computer sleep , wake duration of time later, whole program gets messed , no longer checks messages every twenty seconds. there way correct this? instead of using thread.sleep can use timer . a facility threads schedule tasks future execution in background thread. tasks may scheduled one-time execution, or repeated execution @ regular intervals. your code might be: final timer timer = new timer(); final timertask task = new timertask() { @override public void run() { newmessages(); } }; timer.scheduleatfixedrate(task, new date(), 20000); timer javadoc

jquery - Php to query sidebar -

i starting website , can query products in table display on page. in left sidebar displays color , price color yellow (3) white (9) tan (1) red (3) purple (1) pink (7) orange (1) multi (1) green (8) brown (1) blue (3) black (3) price under $25 (4) $25-$50 (4) 2/$40 (22) 2/$50 (10) 3/$33 (1) so used count , group display this. want click on 1 of colors or 1 of prices , narrow products down. click on black want able query 3 black products here php products in table <?php $dynamiclist =""; $sql = mysql_query("select * test2 limit"); $productcount = mysql_num_rows($sql); if ($productcount > 0) { while($row = mysql_fetch_array($sql)){ $product_name = $row["product_name"]; $image_url = $row["image_url"]; $category = $row["category"]; $subcategory = $row["subcategory"];

mysql - How to JOIN two tables when not using any Primary Keys? -

i'm trying join 2 tables using columns aren't either of tables respective primary keys: select * tablea inner join tableb b on a.col5 = b.col5 yet above returning 0 results though know sure there rows in table a col5 values match values in col5 of table b . what doing wrong? you query: select * tablea inner join tableb b on a.col5 = b.col5; has correct syntax join. if there matching values, return it. (or course, calling application , there errors either in application code or connection database, issue.) some cases values same not: both values floats. same when printed out. bit @ end of value differs. never use floats equi-joins. one value number , other value string. conversion of 1 of values results in different value. one value date/time , other string. conversion of 1 of values results in different value. the values strings. differ in case. think abc same abc1 , sql doesn't. you have spaces or other "hidden" char

javascript - jQuery: How to get the width sum of all previous elements and put it in data attribute -

Image
how width of each previous elements , sum them (after page load) put value in each element data attribute code on jsfiddle http://jsfiddle.net/jsfkj/2/ how make code <ul> <li style="width:130px">num 1</li> <li style="width:150px">num 2</li> <li style="width:140px">num 3</li> <li style="width:175px">num 4</li> <li style="width:100px">num 5</li> </ul> to this <ul> <li style="width:130px" data-num="0">num 1</li> <li style="width:150px" data-num="130">num 2</li> <li style="width:140px" data-num="280">num 3</li> <li style="width:175px" data-num="420">num 4</li> <li style="width:100px" data-num="595">num 5</li> </ul> this image explain more want hope i've explained want

R: XPath expression returns links outside of selected element -

i using r scrape links main table on that page , using xpath syntax. main table third on page, , want links containing magazine article. my code follows: require(xml) (x = htmlparse("http://www.numerama.com/magazine/recherche/125/hadopi/date")) (y = xpathapply(x, "//table")[[3]]) (z = xpathapply(y, "//table//a[contains(@href,'/magazine/') , not(contains(@href, '/recherche/'))]/@href")) (links = unique(z)) if @ output, final links not come main table sidebar, though selected main table in third line asking object y include third table. what doing wrong? correct/more efficient way code xpath? note : xpath novice writing. answered (really quickly), much! solution below. extract <- function(x) { message(x) html = htmlparse(paste0("http://www.numerama.com/magazine/recherche/", x, "/hadopi/date")) html = xpathapply(html, "//table")[[3]] html = xpathapply(html, ".//a[contain

glob - Finding latest file's name and modification time in PHP -

i search director glob function , matched files' list. checking filemtime of files create map. sort map respect file dates. @ last latest file's name , modification time. code this. works small directories, it's slow big directories. wonder whether there faster/clever way? $filelist = array(); // $id = argument of function $files = glob('myfolder'.ds.'someone'.$id.'*.txt'); if (empty($files)) { return 0; } foreach ($files $file) { $filelist[filemtime($file)] = $file; } if (sizeof($files) > 1) { ksort($filelist); } $latestfilename = end($filelist); $filelastmodifdate = filemtime( $latestfilename ); i suspect "mapping" creating hash table, , sort not efficiant 1 might expect, try this: (this basic, u can fancy up) class file_data { public $time; // or whatever u use public $file; } $arr =new array (); foreach ($files $file) { $new_file = new file_data (); $file_data->time = filetime($fi

android - Saved Bitmap doesn't appear on SD Card -

i working on app in save bitmaps sd card. have looked @ lot of examples , other questions, , have made following code: bytearrayoutputstream bytearrayoutputstream = new bytearrayoutputstream(); bitmap.compress(bitmap.compressformat.jpeg, 100, bytearrayoutputstream); string dirpath = environment.getexternalstoragedirectory().tostring() + "/myfolder"; file dir = new file(dirpath); dir.mkdirs(); string filename = "bitmapname.jpg"; file file = new file(dirpath, filename); fileoutputstream fileoutputstream; try { boolean created = file.createnewfile(); log.d("checks", "file created: " + created); fileoutputstream = new fileoutputstream(file); fileoutputstream.write(bytearrayoutputstream.tobytearray()); fileoutputstream.close(); } catch (filenotfoundexception e) { log.d("checks", "filenotfoundexception"); e.printstacktrace(); } catch (ioexception e) { log.d("checks", "ioexception&

Ruby on Rails Method Mocks in the Controller -

i'm trying mock method call outside api inside 1 of rails controllers (in case, instagram.get_access_token) , i'm having trouble. written, code still calling real instagram.get_access_token method. how have controller use simple mock instead? sessions_controller.rb: class sessionscontroller < applicationcontroller require 'instagram' include applicationhelper def auth_callback response = instagram.get_access_token(params[:code], redirect_uri: auth_callback_url) #<snipped code> end end sessions_controller_spec.rb: require 'spec_helper' require 'ostruct' describe sessionscontroller describe "get #auth_callback" context "when there existing user" let(:response) { openstruct.new(access_token: "good_access_token") } "parses access_token response" instagram.should_receive(:get_access_token).and_return(response)

python - Convert pandas timezone-aware DateTimeIndex to naive timestamp, but in certain timezone -

you can use function tz_localize make timestamp or datetimeindex timezone aware, how can opposite: how can convert timezone aware timestamp naive one, while preserving timezone? an example: in [82]: t = pd.date_range(start="2013-05-18 12:00:00", periods=10, freq='s', tz="europe/brussels") in [83]: t out[83]: <class 'pandas.tseries.index.datetimeindex'> [2013-05-18 12:00:00, ..., 2013-05-18 12:00:09] length: 10, freq: s, timezone: europe/brussels i remove timezone setting none, result converted utc (12 o'clock became 10): in [86]: t.tz = none in [87]: t out[87]: <class 'pandas.tseries.index.datetimeindex'> [2013-05-18 10:00:00, ..., 2013-05-18 10:00:09] length: 10, freq: s, timezone: none is there way can convert datetimeindex timezone naive, while preserving timezone set in? some context on reason asking this: want work timezone naive timeseries (to avoid hassle timezones, , not need them case working o

How to avoid returning NULL on error if it has to return something? (in C) -

i've stumbled on articles here , here , says programming practice never return null. functions need return something, should return? value of -1 not going cut since lets have function: char *return_some_string(int input) { /* */ if (error) return some_thing_not_null; } how round problem? i've stumbled on articles says programming practice never return null. unconditionally stating shows quality of article. burn it. but functions need return something, should return? null . conceptually, that's "invalid pointer", "pointer points nothing", whatever. there's reason it's in language.

python - CherryPy can't seem to find CSS script (static or absolute paths) -

i'm using cherrypy framework serve site, cannot seem find css script either static path or absolute path. css script works fine if go index.tmpl file via browser, when request via cherrypy not use css script. root directory structure: site.py template/index.tmpl static/css/main.css site.py import sys import cherrypy import os cheetah.template import template class root: @cherrypy.expose def index(self): htmltemplate = template(file='templates/index.tmpl') htmltemplate.css_scripts=['css/main.css'] return str(htmltemplate) # on startup current_dir = os.path.dirname(os.path.abspath(__file__)) + os.path.sep cherrypy.config.update({ 'environment': 'production', 'log.screen': true, 'server.socket_host': '127.0.0.1', 'server.socket_port': 2000, 'engine.autoreload_on': true, '/':{ 'tools.staticdir.root' : current_dir,

delphi - Procedure in a component that uses another procedure in a DLL -

i having problem trying create procedure component uses procedure contained in dll (texecute) needs declaration in current code. procedure has pointer parameter know evaluation. following code works fine need procedure eval inside component use private variables component. working code following, note eval procedure global in case. texecute = procedure(eval: pointer, var variablearray: double);cdecl tmycomponent = class(tcomponent) public fhandle: thandle; fexecute: texecute; procedure calculate; var n: integer; x: array of double; procedure eval(var x: double); implementation procedure eval(var x:double); var mx: array[0..200] of double absolute x; begin mx[0]:= 2*mx[0]; end; tmycomponent.calculate; begin fhandle:= loadlibrary(.....); fexecute:= getprocaddress(fhandle, 'main'); n:=2; setlength(x,n); fexecute(@eval,x[0]); end; i got problem when put procedure eval inside tmycomponent that: texecute = procedure(eval

bash4 - How can you search for a char in a string in bash? -

if have string var="root/desktop" , how can determine whether var var contains '/' character? bash can match against regular expressions =~ , try: [[ $var =~ "/" ]] && echo "contains slash"

css3 - Font-Weight CSS Transition in Chrome -

trying font-weight gracefully transition '400' '600' using css doesn't appear working in chrome. known bug or doing wrong? check fiddle here example the problem font weights, when represented numerically, must multiple of 100. animate between 400 , 600, font change 400 500 600 (3 'frames', if like) , wouldn't smooth. animation wouldn't increment weight 1 each time (400, 401, 402...) increment weight 100 (400, 500, 600). if animation lasted 2 seconds, after 1 second weight become 500, , after 2 seconds weight become 600; there no in-between variations. a further problem you're attempting here font you're using (or jsfiddle's default, @ least) doesn't have different font-weight:500 , meaning defaults 400: <p style="font-weight:400;">a - 400, normal</p> <p style="font-weight:500;">a - 500 (no support, defaults 400)</p> <p style="font-weight:600;">a - 600 (bo

javascript - correct way to exclude certain characters from crypto.randomBytes -

i have following code, based on http://nodejs.org/docs/v0.6.9/api/crypto.html#randombytes crypto.randombytes 32, (ex, buf) -> user.tokenstring = buf.tostring("hex") user.tokenexpires = date.now() + token_time next() i using generate tokenstring use node.js/express user validation. in cases tokenstring generated includes '/' forward slash character, , breaks routes, example, tokenstring if tokenstring ' $2a$10$oyjn2r/ts.guywqx7ijtwo8cij80m.uiqv9njgtt18nqu8lt8oqpe ' can't find /user/activate/$2a$10$oyjn2r , 404 error is there more direct way exclude characters being included when generating crypto.randombytes? crypto.randombytes generates random bytes . has nothing characters, characters determined way look @ bytes. for example: user.tokenstring = buf.tostring("hex") would convert buffer string (where 2 characters represent each byte), in character range 0-9a-f another (might more suiting approach use more c

tell javascript to run jquery ajax first -

in short, how let alert(1) run first: $.post('example.php', function() { alert(1); }) alert(2); alert(3); alert(4); but jquery ajax call seem run in asynchronous method. javascript run below first, alert(2) alert(4), post method, alert(1). certainly can put code in ajax function, make no sense when have dozens of functions, have add code functions. $.post('example.php', function() { alert(1); example(); }) function example() { alert(2); alert(3); alert(4); } i want json data ajax call, , use later. there smart solution? in jquery prefer use $.when , $.then it's easy , code more readable using this. function catchthefish(){ console.log('we catching fish'); } function eatthefish(){ console.log('now time eat fish'); } $.when ( catchthefish() ).then( eatthefish() ); this code work in latest version of jquery 1.9.1

java - Null Error Trying to Upload picture from android phone to a php file to my computer -

i'm getting null error when try upload picture phone php file sends computer. file not getting computer. app works when upload picture shows when try send computer sends null error. this line of code gives error. httpresponse response = httpclient.execute(httppost); any ideas? thanks! java class below , php file follows. package test.example; import java.io.bytearrayoutputstream; import java.io.ioexception; import java.io.inputstream; import java.nio.bytebuffer; import java.util.arraylist; import org.apache.http.httpresponse; import org.apache.http.namevaluepair; import org.apache.http.client.httpclient; import org.apache.http.client.entity.urlencodedformentity; import org.apache.http.client.methods.httppost; import org.apache.http.impl.client.defaulthttpclient; import org.apache.http.message.basicnamevaluepair; import android.app.activity; import android.content.intent; import android.database.cursor; import android.graphics.bitmap; import android.graphics.bitmapfa

objective c - Facebook iOS crash -

Image
i trying set facebook sdk 3.5 ios. have gotten work fine crashing. crash seems happen when user logged in through default ios facebook settings (aka not facebook application app store). app crashes when facebook "login" view tapped. the crash is: error: [nserror fberrorshouldnotifyuser]: unrecognized selector sent instance. i have done research , people suggesting put -objc "other linker flags". don't have have similar think. needed other options other libraries. here options: can tell me if causing problem? if not, know causing crash? thanks! edit it seem error happening in method on first "if" - (void)loginview:(fbloginview *)loginview handleerror:(nserror *)error { nsstring *alertmessage, *alerttitle; if (error.fberrorshouldnotifyuser) // crash here { // if sdk has message user, surface it. conveniently // handles cases password change or ios6 app slider state. alerttitle = @"facebook error"; alertmessage = error.fber

documentation - C++ Boost Docset -

is there docset boost? i'ld add dash offline documentation search, , can't find 1 anywhere. attempts of own build have failed, rather spectacularly. not i've found; don't offer complete set of offline docs, let alone dash docset. (alas, pdfs marchall clow mentions small subset.) i've been toying idea of creating one, gave in frustration. if want collaborate, drop me line! as understand it, you'd need to: create offline mirror of entire set of boost docs. easy enough, following should work: wget --mirror -p --no-parent --convert-links -p ./boost_docs \ http://www.boost.org/doc/libs/1_53_0/libs/libraries.htm index docs. (this hard part.) scrape html , try , pull out interesting semantic elements: classes, functions, types , on, , create index. many of components of boost seem use consistent documentation format, complicates things many other components have own, idiosyncratic approach, , html markup not semantic. ( boost::filesystem

linux - Lex file unrecognized rule -

i trying run following program, , getting unrecognized rule: 37. not sure why giving me error in line 37. command: $ lex mycsv2html.l %{ //definition section #include <stdin.h> #include <stdout.h> int c; extern int yylval; %} %% // rule section " " ; [\n] { c = yytext[0]; yylval = c - '\n'; return(br); } ["] { c = yytext[0]; yylval = c - ''; return(''); } [<] { c = yytext[0]; yylval = c - ''; return('&lt'); } [>] { c = yytext[0]; yylval = c - ''; return('&gt'); } int main(void) //c code section { /* call lexer, quit. */ yylex(); return 0; } you should add %% be

windows - Options to learn in Ruby besides IRB and FXRI -

i wondering if had suggestions test coding lines in windows. right now, using repl.it i used use fxri, doesn't work in later versions , feel irb lacks lot of useful tools fxri has (example:built in, accessible library descriptions of commands) any appreciated. the pry tool great learning resource. can view source code , documentation on demand, , trivially explore library or program using intuitive file system metaphor.

datepicker - JavaScript date math not working -

i have searched forum , found many useful answers, 1 of answers used works under conditions. i populating week calendar, , need determine start of week (monday) date picker, , add date populate text fields following 6 days. works if date picker selection in same month. so, if select wednesday may 15th 2013, correctly returns , populates monday may 13, tuesday may 14, etc. but, if select wednesday may 1, 2013, correctly populates monday apr 29, tuesday puts may 30 (adding month instead of day). i should note building in application craft, don't know if has impact. here's code: var curr = new date(app.getvalue("datepicker2")); // selected date var first = curr.getdate() - curr.getday() +1; // adjust monday start of week var firstday = new date(curr.setdate(first)); var secondday = new date(); secondday.setdate(firstday.getdate()+1); can see have gone wrong? thanks tammy here secondday.setdate(firstday.getdate()+1) since specifying dat

objective c - Unable to change NSNumber to Double and do some calculations with it -

my problem have array holds double values nsarray *level4results = [context executefetchrequest:request error:&error]; then sum values in array nsnumber *l4sum = [level4results valueforkeypath:@"sum.self"]; the next thing want divide 8 sum of array... , stuck. have tried many options , ways of doing either way kept on getting different error. have in code double l4average = ([l4sum doublevalue] / 8); however throwing following error * terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[__nsarrayi doublevalue]: unrecognized selector sent instance help in solving problem appreciated. thanks it's collection operator. line: nsnumber *l4sum = [level4results valueforkeypath:@"sum.self"]; should written: nsnumber *l4sum = [level4results valueforkeypath:@"@sum.self"];

C++ equivalent of Java's paintcomponent? -

after year on java, i've come use paint component can "visually" see programs work. i want learn c++, cant visualize programs console. there recommendations library or header similar javas paintcomponent? i not mind buttons, textfields, want @ least have window open code paints on it. , please no win32, mfc or qt. fear these complex me now, unless recommend it. thanks in advance! and please no win32, mfc or qt. fear these complex me now, unless recommend it. doing graphics without kind of framework a lot harder using 1 of frameworks have listed. orders of magnitude harder ... if measure hardness objectively. to echo other people's recommendations: qt should fine. i want learn c++, cant visualize programs console. i don't know if expressing clearly, if want visualize code (i.e. kind of pictorial representation of code structure ) should looking ide understands c++. writing own software visualize c++ code inventing new kind h

Writing a recursive function XSLT/XPath for computing new values -

i trying write recursive function computes new values. basic idea of motivates me given levels of outline, want compute new levels such numbers sequential (that is, can't go level 2 level 5) while respecting original relationships. given input (note inputs quite different): <root> <item outlinepos="1">yo</item> <item outlinepos="2">yo</item> <item outlinepos="2">yo</item> <item outlinepos="4">yo</item> <item outlinepos="1">yo</item> <item outlinepos="8">yo</item> <item outlinepos="8">yo</item> <item outlinepos="9">yo</item> <item outlinepos="3">yo</item> <item outlinepos="8">yo</item> <item outlinepos="4">yo</item> </root> i want output <root> <item outlinepos=&quo