Posts

Showing posts from May, 2010

jQuery wildcard selector on attributes -

i have stuff <table> <tr> <td> foo </td> <td> <a href="#" data-action:edit="1">[edit]</a> <a href="#" data-action:delete="1">[del]</a> </td> </tr> <tr> <td> bar </td> <td> <a href="#" data-action:edit="2">[edit]</a> <a href="#" data-action:delete="2">[del]</a> </td> </tr> <tr> <td> foobar </td> <td> <a href="#" data-action:edit="3">[edit]</a> <a href="#" data-action:delete="3">[del]</a> </td> </tr> </table> and able individual attributes selectors: $('[data-action\\:edit]') or $('[data-action\\:delete]') how can data-action:* elements?

c# - How many custom headers Can I have in a request? -

i wondering if can have custom headers requireds on web api application. i don't know headers, http protocols , etc. after reading little, thought on required code access application header. so, client app need pass 2 codes on header. approach? can give kind of names headers? "firstcode" , "safecode"? when test web api console application this: var request = new httprequestmessage(); content.headers.tryaddwithoutvalidation("firstcode", "1"); content.headers.tryaddwithoutvalidation("safecode", "2"); message = client.getasync("/auth?code=" + code).result; the webapi receives 1 header value of both this: "firstcode:1safecode:2"

javascript - getting the absolute index of a DOM node -

i have piece of code returns me dom node. <script> function a(){ var userselection; if (window.getselection) { userselection = window.getselection(); } else if (document.selection) { // should come last; opera! userselection = document.selection.createrange(); } var rangeobject = getrangeobject(userselection); var node = rangeobject.startcontainer; } function getrangeobject(selectionobject) { if (selectionobject.getrangeat) return selectionobject.getrangeat(0); else { // safari! var range = document.createrange(); range.setstart(selectionobject.anchornode,selectionobject.anchoroffset); range.setend(selectionobject.focusnode,selectionobject.focusoffset); return range; } } </script> so need absolute index of var node, respect beggining of body tag. manage index in parent node. need absolute the idea store index starting position of selected text in database , later retrieve them. i trying build annot

xcode - Outlet in a Static Table Cell Causes EXC_BAD_ACCESS on load -

i creating simple static table 2 sections, 2 cells in each section. table view controller (tvc) subclassed . within each of table cells have stepper control, , and label. using allow updating though ibaction stepper, setting property in tvc. @ same time label updated through it's outlet show current value. the outlet defined in @interface section of "tvc.m" file normal using standard ib tools. on run breaks on thread 1 level under uiapplicationmain in named _0 obj_loadweakretained_ , error is: thread 1: exc_bad_access(code -2, address = 0x1da7cc0. any idea may doing incorrectly? there has done differently when adding views tablecells , setting outlets them? here's code - nothing unusual. #import "advancedtvc.h" @interface advancedtvc () - (ibaction)stepperchanged:(uistepper *)sender; - (ibaction)switchtoggled:(uiswitch *)sender; @end @implementation advancedtvc - (ibaction)stepperchanged:(uistepper *)sender { } - (ibaction)switc

c - write() returns -1 when writing to I2C_SLAVE device -

i've read through linux kernel documents on i2c , written code try replicate command i2cset -y 0 0x60 0x05 0xff the code i've written here: #include <stdio.h> #include <linux/i2c.h> #include <linux/i2c-dev.h> #include <fcntl.h> #include <stdlib.h> #include <unistd.h> #include <sys/ioctl.h> #include <stdint.h> #include <string.h> int main(){ int file; file = open("/dev/i2c-0", o_rdwr); if (file < 0) { exit(1); } int addr = 0x60; if(ioctl(file, i2c_slave, addr) < 0){ exit(1); } __u8 reg = 0x05; __u8 res; __u8 data = 0xff; int written = write(file, &reg, 1); printf("write returned %d\n", written); written = write(file, &data, 1); printf("write returned %d\n", written); } when compile , run code get: write returned -1 write returned -1 i've tried follow docs tell me, understanding address set first call ioctl , need write() register ,

apache - htaccess get folder one level below -

i have folders in root of server: css/ js/ gfx/ new_www/ ... and more. assuming want in folder new_www copy of current page, force use things root folder (for example gfx folder). i've tried following .htaccess not working: rewriteengine on rewritebase / rewriterule /new_www/_js/(.*) /_js/$1 [l] rewriterule /new_www/gfx/(.*) /gfx/$1 [l] what doing wrong? .htaccess placed in root of folder. please understand rewriterule doesn't match leading slash in uri when used in .htaccess. code should replaced this: options +followsymlinks -multiviews # turn mod_rewrite on rewriteengine on rewritebase / rewriterule ^new_www/(_js/.*)$ /$1 [l,nc] rewriterule ^new_www/(gfx/.*)$ /$1 [l,nc] or better have 1 rule this: rewriterule ^new_www/(.+)$ /$1 [l,nc]

spring - when I am running test cases that time entity manager is injected successfully but while running web app its throwing NullPointerException -

i have strange problem. injecting entity manager using persistencecontext using applicatiocontext bean. problem when running test cases time entity manager injected while running web app throwing nullpointerexception this abstractrepository injecting entitymanager package com.ajit.retail.repository; import javax.persistence.entitymanager; import javax.persistence.persistencecontext; import javax.persistence.persistencecontexttype; public class abstractrepository { @persistencecontext(type = persistencecontexttype.extended) entitymanager entitymanager; } this repository using entity manager package com.ajit.retail.repository; import com.ajit.retail.exception.invalididexception; import com.ajit.retail.model.buyer; import org.springframework.stereotype.repository; import javax.persistence.noresultexception; @repository public class buyerrepo extends abstractrepository { public buyer getbuyer(string buyername) throws invalididexception { javax.persist

My Host changed MySQL Auto_increment column to two -

after recent change host has made, auto_increment columns incrementing two. after emailing host this, said: this sites located on our new load balanced shared platform. behaviour expected on new cluster. auto increment not affect performance or working of tables, , can still counts on tables , use incremented columns in same way. if check directly on database see these incrementing two. eventually behaviour applied our servers perform update on our entire platform. what know: saying right? in mind auto increment column should increment 1 , not two!! this going cause few issues older sites use generate order numbers etc. everything else have got continue work ok, bit annoying. disregarding specifics of host, if piece of code depends on auto increment going 1 one , not having holes, code wrong because never guarantee. the guarantees have column not have duplicates, , new rows have next sequence value column; last value + 1, not guaranteed - gu

Record iOS and Android screen -

is possible make program run in background ios , android record screen? there lib easily? you use third party screen recorder (on computer) , ios or android emulator provided record video. currently not possible use app on apple app store record ios screen, there few apps out there android allows record screen (google friend). 1 downside can't tell you're tapping, third party screen recorder (on computer) can show mouse.

android - Actionbar with customView has extra padding that cannot be removed -

Image
having trouble getting actionbar display icons proper styling. my customer wants actionbar has specific icons varying shades of transparency. if place icons xml file in res/menu, have no way icons lie adjacent each other , backgrounds of each icon result in vertical gaps so: res/menu/global_nav.xml <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/menu" android:icon="@drawable/ic_main_menu" android:showasaction="always" android:title="@string/nav_menu_main"/> <item android:id="@+id/login" android:icon="@drawable/ic_people" android:showasaction="always" android:title="@string/nav_menu_login"/> <item android:id="@+id/location" android:icon="@drawable/ic_location" android:showasaction="always&

java - Is there a method to detect and display changes to an HTML file on the Internet? -

what i'm looking program detect changes in html file, , display change on computer. goal notified changing feed in html format. executable c++ program preferred, yet java, or other works well. does have ideas? thanks ahead of time. maybe yahoo pipes xpath fetch page + feed reader

PHP regex - find and replace link -

i trying regex match , replace not able it. example <a href=one target=home>one</a> <a href=two>two</a> <a href=three target=head>three</a> <a href=four>four</a> <a href=five target=foot>five</a> i want find each set of tags , replace this find <a href=one target=home>one</a> change to <a href='one'>one</a> same way the rest of tags. any appreciated! use this: preg_replace('/<a(.*)href=(")?([a-za-z]+)"? ?(.*)>(.*)<\/a>/', '<a href='$3'>$5</a>', '{{your data}}');

Json regex deserialization with JSON.Net -

i'm trying read following example json text file string using json.net parsing library. content of c:\temp\regelib.json { "regular expressions library": { "sampleregex":"^(?<field1>\d+)_(?<field2>\d+)_(?<field3>[\w\&-]+)_(?<field4>\w+).txt$" } } example code try , parse: newtonsoft.json.converters.regexconverter rconv = new newtonsoft.json.converters.regexconverter(); using (streamreader reader = file.opentext(libpath)) { string foo = reader.readtoend(); jobject jo = jobject.parse(foo);//<--error //how use regexconverter parse?? newtonsoft.json.jsontextreader jtr = new newtonsoft.json.jsontextreader(reader); jobject test = rconv.readjson(jtr);//<--not sure parameters provide string sampleregex = test.tostring(); } it seems need use converter, know code above wrong, can't find examples describe how /

Simple HTML Code for Horiz Bar doesn't work for Google Sites -

i"m trying add piece of html code google sites html box. new this, please bear me! i've tried code out on html test sites, , works fine no errors. once copy/paste google sites html box, gives me error follows: 6+1 - 2: expected <selector> not < my frankenstein (pieced crudely myself) html follows: <body> <style type="text/css"> body {background-color:#;} #header {background-color:#ccc; width: 100%; } <div style="overflow:auto” </style> <div id="header"> <p> <img src= http://tctechcrunch2011.files.wordpress.com/2012/08/gmail-logo-icon.png?w=300 align="center">...some text... </p> </div> </body> </html> can shed light on why doesn't work in google sites html box?? in advance! ok try you. always format code. it's better , others read later. i don't know doctype use u missing close img tag.

c - Minecraft Flood fill -

i trying calculate minecraft's light values, algorithm use slow. what better way calculate lighting array? the code looks this: struct chunk_data { char light[16*16*256]; }; int j; void fill(chunk_data* c, int i, int l) { ++j; if(c->light[i] > l) return; c->light[i] = l; if(!--l) return; if((i&0x0f) != 0x0f) fill(c, + 0x01, l); if((i&0x0f) != 0x00) fill(c, - 0x01, l); if((i&0xf0) != 0xf0) fill(c, + 0x10, l); if((i&0xf0) != 0x00) fill(c, - 0x10, l); if((i&0xff00) != 0x0000) fill(c, - 0x0100, l); if((i&0xff00) != 0xff00) fill(c, + 0x0100, l); } when move check before call recursion, number of stack pushes reduced. reduces running time 250ms 23us. improved code: void fill(chunk_data* c, int i, int l) { c->lig

Is there a `flip` function in the OCaml standard library? -

in haskell, have flip function: flip f x y = f y x , takes function , returns same function except 2 arguments swapped. wonder if there counterpart in ocaml, since not find 1 , don't want rewrite every time. cheers, many functions generalized fp plumbing aren't defined in standard ocaml library. have missed them. however, nowadays there ocaml libraries supply or of these missing functions. ocaml batteries included project defines flip in batstd module. jane street core project defines flip in fn module.

c# - use external htmlhelper extensions with ServiceStack -

is possible use system.web.mvc.htmlhelper extensions servicestack.razor implementation. i'm trying use ext.net extensions, others extensions devexpress, kendo have same problem. maybe it's possible create instance of system.web.mvc.htmlhelper correct data , pass instance other extensions , return result servicestack.html.htmlhelper instance. thanks servicestack includes own port of mvc htmlhelper extensions, these bind servicestack.html htmlhelper , not mvc's htmlhelper distinct, separate concrete implementation. this results in libraries binding mvc concrete htmlhelpers not interchangeable libraries binding servicestack's htmlhelper. this not ideal scenario , shows limitation of binding concrete implementations in statically typed languages. solution have adapters classes provided ext.net, devexpress, etc binds servicestack's concrete htmlhelpers in addition mvc htmlhelper. the ideal solution would've been asp.net framework include emp

How to drop local state in git -

how drop local state in git ? eg. 199 commit ahead of origin/mybranch on local mybranch unfortunalty have done nonsense ... what want achieve similar : cd .. rm my-git-dir git clone https://github.com/me/my-git-dir.git cd my-git-dir git checkout mybranch git checkout mybranch git reset --hard origin/mybranch

bash4 - bash: iterating through txt file lines can't read last line -

while read p; do echo $p done < file.txt this code can read lines in file.txt except last line ideas why. thanks if youre in doubt last \n in file, can try: while read p; echo $p done < <(grep '' file.txt) grep not picky line endings ;) you can use grep . file.txt skipping empty lines...

java - Android opencv library reference is not working correctly -

Image
at first working 5 hours solve problem , tried hard describe well, if not clear please tell me. i have downloaded tegra developer pack imported open cv 2.4.3 library project , sample projects work great on device samsung galaxy note 2 . have tried many ways make opencv project work not. i have created project , added android library reference in project properties . exacly every sample project has done. "they" green tick @ first green tick when enter properties again red cross appears : my project: sample project: in end project full of errors(cannot import class etc.), sample projects clean. i have tried import opencv adding jar file build path this. then import problems in java files gone stil xml containing opencv parts not work. example: result: the following classes not instantiated: - org.opencv.android.javacameraview (open class, show error log) see error log (window > show view) more details. tip: use view.isineditmode() i

multithreading - Achieving higher Mbps with every window in Perl -

so hosted website purpose of doing security-tests on it, created script in perl generate 60-72 mbps (info) being sent. noticed if run script multiple times simultaneously generate 150 mbps. how possible able achieve 150 mbps without need of running script multiple times? thank you! you want open multiple tcp connections. you either need use evented loop handle back-and-forth of keeping pipes full, or need use threads/processes. commented above, can use 'fork' make multiple copies of script, each 1 can make 1 tcp connection , keep connection full. that's simple solution. if want keep program single process, it's bit more work, still possible. if opening lot of connections, you'll want read this: http://www.kegel.com/c10k.html you might consider using faster language c or go, since using perl involve overhead. (i'd test first, maybe overhead negligible. test using tool curl send big file see if gets higher bandwidth perl program.)

ant - zend framework 2 + phpunit + multiple modules + continuous integration -

thanks in advance comments. have started switch zend framework 1 zf2 , after running through quick start , several other tutorials noticed there short coming 'default' way use phpunit. either or lost , confused. the folder structure default project project | - config | | - autoload | | | - global.php | | | - local.php.dist | | - application.config.php | - data | - module | | - application | | | - config | | | - src | | | - test | | | | - applicationtest | | | | - bootstrap.php | | | | - phpunit.xml | | | | - testconfig.php.dist | | | - view | | | - module.php | | - album | | | - config | | | - src | | | - test | | | | - albumtest | | | | - bootstrap.php | | | | - phpunit.xml | | | | - testconfig.php.dist | | | - view | | | - module.php | - public | - vendor my question how use jenkins ant test of phpunit test suites. understand reason behind testing each module individually how can automate 1 report.xml back. , better if didn't need specify each module in phpu

xcode4.6 - How to add Social Framework in Xcode project? -

just starting learn xcode , lesson i'm supposed add social framework in xcode add twitter composer features. so i'm following steps in book: i select project , target , go build phrases. i open link binary libraries , click + sign i social frameworks , click on add i can see social frameworks beneath project then i'm supposed go .m file , add code: code: slcomposeviewcontroller *composer = [slcomposeviewcontroller composeviewcontrollerforservicetype:slservicetypetwitter]; [composer setinitialtext:self.tweettextview.text]; [self presentviewcontroller:composer animated:yes completion:nil]; it shows 3 error signs saying : 'use of undeclared identifier: slcomposeviewcontroller' . , project won't build. have done wrong? you need add: #import <social/social.h> to top of .m file you're using social framework api's. i did chat.stackoverflow.com presentation on social framework , transcript here , and sample project can

Translating from Matlab to C a function -

i translating funciton matlab c. have problem lines fourier transform. code, commented lines in matlab , that's need translate. mat loggabor(mat imfft,int *sz2filt_r,int *sz2filt_c,double r_o, double theta_o,double sigma_theta,double **radius,double **theta,int cols,int rows,double sigma_r,int *padsize); mat rpad; int k=*padsize; int rs=*sz2filt_r; int cs=*sz2filt_c; double x[rs-(2*k)],y[cs-(2*k)],sintheta[rows][cols],costheta[rows][cols]; double ds[rows][cols],dc[rows][cols],divis[rows][cols],divis2[rows][cols]; double filter[rows][cols],dalpha[rows][cols],spread[rows][cols]; double div=(pi)/180.0; for(int a=0; a<rows; a++){ for(int b=0; b<cols; b++){ theta[a][b]=theta[a][b]*div; sintheta[a][b]=sin(theta[a][b]); costheta[a][b]=cos(theta[a][b]); ds[a][b] = (sintheta[a][b] * cos(theta_o) - costheta[a][b] * sin(theta_o))*div; dc[a][b] = (costheta[a][b] * cos(theta_o) + sintheta[a][b] * sin(theta_o))*div; dalpha[a][

iphone - TFHpple - getting element HTML without element's tags? -

i'm parsing html , need innerhtml of <body /> . i'm doing way: tfhpple *doc = [[tfhpple alloc] initwithhtmldata:[nsdata datawithcontentsoffile:sectionfilepath]]; tfhppleelement *body = [doc searchwithxpathquery:@"//body"][0]; nsstring *bodyhtml = body.raw; however returns: <body>stuff inside body</body> instead of just: stuff inside body question: there way purely inner html of element, excluding own tags? i came method, feel i'm reinventing wheel here. method quite slow. tfhppleelement *child; for(int = 0; i<body.children.count; i++){ child = (tfhppleelement*)body.children[i]; if(child.raw != nil) [bodyhtml appendstring:child.raw]; else if(child.content != nil) [bodyhtml appendstring:child.content]; } try this... nsurl *url = [nsurl urlwithstring: url_here]; nsdata *htmldata = [nsdata datawithcontentsofurl:url]; tfhpple *parser = [tfhpple hpplewithhtmldata:htmldata]; nsstring *xpathquerystr

javascript - printing path name in browser for a spring framework -

i integrating js html.. end spring frame work... dont have knowledege abt spring frame work... trying print path name path="xxcpdeprbehavior.name"in browser... providing code below... <!doctype html> <html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"> </script> <script> $(document).ready(function(){ $("p").click(function(){ $(this).hide(); }); }); </script> </head> <body> <p>if click on me, disappear.</p> <p>click me away!</p> <p>click me too!</p> </body> </html>

java - Collision works after going to the other side -

i'm making simple pong game, , need make player paddle cannot go out of screen. it works, if go edge, go , go same edge again, works first time not second. if go top edge, , bottom works fine. cannot figure out, appreciate ;) game.java: http://pastebin.com/nfapk339 screen.java http://pastebin.com/z0bb34sn ball.java http://pastebin.com/ydvmtg6e player.java http://pastebin.com/rbu0hsd8 computer.java http://pastebin.com/dra1swze what code stops player paddle going outside of screen. instead of posting code show stub you're asking well. just had , saw check being done in keypress. try putting check in player.update() method. update parse in height public void update(int height) { if(y < 0) { y = 0; } else if( y > height ) { y = height } else { y = y + yvelocity; } }

android - SQLiteDatabase.endTransaction throws SQLiteDatabaseLockedException -

my code: sqlitedatabase db = ...; db.begintransaction(); try{ db.update(...); db.settransactionsuccessful(); }finally{ db.endtransaction(); } now problem endtransaction throws sqlitedatabaselockedexception , , don't know reason, or how repeat same exception. from sqlitedatabaselockedexception read: thrown if database engine unable acquire database locks needs job. and begintransaction read: begins transaction in exclusive mode. from sqlite manual read: an exclusive lock needed in order write database file. 1 exclusive lock allowed on file , no other locks of kind allowed coexist exclusive lock. in order maximize concurrency, sqlite works minimize amount of time exclusive locks held. so how can db lock not acquired in endtransaction when hold exclusive lock begintransaction? android version happens 4.0.4 (i have crash report, not able repeat this). need enabled sqlitedatabase.enablewriteaheadlogging on db, maybe matters? a

python - pandas read_csv end of section flag -

is there smart/easy way tell read_csv in pandas not load data after "end of section" flag? or stop if gets empty row? data = pd.read_csv(path, **params) eos_line = (data['id'] == eos_string).idxmax() data = data.drop(range(eos_line-2, data.shape[0])) i feel ought better way. unfortunately don't know number of rows or length of footer want skip before calling read_csv. data looks like 1,2,3 4,5,6 dont want data after line 7,8,9 10,11,12 (note: -2 b/c there 2 empty rows before end of section string, if read_csv read until point guess dropna() remove these 2 rows pretty painlesslly) wes did think of everything! in [40]: data = """a,b,c ....: 1,2,3 ....: 4,5,6 ....: 7,8,9 ....: want skip ....: also skip ....: """ in [41]: read_csv(stringio(data), skip_footer=2) out[41]: b c 0 1 2 3 1 4 5 6 2 7 8 9

oracle - Using UPDATE cursor in PL/SQL -

as far can see, can make update in pl/sql without using cursor. example: create or replace procedure update_my_table (id number) ... begin ... update my_table set column=null my_id = id; ... end i guess cursor needed if want perform fetch of updated row, right? oracle uses cursors under hood update , selects, going bit beyond you're asking. no, don't have select rows updated in visible explicit or implicit cursor. you don't have use cursor select row though. can select ... into : create ... my_row my_table%rowtype; begin select * my_row my_table my_id = id; -- row data dbms_output.put_line(my_row.my_col); end; or can select individual columns separate variables instead of rowtype variable. have 1 row (or 1 row's worth of columns) query; if there no matches you'll no data found error, if more 1 too many rows . can select multiple rows pl/sql table , manipulate data there, still without visible cursor. however, i

javascript - JQuery get all elements by class name -

in process of learning javscript , jquery, went through pages of google can't seem working. i'm trying collect innerhtml of classes, jquery seems suggested plain javascript, document.write. here's code far; <div class="mbox">block one</div> <div class="mbox">block two</div> <div class="mbox">block three</div> <div class="mbox">block four</div> <script> var mvar = $('.mbox').html(); document.write(mvar); </script> with this, first class shows under document.write. how can show block oneblock twoblock three? ultimate goal show them comma seperated block one, block two, block three, block four. thanks, bunch of relevant questions come none seem simple. one possible way use .map() method: var = $(".mbox").map(function() { return this.innerhtml; }).get(); console.log(all.join()); demo: http://jsfiddle.net/y4bhh/ n.b. please don&#

c - loop not running as intended -

i can't find break in logic here when run output of 3125 supposed largest prime factor. 3125 not prime nor largest non-prime factor. not designed efficient method find prime factors, trying figure out. long long modulo= 99999; long long lrgprimefactor=0; long long currentfactor=0; long long tempmodulo=0; int break1 =0; int break2 =0; while (modulo>0&&break2==0) { if ((100000%modulo) ==0) { currentfactor=modulo; (tempmodulo=currentfactor-1;tempmodulo>0;tempmodulo--) { if (currentfactor%tempmodulo==0) { lrgpfactor=currentfactor; break1=1; break; } else if(break1==1) { break2=1; break; } } } else { modulo-=2; } } i made changes code, , gives correct result. hope helps. long long modulo = 99999; long long lrgpfactor = 0; long long currentfa

itunesconnect - Apple iAd enabled, yes or no? -

Image
this awkward. trying upload first app apple, , since has free version, i'd use iad services. in itunesconnect, in order allow iad services you'd need configure ad services. find weird ux wise, is not clear if button enables iad services, or pressing enable them? iad services on or off? what weirder save button make not easy undo in case mistaken. apple known brilliant ux/ui. puzzling. thanks iad off . if want use iad , should click button . if not want use iad, do not click button.

redirect to URL via PHP -

this question has answer here: redirect different url .htacess or php [closed] 1 answer i have form @ index.php takes in user input, includes , sends user input php file processing. here code of index.php: <?php if(isset($_get['q'])){ include_once "form.php"; exit(0); } ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title>search</title> </head> <body> <form method="get"> <input type="text" name="q" /> </form> </body> </html> when 1 submits form goes http://mysite.com/?q=textuserentered (if domain visited before) or http://mysite.com/index.php?q=textuserentered (if index.php visited before) how can go http://mysite.com/form?q=

java - JFrame with custom border not showing controls -

Image
i'm trying make own custom border, , have done through overriding paint function in jframe. problem have run into, fact paint being called after constructor, causing paint window on controls. because of this, table appears when happen click on in jframe. wondering if there way make paint function happen before constructor, or if there better way create custom border. here code: public class guimain extends jframe { int posx=0, posy=0; jtable serverlist; public guimain() { this.setundecorated(true); this.setlayout(new gridbaglayout()); serverlist = new jtable(variables.servers, variables.serversheader); add(serverlist); this.addmouselistener(new mouseadapter(){ public void mousepressed(mouseevent e) { posx = e.getx(); posy = e.gety(); } }); this.addmousemotionlistener(new mouseadapter(){ public void mousedragged(mousee

api - Check if YouTube User Exists with PHP -

okay i'm trying redirect user subto.me.com if subto.me/args doesn't exist have code if(file_exists($basepath."partials/".$request['args'][0].".php")) { require($basepath."partials/".$request['args'][0].".php"); } else { header("location: http://www.youtube.com/subscription_center?add_user=".$request['args'][0]); } if youtube user doesn't exist, using link https://gdata.youtube.com/feeds/api/users/fdsafsdfasdfasd . how incooperate if source code equals "user not found" i have solution that: $yuser = "http://www.youtube.com/user/xxxx"; $yt_headers = @get_headers($yuser); if($yt_headers[0] == 'http/1.1 404 not found') { echo "youtube user dosen't exist"; } else { echo "youtube user exists"; } this can used function make process more pretty!

android - getApplicationContext() on Universal Image Gallery is Undefined? -

i trying load images array , following schedule adapter. getting undefined context. not sure ? no images being loaded public class schedule_arrayadapter extends arrayadapter<string> { private final activity activity; private final string[] name, category, image; typeface colab, colab_bold, bebas; int selected = -1; public schedule_arrayadapter(activity activity, string[] name, string[] category, string[] image) { super(activity, r.layout.schedule_item, category); this.activity = activity; this.name = name; this.category = category; this.image = image; this.colab = typeface.createfromasset(activity.getassets(), "colabthi.otf"); this.colab_bold = typeface.createfromasset(activity.getassets(), "colabmed.otf"); this.colab_bold = typeface.createfromasset(activity.getassets(), "bebasneue.otf"); // imageloader.getinstance().init(config); imageloader = imageloader.getinstance(); } imageloaderconfiguration con

views - How can I use a list function in CouchDB to generate a valid (/normal) ViewResults object? -

i have simple problem need solve, , list functions current attempt so. have view generates need, in cases there duplicate entries make through when send in edge-case parameters. therefore, looking filter these results out. have found examples of filtering, using (see this post ). however, rather generate html or xml or what-have-you, want regular ol' view result. is, same kind of object if queried couchdb without list function. should have json data normal , same in every way, except missing duplicate results. any on appreciated! have tried send() data in quite few different ways, "no json object decoded", or indices need integers , not strings. tried use list store every row until end , send entire list object @ once. example code (this using example from page send data: function(head, req) { var row; var dupes = []; while(row=getrow()) { if (dupes.indexof(row.key) == -1) { dupes.push(row.key); send(row.value);

gridview - grid scrolling by code in C# -

i want scroll gridview code in c#. when added row,then gridview show last row. used this: datagridview1.currentcell = datagridview1.rows[datagridview1.rowcount - 1].cells[1]; but not work correctly. you can try solution , works long autosizerowsmode property not set displayedcells: datagridview1.firstdisplayedscrollingrowindex = datagridview1.rows.count-1;

css - Why does using `-webkit-appearance: none` on a select option in OSX make the text disappear? -

Image
in order styling want on chrome in os x, have use -webkit-appearance: none; attribute. see this question , this answer . the issue is, when select answer, doesn't show up. field remains blank. this how looks without attribute: this how looks attribute: for it's worth, how creating select menu - simple form: <%= f.input_field :country_id, collection: piggybak::country.send(type), class: "required" %> this html generates: <select class="select required required valid" id="piggybak_order_billing_address_attributes_country_id" name="piggybak_order[billing_address_attributes][country_id]"><option value=""></option> <option value="231" selected="selected">united states</option></select> how fix this? edit 1 this css : form.simple_form select { padding: 20px; -webkit-appearance: none; } i had problem , turned out height prop

html - JavaScript: getElementById not working in IE8 -

i've simple javascript display selected option in span. works fine in browsers except ie8. code - <select onchange="searchdisplay(this.value)"> <option>kill</option> <option>bill</option> <option>by</option> <option>torentino</option> <option>is </option> <option>not </option> <option>good</option> <select> <span id="container"> <span> script - <script> function searchdisplay(val) { var div = document.getelementbyid('container'); div.innerhtml = val; } </script> any solution this? thanks. issue this.value in ie8 change :- <select onchange="searchdisplay(this.options[this.selectedindex].value)"> , shall work fine. demo in current code fix markup others said in comments. <select onchange="searchdisplay(this.options[this.selectedindex].value)"> <option>

Can I access Chrome chrome://gpu/ data with Javascript? -

when open page chrome://gpu/ can see if video hardware accelerated or not, can information using javascript? (i'm building chrome extension maybe there api?) thx in advance! check out requirements section of manifest: hosting sites such chrome web store may use list dissuade users installing apps or extensions not work on computer. supported requirements include "3d" , "plugins"; additional requirements checks may added in future. we're discussing system-capability api let individual apps , extensions progressively enhance behavior according runtime environment. red john's basic answer in comment correct, though: internal chrome pages off-limits.

format - How to center align columns of different lengths using numpy.savetxt in Python? -

i have several lists contain both strings , floats elements. import numpy num column_1 = ['kic 7742534', 'variable star of rr lyr type' , 'v* v368 lyr', 'kic 7742534', '4.0', '0.4564816'] column_2 = ['kic 76', 'variable star' , 'v* v33 lyr', 'kic 76', '5.0', '0.45'] dat = num.column_stack((column_1, column_2)) num.savetxt('savetxt.txt', dat, delimiter=' ', fmt='{:^10}'.format('%s')) the output when running file following: kic 7742534 , kic 76 variable star of rr lyr type , variable star v* v368 lyr , v* v33 lyr kic 7742534 , kic 76 4.0 , 5.0 0.4564816 , 0.45 the ideal output (including aligned header) #element1 element2 kic 7742534 , kic 76 variable star of rr lyr type , variable star v* v368 lyr

php - hashing password in registration different from the login password -

this question has answer here: hashing password using crypt not work on login displays incorrect pass 2 answers i have registration page allows users insert password. hash password upon registration stored more securely in database. when user logs in same password, 2 hashes don't match , user cannot log in. this first time using hash , didn't behave expected: this hashing code on registration page: $salt =""; function cryptpass($input, $rounds = 9) { $salt = ""; $saltchars = array_merge(range('a','z'), range('a','z'), range('0','9')); for($i = 0; $i<22; $i++) { $salt .=$saltchars[array_rand($saltchars)]; } return crypt($input, sprintf('$2y$%02d$test$', $rounds) . $salt); } $hashedpass = cryptpass($pass1); echo $hashedpass; //****

osx - Qt5 OS X menubar empty menu-item not hidden -

i'm using qt5 on os x 10.8 , i'm creating application menu bar in qt creator. placing items quit or preferences in application menu works specifying menurole accordingly. however, since items need placed in menu , moved automatically qt application menu end empty menu items. according this empty items should hidden me not. what have this: file preferences <separator> quit preferences , quit , about correctly moved application menu. unfortunately file , about still shown. how can make qt hide them? after going project 10 months , 2 minor qt versions later, problem gone. installed qt 5.2 on os x 10.9 , app's menu expected.

c# - I can't implements DoDragDrop Operation on second dialog -

well struggled problem lot. tried simple drag , drop operation, did in main form(the 1 operate main thread) , easy sounds. code this: protected override void onmousedown(mouseeventargs e) { dragdropeffects effectresult=dodragdrop("hello", dragdropeffects.copy); base.onmousedown(e); } i'm talking source code. don't care target. so, in main form code works fine , , when push mouse down, hold , move it, see sign of dragging (in case circle line on it). now in main thread i'm calling other thread , openning new form code showdialog() the problem start here, when put same code in new form, returns none effectresult variable , nothing cursor. i guess problem because of new thread, work async, how can fix it?

objective c - Bundle declarations into one statement or not? -

given following objective-c example, matter of style , ease of reading keep separate statements or bundle them one? there actual benefits of either? waste of memory declare individual variables? nsdictionary *thedict = [anobject methodtocreatedictionary]; nsarray *thevalues = [thedict allvalues]; nsstring *theresult = [thearray componentsjoinedbystring:@" "]; or nsstring *theresult = [[[anobject methodtocreatedictionary] thevalues] componentsjoinedbystring:@" "]; i take following consideration when declare separate variable: if might want see value in debugger. if accessing variable more once. if line long. there no practical difference between 2 approaches, however.

javascript - Toggling links in menu? -

how make links can works sub-items? <ul> <li><a href="item-1">item 1</a> <ul> <li><a href="item-1-1">item 1.1</a></li> </ul> </li> <li><a href="item-2">item 2</a></li> <li><a href="item-3">item 3</a> <ul> <li><a href="item-3-1">item 3.1</a> <ul> <li><a href="item-3-1-3">item 3.1.1</a></li> <li><a href="item-3-1-2">item 3.1.2</a></li> </ul> </li> </ul> </li> </ul> i did basical example. $('ul').on('click','a',function(){ if ($(this).next('ul').toggle()) return false; }); this might toggling links sub-items , if link h

c# - Two xml declaration in single xml file error -

my requirement create xml file , add xml elements existing xml file. first tried creating new xml file following code. using (xmlwriter xmlwriter = xmlwriter.create(fstream, xmlsettings)) { xmlwriter.writestartdocument(true); xmlwriter.writestartelement("friends"); xmlwriter.writestartelement("friend"); xmlwriter.writeelementstring("name", "safiq"); xmlwriter.writeelementstring("like", "char"); xmlwriter.writeelementstring("unlike", "anger"); xmlwriter.writeelementstring("nickname", "good"); xmlwriter.writeelementstring("gift", "c#"); xmlwriter.writeendelement(); xmlwriter.writeendelement(); xmlwriter.writeenddocument(); xmlwriter.flush(); } next tried adding new elements existing file. xdocument xdoc = xdocument.load(fstream); xelement x = new xelement("friend"); x.add(new xelement("name"

ruby on rails - Calling destroy on relation in Mongoid many to many relation with helper model does not remove model from List -

i have many many relation user project helper model. user , project has many user_project_memberships , user_project_membership has 1 project , 1 user. when try remove relation project's related_users (or user's related_projects) data removed database correctly related_users array still has relation data! def remove_user(uid) rel = self.related_users.where(user_id: uid)[0] if rel rel.destroy self.related_users.delete(rel) # added remove relation manually end end project.related_users.count return correct amount of relations project code not doing expected! project.related_users.each |user| puts user.id end if project.related_users.count shows 4 small code above prints hello 5 times! any appreciated, know happened! ps : i'm not expert in ruby, it's maybe ruby's problem!

iphone - Label updating during audio processing -

i'm new ios programming , i'm facing problem regarding update of labels during audio processing tasks. i use classic recordingcallback -> processaudio method. in processaudio stop recording if level low. quite easy do. when stops, can't change text label "recording" "stopped". works great button (play/stop) not when calling back. there no error during compiling. nothing happens... here code : -(void)processaudio:(audiobufferlist *)bufferlist{ audiobuffer sourcebuffer = bufferlist->mbuffers[0]; // copy incoming audio data temporary buffer memcpy(tempbuffer.mdata, bufferlist->mbuffers[0].mdata, bufferlist->mbuffers[0].mdatabytesize); int16_t* samples = (int16_t*)(tempbuffer.mdata); ( int = 0; < tempbuffer.mdatabytesize / 2; ++i ) { if (samples[i]< leveltrigger) { presence++; if (presence== 2 * samplerate) { printf("nothing"); //dispatch_async(dispatch_get_ma

javascript - previousSibling not working -

i want target first <p> inside div selecting second <p> , using previoussibling property not working. <div id="par"> <p id="p1">test</p> <p id="p2">test</p> </div> document.getelementbyid('p2').previoussibling.classname = 'red'; edit: ok works on browsers except ie8 want work in ie8 well, tried following conditional no effect: var c = document.getelementbyid('p2').previouselementsibling.classname = 'red'; if (c == undefined) { c = document.getelementbyid('p2').previoussibling.classname = 'red'; } it still works everywhere ie8. how can change above conditional ie8? edit 2: managed work in ie8 well: var c = document.getelementbyid('p2'); if (c.previouselementsibling) { c.previouselementsibling.classname = 'red'; } else { c.previoussibling.classname = 'red'; } you need use previouselements