Posts

Showing posts from September, 2014

node.js - How to get and update a specific object inside an array with Mongoose? -

i'm having real trouble mongodb , mongoose queries. thing is, have menu schema: var menuschema = new schema({ userid: string, name: string, meals: [{ day: number, hour: number, minute: number, aliments: [{ name: string, amount: number, }], }], }); so i'd know how specific meal or aliment , how update them throught _id value, automatically generated when add them. thank much. david. i working meals, not aliments. i'm doing meals: menu.update({_id: request.params.menu_id, 'meals._id': request.params.meal_id}, {'meals.$.hour': request.body.hour)}, function(error, affected, raw) { response.send(error); }); and aliments: menu.update({_id: request.params.menu_id, 'meals.aliments._id': request.params.aliment_id}, {'meals.aliments.$': {name: request.body.name, amount: request.body.amount}}, function(error, affected, raw) { response.sen

jquery - animate creating a full rotate loop -

i creat fish animation , want him complete full (circle) rotation function anim() { $(".fish_wrap").animate({ "left": "-90px" }, 5000); } anim(); function animaterotate(d){ var elem = $(".fish_wrap"); $({deg: 0}).animate({deg: d}, { duration: 9000, step: function(now){ elem.css({ transform: "rotate(" + + "deg)" }); } }); } animaterotate(120); $(".fish_wrap") .css({top:200,position:'absolute'}) .animate({top:0}, 8000, function() { }); here fiddle link: http://jsfiddle.net/txc5y/4/

ruby - How do I run boxen in Mavericks with rbenv installed? -

i upgraded mac os 10.9 , message when run boxen: bundler not compatible ruby 2.0 or rubygems 2.0. please upgrade bundler 1.3 or higher. can't bootstrap, dependencies outdated i imagined set boxen's .ruby-version file 1.8.7, based on message above, still seems using ruby 2.0. how can run boxen in mavericks? i ran exact same issue. answer deceptively simple. since mavericks includes ruby 2.0.0p247 , rubygems 2.0.3, , apparently upgraded, system ruby not find bundler or ansi gems. need install both system ruby, root. sudo /usr/bin/gem install bundler sudo /usr/bin/gem install ansi then restart or terminal. can run boxen normally. also, in order not keep old files lying around, may want cleanup /library/ruby/gems/1.8/ because include old installation of both bundler , ansi on ruby , gem installation no longer have.

java - Spring Unit Testing on EHCache -

i have annotated @runwith(springjunit4classrunner.class) @contextconfiguration(locations = { "file:webcontent/web-inf/dispatcher-servlet.xml" }) <!-- start of ehcache --> <cache:annotation-driven /> <context:component-scan base-package="caching" /> <bean id="cachemanager" class="org.springframework.cache.ehcache.ehcachecachemanager" p:cachemanager-ref="ehcache"/> <bean id="ehcache" class="org.springframework.cache.ehcache.ehcachemanagerfactorybean" p:configlocation="/web-inf/ehcache.xml" p:shared="true"/> <!-- end of ehcache --> it keeps saying ehcache.xml not found... on normal server can found. may know issue? if understand correctly both spring config , ehcache config in same directory. seems use p:configlocation="ehcache.xml"

Do-while loop only executing when it feels like it in C++? -

so have do-while loop supposed repeat asking if want enter info student if press y , enter info via input() function data stored in vector. if press q, program supposed print info contained in vector , exit loop. for reason loop executes first , second student enter. instead of repeating loop asking if want enter third student seems execute input() function. doesn't ask 'enter y continue or q quit' , student info enter here not seemed stored. intermittently changing between executing full loop , input() function. i'm wondering if knows why happening , can fix it. cheers #include <iostream> #include <iomanip> #include <cmath> #include <cstring> #include <string> #include <vector> using namespace std; const int no_of_test = 4; struct studenttype { string studentid; string firstname; string lastname; string subjectname; string coursegrade; int arraymarks[4]; double avgmarks; }; studenttype inpu

ruby on rails - RSpec leaves record in test database -

whenever run user test, rspec leaves fabricated user in test database after test has completed, messing other tests. rake db:test:prepare , when run tests again, record recreated in database. have no idea why happening. happens user objects. in spec_helper file have: config.use_transactional_fixtures = true here example test creates record: it "creates password reset token user" alice = fabricate(:user) post :create, email: alice.email expect(assigns(alice.password_reset_token)).to_not eq(nil) end fabricator: fabricator(:user) email { faker::internet.email } password 'password' name { faker::name.name } end could have users model? you should use gem called database_cleaner truncate database , reset automatically in gem file add gem database_cleaner after inside spec_helper.rb configure it spec_helper.rb config.use_transactional_fixtures = false config.before(:suite) databasecleaner.strategy = :truncation end config.bef

arrays - object to json in php -

hi guys got problem . while implementing code reached point need use tojson method in each object so inside class have added code public function tojson(){ return json_encode($this); // $this refers current object } it has returned {} knew not recognize properties of class instead have tried convert public function tojson(){ $array=(array)$this; return json_encode($array); } i got weird result string '{"\u0000response\u0000status":0,"\u0000response\u0000data":null,"\u0000response\u0000error":" type non valide "}' (length=112) i write customized json object like public function tojson(){ $myjson="{field1:data1,field2:data2}"; return $myjson; } but not want return each time add new property i appreciate if have idea why converting not work you need convert object properties array before encoding json: public function tojson(){ return json_encode(get_obj

Error Parsing xml file from sd card in Android -

i have written code parsing , showing data xml file. not working. showing error @ main activity. androidxmlparsingactivity: package com.androidhive.xmlparsing; import java.util.arraylist; import java.util.hashmap; import org.w3c.dom.document; import org.w3c.dom.element; import org.w3c.dom.nodelist; import android.app.listactivity; import android.content.intent; import android.os.bundle; import android.view.view; import android.widget.adapterview; import android.widget.adapterview.onitemclicklistener; import android.widget.listadapter; import android.widget.listview; import android.widget.simpleadapter; import android.widget.textview; public class androidxmlparsingactivity extends listactivity { // static variables static final string url = "file:///sdcard/download.xml"; // xml node keys static final string key_item = "item"; // parent node static final string key_id = "id"; static final string key_name = "name"

delphi - How do I make standard actions (like TEditCopy) recognize additional controls (like TEmbeddedWB)? -

i satisified functionality of teditcut , teditcopy , teditpaste , teditselectall except don't work on controls not standard. for example, may work fine on tedit or tmemo controls, not on tembeddedwb — it, standard actions disabled regardless of whether text selected, though tembeddedwb has methods copytoclipboard , selectall . how can make standard actions work tembeddedwb ? how standard actions determine whether should enabled or disabled (and in event — in onupdate event)? can extend standard actions add support unrecognized components, or need write replacement? the default edit actions not work on tembeddedwb control, because component not descend tcustomedit . teditaction , teditselectall descends from, knows how handle tcustomedits . use onupdate , onexecute events of action override behaviour. note default behaviour ignored, implement manually. here example teditselectall action. procedure tform1.editselectall1update(sender: tobject); begin

geometry - How to determine the radius of a circle from the scale of the sprite? -

i making game sprite of circle( origin set @ center of sprite) being up-scaled , rotated simultaneously. need determine change in radius of circle in relation scaling.how go doing that? scaling do? mean 2x scale mean? mean sprite has twice area previous? btw , using libgdx. i figured out myself.the problem bounding rectangle of sprite changes in size sprite being rotated.so raidous of circle can not determined using of rectangle @ time. found width of bounding rectangle product of scale , initial width .so can calculate width @ instance if sprite rotating. , radius that.

When should one consider using Azure's site-to-site connectivity? -

can please explain azure's site-to-site connectivity feature? how different point-to-site connectivity? i not understand difference azure's official documentation. site site making connection between local, on premises network , virtual network in windows azure. example, if spin few virtual machines in windows azure host sql servers, of machines in local network can access them. referred "extending data center". best used when want host 1 more virtual machines in windows azure , have bi-directional communication between machines , machines within own local network. the point-to-site connection between single machine , virtual network in windows azure. example might have virtual machines in windows azure , want single machine on local network, or maybe operations person's laptop, have access cloud based machines. i've heard of people doing in development , testing environment troubleshooting , maintenance tasks. in addition i've heard

java - Set request property content type to raw byte data? -

i have httpurlconnection send audio to. use setrequestproperty("content-type", "audio/x-flac; rate=48000"); to specify type of audio sending. supposed receive string of whatever audio file says. it works when byte array of audio file , send want able send audio taken microphone byte array don't know how specify that. or send wav file tried test file using "audio/wav" , still doesn't work. the error when doesn't work is java.io.ioexception: server returned http response code: 500 url: https://www.google.com/speech-api/v1/recognize?xjerr=1&client=speech2text&lang=en-us&maxresults=10 the line refers connection.getinputstream(); thanks.

rubygems - Puppet - Bundler does not install a gem from GitHub -

i have virtual machine want run rails application. use vagrant run , puppet provision tool. i want run bundle install during provision vm ready. use this: exec { 'bundle install': command => 'bundle install', cwd => '/vagrant/', logoutput => true, } all gems 1 installed. problem ember-rails , 1 github repo specified in gemfile: gem 'ember-rails', github: 'emberjs/ember-rails' i think must puppet issue. when ssh vm , run bundle install manually, gem downloaded , used. when running provision via vagrant, puppet logs message, gem seems missing: /stage[main]/bundler/exec[bundle install]/returns: using ember-rails (0.9.2) git://github.com/emberjs/ember-rails.git (at master) i have noticed 1 difference. when run bundle install manually, bundler logs this: fetching git://github.com/emberjs/ember-rails.git however, there no such message in puppet log. ideas might problem? gems installed git repos visible b

xslt - XSL FO Table row header content is smashed -

i creating xsl fo table have varying number of columns. application uses apache fop display transformed document. when there low number of columns, displays fine (i.e. content of cells centered , displayed in full although columns end taking 2 lines because text wraps). however, tables have on 12 columns, , problem occurs: in column header cells, name of column way right of cell taking multiple lines. looks words wrapping, last 2 characters seemingly cut off. text not leaking neighboring cells. here input xml file in case it's row table header , 1 row body brevity's sake. didn't include chart elements referenced in xsl document part displays properly: <exports> <export> <table> <tblrow> <hdrcell>month</hdrcell> <hdrcell>allow amt pepm med</hdrcell> <hdrcell>allow amt pepm rx</hdrcell> <hdrcell>allow amt pepm med , rx</hdrcell>

Issue on Adjusting Carousel Image Size on Bootstrap 3 -

Image
can please take @ link , let me know doing wrong here make image size shorter side box on ipad landscape (col-md-*) sizes! can see have perfect size devices on ipad landscape view! am doing thing wrong on calculating image size? have fix it? or wrong grid setting? again testing on screnfly image looks on devices until 12" , 10" notepads , ipad landscape. (of course problem may continue smaller size devices since have made infobox hidden, not clear here!? here code using <div class="well banbox"> <div class="row"> <div class="col-lg-9 col-md-9 col-xs-12 banpic"> <div id="carousel-example-generic" class="carousel slide"> <!-- indicators --> <ol class="carousel-indicators"> <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li> <li data-target="#carousel-example-gene

css - WordPress admin stylesheet not showing images -

in plugin have styles admin area. originally, doing them in main plugin file, inline, i've enqueued them. stylesheet enqueued properly; styles working, except -- images referenced in stylesheet not show up. when styles inline showed fine, when enqueue stylesheet not show up. it's not issue path because stylesheet in same directory plugin file styles formerly found inline. here's how i've enqueued it: function my_style() { wp_register_style( 'style', plugins_url('style.css', __file__) ); wp_enqueue_style( 'style' ); } add_action( 'admin_enqueue_scripts', 'my_style' ); and again: enqueue correct because other styles work fine. here example of image in stylesheet: #mycustom-mb h3:before { content:url("../wp-content/plugins/my-plugin/images/banner.png"); } and same line works when style inline, rather enqueued. wordpress doing weird block images? doesn't give me file not found error in firebug, nor show

tree balancing - Understanding Balance Factors/Node Height for AVL rotations -

so having hard time understanding how balance avl trees. understand rotation stuff, can't figure out how find balance factor of node heights, example: http://i.imgur.com/yh5znil.png can explain me how find balance factor each node? i know if height of [(left subtree) - (right subtree)] not within (-1<= x <= 1) unbalanced...but can't figure how find "x". (edit: don't need code, want understand how find bf). if understand question correctly, want know how maintain balance-factor of given node. best way keep track when doing "insert" in tree. because know whether new node going left or right side of "current" node. when goes left, decrement balance , when goes right, increment balance. idea have tree balanced before exit "insert" method. another approach have seen not doing balancing during "insert". insert in bst. after insert, begin balancing act left subtree , right subtree height @ each node , s

css - Decode google chrome cache file -

i wondering if it’s possible convert chrome cache file contents normal text. accidentally deleted 1 important css file , need back. have file lots of binary code. possible recover somehow? some content of file have: http://localhost/ateitiesklinika/css/style.css http/1.1 200 ok date: thu, 03 oct 2013 13:54:17 gmt server: apache/2.2.22 (win32) php/5.3.13 last-modified: thu, 03 oct 2013 05:13:33 gmt etag "420000000161d8-3cd6-4e7cf3f54c270" accept-ranges: bytes content-length: 15574 content-type: text/css 0000000: 28 01 00 00 03 00 04 00 ab c3 26 ce 6c 46 2e 00 (.........&.lf.. 00000010: e3 0d 27 ce 6c 46 2e 00 f7 00 00 00 48 54 54 50 ..'.lf......http 00000020: 2f 31 2e 31 20 32 30 30 20 4f 4b 00 44 61 74 65 /1.1 200 ok.date 00000030: 3a 20 54 68 75 2c 20 30 33 20 4f 63 74 20 32 30 : thu, 03 oct 20 00000040: 31 33 20 31 33 3a 35 34 3a 31 37 20 47 4d 54 00 13 13:54:17 gmt. 00000050: 53 65 72 76 65 72 3a 20 41 70 61 63 68 65 2f 32 server: apa

Compile single .java file with two classes into two .class files -

i have .java file set this: package com.ds; class c{...} public class main{...} when compile file main.java, results in single .class file being main.class. when try run .class java com.ds.main not work! says cannot find or load class. when try run .class java main runs, error so: exception in thread "main" java.lang.noclassdeffounderror: main (wrong name: com /datingservice/main) @ java.lang.classloader.defineclass1(native method) @ java.lang.classloader.defineclass(classloader.java:792) @ java.security.secureclassloader.defineclass(secureclassloader.java:142) @ java.net.urlclassloader.defineclass(urlclassloader.java:449) @ java.net.urlclassloader.access$100(urlclassloader.java:71) @ java.net.urlclassloader$1.run(urlclassloader.java:361) @ java.net.urlclassloader$1.run(urlclassloader.java:355) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:354) @ java.lang.classloader.loadclass(classlo

android - Where is this toast coming from? -

for reason app i'm working on displaying toast shows internal storage space left on device though didn't code in. here screenshot http://i.stack.imgur.com/z2eru.png , here code (only) activity. http://pastie.org/8382286 as can see, of toasts commented out , i'm not importing android.widget.toast . yet i'm still getting toast shown in screenshot. can tell me why happening? are using phone emulator? such message when use phone emulator. such messages wont appear when try running app on device. toast when app run through ide

asp.net mvc 4 - preventing refresh when clicking on the current page -

i'm new asp.net mvc4. i'm implementing navigation bar in website. i'd prevent refresh when clicking current page in nav bar. update i'm using razor navigation bar: <ul> @html.actionlink("feature_1_url","feature_1_url","home") @html.actionlink("feature_2_url","feature_2_url","home") @html.actionlink("feature_4_url","feature_4_url","home") </ul> how can accomplish it? in given solutions page refreshed reduce server call , not call action again , again. in mvc4 1 of best way can achieve purpose using caching [outputcache(duration=30)] public actionresult feature_1_url(){} so specifying time store result in caching when click next time actionlink give result caching data per duration time , reduce request server. this can useful @ least fast response

installer - Inno Setup: Exec can't read string? -

i'm trying put simple inno setup installer looks previous version , removes before proceeding. working fine until following code: if exec(uninstallstring, '/silent', '', sw_show, ewwaituntilterminated, resultcode) begin msgbox('previous version found , uninstalled successfully.', mbinformation, mb_ok); end else begin msgbox('please uninstall previous version of mod before continuing.', mbinformation, mb_ok); result := false; end; it's simple bit of code, fails. i've checked contents of uninstallstring , they're correct ( c:\windows\unins000.exe ) exec fails error: "the directory name invalid." it appears can't read contents of "uninstallstring" correctly, because if enter them manually (e.g. exec('c:\windows\unins000.exe, ... ) works fine. how can make exec process string "uninstallstring" intended? i don't know if did msgbox determine exact string

css - Changing the size of a lot of different images with out affecting aspect ratio -

basically want whole bunch of images 1 under each other. these images different sizes , aspect ratios. want images maximum width , maximum height without changing aspect ratios of each image. how using html 5 , css3? take parent block, example div class name main_div , add css .main_div img { width:100%; height: auto; }

c - I'm losing the type of my object at some point -

// construct array of length max_points. // populate array given points , initialize number points being handled. // print given points user. struct point points[max_points]; int numpoints = readpoints(points); printf("set of points: \n"); displaypoints(points, numpoints); // construct array represent hull max possible points (numpoints). struct point hull[numpoints]; struct point pointonhull = leftmostpoint(points, numpoints); struct point endpoint; int e = 0; // perform jarvis march. { hull[e] = pointonhull; endpoint = points[0]; ( int = 1; < numpoints; i++ ) if ( (endpoint == pointonhull) || (ccw(hull[e], endpoint, points[i]) > 0) ) endpoint = points[i]; ++e; } while ( endpoint != hull[0] ); // we've looped beginning. // print mapped hull points. printf("convex hull: \n"); displaypoints(hull, numpoints); that's code jarvis march (gift wrapping) program solve convex hull. gcc raising errors on both

android - Determining if user installed an app (AIR / AS3) -

ok, i'm working on mobile game using air , as3. idea here want provide incentive installing game. in other words: user taps button in game a, brings them app page game b. user installs game b, goes game a, get's reward in game a. is there way detect game b has been installed? way seems detecting if game b installed when game resumes, can't seem find way of doing using as3/air. i need both android , ios, assume require different methodology. there couple ways answer this: custom url scheme: https://developer.apple.com/library/ios/documentation/iphone/conceptual/iphoneosprogrammingguide/advancedapptricks/advancedapptricks.html ( communicating other apps section) this requires app attempting up-sell in fact implement custom url scheme, simple thing implement. once have url scheme, can make method checks: canopenurl: returns whether app can open given url resource. (bool)canopenurl:(nsurl *)url (in uiapplication) if want more significant data exchan

system - Retrieving Last Boot Time Stamp In C -

i've been able retrieve uptime value proc/uptime (which in seconds). however, need retrieve last boot time stamp using c. (i cannot use system() function call uptime). for example, correct time need is, when run "uptime", value is: 15:31:35 2 days, 4:14, 3 users, load average: 0.04, 0.05, 0.05 i need first part: 15:31:35. there built in c function can me this? appreciated! open /proc/uptime , read it. first number uptime in seconds.

Call method from another app (Jailbreak iOS) -

on jailbroken ios device, possible 1 app call method app (an instance method, not static one)? way of phrasing this: how can instance of app (assuming app running) can call 1 of methods? background: trying call function in music player app hooked method in ipodui private framework (see this post more details). this question has been asked android , didn't find jailbreak ios. if that's because i'm asking wrong question , there's different approach take, i'm open that. an easy , alternative way achieve cycript , system() call, please beware of dangers of using system() before using potentially insecure (which is, opinion, not important on jailbroken ios pretty unsafe) let's have method [[someclass sharedinstance] methodtobecalledexternally] want call other process you can save call text file in /tmp/something.cy then inject code externally running: cycript -p music /tmp/something.cy but if need programatically, , of course if environm

java - Setting text to a custom dialog class -

i trying build custom dialog setting text dynamically. here code throwing nullpointerexception . updataed code listview.setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { homeitem homeitem = (homeitem) adapter.getitem(position); final dialog dialog = new dialog(databasefightcard.this, android.r.style.theme_black_notitlebar_fullscreen); windowmanager.layoutparams lp = (dialog.getwindow().getattributes()); lp.dimamount = 0.5f; dialog.getwindow().addflags(windowmanager.layoutparams.flag_dim_behind); window window = dialog.getwindow(); window.setgravity(gravity.center); dialog.setcontentview(r.layout.custom_dialog); layoutinflater inflater = (layoutinflater) databasefightcard.this.getsystemservice(context.layout_inflater_service); relati

networking - Testing a software bridge application using virtualization -

Image
good evening, i stuck @ point of development.. part of routing/switching course, have program 2 port software switch/bridge.. main problem me testing it.. dont have multiple network cards in laptop, , have 1 computer. need simulate topology this: however, dont know how it.. have windows xp installed 2 virtualbox machines.. dont know how set make work.. neither network option sufficient(nat, bridge, host only...) can please me? i thank in advance advice. robert why don't split single network port multiple subinterfaces eth0:1 eth0:2 etc. can run switching program on these subinterfaces. can work on subinterfaces same way work regular interfaces, though these subinterfaces bydefault attached parent interface.

malloc - C - writing buffer into a file then FREEing the buffer cause segfault -

i'm writing buffer binary file. code in following : file *outwav = fopen(outwav_path, "wb"); if(!outwav) { fprintf(stderr, "can't open file %s writing.\n", outwav_path); exit(1); } [...] //create sample buffer short *samples = malloc((loopcount*(blockamount-looppos)+looppos) << 5); if(!samples) { fprintf(stderr, "error : can't allocate memory.\n"); exit(1); } [...] fwrite(samples, 2, 16*k, outwav); //write samplebuffer file fflush(outwav); fclose(outwav); free(samples); the last free() call causes me random segfaults. after several headaches thought because fwrite call execute after delay, , read freed memory. added fflush call, yet, problem still occurs. the way rid of not free memory , let os me. supposed bad practice though, i'd rather ask if there no better solution. before asks, yes check file opened correctly, , yes test memory allocated properly, , no, don't touch returned pointers in

sl4a python make a Toast for android phone -

i wrote 3 lines in python using sl4a : import android droid = android.android() droid.maketoast(u"ascc4r") when code runs, following error: pydev debugger: starting traceback (most recent call last): file "c:\users\tibi\desktop\adt-bundle-windows-x86_64-20130917\eclipse\plugins \org.python.pydev_2.8.2.2013090511\pysrc\pydevd.py", line 1446, in <module> debugger.run(setup['file'], none, none) file "c:\users\tibi\desktop\adt-bundle-windows-x86_64-20130917\eclipse\plugins org.python.pydev_2.8.2.2013090511\pysrc\pydevd.py", line 1092, in run pydev_imports.execfile(file, globals, locals) #execute script file "c:\users\tibi\workspace\26\src\26module.py", line 7, in <module> droid = android.android() file "c:\python26\lib\android.py", line 34, in __init__ self.conn = socket.create_connection(addr) file "c:\python26\lib\socket.py", line 547, in create_connect

php - Fatal error: Can't use function return value in write context in.. when i'm trying to display my errors in register.. using array display -

i have php code here: if(empty($_post) === false) { $required_fields = array('username','password','confirm_password','first_name','email'); foreach($_post $key=>$value) { if(empty($value) && in_array($key, $required_fields) === true) { $errors() = 'fields marked asterisk required'; break 1; } } } print_r($errors); what i'm trying display arrays can figure out where's error.. browser said fatal error: can't use function return value in write context in .. , marks fatal error in statement. $errors() = 'fields marked asterisk required'; help me please.. anyway registration-form.php :) change bracket square ones: $errors[] = 'fields marked asterisk required';

iphone - controlling order of received data in NSURLConnection? -

i have array of urls use receive associated images remote server using nsurlconnection nsurl *url = [nsurl urlwithstring:urlstring]; nsmutableurlrequest *urlrequest = [nsmutableurlrequest requestwithurl:url cachepolicy:nsurlrequestuseprotocolcachepolicy timeoutinterval:2.0f]; // run network request asynchronously nsurlconnection *urlconnection = [[nsurlconnection alloc] initwithrequest:urlrequest delegate:self]; in delegate protocol - (void)connection:(nsurlconnection *)connection didreceivedata:(nsdata *)data { // chuncks of image received, build our data file [self.imagedata appenddata:data]; } and - (void)connectiondidfinishloading:(nsurlconnection *)connection { // data has been downloaded, can set image in images array _img = [uiimage imagewithdata:self.imagedata]; [self.imagesarray insertobject:_img atin

ffi - How to bring methods from a module into the scope of the caller of a method in ruby? -

the code should this: def bring_into_scope(module) #here caller of method should methods +module+ end class bar def bar_method #do stuff end end class foo def initialize(bar) bring_into_scope(bar) bar_method end end i need functinality because want write library inlines rust code, 1 should able write: class rustandruby def ruby_method; end #this should make fn's in rust code available in rustandruby rust.code { "string rust code..." } end is possible in ruby? (if need further information feel free ask!) maybe take @ this , written 1 of main contributors of rust.

unix - ": No such file or directory" when file exists -

i'm having problems code, it's saying file not exist, when know does. code follows: #! /bin/ksh echo "enter file name" read filename if [ -e $filename ];then less -m $filename gedit $filename else echo "$filename not file" fi i've missed blindingly obvious... wish knew was. anyway, appreciated. i see 2 options here: a typo in the variable name pressing enter without file name. either way can resolved adding set -u top of script, or using parameter expansion test: ${...:?} finally, it's better deal exceptions first, , try report happens. error message in original script far removed actual test, , not reflect test did. in case, it's better let system tell what's wrong. below example #! /bin/ksh echo "enter file name" read filename && [[ -e ${filename:?} ]] || exit less -m ${filename:?} || exit gedit ${filename:?}

java - What is the Fastest way to reorder an array -

what fastest (realtime data processing application) way reorder (the new indices same) array in java: e.g.: have got: double[] = new double[] {1, 234, 12,99,0}; i need swiftly: double[] b = new double[] {a[2], a[4], a[0],a[1],a[3]}; but maybe this efficient way anyway? many feedback i doubt can better current approach of double[] b = new double[] {a[2], a[4], a[0], a[1], a[3]}; likely candidates other sequences might forms of arrays.copyof or arrays.copyofrange , minimum amount of work must here consists of: create new array random access each element in array there's small chance might better specific read/write orders (to take advantage of cache lines), 1 guess reads entirely in order , writes entire in ascending order: double[] b = new double[a.length]; b[2] = a[0]; b[3] = a[1]; b[4] = a[3]; b[0] = a[2]; b[1] = a[4]; but don't have strong expectations of being noticeably better. if you're @ point you're

excel vba - Hide last column in range and clear cells -

i have checklist workbook allows check multiple items within work order. maximum amount of items 15. have piece of code allow me hide columns, starting farthest right, not needed cannot figure out how clear range within column hidden. need clear data row 7, 10, & 13:28 of column hidden. here have: sub removeitem() dim long = 20 7 step -1 if columns(i).hidden = false bfirst = true columns(i).hidden = true exit end if next end sub any appreciated, thanks! this can done better, below code job done: sub test() dim long = 20 7 step -1 if columns(i).hidden = false bfirst = true columns(i).hidden = true rows(7).clearcontents rows(10).clearcontents range(cells(13, i), cells(28, i)).clearcontents end if next end sub

r - How can I make the legend in ggplot2 the same height as my plot? -

Image
i have generated simple plot in r (version r version 3.0.1 (2013-05-16)) using ggplot2 (version 0.9.3.1) shows correlation coefficients set of data. currently, legend colorbar on right side of plot fraction of entire plot size. i legend colorbar same height plot. thought use legend.key.height this, have found not case. investigated grid package unit function , found there normalized units in there when tried them ( unit(1, "npc") ), colorbar way tall , went off page. how can make legend same height plot itself? a full self contained example below: # load needed libraries library(ggplot2) library(grid) library(scales) library(reshape2) # generate collection of sample data variables = c("var1", "var2", "var3") data = matrix(runif(9, -1, 1), 3, 3) diag(data) = 1 colnames(data) = variables rownames(data) = variables # generate plot corrs = data ggplot(melt(corrs), aes(x = var1, y = var2, fill = value)) + geom_tile() + geom_te

visual studio 2010 - Calculating Factorials in C# - No Errors, But Doesn't Work? -

i have simple program supposed calculate factorial of entered number. says have no errors, when run program stalls , not work. can please tell me why? private void getfactorial_click(object sender, eventargs e) { int usernumber, numberfactorial = 1; usernumber = int.parse(numberinput.text); if (usernumber <= 0) { numberoutput.text = numberfactorial.tostring(); } else { (int = 1; 1 <= usernumber; i++) { numberfactorial = numberfactorial * i; numberoutput.text = numberfactorial.tostring(); } } } } } it's simple things us. in loop have this: for (int = 1; 1 <= usernumber; i++) i believe mean this: for (int = 1; <= usernumber; i++) in conditional part of loop used '1' rather 'i'.

html - What's a cross-browser way to build 2-fixed-width-columns separated by fluid padding? -

Image
looking build 2-fixed-width-columns , each width: 320px; , height: 95%; what's way have them centered on page, separated 15% padding/margin? here's prospective layout: are looking op, problem ran couldn't set wrapper {width: 100%} think needs set width, isn't 100%. anyway here codepen http://codepen.io/anon/pen/zydkk

c - Segmentation fault with struct array -

trying calculate left point in array of points, program blows on me (segmentation fault (core dump) error). here's interface: //points.h #define max_points 100 struct point { char label; int x; int y; }; int leftmostpoint(struct point points[], int numpoints); here's leftmostpoint implementation: //points.c //get point smallest x value int leftmostpoint(struct point points[], int numpoints) { int smallestx = points[0].x; //assume first point smallest int index; (int = 1; < numpoints; i++) { if (points[i].x < smallestx) { smallestx = points[i].x; index = i; } } return points[index]; } here's magic happens: //magic.c struct point points[max_points]; //build array via standard input (this works, tested printing points) //only 5 points added in displaypoint(points[0]); //works displaypoint(points[4]); //works struct point hull; hull = leftmostpoint(points, numpoints); //this program blows i pret

sql server - When backup run on the schedule time 12am every night, It says the backup job completed successfully but I cannot see the backup file on the drive -

anybody have solution this. when backup run on schedule time 12am every night, says backup job completed cannot see backup file on drive. job message details date 10/6/2013 12:00:02 log job history (maintenancejob_fullbackup) step id 2 server sgksltusql04clt job name maintenancejob_fullbackup step name 2 - taking full backup of database duration 00:27:16 sql severity 0 sql message id 3014 operator emailed operator net sent operator paged retries attempted 0 message executed user: xxx\yyy. ...e 'workforcedw' on file 1. [sqlstate 01000] (message 4035) processed 4 pages database 'workforcedw', file 'workforcedw_log' on file 1. [sqlstate 01000] (message 4035) backup database processed 1396804 pages in 118.187 seconds (96.817 mb/sec). [sqlstate 01000] (message 3014) processed 12616 pages database 'msdb', file 'msdbdata' on file 1. [sqlstate 01000] (message 4035) processed 8 pa