Posts

Showing posts from September, 2010

javascript - Using KineticJS to remove drawn objects -

hopefully simple question here: say i've used kineticjs draw line follows: var redline = new kinetic.line({ points: [73, 70, 340, 23, 450, 60, 500, 20], stroke: "red", strokewidth: 15, linecap: "round", linejoin: "round" }); and it's been added layer has been added stage. but need remove line if never there react user event. how go doing this? let's have layer below: var layer = new kinetic.layer(....); to remove redline layer write: layer.remove(redline);

java - JpcapWriter causes app to crash -

i working on relatively simple packet capture application, , using jpcap library. has been working until added in save feature program. my write function public void write() { try { writer = jpcapwriter.opendumpfile(captor, filename); } catch (ioexception e) {e.printstacktrace();} (packet packet : this.packets) { writer.writepacket(packet); } writer.close(); } it correctly gets captor , filepath, loops through packets successfully, when tries write @ end of code block, jvm crashes. my question is, why application crash when trying close jpcapwriter? update : weird thing discovered, is writing file. crashes after write. added print statement after close, , never reaches it. i found several other people same issue me. i'm not sure why removing call close writer fixed problem. file writes correctly, , has no issues. now, content working, may come issue @ later date. update: turns out the file closes when call made stop capt...

variables - Bash avoid filename interpretation -

i'm looking @ aliases save current directory can opened later. alias cdo='pwd|sed 's/ /\ /g' > ~/.cdo' aiias cdn='cd "$(cat ~/.cdo)"' the sed command deals spaces. however, still have curious problem cannot fix must involve variable interpretation. jk@bt:~# cd hello\ world/ jk@bt:~/hello world# pwd|sed 's/ /\\ /g' > ~/.cdo jk@bt:~/hello world# cat ~/.cdo /home/jk/hello\ world jk@bt:~/hello world# cd .. jk@bt:~# cd "$(cat ~/.cdo)" bash: cd: /home/jk/hello\ world: no such file or directory looks me if you're doubling masking. one way handle spaces mask them individually backslash: cd here\ i\ go or mask of them double quotes: cd "here go" while allowed well: cd here" "go however, mixing them means, want literally backslashes: cd "here\ i\ go" and that's what's happening. note while not common, tabs , newlines can included in files well. m...

c# - Caller ID - Cannot obtain incoming Number -

the label on ui keeps reading "ring ring" , empty "". doesn't display incoming number, want. tried add if function checking if there '0' in data reason still doesn't work. the following code: using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms; using system.io.ports; namespace callerid { public partial class callerid : form { public callerid() { initializecomponent(); port.open(); watchmodem(); setmodem(); } protected override void onpaint(painteventargs e) { base.onpaint(e); watchmodem(); } private serialport port = new serialport("com3"); string callname; string callnumber; string readdata; private void setmodem() { ...

Deploying spring app in Tomcat with Mongodb running in Micro cloud foundry -

i getting following exception when trying connect micro cloud foundry mongodb server through spring application running inside localhost tomcat server. exception: jun 05, 2012 4:30:44 pm com.mongodb.dbtcpconnector fetchmaxbsonobjectsize warning: exception determining maxbson size using0 java.io.ioexception: couldn't connect [/192.168.80.128:27017] bc:java.net.connectexception: connection refused: connect @ com.mongodb.dbport._open(dbport.java:228) @ com.mongodb.dbport.go(dbport.java:112) @ com.mongodb.dbport.go(dbport.java:93) @ com.mongodb.dbport.findone(dbport.java:146) scenario: spring app configured cloud foundry works in micro cloud foundry set up. works when deployed live cloudfoundry.com deployed app in vmware vfabric tomcat inside spring tool suite(sts), pointing mongodb running in virtual machine ( 192.168.80.128) root-context.xml: (with change in host configuration) <beans profile="default"> <mongo:db-factory id="m...

asp.net - Configuring federated passive Relying Party for IIS 7 classic mode error (Failed to Execute URL) -

i have asp.net relying party uses microsoft identity model , wif passive federated identity. web application works fine in iis 7 under .net 4 integrated pipeline application pool. when switch .net 4 classic pipeline application pool, fails , gives me following error. how can fixed? exception details: system.web.httpexception: failed execute url. stack trace: [httpexception (0x80004005): failed execute url.] system.web.hosting.isapiworkerrequestinprocforiis6.beginexecuteurl(string url, string method, string childheaders, boolean sendheaders, boolean adduserindo, intptr token, string name, string authtype, byte[] entity, asynccallback cb, object state) +4040320 system.web.httpresponse.beginexecuteurlforentireresponse(string pathoverride, namevaluecollection requestheaders, asynccallback cb, object state) +590 system.web.defaulthttphandler.beginprocessrequest(httpcontext context, asynccallback callback, object state) +286 system.web.callhandlerexecutionstep.system....

Grails - remoteField with additional parameters (3 parameters, no id work around) -

in work around i've used in past, i've used id field pass additional parameter needed. need pass 3 parameters through remotefield , presented fact need find way pass these parameters: <g:remotefield action="updatefields" update="thediv" id-"${personinstance.id}" paramname="search" name="updatefields" value="" /> need: search field (search), person id (id), , need company person works (c_id). i can this: <g:remotefield action="updatefields" update="thediv" id-"${personinstance.id}" paramname="search" name="updatefields" value="" params="${[c_id:c_id, search:/'+this.value+/']}"/> if try obtain search value params, search field '+this.value+'. can pass object search field addition param in map (like above) referencing this.value? if so, doing wrong, since gsp doesn't load. edit my current work around tie...

html - iterating over JSON in javascript to put into select options -

i keep having issues iterating on json put in select options (btw, ignore actual values "label", garbage atm). here example php passing this: [{"value":"1","label":"04-22-12"},{"value":"4","label":"04\/04\/12"}] i trying loop: *note, dateselect defined somewhere else for (res in json.parse(request.responsetext)) { var date = document.createelement("option"); date.value = res.value; date.text = res.label; dateselect.add(date, null); } however, adding "undefined" options... how each value , corresponding label put in there correctly? you have array, don't for-in . in code, res property name (the index of array in case) in form of string , properties you're looking aren't going defined on string. do this... for (var = 0, parsed = json.parse(request.responsetext); < parsed.length; i++) { var res = parsed[i]; var...

android - Play developer console: 2 error reports on 13k active users -

i have small question starting developer. i've created app has been downloaded quite lot last 2 weeks , has 13k active users. i've tested on few (samsung) phones , of course in emulator. can't generate errors, since app simple wasn't expecting so. but today i've looked play developer console , found 2 error reports. should concerned or can errors randomly generated? know example bad custom roms can create crash, i've experienced myself. i post class created this, plays selected sound when button clicked. 1 of crashes in nullpointerexception when button clicked, other illegalstateexception generated when mp.stop() called. me seems not possible generates error, of course wrong. code: public class soundactivity extends activity implements onclicklistener, oncheckedchangelistener { button btn; mediaplayer mp; radiogroup slct; radiobutton radio0, radio1, radio2, radio3, radio4; int t = 1; /** called when activity first created. */ @override public voi...

postgresql - Can't delete database -

i'm new postgresql , having problem perceive simple command drop database , dropdb . why following commands not delete database? postgres=# drop database clientms postgres-# \l list of databases name | owner | encoding | collate | ctype | access privileges -----------+--------------+----------+-------------+-------------+----------------------- clientms | clientmsuser | utf8 | en_gb.utf-8 | en_gb.utf-8 | postgres | postgres | utf8 | en_gb.utf-8 | en_gb.utf-8 | template0 | postgres | utf8 | en_gb.utf-8 | en_gb.utf-8 | =c/postgres + | | | | | postgres=ctc/postgres template1 | postgres | utf8 | en_gb.utf-8 | en_gb.utf-8 | =c/postgres + | | | | | postgres=ctc/postgres (4 rows) postgres-# dropdb clientms postgres-# \l ...

php - How to manually create a user in Moodle? -

i trying create authentication plugin, having problems when user not exist in moodle database. therefore trying find way manually create user. i tried: $user = new stdclass(); $user->username = $ucuser; $user->auth = 'ucauth'; $user->firstname = "first"; $user->lastname = "last"; $user->id = $db->insert_record('user', $user); but didn't work... got insert error. else need in $user object? user object should have following values: $user = new stdclass(); $user->auth = 'manual'; $user->confirmed = 1; $user->mnethostid = 1; $user->email = "email"; $user->username = "username"; $user->password = md5('password'); $user->lastname = "lastname"; $user->firstname = "firstname"; $user->id = $db->insert_record('user', $user); please try this.

performance - Differences among clocks in Linux (CLOCK_MONOTONIC, CLOCK_REALTIME, CLOCK_SGI_CYCLE, etc) -

where can find documentation that? 1 has more precision? 1 has more performance? difference among them? here nice test program investigate differences in various system clocks: http://lwn.net/articles/105582/ the resolution same on of them, each measure different things.

ssms - SQL Server Default Database when Query - master -

Image
i've been using sql server management studio (ssms) last 8 years, , keep on stumbling upon problem. when right click on table, , select select top 2000 rows, query editor opens new file query inside. nice , quick review of table. the problem have default database changed actual database master database. have sysadmin rights. the query gets generated ssms, has databse, schema, , table in brackets, i.e. [db].[dbo].[tablename] is there way set default database on select top 2000 rows command, not go , set default database 'master' ? the other workaround click on table, , 'new query', keep current database, , have type in 'select * tablename' in ssms go security > logins - choose login, right-click , choose properties - @ bottom of tab option called "default database" - want change.

asp.net - Property null after postback - Dynamically loaded control -

i'm aware question has been asked many times before suspect have unique scenario. i'm loading child control (ascx) , setting property on control. works fine until postback property null. herewith first class loads childcontrol : protected override void createchildcontrols() { myusercontrol control = (myusercontrol)page.loadcontrol(_ascxpath); control.myproperty = base.myproperty controls.add(control); } then, on child control i've got following code: public partial class myusercontrol : usercontrol { public mytype myproperty { get; set; } protected void page_load(object sender, eventargs e) { //exception on next line because property null (only on postback) var somevalue = myproperty.subproperty; ok. let me try explain it. 1. once page created, full page lifecycle 2. click on control create user control, , it 3. entering value control, , getting postback 4. on server side postback handled, can see viewstate ...

java - Maven: assembly-plugin is not run at all -

i pretty new maven, tried learn couple of times before , figured better off without maven. now, (un)fortunately have use maven in project i'd contribute to. problem @ point regarding packaging. i'd produce self-contained (aka "fat") jar dependencies included, , colleague who's played around maven helped me out pom file. i have checked pom files, samples here on so. xml looks legit plugin not run @ all. note no errors, goes fine except no "fatjar". ideas might cause of problem? below relevant portion of pom.xml. have seen contradicting code samples regards positioning of <configuration> , <executions> tags, tried pretty every variation have found, still no joy. <plugin> <artifactid>maven-assembly-plugin</artifactid> <version>2.3</version> <executions> <execution> <id>make-jar-with-dependencies</id> <!-- used inheritance merges --> <phase>pac...

c# - HttpWebRequest truncating URL with non-english symbols in it -

i'm creating httpwebrequest dynamic url can contain russian symbols. , i'm encounter issue not sure how deal with: while encoding url each of ru characters has been converted url character-entity equivalents (%20...). apparently after such conversion url becoming long httpwebrequest truncating few last characters instead of proper http result i'm getting 404 error. is there way bypass limitation? my url looks this: http:\\1.1.1.1\some?page=2&var=тестовое значение строки (this part can long) i'm sending since web-app i'm working expecting request @ point. the answer have send in other way there limit length of query string. the error 404 or "http error 414. request url long." you'll because of length of query string data sending longer limit. refer this: http://forums.asp.net/t/1139751.aspx

c# - Error in web browser control navigating -

Image
in web browser app wp7, have 2 xaml pages. 1 mainpage.xaml , other web.xaml. have youtube button in mainpage.xaml, if click on it, navigates youtube.com in web.xaml. if press device button(to navigate mainpage) after youtube navigated, there no error. if press button while youtube navigating throws error. error in recording history think(i have history page record history). error - "cannot write closed textwriter" . error occur sometime someother sites too. have added image of error. can me this? in advance help! public partial class web : phoneapplicationpage { list<uri> historystack; int historystack_index; bool fromhistory; bool navigationcancelled = false; public isolatedstoragefile historyfile = null; public isolatedstoragefilestream filestream = null; public streamwriter stream = null; public web() { initializecomponent(); historystack = new list<uri>(); historyfile = isolatedstoragefile.get...

OCLinEcore and Regex to create valid IPv4 string -

i have ecore model, i'm trying add ocl constraints. my problem comes when try make property (a string) in valid ipv4 form. guess should use regular expression, have no idea @ how use regex on oclinecore. as of eclipse juno, can use regular expressions in ocl. function call on matches(regex), in java. context packet inv validipv4 : ip.matches('\b([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\b') source: http://help.eclipse.org/juno/index.jsp?topic=%2forg.eclipse.ocl.doc%2fhelp%2fcompleteocltutorial.html if have previous version of eclipse, suggest adding java constraint on ecore element, validate element through generated java template code.

ios - How to move to the next screen when the image drops onto when I tap the button? -

i wrote animation concept in viewdidload method wrote: scalefactor=2; angle=180; cgrect frame = cgrectmake(10,10,45,45); uiview *box; box=[[uiview alloc] initwithframe:frame]; box.backgroundcolor=[uicolor colorwithpatternimage:[uiimage imagenamed:@"images673.png"]; [self.view addsubview:box]; // code touch event of object in screen // object movement wrote method shown below: -(void)touchesended:(nsset *)touches withevent:(uievent *)event { uitouch *touch=[touches anyobject]; cgpoint location=[touch locationinview:self.view]; [uiview beginanimations:nil context:nil]; [uiview setanimationdelegate:self]; [uiciew setanimationduration:1]; [uiview setanimationcurve:uiviewanimationcurveeaseinout]; box.center=location; [uiview commitanimations]; } // , then,now wrote button has navigate class file// general navigation principle wrote -(ibaction)settings:(id)send...

php - Replicate mysqldump functionality using only queries -

how backup mysql database using queries? mean, php's system() function disables security reasons, cannot invoke mysqldump . for table structure use this: show create table table_name but how table data? predefined sql command exist? tried select ... var_list , cannot work ( select ... outfile not suitable me, db host different server have access to). thanks help, , sorry being such noob, first question here! :) it should pretty straightforward create insert statements in php code select * table query. here's example: $db = new pdo('mysql:dbname=database;host=host', 'user', 'password'); $result = $db->query('select * table'); $columns = array(); for($i = 0; $i < $result->columncount(); $i++) { $column = $result->getcolumnmeta($i); $columns[] = sprintf('`%s`', $column['name']); } $colstring = implode(',', $columns); $rows = $result->fetchall(pdo::fetch_num); $inserts = array();...

c# - Does a concurrect exception happen to both user -

if user edits data record , same time user edits same record , both save. 1.) concurrency exception happen 1 user? actually logical first wins first in technical aspect... possible both user kind of exception? 2.)the 1 late , getting concurrent exception guess can access new updated data record other user yes? 1) think yes. 1 earlier other; there no other way around it. 1 update work normal, other throw concurrency exception. this might depend on data access method using, there might systems can handle such situations more elegantly. doubt there systems give both users same exception without building behaviour on purpose. as adam houldsworth says: depend on way code yourself. check multiple users beginning edit same record, , throw exception both. not believe asking. if so; misunderstood. 2) of course possible, build in application. catch concurrency exception , refresh whatever edit form user b trying update. he/she can try again. speaking obviously; not kno...

Updating non PK fields in SQL Server 2008 -

Image
my maintable has column primarycode. these codes incorrect , need updated based on updatecodes table. incorrect codes in column primarycode on maintable , primarycode on updatecodes table. descrip column correct version. since i'm not sure how rollback works, below query fixing problem; think it's right, not sure. edit: there many more codes in maintable these. these ones need updated. don't know if affect query or not. update maintable set maintable.primarycode=update.descrip maintable inner join updatecodes on maintable.primarycode=updatecodes.descrip how this: update maintable set maintable.primarycode = updatecodes.descrip maintable inner join updatecodes on maintable.primarycode = updatecodes.primarycode joining on values "wrong" correct ones update...

facebook social plugins - Like Box Body Text Color -

i can't actual text of box stream display in white using "dark" color scheme. the title , links etc fine main body of post in either black or dark grey pretty unreadable. <div style="background-color:#000000;" class="fb-like-box" data-href="http://www.facebook.com/wecouldbeastronauts" data-width="260" data-height="250" data-colorscheme="dark" data-show-faces="false" data-border-color="#000000" data-stream="true" data-header="false"></div> is code. visited facebook dev site again remake thinking must have got wrong has same issue. it not possible alter colors content within social plugins, have no option other stick original color schemes facebook provides light , dark . in dark scheme text of stories colored grey (aka #999 ) should seen on black background (well, people comfortable dark backgrounds)...

c# - How can I create a function that attaches multiple event handlers to multiple controls? -

question: how can create function attaches multiple event handlers multiple controls? intent: using c# develop windows forms application. want create function takes collection of controls , collection of event handlers. function attach event handlers controls. elegant, , reusable way this. have pretty ugly way delegates, but less work me throw loop, , abandoning function. behavior want: foreach(control control in controlcollection) foreach(eventhandler handler in eventhandlercollection) control.event += handler; function: attachhandlers(? controlcollection, ? eventhandlers) edit: going subscribe handlers same event on controls. didn't explicitly in description, believe reason of confusion. if controls in question inherit same base class or interface (or same class), can like: void attachclickeventhandlers(list<iclickablecontrol> controls, list<myclickhandler> eventhandlers) { foreach (var control in controls) ...

asp.net - Connection Strings -

could me understand piece of code in simple english? beginner. thank in advance. <connectionstrings> <add name="balloonshopconnection" connectionstring="server=(local)\sql➥ express; database=balloonshop; user=balloonshop; password=ecommerce" ➥ providername="system.data.sqlclient" /> <remove name="localsqlserver"/> <add name="localsqlserver" connectionstring="server=(local)\sqlexpress;➥ database=balloonshop; user=balloonshop; password=ecommerce" providername=➥ "system.data.sqlclient" /> </connectionstrings> this tutorial. covered first half of book seems strange. the web.config app part of configuration settings app gets. total configuration combination of web.config machine.config file, , settings defined in iis. line: <remove name="localsqlserver"/> implies there connection string named localsqlserver defined elsewhere may getting somewhere other web...

java - Is spring getbean case sentitive or not? -

when use getbean("test") i have class like @component public class test { } can bean loaded? getbean() is case sensitive, spring uses custom bean naming strategy @component , @bean classes. see 4.10.5 naming autodetected components : when component autodetected part of scanning process, bean name generated beannamegenerator strategy [...]. default, spring stereotype annotation ( @component , @repository , @service , , @controller ) contains name value thereby provide name corresponding bean definition. if such annotation contains no name value or other detected component (such discovered custom filters), default bean name generator returns uncapitalized non-qualified class name . and @configuration / @bean see 4.12.4.5 customizing bean naming : by default, configuration classes use @bean method's name name of resulting bean. functionality can overridden, however, name attribute. back question. because class not following ...

java - Hibernate data consistency -

i have java-servlet application +hibernate + streaming server flow: user login begin video streaming decrement abonament minutes in data base every 2 seconds if minutes < 0 send request new minutes(response may after long time, if continue decrement ) problem: appears data consistency problem, other words while decrementing minutes, ex: user.setminutes(user.getminutes() - 2) may not see changes maded new minutes response, , minutes corrupted i thought sollution create new hibernate transaction , commit every time when change minutes, didn't worked: transaction t = session.begintransaction(); user.setminutes() session.flush(); t.commit(); question: how solve problem, when each change recent data? the hibernate session caches entities in memory (in case user entity). it's not enough create new transaction changing remaining minutes, have reload changes made other tasks (addditional minutes request). can achieve calling refresh() : session....

oop - creating numbered objects from a constructor in javascript -

i have constructor makes squares. i code automatically create squares constructor using loops , name them square1, square2, square3 ect. eg. for (n=1; n < x; n++){ var square(n) = new square(); } is possible? if how , how refer them in loop - square(n)? i'm new programming, oop , javascript sorry if ovb. in advance that's arrays for: var squares = new array(); (var n = 1; n < x; n++) { squares.push( new square() ); } now you're able access them zero-based index: squares[0].somemethod(); // etc.. to iterate on squares in array: for (var = 0; < squares.length; i++) { squares[i].somemethod(); }

iphone - Disable touches on layer/scene for pause -

i'm trying create pause menu game. using [[ccdirector shareddirector] pause] works well, game sprites have own cctouch methods, can still dragged around while game paused. i'm creating pause menu creating cclayer on top of existing scene, , removing , resuming when hit resume. is there easy way perhaps make perhaps pause layer receives touches? or other alternatives? thanks you can implement kind of lock , unlock of layers, in disable , enable user interaction. implement logic translate lock/unlock commands lockable children. can implemented, example, protocol

css - Auto width for floated div -

here code <div class='content'> <div class='div1'>content</div> <div class='div2'>content</div> </div> .content { width:300px;} .div1 { float:left;width:200px;} .div2 { float:left;width:100px;} in case need set display:none div2 . possible set .div1 width full-size of .content ( 300px ) reorder divs, , use overflow: hidden : <div class='content'> <div class='div2'>content 2</div> <div class='div1'>content 1</div> </div> .content { width:300px; overflow: hidden;} .div1 { overflow: hidden;} .div2 { float:left; width:100px;}

css - Triangle shape with background image -

Image
i working on project calls 2 triangles hold background images, , links. here mock how 2 triangles. currently, have 2 divs span 900x600 each triangle background image. issue having can't hover on transparent part of cinema div reach photo div. can accomplish design css3 triangles , set background images? thought custom shape made border, border-color. is possible css3 triangles, , if so, can me code? here have. .pageoption { position: relative; width: 900px; height: 600px; } .pageoption .photo { position: absolute; top: 0px; left: 0px; width: 900px; height: 600px; background: url('../images/menuphoto.png') no-repeat 0 0; } .pageoption .cinema { position: absolute; bottom: 0px; right: 0px; width: 900px; height: 600px; background: url('../images/menucinema.png') no-repeat 0 0; } <div class="pageoption"> <a href="#" class="option photo" id="wed...

In BlackBerry UI Right Align Issue -

in blackberry ui trying align labelfields right aligned , left aligned: for have created 1 vertifieldmanager @ top level adding horizontalfieldmanager , lalbelfields added horizontalfieldmanager, horizontal field manager forcing content left aligned. how can align fields in right side? i tried spacing not looks in bb devices having different pixcels resolution. please advise. i'm still new on bb, have tried change long style horizontalfield ?

php - SQL Query logic with zend framework -

so, situation in logics kind'a bad, , math not good, need "building" query fetch information 3 different tables join query. structure this: users table : primary key "id" campaigns table : primary key "id" user_campaign table : user_id, , campaign_id rows. i want pull campaigns doesn't exist in user_campaign table user id x. my query zend framework. appreciate kind of help, thanx, , evening israel! my current query: $q = $this->select() ->setintegritycheck(false) ->from(array('c' => 'campaigns')) ->join(array('uc'=> 'user_campaign'), 'uc.campaign_id != c.id , uc.user_id != 1', array('campaign_id', 'user_id')); try query out, using left join, , adding on joined table valid id being null, return results don't exist on right side of join public function check_access($campaign_id, $user_id) { $q ...

c - Android 2.1 - Object Detection on OpenCV 2.0 and image's quality of different devices. -

now, i'm working on project object detection using opencv on android 2.1. , have many problems: i cannot use lastest version of opencv on android 2.1 project, , use opencv 2.0 written on c-language. see many function haarcascade or image process missed or haved many bug:( each android device give me different image's quality. so, make detection module give wrong result. example: htc desire give me darken image, sony arc give me image have more blue or yellow value etc... how can process these image same quality training , detecting. when run haartraining command (on opencv 2.0), npos = 20, nneg = 10, never successful, if run more 24 hours. today deadline of project. http://opencv.willowgarage.com/documentation/object_detection.html supports.

How does ASP.NET MVC work? -

about asp.net mvc,i want know:what's different asp.net web form ? , what's lifecycle? , extension points ? not best question site, doesn't fit q&a format of so. research before: http://msdn.microsoft.com/en-us/magazine/dd942833.aspx and come if have specific question.

sql - Naming convention for an identity column in a database -

what point behind naming convention when identity column in table called userid , productid etc. instead of id ? prons , cons? one advantage of longer names: when use columns in complicated query many tables (e.g. joins) don't have prefix columns know table come , minimize problems column names ambiguity.

regex - Regular expression for numeric range -

looking regular expression cover number range. more specifically, consider numeric format: nn-nn where n number. examples are: 04-11 07-12 06-06 i want able specify range. example, between: 01-27 , 02-03 when range, if - not there. range: range 01-27 02-03 would cover: 01-28, 01-29, 01-30, 01-31 , 02-01 i want regular expression can plug in values range easily. ideas? validating dates not regexes strengths are. for example, how validate february regarding leap years. the solution use available date api's in language

c# - How to extract text from Pdf, Word and Excel documents? -

i'd need .net library using can extract text data pdf, excel , word files. ideally, free tool! would recommend any? many thanks, as has spent many days looking free solutions (nearly) exact problem, can tell not find free library able extract text all of formats well. library i'm aware of great job of formats (and more) commercial library, , it's not native .net, it's c++/com library, c++/cli .net wrapper. what options? itextsharp -- 1 absolutely fantastic in extracting text pdfs. while later versions of library commercial friendly (lgpl), authors have decided instead want charge software, they've instead released under agpl, unless want release of source code, don't want use 1 of versions. however, last version (4.1.6) licensed under lgpl can found on internet. this question has link version under lgpl. pdfbox -- pdf library. one, imo, better because it's under apache 2.0 license. there few issues it, sometimes (perhaps ra...

C: Array initialization segfaults depending on size and call to printf() -

another student asked me wrong c code. reproduced erroneous behavior , have no idea why segfaults. consider tiny c programm: #include <stdio.h> int main(void) { int n = 590; double a[n][n]; double b[n][n]; double c[n][n]; printf("done"); } set n value <= 590: runs without errors, or without output. set n value > 590: runs flawlessy output line removed. compile , run output: segmentation fault what's reason this? can explain? you try allocate more memory it's available on stack causes stack overflow . better allocate huge arrays dynamically using malloc , calloc or realloc . don't forget free memory calling free when finish :) these questions too: c/c++ maximum stack size of program segmentation fault on creating array in c segmentation fault when using variable initiate array

php - Twitter api: Does x follow y? -

i'm looking simple script tell me if 1 twitter user follows twitter user. looked through twitter developer docs, couldn't find information relating want accomplish. an example of i'm looking demonstrated on site: http://doesfollow.com/jjmpsp/rhyyysss i did consider using website, , checking if page contains string "yup", isn't efficient way this. anyone have suggestions/resources how go accomplishing want do? okay, figured out. lol... https://api.twitter.com/1/friendships/show.json?source_screen_name=jjmpsp&target_screen_name=rhyyysss

c# - Login to mediawiki by api on wp7 -

i trying create app wp7 login wikipedia , translating pages. stuck right @ beginning since can't login through mediawiki api. relevant part of code goes this: data.append("action=login&lgname" + httputility.urlencode(textbox1.text)); data.append("&lgpassword=" + httputility.urlencode(passwordbox1.password)); request.begingetrequeststream(new asynccallback(getrequeststreamcallback),request); request.begingetresponse(new asynccallback(getresponsecallback), request); public void getrequeststreamcallback(iasyncresult asynchronousresult) { httpwebrequest request = (httpwebrequest)asynchronousresult.asyncstate; stream poststream = request.endgetrequeststream(asynchronousresult); byte[] bytedata = utf8encoding.utf8.getbytes(data.tostring()); poststream.write(bytedata, 0, data.length); poststream.close(); } private static void getrespons...

ruby - Capybara testing of sinatra app fails -

i trying test sinatra app using minitest , capybara several errors on tests using capybara features fill_in or visit. test_index gives: undefined local variable or method `app' # test_create_user gives: invalid expression: .////form[@id = 'register'] test_same_email gives: unable find css "#register" test_login gives: cannot fill in, no text field, text area or password field id, name, or label 'email' found any suggestions on may wrong? test.rb require "test/unit" require "minitest/autorun" require "capybara" require "capybara/dsl" require "rack/test" require_relative "../lib/kimsin.rb" env["rack_env"] = "test" class kimsintests < test::unit::testcase include rack::test::methods include capybara::dsl capybara.app = sinatra::application def test_index visit "/" assert stuff.. end def test_create_us...

Endless Scroll with Jquery, PHP, and Ajax -

so i'm trying impliment endless scroll pulling table in mysql database , have when bottom of page reached call new number of reviews pulled newsfeed reason when gets bottom shows loading gif , nothing new loads. messing awesome. guys here jquery/ajax: <script> //script continue home newsfeed after 10 posts $(window).scroll(function() { if($(window).scrolltop() === $(document).height() - $(window).height()) { $('div#load_more_posts').show(); $.ajax( { url: "load_more_posts.php?lastpost=" + $(".display_newsfeed:last").attr("id"), success: function(html) { if(html) { $("#outputdiv").append(html); $('div#load_more_posts').hide(); } else { $('div#load_more_posts').replacewith("<center>finished loading posts!</center>") } } }); } }); </script> here part of code...

glReadPixels get wrong data in android opengl es 2.0 -

i yuv data camera , , send them opengl, use fragment shader convert data rgba format , show on screen. goes when use glreadpixels rgba data framebuffer int array, wrong data. // use vbo draw glbindbuffer(gl_array_buffer, squareverticesbufferid); glvertexattribpointer(gvpositionhandle, 2, gl_float, gl_false, 0, 0); glenablevertexattribarray(gvpositionhandle); glbindbuffer(gl_array_buffer, textureverticesbuferid); glvertexattribpointer(gvtexturehandle, 2, gl_float, gl_false, 0, 0); glenablevertexattribarray(gvtexturehandle); glbindbuffer(gl_element_array_buffer, squareverticesindexbufferid); gldrawelements(gl_triangle_strip, 4, gl_unsigned_int, 0); // use glreadpixels read rgba data unsigned char *returndatapointer = (unsigned char*) malloc(width * height * 4); glreadpixels(0, 0, width, height, gl_rgba, gl_unsigned_byte, returndatapointer); unfortunately wrong data, last thousands elements in array 0s,the same code works on ios, did miss something? i work on android 4.0.3 , us...

Failure adding assembly to the cache Windows XP SP3 -

Image
i trying add assembly gac error indicates "failure adding assembly cache: administrator permissions needed use selected options. use administrator ommand prompt complete these tasks." i using windows xp sp3 , user account type administrator. please refer image below. tia http://i.stack.imgur.com/tzxpc.png you administrator on machine don't run visual studio command prompt (or cmd.exe) admin ...

r - How to get Dow Jones Index (DJI) data from Google? -

i trying data dow jones index google. have tried number of things not seem work. require(quantmod) getsymbols(".dji",src = "google") getsymbols("^dji",src = "google") getsymbols("indexdjx:.dji",src = "google") the error "http: 404 not found". means page getsymbols uses doesn't exist dow jones index (it not exist s&p500 , nasdaq composite). there's nothing quantmod can if google doesn't provide data...

Java/Android : passing accelerometer value from onSensorChanged method to onCreateSetContentView() -

i'm new on java , android programming language , first platform studied. want ask, how can access event.values[1] in method? public void onsensorchanged(sensorevent event) {synchronized (this){ if (event.sensor.gettype() != sensor.type_accelerometer) return; maccvals.x = (float) (event.values[1] * filtering_factor + maccvals.x * (1.0 - filtering_factor)); //maccvals.y = (float) ((-event.values[1] * filtering_factor + maccvals.y * (1.0 - filtering_factor))); maccvals.z = (float) (event.values[2] * filtering_factor + maccvals.z * (1.0 - filtering_factor)); scene.camera().position.x = maccvals.x * .2f; scene.camera().position.z = maccvals.z * .8f; scene.camera().target.x = -scene.camera().position.x; scene.camera().target.z = -scene.camera().position.z; } i want event.values[1] , display on textview protected void oncreatesetcontentview() { setcontentview(r.layout.custom_layout_example); linearlayout ll = (linearlay...

How to install sdks for android inside eclipse -

the other day on different machine able install many android sdk versions @ once using in eclipse. cannot remember how did , wondering if might know how this? thanks follow directions given @ http://developer.android.com/sdk/installing.html , , use sdk manager select, download , install whichever sdk(s) need.

Disable form security CakePHP -

is possible turn of cakephp security features 1 particular form in view? don't hidden fields (tokens) in form. thank you, bart you can disable action via: public function beforefilter() { parent::beforefilter(); if ($this->request->params['action'] == 'action') { $this->security->validatepost = false; } }

javascript - Wrap all elements up until :nth-child -

i having hard time figuring out, sure simple. i know have use :nth-child count every set of elements want wrap. wondering how count :nth-child , wrap previous elements including :nth-child in div each set of elements match :nth-child . assuming there .each() involved. the code laid out so: <div class="wrapper"> <h3>heading</h3> <a href="#">link</a> <a href="#">link</a> <a href="#">link</a> <a href="#">link</a> <a href="#">link</a> <a href="#">link</a> <a href="#">link</a> <h3>heading</h3> <a href="#">link</a> <a href="#">link</a> <a href="#">link</a> <a href="#">link</a> <a href="#">link</a> <h3>heading</h3> <a href="#">link</a> <a...

Difference between int and int received by ParseInt in java -

int = 0; int k = integer.parseint("12"); int j = k; system.out.println(i+1 + " " + j+1); strangely output received 1 121 i can not figure out basic difference. please me. use brackets follows system.out.println((i+1) + " " + (j+1)); from docs the + operator syntactically left-associative, no matter whether later determined type analysis represent string concatenation or addition. in cases care required desired result. example, expression: a + b + c regarded meaning: (a + b) + c extending scenario i+1 + " " + j+1 it becomes (((i + 1) + " ") + j)+1 since i int (i + 1) = 1 , simple addition " " string hence ((i + 1) + " ") = 1 with space (string concatenation ) similarly when j , last 1 added, being added string hence string concatenation takes place, justifies output getting. see jls 15.18.1 string concatenation operator +

objective c - Create an NSString with leading zeroes for minutes and seconds -

i need update playback time in label. getting time nstimeinterval currentprogress = self.movieplayercontroller.currentplaybacktime; returns double value. format in need display "mm:ss" (00:00). have tried following code nstimeinterval currentprogress = self.movieplayercontroller.currentplaybacktime; float min = floor(currentprogress/60); float sec = round(currentprogress - min * 60); when progress time 10 minutes , 10 seconds displays fine, "10:10". problem here if progress time 1 minute , 7 seconds, displays "1:7" in label. intended display "01:07". how can that? nsstring *time = [nsstring stringwithformat:@"%02d:%02d", (int)min, (int)sec]; try this. should work!

objective c - What is the difference between this 2 @synthesize Pattern and which is Recommended? -

many places in sample code have seen 2 different way of @synthesize variable. example here taking 1 sample button. @property (strong, nonatomic) iboutlet uibutton *logonbutton; 1.@synthesize logonbutton = _logonbutton; 2.@synthesize logonbutton; among 2 methods 1 recommended? short answer the first method preferred. long answer the first example declaring generated ivar logonbutton property should _logonbutton instead of default generated ivar have same name property ( logonbutton ). the purpose of prevent memory issues. it's possible accidentally assign object ivar instead of property, , not retained potentially lead application crashing. example @synthesize logonbutton; -(void)dosomething { // because use 'self.logonbutton', object retained. self.logonbutton = [uibutton buttonwithtype:uibuttontypecustom]; // here, don't use 'self.logonbutton', , using convenience // constructor 'buttonwithtype:' inst...

proper threadpool using pthreads -

i trying write customized threadpool suited purpose using pthreads, , new pthreads. read these ( posix threads programming , linux tutorial posix threads ) tutorials online , quite helpful, still have (maybe silly) doubts regarding mutexes , condition variables: what scope of mutex? global mutex lock global variables 1 thread can access them @ time? if have 2 global mutexes, lock same set of variables? mutex declared inside class or function, happen when lock/unlock it? if plan read global variable, , not modify @ all, should still use mutex lock? if correct, condition variable used wake other threads sleeping (or blocked using pthread_cond_wait() ) on condition. wake call sleeping threads given pthread_cond_signal() or pthread_cond_broadcast() other thread. how flow of control supposed occur or 1 thread wake(s) work , wait until next work available? particularly interested in scenario 4 threads. is there way set affinity of thread particular processor core before created ...

maven - Eclipse + m2eclipse : One project depending on the other, without having to run "mvn install" -

i'm using eclipse indigo + m2eclipse. i have 2 projects in workspace, projecta declaring maven dependency projectb in pom.xml. i want able make changes projectb and, without having run "mvn install" on projectb, being able see changes when run projecta! i have properties/maven/resolve dependencies workspace projects checked on both projects. doesn't work. have "mvn install" on projectb (and potentially "maven/updates dependencies..." on projecta changes seen. my dependency projectb, in projecta's pom : <dependency> <groupid>com.xxxx</groupid> <artifactid>projectb</artifactid> <version>0.7-snapshot</version> </dependency> the groupid, artifactid , version match found in projectb's pom. i read found on internet no success! any idea? update : don't know if information may helps, have projectc in workspace depends on projectb. , project...

node.js - EJS: <%= versus <%- -

i'm using ejs node.js web server i'm building. see many ejs examples use <%= when outputting html or strings, while other examples (sometimes within same template) use <%- . i tried reference the ejs docs , getting started guide , both gave no info <%- notation. also, google search attempts yielded nothing useful. thanks! the version of ejs you're using in node not same version see on google code; in node version, <%= escapes html going buffer, while <%- not. source

javascript - HTML/CSS: Background Image from raw image data, not url -

i raw image data of png-image webserver, , want use background image of div-element. possible without saving data image-file first? use data uri : document.getelementbyid('e').src = 'data:image/png;base64,ton_of_crap'; in wikipedia article, there code php , python outputs base-64 encoded images. can shove url() of css file (or src attribute of <img /> tag) , should work.

debugging - GWT client umbrellaexception get full error message in java -

i'm working gwt find impossible find errors current error messages in chrome console. errors both when in local development mode , when i'm hosting app on gae. how actual java error? says line , exception got? , btw error i'm looking called? thanks in advance! in gwt 2.1.1 here comes umbrellaexception collects set of child throwables together. try this: public void onmoduleload() { gwt.setuncaughtexceptionhandler(new gwt.uncaughtexceptionhandler() { @override public void onuncaughtexception(@notnull throwable e) { ensurenotumbrellaerror(e); } }); } where ensurenotumbrellaerror defined follows: private static void ensurenotumbrellaerror(@notnull throwable e) { (throwable th : ((umbrellaexception) e).getcauses()) { if (th instanceof umbrellaexception) { ensurenotumbrellaerror(th); } else { th.printstacktrace(); } } }

android - Maven does not fail from introduced compilation errors -

just moving android project on maven / jenkins , exploring build / compile / testing procedures. issue: introduced simple compilation error in java code, when run mvn clean install package build success. it's when deploy app device crashes , fails. is there wrong pom? ps. have xxxxx'd out info. don't worry it. <?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelversion>4.0.0</modelversion> <parent> <groupid>xxxxx</groupid> <artifactid>xxxxxx</artifactid> <version>1.0.0</version> </parent> <groupid>xxxxx</groupid> <artifactid>xxxx</artifactid> <version>1.0.0</version> <pack...