Posts

Showing posts from September, 2011

ios - What conditions can prevent layoutSubviews from being called after setNeedsLayout? -

the problem in custom view of mine (a uiscrollview subclass) calling setneedslayout in response "reload data" event (triggered external source). of time works correctly , layoutsubviews called when next view layout cycle occurs. sometimes, however, layoutsubviews not called! until living "certain knowledge" setneedslayout always triggers layoutsubviews . apparently wrong. tried calling layoutifneeded after setneedslayout , still no success. the question obviously, solve particular problem. on other hand, improve understanding of view layout process on ios, formulating question in general way: know of conditions can prevent layoutsubviews being called after setneedslayout has been called? answers focus on uiscrollview quite welcome, since having trouble. problem context i on ios 7.1, using xcode 5.1.1. notes on implementation of custom scroll view: the scroll view has single container view of type uiview same size scroll view content size ...

csv - Downloading Many Files using Python Web-Scraping -

if have link csv on yahoo finance: http://ichart.finance.yahoo.com/table.csv?s=low&d=4&e=29&f=2014&g=d&a=8&b=22&c=1981&ignore=.csv how write web scraper download multiple files based on list of symbols: [low, spy, aapl] from stringio import stringio urllib2 import urlopen symbol in symbols: f = urlopen ('http://www.myurl.com'+symbol+'therestoftheurl') p = f.read() d = stringio(p) f.close do need write contents of url file, or download automatically directory? you can use method download files: import urllib2 file_name = "myfile.xyz" u = urllib2.urlopen(url) f = open(file_name, 'wb') block_sz = 4096 while true: buffer = u.read(block_sz) if not buffer: break f.write(buffer) f.close()

dynamics crm 2011 - Find out what's hitting the CRM Organization.svc -

saving record in crm quick, saving same record through organization service taking lot longer. there way see logs organization.svc, or see requests being made on it? there other applications may using organization.svc. i believe hardest part application building of service proxy. question - recreate , reopen connection crm endpoint everytim perform operation? in case yes - suggest store organizationservice proxy somewhere use in code.

raspberry pi - Streaming too fast with avconv on Raspbian to justin.tv via RTMP -

i want stream *.mp4 files justin.tv using avconv on raspbian. i'm using following command this: avconv -i ./${file_to_stream} \ -vcodec copy \ -acodec copy \ -threads 0 \ -r 24 \ -f flv rtmp://live-fra.justin.tv/${secret_key} i can see stream short time on justin.tv it's streaming fast. stream jumps part of file , plays part, after time jumps again, , on. fps far high can see in output of avconv says: frame= 2673 fps=423 q=-1.0 lsize= 4431kb time=106.58 bitrate= 340.6kbits/s the frames , time increasing fast, seen in fps. hoped clamp fps -r 24 command, it's still on >200 fps. can do? solved adding -re parameter read input @ native framerate. so worked me: #!/bin/bash avconv -re \ -i ${file_to_stream} \ -threads 0 \ -vcodec copy \ -acodec copy \ -f flv rtmp://live-fra.justin.tv/${secret_key}

ios - Auto Layout defining constraints -

i have 2 buttons on uiview . want horizontal distance between these 2 buttons should, 20% width of superview? any this? you can accomplish using empty dummy view in between 2 buttons, width 20 % of width of superview. in code, this: // important thing here buttons flush against spacer [superview addconstraints: [nslayoutconstraint constraintswithvisualformat:@"[button1]-0-[spacer]-0-[button2]" options:0 metrics:nil views:@{@"button1" : button1, @"button2" : button2, @"spacer" : spacer}]]; // here, set width of spacer 20% of super view [superview addconstraint: [nslayoutconstraint constraintwithitem:spacer attribute:nslayoutattributewidth relatedby:nslayoutrelationequal toitem:superview attribute:nslayoutattributewidth multiplier:0.2 constant:0]];

windows phone 8 - wp8 background gps tracker stop working -

i want implement application windows phone 8 in order , send device location data server every minute. for have followed example: http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj662935(v=vs.105).aspx instead of using: app.geolocator.movementthreshold = 100; i use: app.geolocator.reportinterval = 1 *60 * 1000; the app works in foreground. if press start button app works following limitations: if open appication, backgroud gps tracker stop working. after 1 hour aproximately, or more, background gps tracker stop working too. i have read apps running in background can deactivated system due factors: http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj681691(v=vs.105).aspx is there way or strategy assure gps tracker keep working in background under above 2 conditions? there wp8 application working under conditions? possible or not in wp8? you must add snippet in wmappmanifest.xml in order keep gps running in background: ...

How to use jzy3d in android using eclipse? -

Image
hi. want create 3dplot graph in android. want use jzy3d lib , found example beginning. import org.jzy3d.chart.chart; import org.jzy3d.colors.color; import org.jzy3d.colors.colormapper; import org.jzy3d.colors.colormaps.colormaprainbow; import org.jzy3d.maths.range; import org.jzy3d.plot3d.builder.builder; import org.jzy3d.plot3d.builder.mapper; import org.jzy3d.plot3d.builder.concrete.orthonormalgrid; import org.jzy3d.plot3d.primitives.shape; import org.jzy3d.plot3d.rendering.canvas.quality; import org.jzy3d.ui.chartlauncher; import android.os.bundle; import android.app.activity; import android.view.menu; public class mainactivity extends activity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); mapper mapper = new mapper() { public double f(double x, double y) { return 10 * math.sin(x / 10) * math.cos(y / 20) * x; } }; // define range...

Old sendmail with Perl need to embed attachment -

before says need use mime::lite or pm... job has base set of pms , can't change them... need working within confines of system: we have been using code send email our clients years: open mail, "| /usr/lib/sendmail -t"; print mail qq[to: $email from: myfoofoo\@www.foobar.com reply-to: not reply subject: subject hello, body of message thank ]; close mail; now, asking me embed image in email... have tried use unix sendmail - html embed image not working reference, can't figure out boundary/mime types... you have build mail mime message multipart/related , feed sendmail. see http://tools.ietf.org/html/rfc2110 , contains examples of how such mail looks , how embed images html mail etc. need way base64 encode data, either can use mime::base64 it, external command line tool or program in few lines (see source of mime::base64).

mysql - How to insert a string with ' and " in sql table -

i want insert string both ' , " database. know how handle one, when both present, can use escape characters? depending on database software (mysql? oracle?) in mysql, escape single quote backslash: \' in oracle use double quote: '' (this 2 single quotes). there no need escape " . also added bonus, should not doing this. use @ least "parametrized queries" or orm (object relation mapping) framework.

Reusable CSS when different breakpoints are needed? -

im trying make css modular , reusable possible. im using media query style table differently large , small screen widths. issue different tables need breakpoint @ different widths. its not code maintenance duplicate same code , change breakpoint , selectors change breakpoint specific table, have other choices? im sure sass or less solve im not using them, plain old css.

Java: While loop does not exit -

does 1 have idea why while exits if theres system.out.println()? the same code doesn't work if comment out println() do{ system.out.println(""); if(haswon()){ inout.out(output() + "\nyou won"); system.exit(0); } } while (!haswon()) the program follows static final int gridsize = integer.parseint(inout.in(1, "enter grid size")); static tile[][] board = new tile[gridsize][gridsize]; static int wincond = 1; static guiframe f = new guiframe(gridsize); static btnpanel p = new btnpanel(gridsize); static jbutton[][] btn = new jbutton[gridsize][gridsize]; public static void main(string[] args) { //creating objects (int = 0; < gridsize; i++) { (int z = 0; z < gridsize; z++) { board[i][z] = new tile(); } } gui(); while (!haswon()) { system.out.println(""); if(haswon()){ inout.out(output() + "\nyou won"); ...

javascript - "Node.js / Edge.js - Insert JS variables into SQL" part 2 -

here's original question . okay, i'm using node.js , edge.js insert values sql database. first attempt straightforward insertion of hardcoded values: var insertrow = edge.func('sql', function () {/* insert dbo.table (column0, column1, column2) values (value0, value1, value2) */}); insertrow(); this hardcoded insertion works expected, of course. , seen in answer of question before me, passing function object allows sql statement recognize name/value pair of object via @, allowing dynamic value assignment: var rowobj = { v0: 'value0', v1: 'value1', v2: 'value2' } var insertrow = edge.func('sql', function () {/* insert dbo.table (column0, column1, column2) values (@v0, @v1, @v2) */}); insertrow(rowobj); works expected. have table , columns variable well, through properties provided same rowobj. tried: var rowobj = { t: 'dbo.table', c0: 'column0', c1: 'column1'...

standards of using and naming of pointer to function as delegates in C++ -

there questions in mind: what standard naming pointer functions delegates? what best way define signature of functions in matter? what techniques of maintaining safety , stability of code when using pointers? there no standard such naming, conventions vary project project (or company company). common rules include avoiding leading underscores in such names (reserved standard library) there no best way "define signature", it's same other functions: choose explicit , clear names both method name , arguments. the best advise avoid explicit pointers functions , , prefer using std::function , powerful polymorphic function wrapper.

laravel - Exception if object doesn't exists -

in application id route/url. should in controller if there no object id? my favorite solution throw 404. idea? there helpers common problem? // url /groups/1 public function group($group_id) { if (! group::find($group_id)) { app::abort(404); } } in django there short cut function problem. https://docs.djangoproject.com/en/1.6/topics/http/shortcuts/#get-object-or-404 eloquent::findorfail($pk) looking for. throw modelnotfoundexception . here's how set up: controller public function group($group_id) { // throw app::error() when $group_id doesn't exist $group = group::findorfail($group_id); } routes (or similar) app::error(function(illuminate\database\eloquent\modelnotfoundexception $e) { // ran when ::findorfail() doesn't find object app::abort(404); });

Simple variable assignment from two-dimensional array in php -

i have two-dimensional array 2 key values, [program] , [balance], created mysql select statement in wordpress. know values of [program] (they never change) - it's balances i'm interested in. for example: *[program] = 'sales', [balance] = 10,000* *[program] = 'commission', [balance] = 1,250* all want assign balance value variable, have: *$sales = (the balance sales program)* *$commission = (the balance commission program)* i know i'm being thick here, cannot see how after hour of searching , screwing around php. it's total brain block , references can find online talk loops , echoing values , stuff. would appreciate de-blocking! //make function function findbalancebyprogram($inputarray,$program) //loop trough keys on first dimension foreach($inputarray $val){ //check in second dimension if program same program checking if($val['program']==$program) //if so.. return value , jump out of function retu...

c++ - Weird boolean conversion (?) -

explain pleasy why second expression returns false cout << (4==4) << endl; //1 cout << (4==4==4) << endl; // 0 (4==4==4) ((4==4)==4) (true == 4) (1==4) 1 false 2 getting printed 0 . note == has associativity left-to-right , doesn't matter (in this case) because if had associativity right-to-left, result have been same. 1. due integral promotion. 2. note 1 might tempted think 4 in (true==4) treated true (after 4 non-zero, hence true ). thinking might conclude (true==4) (true==true) true . not how works. bool gets promoted int, instead of int bool.

heroku - Sending SMS from rails app -

i building medication reminder system using ruby on rails deployed on heroku. using system doctor enter patient's medication details including medication name, dose timing details , app notify patient via sms when time take his/her medicine. i have developed application stuck on sms part since involves running process on , on again until medication's period has elapsed. i want able run script rails app repeatedly query database , when time send sms dispatch patient. cannot function in normal request/response web cycle. i explored rubygems allow developers create background jobs such rufus scheduler , resque can't seem figure out how go doing this. please open types of suggestions. using twilio sending sms i don't know resque/rufus, know sidekiq has ability queue jobs, have them delayed till time. https://github.com/mperham/sidekiq/wiki/delayed-extensions#advanced-options you'd need how exact delay (ie. sidekiq's polling frequency is) d...

java - YourKit - The retained size of an object doesn't equal the retained size of all the objects referred by it -

Image
the retained size of object doesn't equal retained size of objects referred it. here happening: using yourkit capture memory snapshot. click on object & show instances class type let's instance's retained memory bytes (600mb) expand , sum retained size underlying instances let's sum b (300mb) a >> b let me give example. first of all, need understand retained size is. official documentation : retained size of object shallow size plus shallow sizes of objects accessible, directly or indirectly, object. in other words, retained size represents amount of memory freed garbage collector when object collected. in simple retained size of object indeed sum of objects referred it. in picture below retained size of obj1 sum of obj1 shallow size, , obj2 , obj3 retained size: this not case in more complicated referencing models. if obj6 starts referencing obj5, obj5 not accessible obj2. retained size of obj2 include obj4, , excl...

Draggable and Droppable jquery UI within same table -

i working on mvc application , have faced situation. when googled didnot find this. situation follows:- have table follows:- <table> <thead> <tr> <th>test1</th> <th>test2</th> <th>test3</th> <th>test4</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>1</td> <td>1</td> <td>1</td> </tr> <tr> <td>2</td> <td>2</td> <td>2</td> <td>2</td> </tr> <tr> <td>3</td> <td>3...

java - Collections with limited size -

this question has answer here: define fixed-size list in java 7 answers is there collection allows me limit number of elements allowed? what need collection size of 5 elements, when collection full, new element can added, oldest element of collection replaced new element. you can extend old arraylist (or other implementation fits best). import java.util.arraylist; public class limitedcollection<e> extends arraylist<e> { public static final int max_elements = 2; @override public boolean add(e e) { if (this.size() < max_elements) { return super.add(e); } else { return false; } } }

javascript - Control flow of an IF statement & Asynchronous function -

my code structured follows: if (something) { ..stuff ..asynchronous function call } else (something) { ..stuff ..asynchronous function call } ..more stuff let's if condition met, code executes 'stuff', moves onto asynchronous function call. simple call out of if statement , execute 'more stuff' in mean time on assumption of waiting asynchronous function call finish? or does finish waiting asynchronous function call finish executing, continue 'more stuff' normal if statement block do. in prior case, advice on how ensure asynchronous function call finished before exits if block? ** note, i've included more stuff inside both asynchronous function calls ensure calls done before moves on, feel bad programming because if had 50 elif's, have copy paste code 50 times opposed putting @ end of if statement. thank provided! you can approach , less painfully using javascript promises. have following links: http://davidwalsh.name/wri...

php - Strpos find brand names -

$pos = strpos($arr_row1['name'], $arr_row['value']." "); if ($pos !== false){ the following code helps me match product title brand have array of brands "gopro", "hp" etc... unusual brands such "dy" "ge". problem code match "ready" brand "dy " , if chacne match " " . brand . " " not match brands title if stars "hp laptop" ideas how avoid issues , still match right brand title? try following : $pos = preg_match('/\b('.$arr_row1['name'].')\b/', $arr_row['value']); if ($pos == 1) {

Why people say "emacs is good for writing lisp program because it's written in emacs lisp"? -

i can imagine ides eclipse written in java writing java program because tool , language tightly integrated. if 1 "emacs writing emacs lisp programs" make sense in same way me. but people emacs lisp dialects, if lisp dialects , emacs tightly integrated naturally. not emacs lisp, not language, not langauge use repl, lisp dialects. why? there in emacs lisp shared between lisp dialects not in other languages -- including these using repl, unique lisp dialects benefit this? come examples? you're right there's little reason emacs have technical benefit generic lisp environment. it's not 0 though -- since emacs has support makes easy parse lisps, since surface syntax (s-expressions) similar. still technicality. the real reason emacs comes times when there less variance among lisps (in syntax sense, semantics different issue), choice of sophisticated lisp editing environment. such, enjoys benefits of literally decades of lispers used lisp editing , the...

python - Optimize Cython code for numpy variance calculation -

i trying optimize cython code , there seems quite bit of room improvement here part of profile %prun extension in ipython notebook: 7016695 function calls in 18.475 seconds ordered by: internal time ncalls tottime percall cumtime percall filename:lineno(function) 400722 7.723 0.000 15.086 0.000 _methods.py:73(_var) 814815 4.190 0.000 4.190 0.000 {method 'reduce' of 'numpy.ufunc' objects} 1 1.855 1.855 18.475 18.475 {_cython_magic_aed83b9d1a706200aa6cef0b7577cf41.knn_alg} 403683 0.838 0.000 1.047 0.000 _methods.py:39(_count_reduce_items) 813031 0.782 0.000 0.782 0.000 {numpy.core.multiarray.array} 398748 0.611 0.000 15.485 0.000 fromnumeric.py:2819(var) 804405 0.556 0.000 1.327 0.000 numeric.py:462(asanyarray) seeing program spending 8 seconds calculating variance hoping able sped up i calculating variance using np.var() of 1d array length 404 ...

c# - Cannot Install Web Grease 1.5.1 -

when try install web grease 1.5.1 error: you cannot call method on null-valued expression. @ l:\project_path\packages\webgrease.1.5.2\tools\install.ps1:45 char:5 + $msbuild.xml.addproperty("webgreaselibpath", $relativepackageuri.tostring(). ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + categoryinfo : invalidoperation: (:) [], runtimeexception + fullyqualifiederrorid : invokemethodonnull delete folders inside "packages" folder in application folder. try reinstall web grease nuget. see if solves issue.

javascript - Wrap library with thunkify for co -

i wondering how thunkify (wrap in thunk) library use co. library following. client calls use other objects in library. library.client = function(opts) { } library.client.prototype.createlist = function(opts, cb) { options.client = this; var list = new library.list(opts, function(err, data) { if (typeof(cb) === 'function') { cb(err, list, data); } }); } library.list = function(opts, cb) { // setup opts if (cb) this.fetch(cb); } library.list.prototype.fetch = function(cb) { var list = [1,2];// list (var = 0; < list.length; i++) { list[i] = new library.item(list[i]); }); if (typeof(cb) === 'function') cb(err, data); } library.item = function(opts) { } exports.client = library.client; exports.list = library.list; exports.item = library.item; then use library this. var client = new library.client(opts); client.createlist(); here's library want: https://www.npmjs.org/package/thunkify-wrap

Consuming Paypal REST API from C# -

im trying simple test rest api based on curl example: https://developer.paypal.com/docs/integration/direct/make-your-first-call/ curl -v https://api.sandbox.paypal.com/v1/oauth2/token \ -h "accept: application/json" \ -h "accept-language: en_us" \ -u "eoj2s-z6oon_le_ks1d75wsz6y0sfdvsy9183ivxfyzp:eclusmeuk8e9ihi7zdvlf5cz6y0sfdvsy9183ivxfyzp" \ -d "grant_type=client_credentials" my c#: var h = new httpclienthandler(); h.credentials = new networkcredential("client_id", "secret"); var client = new httpclient(); client.baseaddress = new uri("https://api.sandbox.paypal.com/v1/oauth2/token"); client.defaultrequestheaders.accept.add(new mediatypewithqualityheadervalue("application/json")); client.defaultrequestheaders.add("accept-language", "en_us"); var requestcontent = new formurlencodedcontent(new[] { new keyvaluepair<string, string>("grant_type", "client...

New to java, need to learn how to store multiple Doubles with the same name -

i new java , want learn how store different values double. code asks user how many times calculate equation, each time entering different values. program takes numbers entered plugs them formula , produces answer. problem comes trying take answers generated , totaling them, have no idea how this. double wt, rep, t = .0333333, rm = 0, lts; string initwt, initrep, lt; lt = joptionpane.showinputdialog ( "how many lifts calculate" ); lts = integer.parseint (lt); if (lts < 0){ joptionpane.showmessagedialog (null, "you entered invalid number"); system.exit(0); } while (lts > 0){ initwt = joptionpane.showinputdialog ( "please enter inital weight" ); wt = integer.parseint (initwt); initrep = joptionpane.showinputdialog ( "please enter amount of reps" ); rep = integer.parseint (initrep); /* want take each rm value, , store it, can total later.*/ rm = wt * rep * t + wt; joptionpane.showmessagedialog (null, "your 1 rep max ...

objective c - Should I need to unbind cocoa-bindings in dealloc of windowController? -

Image
i have window controller , view controller use core data bindings, want able have views really, deallocated. want reset managedobjectcontext , @ point have given memory possible. i have found required unbind things i've bound in nib, or moc keeps nib objects retained. the issue exec_bad_access trace: if not unbind of bindings, created in interface builder, reset on moc causes exec_bad_access because bindings attempting reflect changes in moc in view that's gone, through array controller should gone, isn't. so did in window controller's dealloc: - (void) dealloc { nslog(@"wincon dealloc"); @autoreleasepool { // remove subview ensure subview dealloc [_viewcontroller.view removefromsuperviewwithoutneedingdisplay]; // tear down bindings ensure moc can reset (nsobject<nskeyvaluebindingcreation>* object in @[_watcherac, _watcherstimestreecontroller, _watchertableview, _itemsoutlineview]...

performance - My Haskell Solution to Euler #3 is Inefficient -

i attempting solve euler problem 3 in haskell, involves finding largest prime factor of number. code runs long time , seems hang. causing code grossly inefficient? primes = sieve (2:[3,5..]) sieve (x:xs) = x:[y | y <- (sieve xs), mod y x /= 0] sieve [] = [] primefactors n = filter (\x -> mod n x == 0) (primesunder n) primesunder z = reverse (takewhile (< z) primes) solve3 = head (primefactors 600851475143) your main problem you're checking enormous primes -- way 600851475143 . can improve things lot observing 2 things: every time find prime, can decrease maximum prime @ dividing away factor. you have primes until reach square root of target. if primes bigger that, , know there no smaller factors, you're done. using these 2 improvements together, without nicety used of checking primes divisibility, makes program run in snap: factor = go (2:[3,5..]) go (p:ps) n | p*p > n = [n] | n `mod` p == 0 = p : go (p:ps)...

ruby - how do I set up RPush in rails? -

i'm bit confused on how of config rpush when starting rails environment. if want rpush.embed , run within same process, should call rpush.embed? go in initializer? unclear on best place set apps. see there nice feature signaling rpush re-read configured app, configure app itself? see can active model calls, don't want create new app everytime start rack (or rails). create apps using database migration, put rpush.embed in config.ru

python - How do I make Flask stream a static file with HTTP 206 Partial Content? -

i want use looping video on site made powered flask. apparently, chrome not loop video, unless streamed http 206 code being returned . flask, however, returns static file http 200. how stream static content flask project (hosted on heroku, record) make video correctly loop in chrome? reponse objects in flask have "status_code" parameter can pass. see this documentation more details, essentially, may want subclass response object. also take @ make_response() - may reveal simpler way, depending on application structure. take @ streaming pattern more details, it's geared towards generated content opposed static.

apache - Sinatra app with Grape API -

i'm running sinatra app along grape. i've seen other postings on in how run 2 or other rack compliant solutions, though quandary bit different. i need preface solutions i've noticed run 2 show have grape mounted on route, though that's not i'm doing. simply: rack::cascade.new[sinatraapp,grapeapi] working should, except when deployed out apache noticed stderr logs out calls api 404, though returning json. i setting mime types out default_format :json on grape routes. not happening? have angular making calls grape via $http service , i confirm in dev tools receiving application/json types. what doing wrong here?

javascript - NativeClient : How to use Messaging_HandleMessage in C -

i've got problem c code , lack of informations nacl in c painful... use earth example .png loaded javascript , send c module when message don't know how convert ppb_vardictionary, got idea ? here c method : static void messaging_handlemessage(pp_instance instance, struct pp_var message) { fprintf(stdout, "%i\n", message.type); if(message.type == pp_vartype_dictionary) { ppb_vardictionary *dictionary = null; dictionary->create(); } } thanks in advance reply. unlike c++, can pass pp_var ppb_vardictionary interface directly. if correct type, work. if not, give error. you can take @ nacl_io_demo example (examples/demo/nacl_io in nacl sdk) see how works. in case, can this: ppb_var* g_ppb_var = null; ppb_vardictionary* g_ppb_var_dictionary = null; pp_export int32_t ppp_initializemodule(pp_module a_module_id, ppb_getinterface get_browser) { g_ppb_var = (ppb_var*)(get_browse...

java - How do I import images using ImageIcon? -

here's code, , i've got 2 problems evidently: package test; import javax.swing.imageicon; import javax.swing.jpanel; import java.awt.component; public class { public static void main(string[] args) { imageicon icon = new imageicon("src/icon.png",("what great image")); jpanel window = new jpanel(); window.setlocation(100,100); window.setsize(300, 500); window.setvisible(true); } so don't know why jpanel won't reveal itself, , importing image right? i've created icon , placed in src folder. if i'm not importing right, how import then? question applies graphics swing since i'm interested in learning soon. so don't know why jpanel won't reveal itself you've not added can displayed. jpanel plain container allow add other components onto it. you need kind of window display container, example... jpanel window = new jpanel(); jframe frame = new jframe("testing"); frame.s...

javascript - Iterating through mutiple checkbox values and matching them against a single text input box's value with jQuery -

i trying check if value string of text input field contains matches correspond values of multiple checkbox inputs. if checkbox's value found match within text input's value string, checkbox should checked, while unmatching checkbox should remain unchecked. code below, of checkboxes show checked, while 1 of checkbox's value match text input's value string. jquery $("input[type='checkbox'][name='hello']").each(function(){ var value = $(this).attr('value'); var id = $(this).attr('id'); if ($("input[type='text'][name='goodbye']:contains("+value+")")) { $("input[id="+id+"]").prop('checked', true); } }); html <input type="checkbox" name="hello" id="1" value="1"><label for="1">one</label> <input type="checkbox" name="hello" id="2" value...

java - JTable header not showing still -

Image
i have looked , found many people weren't putting table scrollpane. though nest table scrollpane frame still fails show header. there else i'm missing ? thanks public class gui extends jframe { abstracttablemodel model; jtable table; public void start(abstracttablemodel model) { this.model = model; table=new jtable(model){ @override public boolean iscelleditable(int arg0, int arg1) { return false; } }; table.setautoresizemode(jtable.auto_resize_off); tablecolumn column = null; (int = 0; < model.getcolumncount(); i++) { column = table.getcolumnmodel().getcolumn(i); column.setpreferredwidth(120); column.setmaxwidth(300); column.setminwidth(50); } jscrollpane pane = new jscrollpane(table); pane.setpreferredsize(new dimension(900,900)); add(pane); setlayout(new flowlayout()); setvisible(true);...

filenames - How to separate the file name and the extension of a file in c# -

this question has answer here: c# - how extract file name , extension path? 3 answers is possible separate name of file it's file type/ file extension. for example have file named sample.text. want separate sample , .txt using c#. can me. thanks. you can use path.getextension : var extension = path.getextension("c:\\sample.txt"); // returns txt ..and path.getfilenamewithoutextension : var filenamewithoutextension = path.getfilenamewithoutextension("c:\\sample.txt"); // returns sample

objective c - Create a subclass of a SKSpriteNode subclass -

let's want create bunch of different types of spaceships. want setup base spaceship class can use create other spaceships minor differences. my base class looks this. // basespaceship.h @interface spaceshipnode : skspritenode @property nscolor color; @property cgfloat enginethrust; + (id)basespaceshipwithimagenamed:(nsstring *)name; @end // basespaceship.m @implementation basespaceship + (id)basespaceshipwithimagenamed:(nsstring *)name { basespaceship *ship = [basespaceship spritenodewithimagenamed:name]; ship.color = [nscolor redcolor]; ship.enginethrust = 2.0; return ship; } @end i can create ship in myscene.m fine. basespaceship *baseclass = [basespaceship basespaceshipwithimagenamed:@"baseship"]; however, i'm not sure how create subclass of basespaceship , example, destroyerspaceship . i'm not sure if should using static methods or not. examples i've seen online use static methods instantiate skspritenode s. came with, it...

Why do my ExtJS 4.2.1 tree nodes no longer expand/collapse? -

Image
i changed icons of extjs 4.2.1 tree panel , nodes not expand/collapse. it seems related css: .navtree .x-tree-elbow-img { height: 0; width: 0; } but need css otherwise there blank space left of new icons. seems clickable area expand/collapse. how remove space occupied tree elbow image, still able click icons expand / collapse nodes? also, expand/collapse nodes if new icon clicked or if text node labels clicked. how can change click targets? also, if comment out above css, collapsing nodes makes white background appear while collapsing, desired background color takes effect. how can not show brief white background? thanks in advance. ext.onready(function() { ext.create('ext.container.viewport', { renderto: ext.getbody(), layout: 'fit', items: [{ xtype: 'treepanel', padding: 0, margin: 0, width: 200, rootvisible: false, lines: false, ...

gorm - Cant access grails one to many relationship data -

i asking dump question new 1 grails. i have 2 domain school , classes class school { static hasmany = [ classes: classes ] } and class classes { static belongsto = [school] } now can not data - if 's' school have c1,c2,c3 classes check 2 ways get. 1. classesinstancelist = classes.findallbyschool(s) it returns null; 2. classesinstancelist = s.getclasses(); it returns follwing error message message: failed lazily initialize collection of role: com.test.school.classes, no session or session closed please suggest can do. stucked . why first 1 not work please explain someone. you can create reference classes domain school , search school object. class classes { static belongsto = [school:school] static constraints = {} } class school { static hasmany = [ classes: classes ] static constraints = {} string tostring(){"$id"} } test: def s = new school() def c = new classes() s.addtoclasses(c) s.save(flush:true...

How to Read xml without knowing its structure -

whether can read xml file without knowing strucutre. can perform kind of mapping between nodes.for example xml <bookstore> <location category="us"> <book category="cooking"> <title lang="en">everyday italian</title> <author>xyz</author> <year>2005</year> <price>30.00</price> </book> <book category="sample"> <title lang="en">everyday italian</title> <writer>abcd</writer> <year>2005</year> <price>30.00</price> </book> </location> <location category="uk"> <book category="cooking"> <title lang="en">everyday italian</title> <author>giada de laurentiis</author> <year>2005</year> <price>30.00</price> </book> <book category="sample...

image - Replace part of filename with javascript -

i want load different images based on screensize, , thought replacing text in filename javascript trick elegantly, long i've got corresponding images named. i'm close this, close won't cut it. http://jsfiddle.net/b7qhz/2/ javascript: if ($(window).width() > 960) { $("div:contains(_small.jpg)").html(function (i, currentval) { return currentval.replace("_small.jpg", "_large.jpg"); }); } html: <img src="...test-image_small.jpg" /> as can see in fiddle, i've got working on text, not filename. ps - don't want load images background-image in media-queried classes. complete function: if ($(window).width() > 960) { $("img[src$='_small.jpg']").each(function() { var new_src = $(this).attr("src").replace('_small', '_large'); $(this).attr("src", new_src); }); } else { alert('less 960'); } ...

html - Hosting Javascript/Css on CDN fails to load on slow connections -

i using various other javascripts/css load google hosted libraries fail load on slow connections. please guide me find alternative solution same. i tried searching solution of them download js/css files , include in project , run, not solution. please find solution slow connections. regards usually javascript or css on cdn loads faster if use libraries hosted google etc. alternative tried attach file/s in project.according that's slow.so have 1 option left.that's copy codes libraries , paste directly html page. point remember that, whatever way try, script or css need downloaded browser in order use them. so,ultimately ways some.but servers google faster of other servers used.so in real time scenario cdn little bit faster.

sas - Running a program in batch mode -

i'm trying open sas in batch mode , i'm confused. i'm able access sas remotely computer school , know how open sas interactively it's slow professor mentioned should use sas in batch mode. based on i've read, opening sas in batch mode opening .sas file code. i open said file, like: sas filename.sas or sas filename (neither has worked me). keep getting invalid file. saved sas files in documents. i'm working mac computer. the basic concept of sas batch mode operation in kind of circumstance that, rather having local pc asking things server, run sas on server directly without having send information local pc. may or may not speed things much, @ least won't have bother updating progress. normal sas operation have file in local sas dm window, push button, sends code server, sends sas engine, compiles , runs it, creates results files, , gives results. batch mode similar, except skip first , last parts; you're in charge of them. start sendin...

javascript - How to make my entire popover backgorund color change -

my problem arrow thing in popover didn't change , still color white. current code: http://jsfiddle.net/gzsh6/19/ css: .popover { background: #be7979; color: white; border-bottom-color: #be7979; border-top-color: #be7979; border-left-color: #be7979; border-right-color: #be7979; } you have change css selector this: .popover.bottom > .arrow:after { border-bottom-color: #be7979; <-----------// replace white color #be7979 border-top-width: 0; content: " "; margin-left: -10px; top: 1px; } .popover.top > .arrow { border-bottom-width: 0; border-top-color: #be7979; bottom: -11px; left: 50%; margin-left: -11px; } .popover.right > .arrow:after { border-left-width: 0; border-right-color: #be7979; bottom: -10px; content: " "; left: 1px; } .popover.left > .arrow:after { border-left-color: #be7979; border-right-width: 0; bottom: -10px; content:...

c# - How do I add an Interface to a MS Proxy Class for MS-CRM 2013 -

so have ms dynamics crm 2013 installation i'm trying integrate items , want send data. have interface (iaccnt) want apply proxy class generated when added service refrence ...xrmservices/2011/organizationdata.svc/ (i added on partial class) when added interface (it had "name" , "accountnumber") going along (i.e. able save items) ... added new item interface didn't have direct corollary ("email") did map (so getter , setter passed data , this.emailaddress1) with change following error on save: error processing request stream. property name 'email' specified type 'microsoft.crm.sdk.data.services.account' not valid. this unexpected i'm sending microsoft.crm.sdk.data.services.account object shouldn't have email on it? , regardless should able send more information needed? there need able add interface proxy class , have save still work? i've tried adding [xmlignore] , [ignoredatamember] on public property impl...

ruby on rails - Use find to select attributes from joined tables -

i have 3 tables, questionsets has_many :questions question has_many :answers answers now answers table has column called "actual_answer" now wanted find can answers actual_answers equal specific value , belongs specific question_set. i have right now: @questionset= questionset.find(params[:id]) @answers = answer.find(:all, :conditions => ["actual_answer=?", someactualanswer]) answers_i_need = [] @answers.each |answer| if answer.question.question_set_id == @questionset.id answers_i_need << answer end end is there better way of doing this, i'm expecting thousand array results , making loop might not perfect way of doing it. thanks! why not use has_many ... :through relation? link to: guides this way can have: questionset has_many :questions has_many :answers, through: :questions question has_many :answers belongs_to :question_set answer belongs_to :question then i...

How to check if xml tag has attributes using SAX Parser in Java? -

i ask problem regarding xml file. want check if xml tag has attributes or not using sax parser in java. any answers? please me... the startelement method of saxparser handler has argument keeps list of attributes associated it. rely on that. example program prints out tags attributes , attribute names associated it. import javax.xml.parsers.saxparser; import javax.xml.parsers.saxparserfactory; import org.xml.sax.attributes; import org.xml.sax.saxexception; import org.xml.sax.helpers.defaulthandler; public class findtagwithattributes { public static void main(string argv[]) { try { saxparserfactory factory = saxparserfactory.newinstance(); saxparser saxparser = factory.newsaxparser(); defaulthandler handler = new defaulthandler() { public void startelement(string uri, string localname, string qname, attributes attributes) throws saxexception { ...

tomcat - How to start two spring boot apps -

im playing spring boot. wanted create 2 microservices interact each other. problem cant start both of them, second app cant launch when first 1 running own tomcat: exception in thread "main" org.springframework.context.applicationcontextexception: unable start embedded container; nested exception org.springframework.boot.context.embedded.embeddedservletcontainerexception: unable start embedded tomcat how can fix this? thank you! you need change port second application uses (to avoid clash same tcp port). 1 way add property server.port = 8090 to application.properties of second application

java - How to set plain header in docx file using apache poi? -

i create header docx document using apache poi have difficulties. have no working code show. ask piece of code starting point. there's apache poi unit test covers case - you're looking testxwpfheader#testsetheader() . covers starting document no headers or footers set, adding them your code like: xwpfheaderfooterpolicy policy = sampledoc.getheaderfooterpolicy(); if (policy.getdefaultheader() == null && policy.getfirstpageheader() == null && policy.getdefaultfooter() == null) { // need create new headers // easy way, gives single empty paragraph xwpfheader headerd = policy.createheader(policy.default); headerd.getparagraphs(0).createrun().settext("hello header world!"); // or full control way ctp ctp1 = ctp.factory.newinstance(); ctr ctr1 = ctp1.addnewr(); cttext t = ctr1.addnewt(); t.setstringvalue("paragraph in header"); xwpfparagraph p1 = new xwpfparagraph(ctp1, sampledoc); x...

c# - StackExchange Redis SortedSetRangeByScoreWithScoresAsync Get Top n Elements -

i'm using stackexchange.redis api in .net application analytics. i'm using sorted sets datastore. equivalent method in stackexchange.redis below redis command: zrevrangebyscore "key:2014052923" +inf -inf withscores limit 0 10 what equivalent way in stackexchange.redis api using sortedsetrangebyscorewithscoresasync function? sortedsetentry[] values = db.sortedsetrangebyscorewithscores( "key:2014052923", order: order.descending, take: 10); or *async twin: sortedsetentry[] values = await db.sortedsetrangebyscorewithscoresasync( "key:2014052923", order: order.descending, take: 10); note additional parameters start , stop , exclude , skip haven't specified because have appropriate values already. in case isn't clear, exclude related ( prefix on ranges, described on zrangebyscore .