Posts

Showing posts from May, 2010

bash - awk system call -

i want use awk , system() function move couple of directories around. have file want process awk names file.cfg organized in following way: /path1 /path2 /some_path /some_other_path , on.. each first path separated second path whitespace here's how did it: awk '{system(mv -r $1" "$2)}' file.cfg but doesn't work , get sh: 0/home/my_user/path1: no such file or directory but file.cfg looks this: /home/my_user/path1 /home/my_user/path2 and there no 0 before /home. missing here? you have quote command give system : awk '{system("mv -r " $1 " " $2)}' file.cfg currently mv -r interpreted value of variable mv minus value of r, 0 since neither defined.

ios - How do I achieve a navigation bar like the one used in iBooks? -

Image
the navigation bar in ibooks i'm looking implement. is, transparent top bar return button in top left , buttons in top right invoke actions. however, i'm not sure how effect accomplished. transparency especially. can point me in right direction of how might accomplish this? use custom uiview subclass. add buttons , set alpha of view. use controller's uinavigationcontroller push or pop controllers.the navigationbar should hidden.

actionscript 3 - Trying to remove object throws error 1009 cannot access a property or method of null object reference -

working on flash game, in previous game had enemies come in using array , when killed or moved off stage remove them array. reason when use same code in game, throws 1009: error when try remove array object, saying there's nothing there. . . strange. here's code: public function addzombie() { var zom:zombie = new zombie(); zom.y = 20; zom.x = math.floor(math.random()*(1 + 500 - 30)) + 30; addchild(zom); zombies.push(zom); numzombies++; } that's function it's added in, zombies array , it's pushed array in function. here's code i'm attempting remove it: for (var i:int = 0; < zombies.length; i++) { if (zombies[i].y + zombies[i].height / 2 > 400) { removechild(zombies[i]); zombies.splice(i,1); numzombies--; addzombie(); } } removechild(zombies[i]); <-- part throws error when attempts remove it. removes of them strangely enough, not of them. i don't believe l

php - Where should be stored the environment dependent configs in a Zend Framework 2 application? -

a zf2 application contains/nneds lot of different config files: /config/application.config.php , /config/autoload/global.php , /config/autoload/local.php , /module/***/config/module.config.php . now i've written module, covers caching functionality application, , need different values livetime of items in local/dev , live environment. able switch cache type dependent on environment. where should such stuff sored? in /config/autoload/global.php , /config/autoload/local.php ? if yes: should first retrieved these files in module class (e.g. in onbootstrap() method) or used directly, it's needed? (it great, if show primitive example saving , getting such config data.) the solution, i'm using is: /config/autoload/global.php and/or /config/autoload/local.php return array( // db credentials 'db' => array( 'username' => ..., 'password' => ..., 'dbname' => ..., 'ho

javascript - Jsoup DOM applies onload java scripts? -

i want know if dom jsoup document doc = jsoup.connect(page.getpageurl()).get(); will same dom browser (just after loading)? in other words, if there dom manipulation done javascript during onload() method, happen before dom returned jsoup ? it same http response's body, not manipulated javascript. a simple fact: jsoup not have javascript engine execute script, can't that.

css - How to make a square button -

i have button on website , want make square: how make square button , make still act button changes little bit when scroll on it here example: note button can't clicked on http://jsfiddle.net/hruwm/ (what css make work?) here tried: <input class="butt" type="button" value="test"/> .butt{ border: 1px outset blue; background-color: lightblue;} this work: .butt { border: 1px outset blue; background-color: lightblue; height:50px; width:50px; cursor:pointer; } .butt:hover { background-color: blue; color:white; } http://jsfiddle.net/j8zwc/

javascript - Protecting Purely Client-Side Backbone Applications -

so implement scrabble game, , wanted 100 percent client-side, i.e. backbone handles game logic. possible protect such solution users weren't able spoof game moves? is possible? i think several things must stay in server side, in (almost) all-client solution security - must have sort of authorization , authentication outside client side validation - can never trust user generated content, , json model sent server during backbone sync, is, in way, user generated content (as can open console , mess models , save) i know solutions firebase handle #1 well, i'm not sure handle #2 therefore in case, sébastien's answer great solution, instead of server validation, have peers validate other peers valid move according representation of game. however, how know right? majority wins? don't see way avoid having sort of server side state, "master" , validating each move "valid" move. one way of doing having server side running on node.j

java - Adding a JPanel Array to a Container -

look @ last line of code, add jpanel array container. alot guys or gals! code: private jframe b = new jframe("lotus"); private jlabel currentp = new jlabel(); private int currents; private container pieces = new container(); private jbutton exitt = new jbutton("exit"); private imageicon b1=new imageicon("c:\\users\\brusty\\downloads\\p1.jpg"); private imageicon b2=new imageicon("c:\\users\\brusty\\downloads\\p2.jpg"); linkedlist<stack<integer>> spotlist = new linkedlist<stack<integer>>(); //creation of gamepiece labels public void labels(){ jlabel[] labelsp1 = new jlabel[10]; jlabel[] labelsp2 = new jlabel[10]; for(int = 0 ; < labelsp1.length ; i++){ labelsp1[i] = new jlabel(b1); for(int j = 0 ; j < labelsp2.length ; j++){ labelsp2[j] = new jlabel(b2); } container c = b.getcontentpane(); c.setlayout(new gridlayout(13,3)); c.add(pieces); pieces.add(labelsp1);

rounding - How to round Python Decimal instance -

how round python decimal instance specific number of digits while rounding nearest decimal? i've tried using .quantize(decimal('.01')) method outlined in docs , , suggested in previous answers , doesn't seem round correctly despite trying different round_ options. i've tried setting getcontext().prec, seems control total number of digits in entire number, not decimals. e.g. i'm trying like: assert decimal('3.605').round(2) == decimal('3.61') assert decimal('29342398479823.605').round(2) == decimal('29342398479823.61') assert decimal('3.604').round(2) == decimal('3.60') assert decimal('3.606').round(2) == decimal('3.61') i think need use decimal.round_half_up option quantize want. >>> x in ('3.605', '29342398479823.605', '3.604', '3.606'): print x, repr(decimal(x).quantize(decimal('.01'), decimal.round_half_up)) 3.605 decim

android - Action Bar dropdown open and closed item styles -

Image
i'm trying style action bar list navigation such has white text in closed state. when i've done that, though, has turned all text white, doesn't work white dropdown. is there way style each individually? docs non-existant :( add custom layout adapter . in have created 1 layout inside have add 1 textview . text color , background color . and set atapter like: arrayadapter<string> adapter = new arrayadapter<string>( getbasecontext(), r.layout.my_spinner_style, r.id.textview1, countries); here r.layout.my_spinner_style custom layout. r.id.textview1 textview id my_spinner_style.xml . you can applay awn style inside textview. check this , this aretical. check code: inside oncreate : /** create array adapter populate dropdownlist */ arrayadapter<string> adapter = new arrayadapter<string>( getbasecontext(), r.layout.my_spinner_style, r.id.textview1,

c# - Simple update with Entity Framework -

i have following code , cannot achieve saving changes. parameter of method string containing refcode of product want modify in database, query pulling baseproduct supposed modified. (i tried simplify code , set in english, have introduced syntactic errors, in code in debug mode, info db). there wrong "select new" in linq query ? public static void updateproduct(viewproduct producttoupdate) { using (var context = new my_entities()) { var baseproduct = (from prod in context.product prod.ref == producttoupdate.baseproduct.refprd select new viewbaseproduct { refprd = prod.ref, descrprd = prod.descrprd, normece = (bool)prod.normece }).firstordefault(); if (baseprod

go - How to ignore fields with sscanf (%* is rejected) -

i wish ignore particular field whilst processing string sscanf. man page sscanf says an optional '*' assignment-suppression character: scanf() reads input directed conversion specification, discards input. no corresponding pointer argument required, , specification not included in count of successful assignments returned scanf(). attempting use in golang, ignore 3rd field: if c, err := fmt.sscanf(str, " %s %d %*d %d ", &iface.name, &iface.btx, &iface.bytesrx); err != nil || c != 3 { compiles ok, @ runtime err set to: bad verb %* integer golang doco doesn't mention %* conversion specification, say, package fmt implements formatted i/o functions analogous c's printf , scanf. it doesn't indicate %* not implemented, so... doing wrong? or has been quietly omitted? ...but then, why compile? to best of knowledge there no such verb (as format specifiers called in fmt package) task. can however, specifying verb , ignorin

amazon web services - Load user data on every boot up of EC2 -

i having aws ec2 instance. i want load user data on every boot of ec2 instance. whether possible or have create new instance each time execute user data? multiple options: create custom ami users , co figurations want. easiest way create ebs backed instance, setup, , the. select dashboard option create ami instance. have settings on remote source(s3 instance), instance setup pull , execute/add/configure. for single instance, ami works well. larger environment, configs management kickstart, puppet, chef, cfengine, or similar better.

c++ - boost::optional reference with boost::variant type -

i'm writing code game , part of involves creating history of actions have taken place far in game. history stored in vector of state_pair_t 's pairs of actions ( action_t 's) , pointers result gamestate after action has been made. have function looks through history starting @ recent point in time , iterates backwards until action of type found returns reference that. decided might design move use boost optional return no_action if no action found , use boost::optional deal these functions should return value might not have value return. when i've tried implement run error don't understand: typedef boost::variant< a, b, b > action_t; typedef boost::optional< action_t& > opt_action_ref_t; const opt_action_ref_t no_action = opt_action_ref_t(); /*! state pair combination of particular action , resulting game state */ typedef std::pair< const action_t, game_state_ptr > state_pair_t; opt_action_ref_t get_last_non_a_action() c

button - How should I set up my touch controls in starling? -

i developing game in starling has 2 controls. 1 users left thumb touching anywhere on left side of screen, drags character , down y axis. other control having trouble implementing single button in bottom right of screen make character fire bullet. my question how set without having character jump down bottom of screen whenever button pressed. will need mess multi-touch in order running? a more specific question have how define rectangle sprite in starling? since starling has no drawing api, can't this... touchlayer.graphics.beginfill(0x000000, 0); touchlayer.graphics.drawrect(0, 0, stage.stagewidth, stage.stageheight); touchlayer.graphics.endfill(); currently character drag working, touch registers everywhere on screen (im not sure how make left side of screen...) any advise appreciated, thank you. here complete code ingame class requested. package screens { import flash.geom.point; import flash.geom.rectangle; import flash.u

c# - Unnecessary wrapping of text in crystal report -

Image
i facing strange problem while working crystal report in vs 2012. using formula field create string , displaying field in report. but problem while executing report, text in field automatically wraps before ending of current line. i've absolutely no idea doing wrong. refer attached snapshot. text in line "1" wrapping way before line ending. code using in formula field: 'आपको उकत आवस जरिये लॉटरी/दिनांक '+cstr({lottaryallotment_detail.allotmentdate},"dd mm yyyy")+' को रुपये '+cstr({master_lottary.totalamount})+' मे आंवटन किया गया है।'+' '+ 'आप द्धारा आवास गृह की अमानत व पूर्व ग्रहण राशी रु '+ cstr({master_lottary.earnestmoney})+' जमा करा दी है एवं शेष राशी किश्तो में जमा करने बाबत मांग पत्र मांग पत्र जारी किया जा चुका है।' i think problem has character encoding since use hindi language. try set font arial unicode ms solve it.

javascript - How do I validate input with MongoDB? -

i have simple little user registration form looks this: // post register new user exports.new = function(req, res) { var db = require('mongojs').connect('localhost/busapp', ['users']); db.users.ensureindex({email:1}, {unique: true}) function user(email, username, password, datecreated) { this.email = email; this.username = username; this.password = password; this.datecreated = new date(); this.admin = 0; this.activated = 0 } if (req.body.user.password !== req.body.user.passwordc) { res.send('passwords not match'); } else { var user = new user(req.body.user.email, req.body.user.username, req.body.user.password); // todo: remove after clarify works. console.log(user.email + " " + user.username + " " + user.password); // save user database db.users.save(u

ruby on rails - Accessing current instance model attributes for a static function -

i have 2 models: user & api , in api model have static function # register account associated characters public def self.register_characters(apiid, vcode, userid) # fetch xml api = eaal::api.new("#{apiid}", "#{vcode}", "account") result = api.characters # pull characters result.characters.each |char| if character.find_by_charid(char.characterid.to_i).nil? character = character.new( :charid => char.characterid.to_i, :user_id => userid, :name => char.name, :corp => char.corporationname ) character.save api = api.new( :user_id => userid, :character_id => character.id, :apiid => apiid, :vcode => vcode ) api.save character.update_character end end end i need call method in user model on after_create filter

internet explorer - ExtJS 4.1 - All js source in one file with store model controller and views. Works in FF but fails in IE and Chrome -

extjs 4.1 - have have separate js files. have created application , have js code in each individual jsp. works fine in firefox not work in chrome or ie. using ext.onready paint first page tabpanel. on click of each tab call different js files have grid panels model store in them. have not created separate model store controller js files , have js code in 1 single file. using liferay portlets in application. please 80% done application , cannot revert back. thanks.

c++ - What is the difference between marching cube and octree? -

is octree special case of marching cube ?? mean octree use same triangulated cubes of marching cube. know octree 3d form of quadtree. want know whether in correct direction or not. after tree have been formed, how octree step formation of triangles ( creating surface) same of marching cube? it different theory. octree cubic subdivision method 3d space, find distributions of things in space, efficiently process large spaces , narrow down areas there find. marching cubes system generating mesh , doesn't use progressive subdivision octree. but marching cube system use octree find areas need processed , throw out things without mesh in it. https://www.youtube.com/watch?v=gnztx3ijjpo

arrays - how to optimise intersect on heroku -

i have postgresql query, check length of intersection of 2 arrays. simplified version of query like: select array_length(users.array & array[1,2,3,4]) users; it part of larger query, not important here. works fine on local database, on heroku, intarray extension not whitelisted. i found simple function intersect arrays, compared & operator rather slow. create or replace function array_intersect(anyarray, anyarray) returns anyarray $$ select array( select * unnest( $1 ) unnest = any( $2 ) ); $$ language sql; on 2000 records of table using & operator takes 50ms , using function above takes 150ms . compare many records can , function doesn't scale '&' operator. is there way faster or add intarray heroku? guess depend on rest of query, , how optimized need be. my first attempt create cte of insecting lengths using unnest , intersect ... fetch values cte within main expression needed... along lines of: with merged ( select *

c# - Partially deserialize with JSON.NET, keeping some fields raw -

i have document this { "field1": 1, "field2": 2, "field3": { type: "themotherload" } } which want convert class, keeping field 3 "raw/as-is". public class fields { public int field1 { get; set; } public int field2 { get; set; } public string field3 { get; set; } } the result should field1 = 1, field2 = 2, field3 = "{ type: "themotherload" }" possible json.net? field3 jobject. when need json call field3.tostring()

android - How to use fragment with Viewpager for Swipe pages -

i got doubt regarding viewpager , fragment .i want create swipe view need fragment classes viewpager .how implement such thing!! i searched through net got using viewpager!! public class viewpagerfragmentactivity extends fragmentactivity { private pageradapter mpageradapter; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); super.setcontentview(r.layout.viewpager_layout); // initialsie pager this.initialisepaging(); } /** * initialize fragments paged */ private void initialisepaging() { list<fragment> fragments = new vector<fragment>(); fragments.add(fragment.instantiate(this, fragment0.class.getname())); fragments.add(fragment.instantiate(this, fragment1.class.getname())); fragments.add(fragment.instantiate(this, fragment2.class.getname())); this.mpageradapter = new mypageradapter(super.getsupportfragmen

c# - Using client certificate with python requests -

i use client certificate authentification @ rest-service. after testing configuration generated certificates in firefox say, configuration right, since authentification @ service works desired. now, have implement certificate python-script. i'm using python-requests: rsp = requests.put(url='{0}recorditems/{1}'.format(daemonconfig['service']['url'], recorditemoid) , data=body, headers=headers , cert=daemonconfig['daemon']['certpath'], verify=false) but when send requests via method , start debugging in visual studio, object request.clientcertificate.certificate has length 0; no certificate included. certificate exists @ location specified in configuration. if have path certificate should passed verify not cert . cert accepts tuple. setting verify=false you're telling requests ignore cert parameter altogether.

if statement - Is it possible to use IF(cond1 AND cond2,result,else result) in MySQL? -

i want update query if consecutive 5 column have 0 value. first idea is: update `table_name` set `count` = if(`col1`=0.00 , `col2`=0.00 , `col3`=0.00 , `col4`=0.00 , `col5`=0.00, count+1, count) but think using , in if condition isn't work. idea? before using and in if valid, grijesh suggets, using condition in where clause usual way it. your query though shouldn't give errors.

javascript - Best way to import coordinates from .gpx file and display using Google Maps API -

i mountain biker , track rides on samsung s3 galaxy using programs such endomondo , strava . regarding ride saved on these 2 websites. i have own personal website display mountain routes in various areas stay. route data recorded via gps using endomondo , strava have exported .gpx file. need data in .gpx file display on own personal website. started solution using google maps api , importing .gpx file without using external tool. i struggled find answer. came across post guy uses jquery extract data in xml file , display data on google map: http://www.jacquet80.eu/blog/post/2011/02/display-gpx-tracks-using-google-maps-api this how implemented html markup: <script> function initialize() { var route1latlng = new google.maps.latlng(-33.7610590,18.9616790); var mapoptions = { center: route1latlng, zoom: 11, maptypeid: google.maps.maptypeid.roadmap }; var map = new google.maps

java - (SOLVED) Calling A Public Method Causes NullPointerException - Android -

ahm, hey everyone, want ask problem in program creating. here snippet codes playactivity.class //more codes here public void stflabel(int numface, context ct) { try { if(numface > 0) facelebel.settext("face hint : see human"); else facelebel.settext("face hint : you?"); } catch(nullpointerexception e) { e.printstacktrace(); log.d(tag, "stflabel has error"); } } //more codes here * camerapreview.class * //more codes ... playactivity pact = new playactivity(); ... //more codes .. public void pausy(int numface) { pact.stflabel(numface, mcontext); } logcat 04-05 16:11:26.150: d/facedetection(27929): face detected: 1 face 1 location x: 65y: -1 04-05 16:11:26.150: w/system.err(27929): java.lang.nullpointerexception 04-05 16:11:26.150: w/system.err(27929): @ com.delihente.faceplay.playactivity.stflabel(playactivity.java:90) 04-05 16:11:26.150: w/system.

java - Spring MVC Default View Resolver Not Working? -

i requests not resolve specific controller mappings go view name derived request path. eg localhost/success should end rendering view located @ /web-inf/view/freemarker/success.ftl . gather spring documentation behaviour should enabled default , doesn't appear working setup. <mvc:annotation-driven /> <mvc:interceptors> <!-- on pre-handle, resolve device originated web request --> <bean class="org.springframework.mobile.device.deviceresolverhandlerinterceptor" /> </mvc:interceptors> <!-- spring mobile --> <bean class="org.springframework.mobile.device.view.litedevicedelegatingviewresolver"> <constructor-arg> <!-- freemarker --> <bean id="viewresolver" class="org.springframework.web.servlet.view.freemarker.freemarkerviewresolver"> <property name="cache" value="false" /> <p

database - Many-to-many relations - lots of them -

i have general question stroring relations in database. let's take social example: followers . want store friend (id 1) following friend b (id 5). i many-to-many relation in database. inserting: table flw (friend,following,relation_id): (1,5,1) and continue.. million relations friends a,b,c,d,... now question is, when need fetch relations friend (or b,c,...) following.. needs trough million of records. still effective ? can't image facebook goes trough billion of rows friends list. the solution use more 1 database. (millions of many-to-many-relations) (only) correct way store what's in example ?

ruby on rails - Devise login based on status of the User? -

i using devise gem authentication. in users table there status column active , inactive status. want of type in application controller: before_filter :check_user_status def check_user_status if @current_user.status == "inactive" #destroy user session redirect_to new_session_path end user able access controller if active otherwise should redirected login page. want in application controller check_user_status executed first before controller action. you should check out active_for_authentication? method realize this. @ documentation find out more details , example.

sql server - Creating a SQL Login for Windows user -

i have .net application connects sql server on network. user logs in windows user. sql server set windows authentication only. client machine, user not created on sql server login yet. on first startup of application, application needs check if windows user sql server login , if not, login must created .net application. my question user log in sql server check if login exists. cannot current windows user, user must created first , on first run not exist on sql server. i know how proceed once connection established, , need on correct login use when windows user not exist login on sql server. keep in mind server set windows authentication only. all of must done through .net code (vb or c#). thanks help. i not understand question, answering upon think asking: you need logged in administrator in windows since using windows authentication only. once have logged in admin, windows recognise , give authentication rights when go sql server these rights automatically pass

fortran90 - How to deal with the extremely large expressions in Fortran? -

i have fortran program this, program test integer,parameter :: f=selected_real_kind(20) real(kind=f)::b1,b2,c1,v,xd,xe,res b1=1._f b2=0.5_f v=1._f/3._f c1=0.25_f xd=0.2_f xe=1._f/6._f res= "extremely large expressions" write(*,*) res end program res large expression, more 50000 lines. , cannot compile program using gfortran compiler. error reason is, out of memory allocating 65536 bytes suggestions welcome. thanks!

optimization - Vectorizing Code for efficient implementation -

the following iir code . need vectorize code can write neon code efficiently. example of vectorization non vectorized code for(i=0;i<100;i++) a[i] =a[i]*b[i]; //only 1 independent multiplication cannot take //advantage of multiple multiplication units vectorized code for(i=0;i<25;i++) { a[i*4] =a[i*4]*b[i*4]; //four independent multiplications can use a[(i+1)*4] =a[(i+1)*4]*b[(i+1)*4]; // multiple multiplication units perform a[(i+2)*4] =a[(i+2)*4]*b[(i+2)*4]; //operation in parallel a[(i+3)*4] =a[(i+3)*4]*b[(i+3)*4]; } please me in vectorizing loop below implement code efficiently using vector capability of hardware (my hardware can perform 4 multiplications simultaneously). main() { for(j=0;j<numbquad;j++) { for(i=2;i<samples+2 ;i++) { w[i] = x[i-2] + a1[j]* w[i-1] + a2[j]*w[i-2]; y[i-2] = w[i] + b1[j]* w[i-1] + b2[j]*w[i-2]; } w[0]=0;

c++ - Recursive function does not fully recurse object / sub-objects -

i have recursive function find() tries find item given id. below extracted relevant parts class make example compile: #include <iostream> #include <cstdarg> #include <cstdio> #include <string> #include <vector> class item { private: std::vector<item> subitems; public: std::wstring id; public: item() : subitems(0), id(l"") {} item(const item& rhs) : subitems(rhs.subitems.size()) { (std::size_t = 0; < rhs.subitems.size(); ++i) subitems[i] = rhs.subitems[i]; id = rhs.id; } item& operator==(const item& rhs) { if (this != &rhs) { (std::size_t = 0; < rhs.subitems.size(); ++i) subitems[i] = rhs.subitems[i]; id = rhs.id; } return *this; } std::vector<item> getsubitems() { return subitems; } item addsubitems(item * item ...) { va_list args; va_sta

c# - Programmatically add MultiTrigger to ContentControl sub-class -

everything works fine until call this.triggers.add(triggerfocus). class sub-classes contentcontrol. here's code: private void createtriggers() { triggerfocus = new multitrigger { conditions = { new condition { property = isfocusedproperty, value = true }, new condition { property = iskeyboardfocusedproperty, value = true } }, setters = { new setter { property = setfocusproperty, value = true }, } }; this.triggers.add(triggerfocus); } any ideas? here's equivalent xaml throws error: <contentcontrol.triggers> <multitrigger&g

php - Get slug from current url -

i getting urls in following patterns: http://localhost/hi-every-body/ http://s1.localhost/hello-world/ http://s2.localhost/bye-world/ and want fetch exact slug like hi-every-body hello-world bye-world with few check & few line of code. tried many checks appeared. this should that: trim(parse_url($url, php_url_path), '/'); it takes path , strips off slashes on both sides.

java - InputStream from jar-File returns always null -

i know question has been asked several times, think problem differs bit others: string resourcepath = "/path/to/resource.jar"; file newfile = new file(resourcepath); inputstream in1 = this.getclass().getresourceasstream(resourcepath); inputstream in2 = this.getclass().getclassloader().getresourceasstream(resourcepath); the file-object newfile fine (the .jar file has been found , can meta-data newfile.length() etc) on other hand inputstream return null. know javadoc says getresourceasstream() null if there no resource found name, file there! (obviously, because it's in file-object) anyone know why happens , how can fix can .jar file in inputstream? the getresourceasstream() method doesn't load file file system; loads resource classpath. can use load, example, property file that's packaged inside jar. cannot use load file file system. so, if file resides on file system, rather in jar file, better use fileinputstream class.

Saving pdf in the background using html2pdf -

am tryng automatically generate pdfs using html2pdf class. got following code working fine, has save pdf manually. however, whenever new product added, automatically save pdf folder without user intervention, , store value in database future reference. how go saving pdf 'silently' i.e. in background without showing popups or requiring user intervene? in advance. include('pdf_content.php'); $content = ob_get_clean(); // convert pdf require_once('html2pdf/html2pdf.class.php'); try { $html2pdf = new html2pdf('p', 'a4', 'en'); $html2pdf->pdf->setdisplaymode('fullpage'); $html2pdf->setdefaultfont('arial'); $html2pdf->writehtml($content, isset($_get['vuehtml'])); //$html2pdf->output($file_name.'_'.date("dmy").'.pdf'); $html2pdf->output($product_id.'_'.$file_name.'_'.date("dmy").'.pdf'); you can try calli

ksh - Unix - condition within condition -

i've been looking on place couldn't find answer. in ksh, how do this: while [ [ ! [ [ -n $var1 ] || [ [ -n $var2 ] && [ -n $var3 ] ] ] ] && [ ! [ [ -n $var1 ] && [ -n $var2 ] ] ] ]; ...etc etc done or in pseudo/a bit easier way see while ((! ((var1 != none) or ((var2 != none) , (var3 != none))) , (!((var1 != none) , (var2 != none)))) { .... } ...essentially kind of conditions grouped i've found lot on simple conditions if [ -z $var1 ] && [ -n $var2 ]; then but not 1 above. any appreciated. it's easier use ksh 's [[ ]] syntax. ( , ) don't need quoted , can use && , || in c language. example: [[ ! ( -n $var1 && ( -n $var2 || -n $var3 ) ) ]] also, don't need double quote $var within [[ ]] make code cleaner.

.net - C# MailMessage to stream - encoding issue -

Image
iam using amazon ses sendrawemail api hence need mailmessage memorystream. i have found several answers mailmessage memorystream issue here on stackoverflow. solution 1: using 1 uses private methods results in wrong encoding of parts of email: https://stackoverflow.com/a/8826833 solution 2: no encoding problems using solution send pickup directory , read in: https://stackoverflow.com/a/14350088 i dislike fact need write temporary file make work correctly. have idea how pure memorystream solution can mess of encoding. the mail message iam testing this: var mailmessage = new mailmessage(); mailmessage.subject = "header special ÆØÅ"; mailmessage.body = "test"; attachment att = new attachment(@"c:\attachmentwithspecial ÆØÅ.pdf"); mailmessage.attachments.add(att); mailmessage.from = new mailaddress("test@test.com", "nameÆØÅ"); mailmessage.to.add(new mailaddress("test@test.com", "nameÆØÅ")); to summari

java - Reusing Persistence Context in JPA -

i working on @embededid code, want auto increment before entity persisted, want without use of @generatedvalue , identity column, below table composite id, create table tbl_employee_002( id integer, country varchar(50), name varchar(50), constraint pk_emp_00240 primary key(id,country) ) this code entity mapping, @entity @table(name="tbl_employee_002") public class employeeentitysix implements serializable{ // contructor's @embeddedid private employeeidtwo id; @column(name="name") private string employeename; // getters , setter's @prepersist public void incid(){ entitymanager em = null; query q = null; entitymanagerfactory emf = null; try{ emf = persistence.createentitymanagerfactory("forpractise"); em = emf.createentitymanager(); q = em.createquery("select max(e.id.employeeid) employeeentitysix e");

servicebus - Calling service bus running on cloud from my local application -

how can call service bus running on cloud local application.if there demo please share link go windows azure site download sdk language using. head on service bus samples site idea on demos.

Java : how to terminate condition check inside for loop -

i have array list shown . my requirement , if list consists of value "m" in , want terminate condition check (equals check shown ) in loop , want continue further operations in loop this program package com; import java.util.arraylist; import java.util.list; public class jai { public static void main(string args[]) { string flag = null; arraylist<string> list = new arraylist<string>(); list.add("m"); list.add("m"); list.add("m"); list.add("f"); list.add("m"); list.add("m"); list.add("m"); list.add("f"); (int = 0; < list.size(); i++) { if (list.get(i).equals("m")) { flag = "m"; } else { flag = "f"; } // indicate need continue further operations // inside l

r - Using ddply instead of for -

i'm quite new plyr package (and r in general) have following code # have dataframe df # columns: # -somefactor: factor # -value: numeric f<-levels(df$somefactor) k<-length(f) m<-mat.or.vec(k,k) for(i in 1:k) { (j in 1:k) m[i,j]=cor(df[somefactor==f[i],]$value,df[somefactor==f[j],]$value) } how simplify code using ddply function (or similar, remove ugly cycles thank lot! fida you can try : cor(as.data.frame(split(df$value, df$somefactor)))

Sorting help. Insertion sort c# -

i have arraylist bunch of objects of same class(distributedapps). constructor: public distributedapps(string appname, string devname, string description, double size, int estlife,double price, int downloads,int ratings,string distributor, double annlicencefee, int maxusers) :base(appname,devname,description,size,estlife,price,downloads,ratings) i want insertionsort sort list(deployedapps) descending on app size(size) public void deployinsertionsortappsizedeployed() { console.writeline("insertion sort on app size deployed!"); int ii; distributedapps temp, prtemp; (int io = 1; io <= (count(deployedapps) - 1); io++) { temp = (distributedapps)deployedapps[io]; ii = io; prtemp = (distributedapps)deployedapps[ii - 1]; while ((ii > 0) && (prtemp.getsize().compareto(temp.getsize()) <= 0)) { deployedapps[ii] = deployedapps[ii

Doctrine2 createNativeQuery returns an object with one result when there are more -

i have following doctrine2 code: $sql = 'select user_name, user_email users'; $rsm = new resultsetmapping(); $rsm->addentityresult('entity\users', 'u'); $rsm->addfieldresult('u', 'user_name', 'username'); $rsm->addfieldresult('u', 'user_email', 'useremail'); $query = $this->em->createnativequery($sql, $rsm); $users = $query->getresult(); which returns array 1 item first user. however, if change $users = $query->getarrayresult(); it returns full set of users expected. can see problem here? thanks! p.s. yes, know simple query doesn't require createnativequery, real query complex querybuilder or dql, , have simplified see whether problem query. isn't. the arrayhydrator (used getarrayresult ) checks if query has 1 entityresult mapping, if continues populate result array after identifiermap has been set entityresult alias. objecthydrator (used getresult ) not pe

jQuery before() method is breaking a generated sub menu when using jQuery 1.9.1, fine on previous version, -

i building select drop down menu mobile devices based on pre-existing ul, working fine old version of jquery (1.4.1). however, have updated jquery version 1.9.1 , code breaks menu. section breaking child menu of section viewing. var mobilemenu = function (menuparent, prevsibling) { var $select = $('<select>', { class: 'mobilemenu' }).insertafter(prevsibling); $(menuparent).each(function () { var $li = $(this), $a = $li.find('> a'), $p = $li.parents('li'), prefix = new array($p.length + 1).join('-'); var $option = $('<option>') .text(prefix + ' ' + $a.text()) .val($a.attr('href')) if ($(this).hasclass("selected")) { $option.attr('selected', true); } $option.appendto($select); if ($(this).hasclass("selected")) { mobilesub