Posts

Showing posts from March, 2011

javascript - I'm making an rss reader and would like to display pictures from an article if there are any. How do I go about getting those pictures? -

i'm new web development , have started using jsonp , google's feed api rss articles using client side javascript. if must gather photos server that's alright doing on client side preferable. have absolutely no idea how relevant photo article. hope not bad having download web page's html , looking gif , png links. any helps appreciated! if i'm not mistaken images might returned in rss feed itself, , have run through feed looking images paste out. if don't include images in feed going have download page , links images.

java - read file, convert string to double, store in 2d array -

i need read list of numbers in file , store 2d array. have far. how go achieving goal? //this part of code public class rainfall { double[][] precip; public rainfall() { precip = new double [5][12]; } public void readfile(bufferedreader infile) throws ioexception { fileinputstream infile = new fileinputstream("numbers.dat"); bufferedreader br = new bufferedreader(new inputstreamreader(infile)); string[][] myarray = new string[5][12]; while (infile.readline() != null) { (int j = 0; j < 5; j++) { (int = 0; < 12; i++) { myarray[j][i] = infile.readline(); } } } infile.close(); } numbers.dat 60 lines of: 1.01 0.03 2.14 0.47 //is each number on new line? you're close, added few lines below. public class rainfall { double[][] precip;

iphone - Help me to automate the app store submission process -

please let me know, there api available automate app-store submission process? my requirement is, have app binary, app-store screens, app details in hand. possible submit app store programmatically of api without use of itunes connect? thanks help. there no apple supported api interacting itunesconnect. don't know if there third-party tools screen scraping interaction or not. one solution if need spam large amount of apps hire virtual assistant in india , have them enter of information manually.

php - PCRE regular expressions using named pattern subroutines -

i experimenting named subpattern/'subroutine' regex features in php's pcre , i'm hoping can explain following strange output: $re = "/ (?(define) (?<a> ) ) ^(?&a)$ /x"; var_dump(preg_match($re, 'a', $match)); // (int) 1 expected var_dump($match); // array( [0] => 'a' ) <-- why? i can't understand why named group "a" not in result (with contents "a"). changing preg_match preg_match_all puts "a" , "1" in match data both contain empty string. i idea of writing regular expressions way, can make them incredibly powerful whilst keeping them maintainable (see this answer example of this), if subpatterns not available in match data it's not use really. am missing here or should mourn have been , move on? it makes perfect sense these subpatterns not capture group - main purpose used more once, can't capture them all. in addition, if default capture subpat

php - Problems trying to find the root category based on category id -

i trying figure out root level category_id of category based on it's parent_id. in function below $this->cat_arr array of categories , parent_id's. if parent_id set 0 assumed root node. wish loop through array until find parent_id of passed $cat_id . function getroot($cat_id) { foreach ($this->cat_arr $row) { if ($row->cat_id == $cat_id && $row->parent_id == 0) { return $row->cat_id; break; } else { $this->getroot($row->parent_id); } } } in application call function when know $cat_id not @ root level (because parent_id greater 0), when try run gets stuck in infinite loop. is logic flawed, or missing simple? try this: function getroot($cat_id) { foreach ($this->cat_arr $row) { if ($row->cat_id == $cat_id && $row->parent_id == 0) { return $row->cat_id; } } return $this->getroot($row->parent_id

android - SharedPreferences for serialization? -

i'm rather new android development, , trying learn bit of hobby project. app has relatively small amount of state needs stored main activity in order app resume properly. moreover, since app syncs webapp, have json-based serialization logic included state might want save. use of sharedpreferences store relatively small (~ few kib) strings serialize objects? better use internal storage , write out text file? advice! shared prefs way save kind of data. don't know better using file in internal storage. (if lot of data, i'd consider using file on sdcard.)

sql server - How to send regular in-line SQL in entity framework -

now don't go getting huffy yet. specific situation. rather asking why ever want send in-line string sql through ef, let's try stay on topic of "how". do need old-fashioned route using regular old ado.net or ef provide me way execute straight sql select/nonquery? thanks in advance. have investigated entity sql ? entity framework q&a : string city = "london"; using (entities entities = new entities()) { objectquery<customers> query = entities.createquery<customers>( "select value c customers c c.address.city = @city", new objectparameter("city", city) ); foreach (customers c in query) console.writeline(c.companyname); } since entity sql lacks dml constructs, not possible issue insert, update, or delete commands using entity sql , object services

multithreading - Improving performance of web server -

i asked question in interview. open-ended question on web-server design. herez gist of question. "queues quite become bottle neck applications web servers. changes make thread handling classes, thread pool , queues improve bottle neck?" i pointed out measures 1. thread pool management 2. using buffers , packets in queues. but interviewer not quite satisfied. design measures should have mentioned? open-ended question, answer doesn't have depend on underlying technology spring, j2ee etc. in case there tutorial on server design, please share it. i can't resist posting this: http://www.engineerguy.com/videos/video-lines.htm the main problem queue blocks waiters deeper down queue. design must either fast queues never fill up, or must take queue fill-up consideration. see recent things on bufferbloat jim gettys have posted: http://gettys.wordpress.com/category/bufferbloat/ where buffering of ip packets in modern routers lead tcp going wrong (an

Print 1 to 100 with out loop and conditions in C -

possible duplicate: printing 1 1000 without loop or conditionals code print 1 100 without using loops , conditions. void print(){ static int i; printf("%d\n",++i); } void exitme(){ exit(1); } int main(){ void (*p[2])()={print,exitme}; static int i; (p[i++/100])(); main(); }

Is it possible to use OAuth/Google AuthSub with just JavaScript? -

it seems hard or downright impossible take advantage of them purely in javascript, without server side script (like 1 in php) helping (like masking secret key.) however, can use javascript on project. still possible use authsub or oauth? you can't use oauth without doing crypto in browser, can use authsub. in fact google have client library makes easy :- http://code.google.com/apis/gdata/docs/js-authsub.html

java - Whats the point of transactional non xa JMS Sessions? -

is me or jms api inconsistent regards how models transacted , xa transacted equivalents ? i dont appreciate why there xa forms connectionfactory, queueconnectionfactory, session , on , duplication: for example xaqueueconnection xaqueuesession createxaqueuesession() throws jmsexception; queuesession createqueuesession(boolean transacted, int acknowledgemode) throws jmsexception; contains methods non transacted , transacted session ? why both ? if have xaqc why want non transacted qs ? if wanted why create xaqueueconnection ? these provide gradient of classes of service. jms allows for... messages outside of unit of work messages inside of single-phase commit (1pc) messages inside of two-phase commit (2pc / xa) the cost of each of these increases degree of reliability. generally, want use least-cost method application requires. if have non-persistent, expiring, fire-and-forget message (for example, stock ticke

sql server - Best practice for creating a hierarchy of dollar bracket measures in SSAS -

i have measure open balance particular account. users want able have hierarchy can bucket dollar balances 0-500,500-1000, etc. is way creating dimension defines hierarchy. there other methods providing functionality users. if want hierarchy proposed way best solution, yes. dimension can derived fact table simple sql query such select case when balance >= 0 , balance < 500 1 when balance >= 500 , balance < 1000 2 end balancegroupid, case when balance when balance >= 0 , balance < 500 "0 - 500" when balance >= 500 , balance < 1000 "500 - 1000" end balancegroupname hth

c# - creating a UI with a button which will dynamically create .edmx file at runtime -

i want create user interface should give me option select database present ones , accordingly create .edmx file. the ado.net team released sample edmx code generator project. it's supposed give enough insight how ado.net entity designer generates code in visual studio , give head start sample source code.

math - determining numerator and denominator in a relatively complex mathematical expression using python -

i'm trying convert calculator input latex. if user inputs this: (3x^(x+(5/x)+(x/33))+y)/(32 + 5) i have convert this: frac{3x^(x+frac{5}{x}+frac{x}{33})+y}{32 + 5x} however having issues determining when numerator begins , ends. suggestions? a package exists kind of transformation : py2tex if want reuse package, can use py2tex.interpret class so.

casting - How to define a data type from file in C++? -

i'm making class object should contain value, value read externally in form of value, datatype, datatype tells me how interpret given value (int, float, double, char, etc). i wonder if possible make casting @ run time , how it, honest i'm bit lost , information i've found topic seems bit bit of overkill. any ideas ? thanks. look discriminated unions , boost::variant in particular, gist is: struct value { enum { int, float, double, char, etc } type; union { int int_; float float_; double double_; char char_; etc etc_; } value; }; then check type before doing operation, , select right union member based on has been stored in it.

refresh desktop using batch -

i need refresh desktop ussing batch possible? i have found following vbscript refreshes containing window however, desktop needs refreahed , not containing window anyways around this? set wshshell = createobject("wscript.shell") wshshell.sendkeys "{f5}" thx- you may try this: rundll32 user32.dll,updateperusersystemparameters it is, however, version dependent. hth!

android - how to get to the gmail tasks programatically -

possible duplicates: gmail task api exist? how gmail tasks programatically hi, i'm developing android applications i need gmail tasks promatically in project. i hope read & write gmail tasks in app ,but couldn't find tasks api. however, there android applications possible, jorte or gtasks like know how possible , apply program. my english poor tried explain. please me

user interface - jquery widget include files -

is possible create jquery widget include files contain 1 specific widget? if use custom ui download builder insists on including ui core. want create load of individual widget files, plus file containing core. way, can include ui core plus each individual widget need site, , can see @ glance ui widgets being used page, rather having single jquery-ui-custom.min.js file not obvious widgets included within it. $('head').append('<script src="http://example.com/widget.js"></script>'); or if want clever check if file has been included first. if( ! $('head script[src="http://example.com/widget.js"]').length ){ $('head').append('<script src="http://example.com/widget.js"></script>'); } which checks if widget has not been loaded add otherwise may conflict , give un-expected results :) .

amazon web services - SQS/task-queue job retry count strategy? -

i'm implementing task queue amazon sqs ( guess question applies task-queue ) , workers expected take different action depending on how many times job has been re-tried ( move different queue, increase visibility timeout, send alert..etc ) what best way keep track of failed job count? i'd avoid having keep centralized db job:retry-count records. should @ time spent in queue instead in monitoring process? imo ugly or un-clean @ best, iterating on jobs until find ancient ones.. thanks! andras amazon released simple workflow serice (swf) can think of more sophisticated/flexible version of gae task queues. it let monitor tasks (with hearbeats), configure retry strategies , create complicated workflows. looks pretty promising abstracting out task dependencies, scheduling , fault tolerance tasks (esp. asynchronous ones) checkout http://docs.amazonwebservices.com/amazonswf/latest/developerguide/swf-dg-intro-to-swf.html overview.

Multiple feature branches and continuous integration -

i've been doing reading continuous integration , there scenario occur don't understand how deal appropriately. we have stable mainline/trunk branch , create branches features. each developer keep own feature branches date merging trunk branch on regular basis. entirely possible 2 or more feature branches created , worked on over period of several weeks or months. in time many releases of software deployed. confusion arises. it changes 1 feature branch cause merge conflicts other feature branches. ci suggests should merge trunk @ least daily resolve conflicts quickly. however, may not want merge feature code trunk because may not finished or may not want feature available in next release. so, how deal scenario , still follow ci principles of daily code integration? there no feature branches in proper ci. use feature toggles instead.

rest - Correct RESTful call for this resource -

i'm designing restful interface existing infrastructure , i'm struggling 1 particular aspect. we have collection of users can accessed @ /users , elements of collection can accessed @ /users/1 etc however each user has list of friends needs able accessed well. users/1/friends restful call make here? doesn't qualify collection of it's own since it's relates 1 user. any appreciated as far restful design concerned, uri can whatever want. however, ensure interface can accessed in restfully need this: <user> <name>bob smith</name> <link rel="friends" href="/peeps/1/amigos" /> </user> by adding layer of indirection, client can discover link list of friends , no longer matters client uri is. can change whenever like. uris implementation detail of server , clients should never couple on them. coupling should on rels , media types.

url - Hide real ASP.NET page name -

can tell me how can hide real name of asp.net page. you looking url rewrite http://www.iis.net/download/urlrewrite or tip/trick: url rewriting asp.net

database - What's the fastest way to query for a free ID in an SQLite table? -

i heard sqlite has special processing id columns , stored special type, "primary numeric key". so what's fastest query can write fetch free id? assuming id's before 1 occupied. max(id) best can get? if need preallocate ids, create table stores last allocated id every table. preallocate id incrementing appropriate value , committing change, use needed, or forget. this bit sequences work in oracle , postgres.

Run Time Critical, reading operation of CSV files in C -

is there way code swift, efficient way of reading csv files?[the point note here is: talking csv file million+ lines] the run time critical metric here. one resource on internet concentrated on using binary file operations read in bulk. sure, if helpful in reading csv files there other methods well, robert gamble written sourceforge code. there way write using native functions? edit: lets split entire question in clearer , better way: is there efficient (run time critical) way read files in c? (in case million rows long .csv file) is there swift efficient way parse csv file? there no single way of reading , parsing type of file fastest time. however, might want build ragel grammar csvs; tend pretty fast. can adapt specific type of csv (comma-separated, ; -separated, numbers only, etc.) , perhaps skip on data you're not going use. i've had experience dataset-specific sql parsers skip on of input (database dumps). reading in bulk might idea, should me

android - How to get result from external application's activity? -

how result external application's activity application has triggered know change. for e.g: my application needs check if user has been logged in. if not logged in, allows login through external app. so current app. call onactivityforresult() trigger external app's activity , onactivityresult() called processing exit status of external app's activity. solved. sorry goof up. i have realized made mistakes entire session of testing. understanding , code fine, every time made changes both files, never ran external app. updated code . even found solution myself, considering nanne's answer hint solution, marked accepted answer. thanks , sorry ur precious time. your activity you've started should set result-value setresult(intvalue) your first activity, called startactivityforresult() can check result code provided in example protected void onactivityresult(int requestcode, int resultcode, intent data) { if (requestcode =

java - What's the difference between encodeURL and encodeRedirectURL? -

i've seen existing question: difference between encodeurl , encoderedirecturl . doesn't answer question really. in testing, these 2 methods same. whatever use print or sendredirect , both work fine. so there difference? want see source code maybe can find difference, httpservletresponse interface no implementation. implementation code? but httpservletresponse interface no implementation. implementation code? it's servletcontainer concrete servlet api implementation. in case of example apache tomcat concrete implementation org.apache.catalina.connector.response . here extracts of relevance: 1128 /** 1129 * encode session identifier associated response 1130 * specified redirect url, if necessary. 1131 * 1132 * @param url url encoded 1133 */ 1134 public string encoderedirecturl(string url) { 1135 1136 if (isencodeable(toabsolute(url))) { 1137 return (toencoded(url, re

.net - Is there such thing as a variable for my whole solution? -

seems beginner, have big solution, , problem when user in subroutine store date in variable in frmmain.vb, based in project 1. after user steps user control in project b, need have same value user stored in frmmain.vb. could please guide me through on how possible? forget noise how can use global variable. fact you're asking question implies you're new language , want learn right way of doing things. that's great! but real answer little bit more complicated. truth is, global variables have fallen out of favor modern programming tasks. vb.net in particular (as many other popular languages) object-oriented language, means interact methods on individual instances of objects. object-oriented programming provides host of benefits, presents whole new set of challenges. if don't have book you're learning vb.net from, highly suggest stop , pick 1 up. it's far easier pick habits in beginning unlearn bad habits later. , trust me, global variables ba

vb.net - List<Of T> Distinct in .NET 3.0? -

net 3.0. is there distinct on list(of t) ? packages need import? if not, there equivalence? no, have roll own, or change project .net 3.5 or 4.0.

java - Basic Spring 3 configuration for IOC -

can tell me basic configuration use string dependency injection? minimum required jars? @ moment i'd use inversion of controll, maybe later i'll integrate orm. thanks try spring roo , there nothing simpler full fledged spring based web application working, dependencies wired together.

prototypejs - getting radio , check box in prototype? -

how can checkbox, radio button, pulldown menu values using id using form in prototype js? see $f edit $f get's text value of element it's id. example if had drop down select box called "month" use $f('month') it's value "february". in response follow question, "how can count of number of check box selected" use this: $$('input:checked').length

data structures - What are some interesting/practical uses for arrays with three or more dimensions? -

when using arrays use 1 or 2 dimensional array -- 3 or more. i'm kind of curious, interesting/practical uses arrays 3 or more dimensions? have ever used array 4 or more dimensions? had professor in college use 6 dimensional array in program demonstrated in class...ever had more this? in scientific programming can quite common. start calling these higher dimensional arrays tensors. scalars 0-dimensional tensors, vectors 1-dimensional tensors, matrices 2-dimensional tensors, , after call them d-dimensional tensors (d=3,4,5,6). dot products called contractions on indices. where used? use them in of physics simulations. instance, 1 method simulating electrons on lattice (regular array of sites) uses tensor different set of indices each connection neighboring site. in 2d square lattice (think sites in center of each space on chess board), means each tensor has 4 indices, 1 each neighboring site, 4-dimensional tensor.

php - Problem using jqGrid Search Function -

i new jqgrid, want grips it. having hard time getting search function work. here xml working with: <?xml version='1.0' encoding='utf-8'?> <rows> <page>1</page> <total>1</total> <records>3</records> <row id='1'> <cell>1</cell> <cell>5 little roodee</cell> <cell>hawarden</cell><cell>ch5 3pu</cell> <cell>895.00</cell> <cell>1</cell> </row> <row id='2'> <cell>2</cell> <cell>28 pant-y-fawnog</cell> <cell>buckley</cell> <cell>ch7 2pd</cell> <cell>610.00</cell> <cell>0</cell> </row> <row id='3'> <cell>3</cell> <

Does anyone know of a CSS documentation tool? -

we have rebuilt our site using oocss principles allow modular way write css. the site large , has many devs working on want able document css css modules reused efficiently possible. does have experience using automated css documentation tool? or adapting documentation tool use css files? css_doc css_doc . blog post explaining it. and example of documentation comment /** * reset text color , line height. */ body { line-height: 1; color: black; background: white; } it implementation in ruby of cssdoc . short tutorial on getting started cssdoc commenting

Python / Django Forms - Display Form Element Content Instead of Html Element -

i looping through forms , want display of values of form elements. have read .data should take care of me. however, returns "none" , form indeed have field , correct stored value... {% document in documents: %} {{ document.title.data }} <!-- note: returns "none" --> {{ document.title }} <!-- element correct initial value --> any ideas? merci beaucoup!!! update: to access initial value directly forms.charfield(initial=x ) use {{ document.title.field.initial }} . accessing initial value passed form constructor ( form = myform(initial={...}) ) doesn't possible via template. boundfield data = self.form.initial.get(self.name, self.field.initial) when rendering widget @ form initial dict, falls form field's initial value. for bound form you've passed in data, such form = myform(request.post) , data available in {{ document.title.data }} in trunk, boundfield.value returns either initial or data! cool stu

Problem assigning javascript object properties -

is there way assign object property pear below? (example doesn't work) var fruitcolors = { apple: "green", pear: fruitcolors.apple}; i can achieve doing however, i'd like above if it's possible. var fruitcolors = { apple: "green" }; fruitcolors.pear = fruitcolors.apple; i don't think can - fruitcolors object doesn't exist @ time trying access it's property.

java - Retrieve all essential data on startup -

in java web application, know if proper (or "standard"?) way essential data such config data, message data, code maintenance data, dropdown option data , etc (assuming data not updated frequently) loaded "static" variables database when server startup. or more preferred way retrieve data querying db per request? thanks advice here. it valid pull out data not going modified during application life-cycle , keep in memory singleton or something. this idea because saves db hits , retrieval faster. lot of environment specific settings , other data can pulled once , kept in immutable hashmap future request. in common web-app not have many config data/option objects can eat lot of memory , cause oom. but, if have table hundreds of thousands of config data, better assume pulling objects , when requested. , if do want keep in memory, think of putting in key-value store memcached.

.net - Binding to a property of an object through object[property] rather than object.property -

i've read through wpf data binding overview , feel should possible can't quite make mental leap here. know if set binding's path foo , , set source obj , binding @ obj.foo . in other words, obj.__getattr__() accessed. all want make @ obj[foo] instead. i'm using ironpython , in case obj class has overridden __getitem__() calls member function , returns value, why need functionality. here above example written programmatically. displays foo property of obj in checkbox: mybinding = binding("foo") mybinding.source = obj acheckbox.setbinding(checkbox.ischeckedproperty, mybinding) solution it's simple this, apparently! mybinding = binding("[foo]") mybinding.source = obj acheckbox.setbinding(checkbox.ischeckedproperty, mybinding) you can use in binding, e.g. if datacontext /source has property public string this[int i] { get{...} set{...} } you can create binding this: <textblock

jquery - Is there a callback for Twitter's Tweet Button? -

is there way register callback on twitter's tweet button? i'd able track particular users on site have tweeted link. can't add on onclick event because it's cross-domain iframe. other ideas? i've seen one way it seems unreliable. their documentation doesn't mention looking work-around. twitter has web intent events loaded , rendered , resize , tweet , follow , retweet , like , , click . twttr.events.bind( 'tweet', function (event) { // there } ); the behavior changed in fall of 2015 due unreliableness of callbacks happening after event complete. they triggered when user invokes action in page, rather after action completed. example loading widgets.js : <script> // performant asynchronous method of loading widgets.js window.twttr = (function(d, s, id) { var js, fjs = d.getelementsbytagname(s)[0], t = window.twttr || {}; if (d.getelementbyid(id)) return t; js = d.createelement(s); js.id = id; j

javascript - jQuery: Trigger help -

i'm using cluetip jquery plugin. i'm trying add own close button. the jquery i'm trying call is: $(document).bind('hidecluetip', function(e) { cluetipclose(); }); there many references cluetipclose() through code , button jquery inserts uses , works function far i'm aware works fine. i'm trying trigger using $('a.close-cluetip').trigger('hidecluetip'); i've created link: <a href="#" class="close-cluetip">close</a> but isn't doing anything. am calling incorrectly? the problem here in cluetip plugin, function cluetipclose() inside closure, have no access unless you're inside closure (i.e. inside plugin's code). i've gotta admit, plugin doesn't seem set extensible. if made function accessible via "cluetip" object set each element uses it, you'd able add jquery method end of closure this: $.fn.cluetipclose = function() { return this.each

Ruby on Rails 3 Book (or even website) in Korean? -

i'm coaching korean friend in ruby on rails, , i'm wondering if there books written in korean ruby on rails 3. i found old o'reilly book in korean ruby on rails, i'm looking book teaches using rails version 3. if nothing exists, there websites (i.e. forums) geared towards korean speaking rails programmers? some korean books on bookstore in korea. but guess read english book. http://www.ruby-lang.org/ko/documentation/books/ hyunuk jung

enterprise manager - How to view ActualNumberOfRows in SQL Server execution plan -

i've been trying diagnose performance issue in database , have googled lot on maxdop. have seen in many places actualnumberofrows, actualrebinds etc. shown in properties view first thing see definedvalues. after running execution plan right click index scan example , expect see these fields can determine how rows distributed amongst threads. i using sql server 2005 enterprise. include actual execution plan , in click on arrow button, there can see actual number of rows

Need some help with Numbers in PHP -

i'm having little problem numbers in php, i'm trying do: $uni number in question , 1 need work (it doesn't matter number can in hundreds of thousands or 5). i'm trying work out how many times "100" can go into $uni , that's not problem, problem need remainding number (after decimal point) formatted. for example: (just working numbers on 100) if have $uni "356" need output "3 credits" ( $credearned = 3; ) & "56" ( $per = 56; ) left over. also, need strip numbers if $per "05" has "5". $uni = 190; if($uni >101){ $credearned = $uni / 100; $per = ; }else{ $credearned = 0; $per = $uni; } i'd appreciate help, , hope explanation wasn't confusing. thanks. this % (modulus) operator for, finding remainder of 1 number divided another: echo 356 % 100; // 56 in case, can find "credits" , "left over" in couple of simple statements instead of complex

Jquery Draggable AND Resizable -

function makeresourcedrag(arrindexid) { $('#imga' + arrindexid).resizable(); $('#imga' + arrindexid).draggable({ start: function(event, ui) { isdraggingmedia = true; }, stop: function(event, ui) { isdraggingmedia = false; // set new x , y resourcedata[arrindexid][4] = math.round($('#imga' + arrindexid).position().left / currentscale); resourcedata[arrindexid][5] = math.round($('#imga' + arrindexid).position().top / currentscale); } }); } this works fine if resizeable line taken out, want these images draggable , resizeable, funny behaviours if try , make same element have both attributes, know way make work? thanks! looks it's because you're doing on <img> , jqueryui wraps in <div> , , draggable component of image happens within wrapping <div> . try wrapping <img> in <div> (which if styled

algorithm - Get number of digits in an unsigned long integer c# -

i'm trying determine number of digits in c# ulong number, i'm trying using math logic rather using tostring().length. have not benchmarked 2 approaches have seen other posts using system.math.floor(system.math.log10(number)) + 1 determine number of digits. seems work fine until transition 999999999999997 999999999999998 @ point, start getting incorrect count. has encountered issue before ? i have seen similar posts java emphasis @ why log(1000)/log(10) isn't same log10(1000)? , post @ how separate digits of int number? indicates how possibly achieve same using % operator lot more code here code used simulate this action<ulong> displayinfo = number => console.writeline("{0,-20} {1,-20} {2,-20} {3,-20} {4,-20}", number, number.tostring().length, system.math.log10(number), system.math.floor(system.math.log10(number)), system.math.floor(system.math.log10(number)) + 1); array.foreach(new ulong[] { 9u, 99u, 999u, 9999u, 99999

user interface - Any GUI non-relational database manager? -

is there make easier manage yaml data files? in process of consolidating 2 bookfuls of yoga poses personal reference. it's yaml text files, dataset grows, it's becoming harder keep track of poses have written down. the poses have fields need filled, name , name in sanskrit. data nested don't relational databases work well. not yaml, rockmongo (for mongodb) manages aspects of non relational mongodb database, , allows creating collections, rows, , editing data. it's php web interface.

How do i access the url variable defined in the Zend Framework config.ini -

[dev] great.url="www.google.com" [test : dev] great.url="www.yahoo.com" [prod : test] great.url="www.aol.com" i have own functions return config of environment used(dev,test,or prod) . problem $myclassinstance->getconfig()->great->url; (when returning url correctly in dev) in test returning notice "notice: trying property of non-object in file test.php on line no 19" error coming due empty of statement ($myclassinstance->getconfig()->great->url;) .it returning correctly in dev . might problem. it must defaulting dev. fix it, need this: $config = new zend_config_ini('/path/to/config.ini', 'prod'); $myclassinstance->setconfig($config); or depending on how have things setup: $myclassinstance->config = $config; then code should work: $myclassinstance->getconfig()->great->url; documentation here: http://framework.zend.com/manual/en/zend.config.adapters.ini.html

xml - Get /documentation children of context nodes with XPath -

on another thread using xslt list every node in xml file, alejandro offered this useful piece of xpath 2.0 code: edit: stylesheet below uses modified version of code alejandro kindly posted in comment. reports @name attribute of elements. i have heavily modified apply .xsd schema following: example schema (a simplified version of source ) <xsd:schema xmlns:xsd="http://www.w3.org/2001/xmlschema"> <xsd:annotation> <xsd:documentation xml:lang="en"> purchase order schema example.com. copyright 2000 example.com. rights reserved. </xsd:documentation> </xsd:annotation> <xsd:element name="comment" type="xsd:string"> <xsd:annotation> <xsd:documentation>doc comment</xsd:documentation> </xsd:annotation> </xsd:element> <xsd:complextype name="usaddress"> <xsd:annotation> <xsd:documentation>doc usaddress</xsd:document

c# - linq to xml initializing array -

i have 2 classes - cd , track i'm trying read xml file using linq. public cd(string t, string a, string cat, datetime rls, track[] tr) public track(string t, int l) the xml looks this. <media> <cd> <artist>ozzy osbourne</artist> <album name="bark @ moon" type="metal" tracks="5" releasedate="1983-12-10"> <track length="300">bark @ moon</track> <track length="235">you're no different</track> <track length="567">now see (now don't)</track> <track length="356">rock 'n' roll rebel</track> <track length="120">centre of eternity</track> </album> </cd> <cd> <artist>journey</artist> <album name="escape" type="rock" tracks="4" releasedate="1981-07-31">

Jquery - Scroll a DIV(overflow:auto;) with a DIV -

how can scroll div (overflow:auto;) div? html <div style="width:100px; height:200px; border:1px solid #ff0000; overflow:hidden;"> <div id="my_div" style="width:100%; padding-right:20px; height:100%; overflow:auto;" class="sph"> <div style=" background-color:#c6c6c6; width:10px; height:20px; position: absolute; left:80px; cursor:pointer;" >s</div> .. content ... <br /> .. content ... <br /> .. content ... <br /> .. content ... <br /> .. content ... <br /> .. content ... <br /> .. content ... <br /> .. content ... <br /> .. content ... <br /> .. content ... <br /> .. content ... <br /> .. content ... <br /> .. content ... <br /> .. content ... <br /> .. content ... <br /> .. content ... <b

javascript jquery fade in fade out -

hey have fading tool-tips problem when roll on buttons in line has fade out complete before can fade in in makes sort of flashing code showbox:function($, $tooltip, e){ $tooltip.fadein(this.fadeinspeed) this.positiontooltip($, $tooltip, e) }, hidebox:function($, $tooltip){ if (!this.isdocked){ $tooltip.fadeout(this.fadeoutspeed) $tooltip.css({bordercolor:'black'}).find('.stickystatus:eq(0)').css({background:this.stickybordercolors[0]}).html(this.stickynotice1) } }, is there way of fading out if starts fading in without having fading out im kinda javascript noob thanks you want jquery.stop : $tooltip.stop(true);

How to store a Word document as a BLOB in mySQL with Coldfusion -

a client wants word documents saved mysql database despite me arguing against. documents should not particularly large, no more 1 mb each. have enabled blob in cf administrator , set blob buffer 1,000,000 here's sql <cfset newmessageid=1569> <cfset filename="c:\temp\0.doc"> <cffile action = "readbinary" file = "#filename#" variable = "filedata"> <cfquery name="addfile" datasource='#application.dsn#'> insert files (fileid, filedata) values (#newmessageid#, <cfqueryparam value="#filedata#" cfsqltype="cf_sql_blob">) </cfquery> i "data truncation: data long column 'filedata' @ row 1" error. filedata field in files table set blob. doing wrong? cf 9.01, mysql 5.4 what doing wrong what kind of blob? there different types including long , medium blob . blob (approximately) 2^16 = 65,536 bytes, medium blob 2^24 = 16,777,216 byt

javascript - Checking for a css class on the nearest sibling() div with jQuery? -

is there way in jquery return nearest sibling() div , check present class? i have visual verticle list of items, in items either have 1px border (to set them apart - premium items) or no border @ (standard items). while looks great when premium item sandwiched between 2 standard items, when 2 or 3 premium items stack borders between them end being 2px thick. i'm looking way, using jquery or otherwise, check if <div class="item"> above current div has class featured-item (so checking if div equals <div class="item featured-item"> ). there, set class name set border-top 0px , make visuals flow little better. can me out? sorry if question convoluted, hard explain! if ($("#current-div").prev().hasclass("someclass")) { // logic here }

c# - Software rendering mode - WPF -

i have wpf user control need force rendering in rendermode.softwareonly . since using .net 3.5, had like, var hwndsource = presentationsource.fromvisual(this) hwndsource; if (hwndsource != null) { hwndsource.compositiontarget.rendermode = rendermode.softwareonly; } but not working on application, wpf program crashing on few machines , turning off hardware acceleration @ registry level seems fix issue. the above code written in loaded event of window. if correct, loaded event happens after controls rendered ( msdn ). make sense have above code in event? if not, event appropriate it? also, setting rendermode on visual affects it's children? or need set each child elements? any great! here's did: private void window_loaded(object sender, routedeventargs e) { if (forcesoftwarerendering) { hwndsource hwndsource = presentationsource.fromvisual(this) hwndsource; hwndtarget hwndtarget = hwndsource.c

c# - XML Deserialization not deserializing element -

good afternoon, i have following classes public class maintenancebundle { [xmlattribute(attributename = "required")] public string required { get; set; } [xmlattribute(attributename = "id")] public string id { get; set; } [xmlelement(elementname = "title")] public string title { get; set; } [xmlelement(elementname = "mntreason")] public maintenancereason reason { get; set; } [xmlelement(elementname = "tasks")] public maintenancebundlecollection tasks { get; set; } } public class maintenancebundlecollection { [xmlelement(elementname = "task")] public list<maintenancebundletask> tasks { get; set; } } public class maintenancereason { [xmlattribute(attributename = "every")] public string every { get; set; } [xmlelement(elementname = "mileage", isnullable = true)] public int? mileage { get; set; } [xmlelement(elementname =

mongodb - Oracle (RAC) vs NoSQL -

i curious if did benchmarks accessing of data in nosql databases vs oracle (particularly talking oracle rac)? project requires work @ least 10mil+ of records, search among them (but not necessary have real time), read important speed, , it's important guarantee ha , reliability (can't lose records!!!) can see myself how cassandra/mongodb might better fit (because key value storage provide faster reads sql when go on 10mil records), find difficult articulate of them nicely. links? suggestions? bullet points? thanks! 10 million records. assume 250 bytes per record. 2.5 gb of data, within capacity of basic desktop / laptop pc. data volumes insignificant (unless each record sized in mb, such picture or audio). what need talk transaction volumes (separated read , write) , consider ha. read-only ha easy relative "read-write ha". can trivial replicate read-only data set off multiple servers @ different geographic locations , distribute query workload on them.

Django - How to add html attributes to forms on templates -

suppose have following template: <div id="openid_input_area"> {{ form.openid_identifier }} <input name="bsignin" type="submit" value="{% trans "sign in" %}"> </div> how can add css class form.openid_identifier? as adhering soc principles , expect designers improve templates not want on form model on template itself. i couldn't find on over docs. there way on template? i've managed code simple solution problem: i wrote custom template tag : from django import template register = template.library() def htmlattributes(value, arg): attrs = value.field.widget.attrs data = arg.replace(' ', '') kvs = data.split(',') string in kvs: kv = string.split(':') attrs[kv[0]] = kv[1] rendered = str(value) return rendered register.filter('htmlattributes', htmlattributes) and have @ template is: {{ form.

java - Get last insert id with Oracle 11g using JDBC -

i'm new using oracle i'm going off has been answered in this question . can't seem work. here's statement i'm using: declare lastid number; begin insert "db_owner"."foo" (id, department, business) values (foo_id_seq.nextval, 'database management', 'oracle') returning id lastid; end; when call executequery preparedstatement have made, inserts database fine. however, cannot seem figure out how retrieve id. returned resultset object not work me. calling if(resultset.next()) ... yields nasty sqlexception reads: cannot perform fetch on plsql statement: next how lastid ? i'm doing wrong. make function returns (instead of procedure). or, have procedure out parameter.

javascript - HTML5 number spinbox controls not triggering a change event? -

we using jquery trigger recalculation on form input field. using html5 nice spinboxes in safari (at least on 5.0.3 mac). updating field spinbox controls doesn't seem trigger change event @ all. it's field hasn't been updated. oversight in webkit? or there ways around this? edit: changing spinbox doesn't trigger input event. $.click() works fine. if click , hold, doesn't until release.

javascript - change iframe content -

this looks like: <iframe id="uploads" name="uploads" src="/uploads/sinisa/" frameborder="yes" scrolling="no" onload="settimeout(autoresize('uploads'),10)"> </iframe> it points directory , retrieves files in list view. need remove/change line "index of /uploads/sinisa" , "parent directory". i've managed read iframe content with: parent.document.getelementsbyname('uploads')[0].contentwindow.document.getelementsbytagname('body')[0].innerhtml but don't know next. website talking here . p.s. wondering how change iframe link's styling many thanks you value of ul element instead of body element, has content assume after. parent.document.getelementsbyname('uploads')[0].contentwindow.document.getelementsbytagname('ul')[0].innerhtml note <li> elements not parent ul itself, need create opening , closing <ul><

oracle - Tricky SQL for a report -

i have table following 4 columns. student_id course_id seq_no date_taken looking on sql oracle db following report. possible report in single query using sub queries? course_id | cr150 ============================================= total students taken | 5 students taken first course | 3 course taken students | 3 students taken 2 courses | 2 you need nested query. inner query should use analytic query select student , course, how many courses student taking, , course in sequence. can use in of group query gives report want. i give sql won't because homework problem, not mine. http://www.orafaq.com/node/55 may learn how analytic queries.

jquery - Quickly select all elements with css background image -

i want grab elements on page have css background-image. can via filter function, it's slow on page many elements: $('*').filter(function() { return ( $(this).css('background-image') !== '' ); }).addclass('bg_found'); is there faster way select elements background images? if there tags know not have background image, can improve selection excluding not-selector (docs) . $('*:not(span,p)') aside that, try using more native api approach in filter. $('*').filter(function() { if (this.currentstyle) return this.currentstyle['backgroundimage'] !== 'none'; else if (window.getcomputedstyle) return document.defaultview.getcomputedstyle(this,null) .getpropertyvalue('background-image') !== 'none'; }).addclass('bg_found'); example: http://jsfiddle.net/q63eu/ the code in filter based on getstyle code from: http:/

java - JMS Alternative -

i reading blog, , 1 of points 'if you're using queues, messed up', in context of jms. i thinking, need jms? simple alternative be, if need asynchronously, why not put job request in table somewhere, , have process(es) polling db every x time units looking new jobs? this approach simpler jms, easy understand, , removes dependency application. what losing if use alternative described? perhaps 1 loses possibility of using jmx able administer things, if job 'queue' fed off table, can write simple code 'manage' processing. i reading blog, , 1 of points 'if you're using queues, messed up', in context of jms. this wrong. you might mess choosing use queue when it's not appropriate, if jms fine choice. i'd more discerning read on internet if you. sounds me author liked making inflammatory statements spice blog , bump google analytics statistics. it's 1 person's opinion, nothing more. the polling solut

regex - Simplify this regular expression -

i'm doing pre-exam exercises compilers class, , needed simplify regular expression. (a u b)*(a u e)b* u (a u b)*(b u e)a* quite obviously, e empty string, , u stands union. so far, think 1 of (a u b)* can removed, union of u = a. however, can't find other simplifications, , not doing other problems far. :( any appreciated, much! little rusty on regex, if * still represents "zero or more ocurrences" can replace: (a u e)b* (a u b)* which leaves first part with: (a u b)*(a u b)* = (a u b)* on right side, have (b u e)a* = (b u a)* now, since u b = b u a, get: (a u b)*(a u b)* on right hand side, leaves just (a u b)* u (a u b)* = (a u b)* i think that's it...

ajax - Servers that supports CORS? -

i wonder if there many servers supporting cors? to make web server support cors, easy making return header. for example, in apache2, add line applicable conf file: header set access-control-allow-origin "*" to more secure (or if don't have access server's conf file) might want not add header in server, add server-side code when want there. for example in php this: (untested) <? header('access-control-allow-origin "*"'); ?>

How to configure .htaccess when a rails application is located inside of another rails' public folder? -

i have rails application running on shared host server , public_html mapped ~/rails_apps/app1/public . done www.mydomain.com launches app1. expected, .htaccess this rewritecond %{request_filename} !-f rewriterule ^(.*)$ dispatch.fcgi [qsa,l] here comes new rails app2, , want access through www.mydomain.com/app2 i created ~/rails_apps/app2 , , created symlink public_html/app2 pointing there (the symlink ~/rails_apps/app1/public/app2 ). this app2 needs dispatch.fcgi launch, app2/public/.htaccess has same rewriterules above. the problem when access www.mydomain.com/app2/hello , first app1 receiving request , it's failing. i'm reading rule "file /app2/hello doesn't exist, send dispatch.fcgi processing". so, tried setting additional rule in app1/public rewritecond %{request_uri} ^/app2/.* rewriterule ^(.*)$ /app2/dispatch.fcgi [l] my app2 getting request, tries process /app2/hello fails since there no /app2 defined in routes. needs receive /he

windows - How to Install Cucumber-Rails under window7 OS -

i folllow guid install cucumber-rails. when run "rails generate cucumber:install # rails 3" , got error "could not find generator cucumber:install." have run "bundle install". output: using rake (0.8.7) using abstract (1.0.0) using activesupport (3.0.3) using builder (2.1.2) using i18n (0.5.0) using activemodel (3.0.3) using erubis (2.6.6) using rack (1.2.1) using rack-mount (0.6.13) using rack-test (0.5.7) using tzinfo (0.3.24) using actionpack (3.0.3) using mime-types (1.16) using polyglot (0.3.1) using treetop (1.4.9) using mail (2.2.15) using actionmailer (3.0.3) using arel (2.0.7) using activerecord (3.0.3) using activeresource (3.0.3) using bundler (1.0.9) using mysql2 (0.2.6) using thor (0.14.6) using railties (3.0.3) using rails (3.0.3) bundle complete! use `bundle show [gemname]` see bundled gem installed. gemfile: gem 'rails', '3.0.3' is there 1 can tell doest cucumber support on windows, , how can install it.

c# - Simple Numeric Regex not working -

i strip string have numeric values , 1 decimal point.... wrong regex? string test = "1e2e3.e4"; var s = regex.replace(test, "^\\d*\\.\\d*$", ""); what you're doing striping away decimal number, try instead: regex.replace(test, "[^\\d.]", ""); if want keep 1 dot, first need determine dot want keep if there's many of them. update : assuming you'd want keep first or last dot, use string.indexof or string.lastindexof split string , use: regex.replace(test, "\\d", ""); on each of resulting strings. potentially slower not using regex in matt hamilton answer tough.

c# - Sharepoint basics and any useful resources? -

sorry having 3 questions in 1 closely related , should simple familiar. i'm used coding java/obj c/php , finding trying modify template annoying partly because doesn't make sense can't find resources. i editing master template , have gotten basics things still allude me. with contentplaceholders, there way use more once? posted code how can said couldn't use code here. is there way modify these contentplaceholders without using sharepoint designer? i thought using sharepoint: tag possible way around this, can't find docos on possible tags , , use them. thanks help. a contentplaceholder in master page maps 1 content section in page/page layout. yes, can modify contents of contentplaceholder using code, building control tree. the sharepoint tag prefix used signify different control namespace, there no sharepoint:placeholder maybe if explain trying do, might able advise best way.

java - ICE PDF | How to deploy and use with print option -

i using icepdf - opensource java application pdf viewer in web. icepdf works fine me (i can view pdf using this) want add print option this. possible. there war file deploy in tomcat. if using viewer applet can use "print" button on toolbar print. if using icefaces webapp example or variant of printing difficult via browser. servlet responsible rendering pdf page render page @ time. in order print whole document pages in document have rendered browser before print initiated. other pdf viewer web apps push print command off client side applet or native pdf viewer.

c# - onkeyup event asp.net -

hi how can register , call server side event onkeyup event in asp.net textbox. is possible? thank you textbox web control doesn't provide onkeyxxx events instead subscribe ontextchanged event; <asp:textbox id='textbox1' runat='server' ontextchanged='handletextbox1ontextchanged'> </asp:textbox> public void handletextbox1ontextchanged(object sender, eventargs e) { } but can provide onkeyxxx behavior client-side. you can add client-side handler : textbox1.attributes.add("onkeyup", string.format("onkeyup({0})", textbox1.id)); and in page `<script language='javascript' type='text/javascript'> function onkeyup(id) { //do something; } </script>` also use pagemethods make call server-side web methods (static methods) javascript functions. this link might help.