Posts

Showing posts from July, 2011

jquery - Save base64 encoded image into the file in PHP -

i have following code : <?php header('content-type: image/png'); $data = "ivborw0kggoaaaansuheugaaauaaaai8cayaaacwih5daaagaelkzjgrcxxoauipzztlg......"; define('upload_dir', '/home/desktop/image.png'); $img = $data; $img = str_replace('data:image/png;base64,', '', $img); $img = str_replace(' ', '+', $img); $data = base64_decode($img); $file = upload_dir . uniqid() . '.png'; $success = file_put_contents($file, $data); print $success ? $file : 'unable save file.'; ?> here $data contain encoded string of image in base-64. want save image file. did previous code go through lot of tutorial in google it's not working. can me going wrong. thanks in advance. define('upload_dir', '/home/xpointers/desktop/'); remember! apache webserver run own user rights (e. g. www-data). take care, apache user or group apache runs in have access desired directory. test can c...

jdbc - SQLite exception on Windows and not Mac OSX -

i'm developing mac os x java application uses sqlite database using jdbc driver. the code works fine on mac, can't use batch inserts using preparedstatement s on windows box. edit: doesn't work simple statement s contains single insert into instructions ( create table works fine). my code basically: table creation: final string sql = "create virtual table " + table_name + " using fts3(" + key_nom + ", " + key_prenom + ", " + key_adresse + ", " + key_adresse2 + ", " + key_adresse3 + ");"; try { final statement s = mconnection.createstatement(); s.execute(sql); } catch (final sqlexception e) { l.e("unable create table: "+sql+"! "+e); } preparedstatement creation: string sql = "insert "+table_name +" (" ...

primefaces - How to apply DataTable filter programatically? -

using primefaces demo filtering datatable ( http://www.primefaces.org/showcase/ui/datatablefiltering.jsf ) example, able provide "filtering" links outside of table user click (say volvo, forw, bmw, etc). when user clicks link, switch selected item in manufacturer filter dropdown , apply filter. haven't been able figure out how filter properties make change. can done via javescript? how access selection list , set current selection? update: following daniel's link, managed dropdown selection change, unable filter apply. in columns filters based on input field, triggering keyup causes data filter can't figure out event trigger on select make filter. here code using: <p:commandlink id="filterlink" value="click filter volvo only" onclick="$('#carform\\:datatable\\:manufacturercolumn_filter').val('volvo'), $('#carform\\:datatable\\:manufacturercolumn_filter').trigger('filter')"...

Jquery : Set Value for a Range in a Dictionary -

i want set values range in jquery dictionary object somthing this var temp_dict = {'1-10': 'woolen', '11-25':'light woolen', '26-36':'light cotton'} here keys 1-10, 11-25, 26-36 different ranges of temprature. want store in dictionary , call them : alert(temp_dict[15]); so checks in range , returns appropriate result. is there way achieve this?? function gettemp(t) { (var key in temp_dict) { var range = key.split("-"); if (t >= range[0] && t <= range[1]) return temp_dict[key]; } } var temp = gettemp(15); demo: http://jsfiddle.net/wpxdx/

php - Run parallel handler of curl with curl_multi_exec -

why in piece of code need call 2 times curl_multi_exec function. on first loop i'm executing curl_multi_exec handler run sub handler. when curlm_call_multi_perform different $mrc loop ends. in second loop, find results curl handlers, , first loop executed again, why? <?php { $mrc = curl_multi_exec($multihandle, $active); } while ($mrc == curlm_call_multi_perform); while ($active && $mrc == curlm_ok) { if (curl_multi_select($multihandle, $timeout) != -1) { { $mrc = curl_multi_exec($multihandle, $active); } while ($mrc == curlm_call_multi_perform); } } ?> the code extracted php-doc site the answers here curl_multi_exec() . it's frustrating php's documentation can useless in aspects ...

javascript - multiple countdowns on same page with jquery -

i'm having little problem jquery/javascript countdown , i'm hoping can me. so, have timer function, has 1 parameter, called selector (jquery selector) .. function timer(selector) { self = $(selector); var sec = parseint(self.find('span.timeout').text()); var interval = setinterval(function() { sec--; if (sec >= 0) { self.find('span.timeout').text(sec); } else { setinterval(interval); } }, 1000); } in, html have this. <div class="element" id="el1"><span class="timeout">10</span></div> <div class="element" id="el2"><span class="timeout">10</span></div> multiple elements same class , different id's and usage of function this: $("body").on('click', '.element', function() { timer(this); }); on first click works fine, timer counts down. when click on secon...

java - JAXB wrap wrapped collections -

i have class contain 2 lists. want generate wrapper element around list elements, , around 2 list. class someclass { private list<typea> lista; private list<typeb> listb; } <some-class> <lists> <list-a> <element-from-list-a /> <element-from-list-a /> <element-from-list-a /> ... </list-a> <list-b> <element-from-list-b /> <element-from-list-b /> <element-from-list-b /> ... </list-b> </lists> </some-class> i can generate wrapper around list xml-element-wrapper can't wrap 2 list 1 element. is possible in jaxb and/or in moxy implementation? after asked question solved problem moxy's xml-path extension, i'm still interested in standard jaxb solution problem.

PHP not displaying results from MySQL database -

i trying display entry mysql database selected data. if (isset($_get["id"])){ $id=$_get["id"]; $result = getselectedblog($id); while($row = mysqli_fetch_array($result)) { extract($row); ?> <div class="headline"><?php echo $headline ?></div> <div class="subtitle"><?php echo $subtitle ?></div> <div class="content"><?php echo $content ?></div> <?php } here sql statement: function getselectedblog($id){ $con = mysqli_connect('localhost', 'root', '', 'michaelwebsite') or die('could not connect'); $sql = 'select * tblarticle tblarticle.articleid "$id"'; $result = mysqli_query($con, $sql) or die('entry not exist.:' . mysqli_error($con)); return ...

d3.js - D3 how to change the width and length of SVG -

i created svg on google map , want control on width , length of svg object the size ok problem location of svg not in right place. how can control on location of object ? i tried add transform .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")") but size didn't work. when tried add scale , translate projection size didn't work. advise me how can control on location , size ? idea first location of svg should same location size should change location should same. current issue when change zoom svg change location <!doctype html> <html> <head> <meta charset="utf-8"> <script src="http://mbostock.github.com/d3/d3.v2.js?2.8.1"></script> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script> <style> html,body,#map { width: 95%; height: 95%; margin: 0; padding:...

scope - Javascript: append script with an object, and create a local instance -

let me expose question: have main script, let's creates instance of "game" object, which, depending on actions of user, loads 1 of many javascript files, let's call them "levels" :d these files contains different objects, example, "level1.js" contains object level1, "level2.js", etc. each time level script loaded, example level1.js, instance of "game" creates instance of object level1 , stores in local variable. the way i've found it, write, @ end of "level" scripts, global variable, has same name, , points definition of current level. in game, when level script loaded, use global variable create instance of current level. know if there way without using global variable. here simplified example: in game.js: function game() { var levelcurrent = null; var scriptcour = document.createelement("script"); scriptcur.type = "text/javascript"; scriptcur.onload = function() ...

Recurrence relation: T(n) = T(n/2) + n -

hi there trying solve following recurrence relation telescoping stuck on last step. t(n) = t(n/2) + n t(1)=0 t(n/2) = t(n/4) + n/2 t(n/4) = t(n/8) + n/4 ... t(2) = t(1) + 2 t(n)= t(1) + n + n/2 + n/4 i think answer nlogn don't know how interpret above nlogn. can see doing logn steps n come from? you have done absolutely correctly, not able find sum. got: n + n/2 + n/4 + ... , equal n * (1 + 1/2 + 1/4 + ...) . you got sum of geometric series , equal 2 . therefore sum 2n . complexity o(n) . p.s. not called telescoping. telescoping in math when subsequent terms cancel each other.

How do I get Hibernate Filters to work in JPA? -

i have following entity class: @entity @filterdef (name = "bylastname", parameters = @parameter (name = "lastname", type="string")) @filters ({ @filter (name = "bylastname", condition = "lastname = :lastname") }) public class user { string firstname; string lastname; } in dao this: public user findbyid (long id) { session s = (session) em.getdelegate ( ); s.enablefilter ("bylastname").setparameter ("lastname", "smith"); user u = em.find (user.class, id); return (u); } now, if i'm understanding correctly, filter should applied, , user try retrieve should come null if lastname not equal "smith". problem filters don't appear applied. user attempt retrieve database, regardless of value of lastname gets returned. am misunderstanding how filters work? or missing in how have configured? note i'm not using hibernate.cfg.xml; configured me using jpa , an...

javascript - Pass an argument as a reference to get a JSON property -

i'm working on facebook app js sdk... i want create function makes api call graph api: this got: function a(reference){ fb.api('/me', function(respond){ var = respond.reference[0].name; alert(it); }); } i try executing way doesn't work. a("inspirational_people"); so you’re feeding text string "inspirational_people" function, , want access property of response object having name? that’s quite easy, basic javascript syntax: every property can access via object.propertyname can access object["propertyname"] . so in case, since want access response.inspirational_people[0].name , it’s response[reference][0].name – actual string value of reference evaluated @ runtime, , should end having wanted.

sql server - Query to transform unknown number of rows to unknown number of columns -

i'm been looking hours @ different options (pivot, cross join etc...) transform unknown number of rows unknown number of columns sql server 2008 , i'm more lost before started. basically have 3 tables: role |id| name| | 1|role1| | 2|role2| | 3|role3| action |id| name | | 1|action1| | 2|action2| | 3|action3| roleaction |roleid| actionid| | 1 | 1 | | 1 | 2 | | 2 | 1 | | 3 | 2 | is there anyway build query or sp transform result of left join nice "pivot" table this: |actionid|actionname|role1|role2|role3|.....|role n| | 1 | action1 | 1 | 1 | 0 |.....| 0 | | 2 | action2 | 1 | 0 | 1 |.....| 0 | | 3 | action3 | 0 | 0 | 0 |.....| 0 | | . | . | . | . | . |.....| . | | . | . | . | . | . |.....| . | | n | action n | 0 | 0 | 0 |.....| 0 | many many help! big thank aaron putting me on right track! alter proce...

flash builder - Phone Date in Android? -

i developing android application, question, can date of phone , show in label?. thank much i’m using flash builder cs5.5 in java, , android system.currenttimeinmillis(); will return long millisecond representation of time/date phone thinks is. once have can use dateformater string display user. edit: missed flash tag =(. how can done native java. have no experience flash on android though, dunno if carry on , work under platform sorry.

maven - mvn integration-test - can't find myproject.gwt.xml to run GwtTest*.java test cases -

i building gwt project, , having problems executing gwttest*.java unit tests. can run project in developer mode (mvn gwt:run). when go run unit tests using 'mvn integration-test' or 'mvn gwt:test' receive following error. loading inherited module 'com.mycompany.site.client.myproject' [error] unable find 'com/mycompnay/site/client/myproject.gwt.xml' on classpath; typo, or maybe forgot include classpath entry source? below pom.xml <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"> <!-- pom file generated gwt webappcreator --> <modelversion>4.0.0</modelversion> <groupid>com.mycompany</groupid> <artifactid>myproject</artifactid> <packaging>war</packaging> <version>0.0.1-snapshot</versio...

sql server - How does an index work/relate to FK? -

i know basic , given i'm @ databases should understand now, not comprehend index is. to make concrete, following t-sql generated orm - creates fk , creates index it. what having index (in posative sense) , excluding (in negative sense)? -- creating foreign key on [item_id] in table 'cakestats' alter table [dbo].[cakestats] add constraint [fk_cakestat_item] foreign key ([item_id]) references [dbo].[items] ([id]) on delete no action on update no action; -- creating non-clustered index foreign key 'fk_cakestat_item' create index [ix_fk_cakestat_item] on [dbo].[cakestats] ([item_id]); go an index balanced tree allows faster searching specific data. indexing in general sense marking easy finding. visualize index in of reference book. it's alphabetically sorted allow quick finding of actual information @ cost of pages in of book making larger/thicker. more stuff index, larger is. there difference between clustered , non...

javascript - Extjs store.filter by date range -

here code, trying filter 'collecttime' allowing date range. i don't see in docs can add nor see example shows working correctly. can point me in right direction? listeners: { 'load': function(store) { if ('color' in $_get) { store.filter([ {property: 'color' , value: $_get['color'] , anymatch: true , casesensitive: false} ]); } if ('priority' in $_get) { store.filter([ {property: 'precedence' , value: $_get['priority'] , anymatch: true , casesensitive: false} ]); } if ('startdate' in $_get) { store.filter([ {property: 'collecttime' , value: $_get['startdate'] , anymatch: true , casesensitive: false} ]); } }...

error handling - ios checking for an empty object -

i have error getting passed reference code found online. error comes empty object meaning there no error. if check error.code bad access because object empty. if check error == nil false because error empty object. how can use logic find error exists, empty? errors of type nserror or subclass of it. passed references in methods declared way: -(void)dosomestuff:(nserror **)error; so, when call method requires pass reference nserror call way: nserror *error = nil; [self dosomestuff:&error]; when method finished work check if error object has filled something: if(error) { //do stuff if there error. //to see human readable description can: nslog(@"the error was: %@", [error localizeddescription]); //to see error code do: nslog(@"the error code: %d", error.code); } else //there no error proceed normal { //do other stuff - no error } p.s. if no error , method not behave expected there wrong implementation method. ...

underscore.js - backbone.js 'undefined' get request -

this code: $(function (){ var slide = backbone.model.extend({ defaults: { castid :1, id :1 }, urlroot: function(){ return 'slidecasts/' + this.get("castid") + '/slides/'; }, }); var slideview = backbone.view.extend({ el: $("#presentation"), events: { 'click #next': 'next', 'click #previous': 'previous', }, initialize: function(){ _.bindall(this, 'render', 'next'); this.model.bind('change', this.render); this.render(); }, render: function(){ this.model.fetch(); var variables = { presentation_name: "this slide-number: ", slidenumber: "xxx", imageurl: this.model.url() +"/"+ this.model.get('imagelinks'), slide_content: this.model.get("content")}; var template =...

javascript - Leaflet.js with a non real world map! Coordinates -

i'm working on creating map of day z (the game) leaflet js , want able plot items on map using in game coordinate system see http://dayz.ollieb.net in game top left coordinate 000 000, 001, 001 units of 10 represent grid 010, 010 top left "grid" (similar ordinance survey). how create method convert provided coordinate systems (either points or latlong) work on way. need go 000, 000 (top left) 145, 130 (bottom right). having trouble using lat/long curves compensate projection , points (x/y) seem change per computer! how can take in game point , create marker on map @ point? presumably need tell leaflet.js "number" top left , bottom right of map somehow? sorry lack of understanding, have read through docs , can't see mentioned! see example here: http://dabrothas.net/sei/daisy/index.asp?mode=mark&z=3&x=-109.2294921875&y=73.49222029152183 i'm leaflet author. check out following issues code examples on setting no...

jsf - commandLink submitForm error after JDeveloper 11.1.1.6 install -

i installed jdeveloper 11.1.1.6 , opened simple test project created in 11.1.1.5. now, when clicking on jsf commandlink (h:commandlink), receive following error in web browser console: uncaught referenceerror: submitform not defined my web.xml contains following entries: <servlet> <servlet-name>resources</servlet-name> <servlet-class>org.apache.myfaces.trinidad.webapp.resourceservlet</servlet-class> </servlet> ... <servlet-mapping> <servlet-name>resources</servlet-name> <url-pattern>/adf/*</url-pattern> </servlet-mapping> integrated weblogic @ version 10.3.5. there no outside or custom javascript being referenced within application. has experienced behavior , found solution it? resolution provided on jdeveloper forum on otn: https://forums.oracle.com/forums/thread.jspa?messageid=10389015 in short: use af:commandlink frank

css - webkit transform blocking link -

i've been working transforms , transitions create animated ui components without javascript , enjoying results, i've come across disturbing issue appears unique webkit browsers. on element have rotated, anchor spans 100% of width of element accessible on right 50% of element. this problem not exist using -moz-transform in firefox, 100% reproducible in both chrome , safari using -webkit-transform. here code: <!doctype html> <html> <head> <title>webkit spincard test bed</title> <style type="text/css"> #card-lists{ width:100%; float:left; } #card-lists ul{ list-style:none; } #card-lists ul li{ width:230px; height:236px; } .non-mobile #card-lists ul.card-list li .flipcard-container:hover .flipcard, .non-mobile #card-lists ul.card-list li .flipcard-container.hover .flipcard{ -moz-transform: rotatey(180deg); -webkit-transform: rotatey(180deg); -moz-transform-style: preserve-3d; -moz-transition: 0s linear 0s...

javascript - Unreliable retrieval of properties in images when loading -

curious problem. have set of images attributes i'd use in div (as caption). using each, want width of image (and other properties), align dynamically generated div (as caption of image). img = $('img') img.each(function(index){ var width = $(this).width(); console.log(width); // other properties $('<div class="caption">some text</div>').insertafter($(this)); $(this).next().css({ 'width': width // other properties }); however, $(this).width() gets right value, other times gets 0. it's particularly behaved when press return in direction bar not when press ctrl+r in chrome. doesn't work same in browsers, it's mess. thought jquery attempting retrieve width() before image loaded, wrap code in document.ready(function(){}) instead of (function(){})() doesn't work either way. what happening?. reference, these styles applied images: display: block; padding: 4px; line-height: 1; max-width: 100%; m...

html - split a page into 2 halfs(top and bottom) -

i want split page 2 halves(not column) row(top , bottom) , give 2 colors 1 top , 1 bottom. demo on dabblet.com html: <div id="top">top</div> <div id="bottom">bottom</div> css: #top, #bottom { position: fixed; left: 0; right: 0; height: 50%; } #top { top: 0; background-color: orange; } #bottom { bottom: 0; background-color: green; }

search - What sort of filter to use for matching something like OCallaghan with O'Callaghan? -

can point me filter normalizes tokens so? l.a. reid -> la reid o'callaghan -> ocallaghan searching la reid match l.a. reid . you can't use filter on output of standardanalyzer, standardanalyzer strip punctuation before filter gets chance combine tokens. you can create own analyzer modifying standard analyzer. standardanalyzer uses jflex create tokenizer. source jflex file here , haven't tried it, change line, aletter = ([\p{wb:aletter}] | {alettersupp}) to like, aletter = ([\p{wb:aletter}] | {alettersupp} | "." | "'" ) you want change class names , package declarations in jflex file. after this, use jflex generate new analyzer. the analyzer generate tokens l.a. , pass output of analyzer tokenfilter strips special characters tokens, @ isolatin1accentfilter example code.

html - left side of webpage cut off on Android phone, but looks fine on Chrome, Safari, and Firefox -

my wesite, http://scissormanmusic.com/ when viewing on droid incredible, displays left 200(ish)px cut off. when view on desktop/laptop computer web browser firefox, safari, or chrome cutting off doesn't happen. haven't clue why. what's best way fix this. here's code: <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title> || scissormanmusic.com || </title> <script language="javascript"> function simplepreload() { var args = simplepreload.arguments; document.imagearray = new array(args.length); for(var i=0; i<args.length; i++) { document.imagearray[i] = new image; document.imagearray[i].src = args[i]; } } simplepreload( 'news.png','news...

PHP numerical methods -

i have non-linear function, , need find root it. knows if there's library php implements numerical methods? (i can write method, i'd know if out there library job) pear has math_numerical_rootfinding .

Twitter Bootstrap - checkbox columns / columns within form -

Image
i have form field has number of checkboxes - how can display checkboxes 3 columns instead of 1? something similar this: i've tried adding row/span divs inside <div class="controls"> seems adding left padding. i know there inline checkbox example in docs elements aren't aligned. you can achieve such setup separating checkbox blocks within .control-group container instead of each .control container so: <div class="control-group"> <p class="pull-left">payment types</p> <div class="controls span2"> <label class="checkbox"> <input type="checkbox" value="option1" id="inlinecheckbox1"> cash </label> <label class="checkbox"> <input type="checkbox" value="option2" id="inlinecheckbox2"> invoice </label> <...

visual studio - ASP.net content tags, and the id attribute -

i've made few master pages in visual studio, , few implementing pages, , visual studio sticks id attributes onto of tags: <asp:content id="content1" contentplaceholderid="othercontent" ></asp:content> what gives ids? for? how access them code behind? all controls run on server must have id attribute unique identifier. finding child controls , keeping control hierarchy in place. if have textbox sits in panel sits in updatepanel that's in webusercontrol that's in contentplaceholder that's in page, takes 1 of them not have proper id attribute in order keep connection between textbox , page. in order access code behind need have runat="server" attribute set on tag.

visual studio 2010 - Solution-wide update to interface text? -

i have large solution called product1 , word "product1" scattered on interface (anything visible user such popups, button text, menu items, etc) , within strings in code. need change "product1" "product2" . how can accomplish this? need update strings in code contain "product1" "product2" . because string maybe used display text, example: string s = "product1 cool"; txtlogo.text = s; i tried doing find on whole solution, finds don't want. example, have controls have prefix of product1 , don't care updating these. cause app break.

php - AFNetworking Uploading Image -

i've @ few examples think problem may in php. trying upload image server iphone using afnetworking. here obj-c code: -(ibaction)uploadbuttonclicked:(id)sender { nsdata *imagetoupload = uiimagejpegrepresentation(mainimageview.image, 90); afhttpclient *client= [afhttpclient clientwithbaseurl:[nsurl urlwithstring:@"http://www.theserver.com"]]; nsmutableurlrequest *request = [client multipartformrequestwithmethod:@"post" path:@"/project/upload.php" parameters:nil constructingbodywithblock: ^(id <afmultipartformdata>formdata) { [formdata appendpartwithfiledata: imagetoupload name:@"file" filename:@"temp.jpeg" mimetype:@"image/jpeg"]; }]; afhttprequestoperation *operation = [[afhttprequestoperation alloc] initwithrequest:request]; [operation setcompletionblockwithsuccess:^(afhttprequestoperation *operation, id responseobject) { nsstring *response = [operation responsestring]; nslog(@"response...

NFA to DFA conversion -

Image
when converting nfa dfa there may result image below... question is, necessary write state {4} it's going 0 state? mean without showing input symbol 1 of {4} same picture below right? or no? it’s matter of convention. personally, prefer not clutter dfa unnecessary states, since dfas obtained via transformation nfas tend become quite complex anyway, , since it’s deterministic know non-displayed transition must invalid. however, i’ve experienced many people in academia teach / use other convention, , require transitions explicitly shown. when working ta (tutor) i’ve had discussion professor – wanted tutors deduct points on final tests missing transitions in dfas convinced him deducting points unfair.

amazon ec2 - How to upload files and folders to AWS EC2 instance? -

i use ssh connect ubuntu instance . ssh can administer files , folders on instance, how upload files , folders local machine instance? is possible right ssh session, without using sftp clients? as mentioned already, i've used winscp, logs me in "ec2-user" - make sure adjust user's permissions via ssh. example: chown -r ec2-user /path/to/files (authenticate root user first.) whatever folder or files need edit via winscp, allow permissions on them (otherwise permission denied error when trying upload/edit files in winscp).

firefox - How to show a menu after clicking on the widget icon? -

i using firefox addon builder (addon kit 1.7) , wonder know if it's possible show simple menu context menu of firefox after clicking on widget icon. need few hints. in advance. i managed make work using menupopup package yaelle borghini , uploaded simple example on addon builder site. you have expand on yaelle's code support dynamic modifications of menu items because it's not built in @ moment (though shouldn't hard add it). here's discussion on mozilla forums how show menus addon sdk got me started.

How can I add GlassFish to my Netbeans Maven Java Application project? -

i use org.glassfish.api.embedded in java application can add web interface it. i'm using netbeans , have set maven java application project. i'm pretty new java. cannot figure out how add glassfish project. tried add various dependencies, none of them had org.glassfish.api.embedded in them. how can add org.glassfish.api.embedded java application in netbeans? from: http://glassfish.java.net/downloads/3.1.2-final.html <dependency> <groupdid>org.glassfish.main.extras</groupdid> <artifactid>glassfish-embedded-all</artifactid> <version>3.1.2</version> </dependency> glassfish server 3.1.2 in single jar, useful embedded use. contains full platform implementation (67 mb). or: <dependency> <groupdid>org.glassfish.main.extras</groupdid> <artifactid>glassfish-embedded-web</artifactid> <version>3.1.2</version> </dependency> gl...

Cocos2d 2.0 - Ignoring touches to transparent areas of layers/sprites -

Image
i have app have several layers created png images transparency. these layers on screen on each other. need able ignore touches given transparent areas of layers , able detect touches, when user taps on non-transparent area of layer... see pic... how do that? thanks. here have possible solution. implement extension on cclayer , provide method: - (bool)ispixeltransparentatlocation:(cgpoint)loc { //convert location node space cgpoint location = [self converttonodespace:loc]; //this pixel read , test uint8 pixel[4]; //prepare render texture draw receiver on, able read required pixel , test cgsize screensize = [[ccdirector shareddirector] winsize]; ccrendertexture* rendertexture = [[ccrendertexture alloc] initwithwidth:screensize.width height:screensize.height pixelformat:kcctexture2dpixelformat_rgba88...

Installing / running a script in a Google Docs Document (not Spreadsheet)? -

the api documentation states use documentapp.getactivedocument() access document opened user, if there 1 (null returned otherwise). active document available if (and if) current script installed (or otherwise saved) in scope of existing document. so far able install script in spreadsheet , manipulate document wonder if possible install script directly in document. have advantage of having script menu right needed. spreadsheet solution seems strange workaround me. add issues/feature requests here: http://code.google.com/p/google-apps-script-issues/issues/list documentapp.getactivedocument() looks suggestbox issue, i.e. docs exist feature not usable. way check if demand exists feature.

c# - What would be too big for a dictionary, when using IEnumerable.ToDictionary()? -

say that, in method, pass in couple ienumerables (probably because i'm going bunch of objects db or something). then each object in objects1, want pull out diffobject objects2 has same object.id. i don't want multiple enumerations (according resharper) make objects2 dictionary keyed object.id. enumerate once each. (secondary question)is pattern? (primary question) what's big? @ point horrible pattern? how many objects many objects dictionary? internally, prevented ever having more 2 billion items. since way things positioned within dictionary complicated, if looking @ dealing billion items (if 16-bit value, example, 2gb), i'd looking store them in database , retrieve them using data-access code. i have ask though, objects1 , objects2 coming from? sounds though @ db level , much, more efficient doing in c#! you might want consider using keyvaluepair[]

Efficient way to Pass variables from PHP to JavaScript -

this question has answer here: how pass variables , data php javascript? 17 answers from time time have pass variables php js script. did this: var js-variable = "<?php echo $php-variable; ?>"; but ugly , can't hide js script in .js file because has parsed php. best solution handle this? if don't want use php generate javascript (and don't mind call webserver), use ajax fetch data. if want use php, encode json_encode before outputting. <script> var myvar = <?php echo json_encode($myvarvalue); ?>; </script>

Command line arguments in c# -

i pretty new c# . got problem command line arguments. want make use of third cmd line argument , write it. have specified path of file want write , other stuffs. question here can access command line arguments(for eg; args[3]) user defined functions? how tat? below code. public class nodes { public bool isvisited; public string parent; public string[] neighbour; public int nodevalue; public nodes(string[] arr, int nodevalue) { this.neighbour = new string[arr.length]; (int x = 0; x < arr.length; x++) this.neighbour[x] = arr[x];//hi...works?? this.isvisited = false; this.nodevalue = nodevalue; } } public class dfs { static list<string> traversedlist = new list<string>(); static list<string> parentlist = new list<string>(); static bufferblock<object> buffer = new bufferblock<object>(); static bufferblock<object> buffer1 = new bufferblock<object>(); static bufferblock<object> buffer3 = new bufferblo...

java - Comparing String with equals -

string site_inclusion = "0;100"; (string inc: site_inclusion.split(";")) { if(!inc.equals(string.valueof(record.getattrs().get(new pdsxattrkey("siteid")).getvalue()))) { continue; } } and record.getattrs().get(new pdsxattrkey("siteid")).getvalue() returns 77 so code should going continue block right? not going continue? any suggestions? i suggest simplify code test what's going on. might have made mistake trying build example. string site_inclusion = "0;100"; (string inc: site_inclusion.split(";")) { string temp = string.valueof(record.getattrs().get(new pdsxattrkey("siteid")).getvalue()); if(!inc.equals(temp)) { system.out.println(inc + " != " + temp); continue; } system.out.println(inc + " == " + temp); }

How do I do this with C? Fibonnacci Sequence -

perhaps me out this. using concept of cycle generate fibonacci series until reaching 10000 or little more that. so have code , it's supossed work , show me want doesn't. can tell me what's wrong it? opens doesn't work @_@ #include <stdio.h> #include <stdlib.h> int main() { int i=0,j=0,sum=1,num; while(sum>=1000){ { printf("%d\n",sum); i=j; j=sum; sum=i+j; } system("pause"); } the code made calculating fibonacci sequence following: #include <stdio.h> #include <stdlib.h> int main() { int i=0,j=0,sum=1,num; printf("introduce limit fibonacci sequence: "); scanf("%d",&num); while(sum<num) { printf("%d\n",sum); i=j; j=sum; sum=i+j; } system("pause"); } in first snippet, have typo while(sum>=1000){ should be whil...

How to save an image from url using PHP? -

the image url is: http://phim.xixam.com/thumb/giotdang.jpeg my code is: $img = 'http://phim.xixam.com/thumb/giotdang.jpeg'; file_puts_content('abc.jpg', file_get_contents($img)); but receive warning: file_get_contents( http://phim.xixam.com/thumb/giotdang.jpeg ) [function.file-get-contents]: failed open stream: http request failed! http/1.0 403 forbidden in ... i try save image curl not work too. the php code seems technically correct seems 1 reason or blocked. assuming trying browser on same machine , works, guess on useragent string filtering. try using valid user agent string curl. from http://curl.haxx.se/docs/manpage.html : -a, --user-agent (http) specify user-agent string send http server. badly done cgis fail if field isn't set "mozilla/4.0". encode blanks in string, surround string single quote marks. can set -h, --header option of course. if option set more once, last 1 one that's used. ...

c# - Displaying Integer in a Label -

how can display integer in label? doing calculating total , trying display in label. public partial class total : system.web.ui.page { int total; protected void page_load(object sender, eventargs e) { label1.text = server.htmlencode(request.cookies["confirm"]["quantity"]); int quantity = (int)session["textbox1value"]; if (request.cookies["user"]["items"] == "tyres") { total = 20 * quantity; label2.text = ??? } } } or there other way display total on same page? use label2.text = total.tostring(); or label2.text = convert.tostring(total); since text takes string have convert total integer value string calling tostring() or convert.tostring(int) .

class - C++ Classes - What is wrong with my program? -

insert method appends item end of linked list. can't figure out how code case node null, , want add it. struct node{ int data; node *next; node(int data):data(data),next(null){} void insert(int data){ if (this==null){ this=new node(data); // compiler complaining here. // how go setting value of (which presently null) new node? } } } you can not assign value this pointer special keyword , should point valid block of memory. looking @ usage, trying mean this: void insert(int data){ if (!next){ next = new node(data); }

PHP MySQL - How easy way to update the database when one or more fields value changed -

i have little problem on database update activity. case study : i created form php editing, , perform queries retrieve value of record wants updated. excerpts of script: <?php $row = mysql_fetch_assoc(mysql_query("select id, field_1, field_2 mytable id = $editid")); ?> ... <form action="" method="post"> field 1 <input type = "text" name = "f1v" value = "<? php echo $ row ['field_1'];?>" /> field 2 <input type = "text" name = "f2v" value = "<? php echo $ row ['field_2'];?>" /> <input type="submit" /> </form> .... // when form posted if ($_post) { $f1v = $ _post['f1v']; $f2v = $ _post['f2v']; mysql_query("update mytable set field_1 = '$f1v', field_2 = '$f2v' id = $editid") or die (); // redirect form } in case want when form submited, there activi...

SSL client-hello, message body structure -

i'm trying work ssl manually without using libs openssl etc... , have fault on 1st step hello message client. from technet : it must consist of: clientversion 3,1 clientrandom[32] sessionid: none (new session) suggested cipher suites: tls_rsa_with_3des_ede_cbc_sha tls_rsa_with_des_cbc_sha suggested compression algorithm: none in code ( c/c++ ), have created message on way: char *request = "clientversion 3,1\r\nclientrandom[32]\r\n sessionid: none (new session)\r\n suggested cipher suites:\r\n tls_rsa_with_3des_ede_cbc_sha\r\n tls_rsa_with_des_cbc_sha\r\n suggested compression algorithm: none\r\n"; but after recv() functions, i've got 0 in result, what's wrong in message structure? ps in http-proto there place, when must double \r\n ( splits headers , body message ), may be, there must or not? you need take @ rfc 2246 , rather making things up. example newlines between elements of message figment of imagination. but why think can wo...

objective c - Don't Backup to iCloud but still rejected -

in app have store core data database , audio files, decoded put them in documents directory. prevent them backing up, when first launch app, put don't backup flag this - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { [self addskipbackupattributetoitematurl:[self applicationdocumentsdirectory]]; } - (nsurl *)applicationdocumentsdirectory { return [[[nsfilemanager defaultmanager] urlsfordirectory:nsdocumentdirectory indomains:nsuserdomainmask] lastobject]; } - (bool)addskipbackupattributetoitematurl:(nsurl *)url { if (&nsurlisexcludedfrombackupkey == nil) { // ios <= 5.0.1 const char* filepath = [[url path] filesystemrepresentation]; const char* attrname = "com.apple.mobilebackup"; u_int8_t attrvalue = 1; int result = setxattr(filepath, attrname, &attrvalue, sizeof(attrvalue), 0, 0); return result == 0; } else { // ios >= 5.1 return [url setresourcevalue:...

Learning go, trying to figure out the exec package. In what ways can I improve my code? -

wrote simple program calls "ls", passes each line through regexp filtering files end in "s". ls used purposes of learning exec package. how can improve code below more correct/succinct/go-ish? package main import ( "bufio" "fmt" "os/exec" "regexp" ) func main() { cmd := exec.command("ls") stdout, _ := cmd.stdoutpipe() s := bufio.newreader(stdout) cmd.start() go cmd.wait() { l, _, err := s.readline() if err != nil { break } if m, err := regexp.match(".*s$", l); m && err == nil { fmt.println(string(l)) } } } the cmd.output example in standard documentation pretty succinct. doesn't text processing, shows how execute command , output single function call. here's way combine example yours, package main import ( "bytes" "fmt" ...

passport.js - Node.js passport skips strategy -

this coffee-script passport implementation looks examples me fails every time , never prints "trying out strategy". redirected "/fail". tried naming strategy executing in (req, res, next) handler. verified form posted sent username , password in fields , tried renaming them mapping in strategy according examples no avail. tips on i'm overlooking? pass = require 'passport' strat = require('passport-local').strategy exp = require 'express' app = exp.createserver() # configure strategy pass.use new strat (username, password, done) -> #logic find user console.log("trying out strategy") user = {nm:username,ps:password} done(null,user) app.configure () -> app.use (req,res,next) -> console.log("got req") next() app.use pass.initialize() ops = { failureredirect: '/fail' } app.post '/auth', pass.authenticate('local',ops), (req, res, next) ->...

java - Using DecimalFormat with Android Development -

i have looked @ ways solve still new java , looking , kind of diving head first , ran problem. problem having want change number of decimal places output "tip calculator" making , want format in currency using $ symbol. code below using public class tipcalculatoractivity extends activity { decimalformat money = new decimalformat("$0.00"); edittext costofmeal, tippercent; textview tiptotal, totalbill; button calctipbtn; bigdecimal costnum, percentnum, billnum; /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); calctipbtn = (button) findviewbyid(r.id.calctipbtn); costofmeal = (edittext) findviewbyid(r.id.costofmeal); tippercent = (edittext) findviewbyid(r.id.percenttiptext); tiptotal = (textview) findviewbyid(r.id.tiptotal...

About header error in PHP -

i working on php project trying redirect 1 page another, using header (location:something.php). it's working fine on local machine when uploaded server, following error occurs: warning: cannot modify header information - headers sent (output started @ /homepages/4/d404449574/htdocs/yellowandred_in/newtest/edithome.php:15) in /homepages/4/d404449574/htdocs/yellowandred_in/newtest/edithome.php on line 43 i tried include , include_once , require , require_once it's giving other errors like: cannot redeclare logged_in() (previously declared in c:\wamp\www\ynrnewversion-1\edithome.php:3) in c:\wamp\www\ynrnewversion-1\adminindex.php on line 5 my code <?php session_start(); function logged_in() { return isset($_session['username']); } function confirm_logged_in() { if (!logged_in()) { include "error404.php"; exit; } } confirm_logged_in(); require_once("connection.php"); $query="select * home"; $homeinfo = mysq...