Posts

Showing posts from September, 2011

.htaccess - Where downloads folder should be placed in CodeIgniter -

where should place downloads files? these should not accessible public. should accessible registered users. my directory structure follows. -application -system -downloads ---abc.7z -index.php as can seen downloads directly accessible user through following. 127.0.0.1/ci/downloads/abc.7z but make restricted added .htaccess following directive deny all its protected public access cannot access views doing earlier mentioned below. <a href="<?php echo base_url().'/downloads/abc.7z' ?>">click here download</a> to make file available download registered users, can hide actual filename user. maintain table map keyword(unique) , actual filename. provide link points controller method parameter keyword of file (do not explicitly display filename). read file per mapping , change filename random key (eg. session id) , provide download.

SVM Support Vector Machine regression openCv c++ -

could explain me how use svm regression in opencv c++? regression should return value, value position in images(coordinates x , y)? or single number? i have use in video analysis. have 3 points of know trajectories along whole video. use trajectories of 2 of them infer trajectory of third one. train svm these trajectories. i thinking organize training data , labels that: training data: position(x,y) in each frame of 2 of points labels: position(x,y) of third point in each frame is proper way? or should organize that: training data: position(x,y) in each frame of 3 points add negative example, changing position of third point, simulate false training set labels: 1 if third point position belong trajectory, -1 if belongs false training set svm can used regression: see here http://alex.smola.org/papers/2003/smosch03b.pdf may problem more suitable multivariate rvm see here (with c++ source): http://mi.eng.cam.ac.uk/~at315/mvrvm.htm here opencv edition of cod...

jquery plugins - Datatable editable - make cell editable based on a condition -

i using jquery datatable editable. wanted know if possible make cell editable based on condition. for example if data rendered way, key text 1 help 2 choice 3 edit key , text 2 columns, want make cell value choice editable , cells value , edit remain readonly. possible achieve via datatable editable ? you may use jeditable js make particular class editable. click here .

Python Selenium get javascript document -

This summary is not available. Please click here to view the post.

aggregate - get max value per id, then only value per id R -

i make df smaller taking 1 observation per person per date, based on persons biggest quantity per date. here's df: names dates quantity 1 tom 2010-02-01 28 3 tom 2010-03-01 7 2 mary 2010-05-01 30 6 tom 2010-06-01 21 4 john 2010-07-01 45 5 mary 2010-07-01 30 8 mary 2010-07-01 28 11 tom 2010-08-01 28 7 john 2010-09-01 28 10 john 2010-09-01 30 9 john 2010-07-01 45 12 mary 2010-11-01 28 13 john 2010-12-01 7 14 john 2010-12-01 14 i first finding max quantity per person per date. works ok, can see, if person has equal quantities retain same amount of obs per date. merge(df, aggregate(quantity ~ names+dates, df, max)) names dates quantity 1 john 2010-07-01 45 2 john 2010-07-01 45 3 john 2010-09-01 30 4 john 2010-12-01 14 5 mary 2010-05-01 30 6 mary 2010-07-01 30 7 mary 2010-11-01 28 8 tom 2010-...

python - let user download pdf by converting html information into pdf -

i have informations pops in fancybox, e.g. user form(which includes images, his/her address, phone no, name etc..), how can convert pdf , let user download pdf file. can achieved using jquery. i use datatables show rows of user informations, when clicked in individual rows popped in fancybox. there plugin in datatables called datatools lets user convert table csv, xls, pdf file, uses 'swf' file. there way convert html rendered page pdf ?? i using python2.7, flask you can convert html pdf using wkhtml2pdf .

Scanning across a universe of stocks for triggers in R -

first of all, apologize if basic question, searched here , unable find answer i'm trying. i'm not new programming, new r (and programming bit rusty, i've changed career focus bit). what i'm trying simple (famous last words): every morning scan across entire universe of stocks (or s&p 500) show me stock within x% of given indicator (eg, approaching lower bollinger band) this how i'm trying proof of concept, , use launching pad developing own indicators. appreciate , helpful comments, links, etc. in advance all! library(quantmod) # vector of stock tickers @ s <- c("aa", "axp", "ba", "bac", "cat", "csco", "cvx", "dd", "dis", "ge", "hd", "hpq", "ibm", "intc", "jnj", "jpm", "ko", "mcd", "mmm", "mrk", "msft", "pfe", "p...

One form with many submit buttons with PHP on a New DomDocument -

my domdocument put down 1 submit button. need buttons submits, first 1 , rest turned textareas, though specify "submit". i know can html, domdocuments prints out 1 submit. how can have more 1 submit button: code: $tsform = new domdocument; $tsfroot = $tsform->createelement('form', ''); $tsfid = $tsform->createattribute('id'); $tsfid->value = 'tsform'; $tsfroot->appendchild($tsfid); $tsfaction = $tsform->createattribute('action'); $tsfaction->value = $_server['php_self']; $tsfroot->appendchild($tsfaction); $tsfmethod = $tsform->createattribute('method'); $tsfmethod->value = 'post'; $tsfroot->appendchild($tsfmethod); /// create button 1 $tsfb1 = $tsform->createelement('input',''); $tsfb1type = $tsform->createattribute('type'); $tsfb1type->value = 'submit'; $tsfb1->appendchild($tsfb1type); $tsfb1name = $tsform->createattr...

payment processing - Eventbrite Auth.net Emulator -

i looking @ integrating payment processor uses auth.net emulator feature - ie ability use auth.net integration, using different url actual transactions. see here example: http://docs.ultracart.com/display/ucdoc/configuring+a+gateway+that+supports+authorize.net+emulation anyone managed integrate other paypal, wallet , auth.net eventbrite? thanks i work on eventbrite's api/platform team, can out here. other payment gateways emulating auth.net's api can plugged in platforms support auth.net, work integrate additional payment gateway has auth.net emulator still fall on eventbrite (and can't independently done third party). we're not looking add additional gateways, if have specific request i'd happy pass on request. you can contact here: http://twitter.com/eventbriteapi

iphone - No results for query of Soundcloud API under iOS -

when using sc.get() function of soundcloud api instead of result receive "http error: 0". same codes working under android , in browser (with same origin policy disabled). this part of code: sc.initialize({client_id : "[myclientid]" ,redirect_uri:"[myuri]"}); sc.get('/resolve', {url : '[myurl]'}, function(track, error) { if (error) alert('error: ' + error.message); trackimg[l] = track.artwork_url; trackid[l] = track.id; ... }); the urls white-listed external hosts within projects .plist , cordova.plist (the project still running under phonegap 1.7.0). there no warning in xcode console blocked urls.. strangely enough app working fine couple of weeks ago. thing found changed callback.html redirect uri got deleted created new one.

php - CakePHP naming conventions in table names -

for cakephp app i'm thinking database table names follow cakephp naming conventions. many times come across general table contains information not entity on it's own contains additional entity information. information in table intended re use placed apart main entity table. for example: work products can master products. in case table "products" link table "master_product_information" information don't want in "products" table. another example: table contains meta data of multiple pages. name table "pages_metadata", cake needs plural , "pages_metadatas" doesn't seem right. once again go "pages_metadata_information". how name tables not contain entities? [entity]_information one? i hope hear recommendations. thanks. the right answer (imo) go cakephp conventions - life easiest way, if have occasional awkward table name. in case, i'd name "master_product_information" table ma...

templates - where is Payment Method part of Magento invoice coming from -

Image
i modified once before, have forgotten part of magento invoice comes from.! \app\design\frontend\default\mytheme\somewhere? the email template new invoice located @ app/locale/en_us/template/email/invoice_new.html around line 64. believe payment method content generated in following file: app/design/frontend/base/default/template/payment/info/default.phtml.

php - Video Streaming Mysql Return -

mysql gives me 1 result, directorie, video. can shows 3 latest videos? <?php $link = mysql_connect('mysql', 'user', 'pass'); if (!$link) { die('could not connect: ' . mysql_error()); } mysql_select_db(database); $sql = 'select * `videos`'; $result=mysql_query($sql); $row = mysql_fetch_array($result); echo $row['path']; mysql_close(); ?> i don't know how database looks should order date (assuming use that) descending , limit 3 $sql = 'select * `videos` order creation_date desc limit 3'; http://dev.mysql.com/doc/refman/5.0/en/sorting-rows.html http://dev.mysql.com/doc/refman/5.0/en/select.html and put mysql_fetch_array in while loop while(row = mysql_fetch_array($result)) { echo '<video width="320" height="240" controls> <source src="/upload/'.$row['path'].'"> browser not support video tag. </video> <br...

python - Which languages allow importing non-rectangular data to plot -

i have deal data multiple experimental runs have different x-axis sizes. data may instance. [1 2 3 4] [5 6] [7 8 9 10 15] [4] this means languages (e.g. matlab) either have tough time reading in data, or aren't plotting friendly (e.g. java). can suggest language makes importing, manipulating, , plotting data easy? switched python numpy/scipy haven't found helpful (i using python). please post specific functionality opposed blanket statements language. thanks here's attempt in free, open-source statistical programming language r - i'll try update more specifics data. as example data file, i'm using .txt these lines: 1, 2, 3, 4 5, 6 7, 8, 9, 10, 15 4 to read in data, i'd write: # set option - trust me options(stringsasfactors = false) # read each line of file vector of strings x <- readlines(con = file("blah.txt")) # split whatever delimiter xlist <-strsplit(x, ", ") # now, each experiment's data el...

c++ - Template a python-like setattr function -

reading through previous answers, feel may have design problem, if answer academic i'd still know if possible. i've been programming in python awhile , shows. i'm trying create setattr access on object. hand looks like: template<class t, class u> void set_parameter_sigma(t &s, u val) { for(auto &x: s) { x.sigma = val; } } template<class t, class u> void set_parameter_epsilon(t &s, u val) { for(auto &x: s) { x.epsilon = val; } } template<class t, class u> void set_parameter_length(t &s, u val) { for(auto &x: s) { x.length = val; } } what i'd looks following pseudocode: template<class t, class u, class n> void set_parameter(t &s, u val) { for(auto &x: s) { x.n = val; } } i call set_parameter(foo, 2.0, "epsilon") , compiler create set_parameter_epsilon function automagically. while i'm sure boost can this, i'd prefer see stl-only version if possible. update: oops ...

php - sync the 2 tables for certain rows -

this question of possible , should try it? i have 2 rows in table 1 named jobs , 1 named contacts (hope still me) in jobs have following columns typeofjob id name phone address budget due in contacts have following columns id name phone address is there way sync 2 tables rows? id name phone address i ask make life lot easier me worried id might conflict and happens if delete user contacts want deleted row i new , learning if can answer me simplify answers great treat trying explain nan or something, on other hand might pick faster :) what want id in 1 of columns id of row in table. so, add column contact_id in jobs table, under assumption each contact potentially spawn multiple jobs. can query it, such select * `jobs` `contact_id` = 'whatever' you use joins more complex , efficient work (remember, less trips database, better!).

ios - How can I access UITextFields from outside the ViewController (from a .m file)? -

i have class keep utility methods; 1 of methods takes values in textboxes stored in viewcontroller , saves values plist. the problem utility methods class not viewcontroller , therefore can't "hook up" outlet properties of textboxes tothe utility class. is there way can pass viewcontroller parameter utility class method? just make utilities class singleton inheriting nsobject. way can access methods wherever you'd , you'll have 1 instance of it. https://developer.apple.com/library/ios/documentation/general/conceptual/devpedia-cocoacore/singleton.html matt gallagher wrote great helper file create singletons. check out here: http://www.cocoawithlove.com/2008/11/singletons-appdelegates-and-top-level.html

android - Upload draft APK without interfering with published APK? -

Image
i have published app. app uses google's license check, in order test new versions of app (using test accounts) apk must uploaded in developer console: the account owner (but not other test accounts) response applications have not been uploaded google play yet. i've done several times. it's no-brainer. well, until now. after uploading new apk 'draft production', gives me warning message: some devices eligible run multiple apks. in such scenario, device receive apk higher version code. this makes me nervous i not want publish new version. previously, marked latest apk inactivated , set. how can done in new developer console? q: how upload new unpublished apk testable google's license check? i'm amazed nobody took time answer simple question. after nervous testing understand how works: uploading apk , clicking save draft enough license check working. new apk not published until explicitly publish it. error message there p...

About modifying the content of an HTML file through php before loading the HTML file -

say instance want go main log in page html/js if password/username fail match when run php. able access main login html page , make div contains error message visible. here code snippets example. works fine, don't how can load index page without telling user went wrong. i've been doing googling haven't managed right. <?php //this in separate file "checklogin.php" . . . if ($count == 1) { session_start(); $_session['loggedin'] = true; header('location: loggedin.php'); } else { header('location: index.php'); } . . . ?> <html> //separate file "index.php" <body> . . . <div id = "nomatch" name = "nomatch" style = "display:none"> <p> username , password don't match </p> </div> . . . </body...

autosaving form data with jquery and php -

i quite ok php, total noob jquery, , got stuck autosaving form data. the autosave function gets called every 30 seconds in dummy.php . i'm sending serialized form data processing (--> database) savetest.php . at moment, stuck question: how savetest.php 'listen' incoming data , react it? at moment, alert 'oh no!' ( = no success) every 30 seconds. here's shortened sample code: dummy.php , snippet 1 (html & php): <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="../../_include/jquery-1.9.1.min.js"></script> </head> <body> <h1>my form</h1> <form name="form1" id="form1" method="post" action="<?php echo $_server['php_self'] ?>"> <input type="radio" name="item_2_1" id="c_2_1_0...

r - How to handle missing values when using a reverse geocode function? -

i working data (n of 271,848) in r looks follows: observation longitude latitude -------------------------------------- 1 116.38800 39.928902 2 53.000000 32.000000 3 na na 4 na na and using reverse geocode function following post: convert latitude , longitude coordinates country name in r when run coords2country(points) line, following error: "error in .checknumericcoerce2double(obj) : non-finite coordinates" my best guess function not know how treat missing values. when run code on subset of observations (excluding na's/missing values), works. i attempted modify function (see last line below) fix problem, still produced error referring above. reproducible example: data <- data.frame( observation = 1:5, longitude = c(116.3880005, 53, -97, na, na), latitude = c(39.92890167, 32, 32, na, na)) library(sp) library(rworldmap) coords2country = function(p...

mysql insert update LOAD DATA LOCAL INFILE -

i using load data local infile load data temp table mid.then use update query update found in table product.the matching field in both model. $q = "load data local infile 'mid.csv' table mid fields terminated '\t' lines terminated '\n' ignore 1 lines (@col1,@col2,@col3,@col4,@col5,@col6) set model=@col1,price=@col3,stock=@col6 "; mysql_query($q, $db); mysql_query('update mid m, products p set p.products_price= m.price,p.products_quantity= m.stock p.products_model= m.model'); it works , update product table.the issue having there new records in mid table don't inserted using update statement. i have looked @ insert query , update on duplicate.i have seen loads of examples of when has work on 1 table none have match against table. either searching wrong thing or there way to this. i appreciate help. regards naf i'm not sure other columns in product table are, here's basic approach should work ...

php - how can i programatically open a docx file, edit it, and then seal it up again without it breaking? -

i have web application converts microsoft word documents html using libreoffice. has been working great, having issues ability interpret indentation on files. using suggestions other kind developers, have discovered how pull apart docx file converting zip, unzipping it, , extracting document.xml file. in process, have noticed libreoffice consistently incapable of interpreting <w:tab> tags , rendering them indentations. i have tried many things fix this, running out of ideas. last ditch effort going to use php programatically replace of <w:tab> tags <w:ind> tags (which libreoffice interprets tabs). however, convert file .zip bash unable seal docx. mean, can it, libreoffice no longer recognizes , throws strange error @ me. is there way can html rendering pulling document.xml file? if not, know how seal these documents again? appreciated. thanks! here update: seems when try zip docx including parent directory. think messing file when convert docx format. ...

jquery - JavaScript MVC Parsing JSON -

i trying work client's api lets me retrieve group of orders in json format. able use code below display 3 alert boxes. first box shows 200 (am assuming that's html success code), blank alert box, third box says: [object object]. in chrome if use f12 key , go network preview see 3 sections, status contains body section contains orders section. there 50 orders in orders section. each order has properties such as: order_type: "pickup", etc. question how iterate through actual orders. don't know syntax reach order, , properties inside order. my end goal loop though 50 orders, assign of order properties javascript vars , pass mvc controller insert order database. getting orders clients database via api , storing them local database. guessing using ajax call inside first .each loop post several of order properties database via call mvc controller database inserts? thank in advance help. $.ajax({ type: 'get', url: 'https://api.custo...

asp.net - First jQuery attempt not working -

Image
i trying show nice tooltip, using jquery plugin called qtip . however, getting strange result. have added jquery library scripts folder, , created "3rdparty" folder off that, qhich has qtip file. i reference them in asp.net masterpage: <head runat="server"> <link rel="shortcut icon" href="/favicon.ico" /> <meta http-equiv="refresh" content="1140" /> <asp:contentplaceholder id="head" runat="server"> </asp:contentplaceholder> <script type="text/javascript" src="/scripts/jquery-2.0.3.min.js"></script> <script type="text/javascript" src="/scripts/3rdparty/jquery.qtip-1.0.0-rc3.min.js"></script> <script> $(document).ready(function() { $('#test').qtip({ content: 'mice eat cheese, not stones.' }); }); ...

Cannot update by clearcase in Eclipse or Clearcase Remote Client -

Image
i work under cloud environment, configurations same others. where's problem? well, delete lock file .systemfolder/lock. not name. name contains lock in it. forget is. this work.

html5 - Video-JS and Firefox playback issue -

appears me firefox has withdrawn support html5 video. doing drupal site, integrated video-js library. works ok in ie, chrome, etc. firefox appears not throw error, , attempts play. if set autoplay true, play audio, video missing. see flash of video content screen half covered green raster. have found display on several other sites purport demo html5 video. there plenty of docs ff supports open format cannot find 1 plays properly, have assume ff has changed. https://developer.mozilla.org/en-us/docs/web/html/using_html5_audio_and_video instance if put snippet above page in web page: <video src="http://v2v.cc/~j/theora_testsuite/320x240.ogg" controls> browser not support <code>video</code> element. </video> the clip apparently loads , there no error event on source, clip doesn't play , alternate content not shown either. wondering if may because outside of u.s. or possibly if there problem firefox setup.

mysql - Is this Ruby on Rails code vulnerable to SQL injection? -

thanks this. i'm new rails (using rails 2, know isn't ideal it's necessary project.) i've got form several inputs. wanted make sure i'm protecting users against sql injection. think i've handled properly, wanted sure, inputs. footwear.html.erb has form save shoes , socks tables <% form_for @shoe, :html=>{:id=>'createanorder'} |f| %> <input id="shoe_name" name="shoename" size="30" type="text" value="new shoe"></p> <p>enter decoration top: <input id="topdecorationinput" type="text" name="topdecorationinput" size="56"></p> <p>or, select decoration list: <select id="topdecorationdropdown" name="topdecorationdropdown"> <option value=""> <% allshoe in @allshoe %> <option value="<%= allshoe.decoration %>"><%...

Mobile Website for Iphone -

i want know if possible make mobile website , store in iphone. iphone localhost. if possible, need use specific web technology that? as now, want pretty simple, want user input value, website generate number of forms based on input of user. download adobe edge inspect app on phone http://html.adobe.com/edge/inspect/ , download adobe edge inspect extension on browser, need running on website above. thats i'm using test site locally on iphone. use trial version if not using cloud services.

HTTP request - Ruby on Rails -

i took on else's rails project , have question http requests. it seems should able pass parameters through http requests, i'm unsure how. example: rake routes shows put /auction2s/:id(.:format) auction2s#update which seems correspond function # put /auction2s/1 # put /auction2s/1.json def update @auction2 = auction2.find(params[:id]) print "hello world" respond_to |format| if @auction2.update_attributes(params[:auction2]) format.html { redirect_to @auction2, notice: 'auction2 updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @auction2.errors, status: :unprocessable_entity } end end end but can't figure out url need pass to, instance, change id=18445&done=true into function. any thoughts? function structured right? need pass request in ruby format, not through bro...

Clearing the screen in C++ using other compilers -

hello i'm interested in learning way clear screen. i'm using c++ seem possible code use known work windows compilers. i'm using ubuntu "g++ compiler". code have research in order use , have tried... ---this don't work g++ compiler system("cls"); error: sh: 1: cls: not found system("clrscr"); sh: 1: clrscr: not found i stumble upon code works, know prints lot's of lines ... cout << string(50, '\n'); any cleaner methods possibly use ? the unix command clearing terminal clear . alternatively, send terminal codes doing same (this varies terminal, sequence works most): cout << "\033[h\033[2j"; (i got sequence running clear | less on system. try , see if same result.)

css - How can I get Twitter-Bootstrap 3's navbar to work in mobile and desktop view justified? -

so wanted bootstrap 3 navbars links justified/centered. asked community why when applying .nav-justified conflicted .navbar-nav . 2 should not applied each other because the .nav-justifed class used nav-tabs / nav-pills (see bootstrap docs) , not nav-bar. 2 concepts different , should not confused. however, can achieve effect looking adding following css: .navbar-nav.nav-justified > li{ float:none; } nav-justifiednow plays nice navbar-nav: what suggested worked perfectly, when use responsive navbar, collapse on mobile view, links stay horizontally aligned in mobile view, instead of them being listed vertically. i have prepared fiddle in case little confused. the first navbar not have .nav-justified applied it, works fine when using mobile view. links not centered, they're pulled left. the second navbar have .nav-justified links centered, when using mobile view links still centered, , not listed vertically first navbar. do ha...

java - Reading lots of data returned by API -

i reading api provided company, problem 1 of accounts getting data has around 22000 json objects, reads fine small amounts of data, 8000 records, issues json not formatted besides problem of being able read response. the response comes way: <?xml version="1.0" encoding="utf-8"?> <string xmlns="http://ywers.com"> [{"name":"edward", "lastname":"jones", "address":"{accepted}"} ,{"name":"carlos", "lastname":"ramirez", "address":"{rejected}"}, ....... 22k more records here]</string> i asked earlier on here best way this, , got response reading using xml parser , json parser, using gson. string xml = "<your xml response>"; xpathexpression xpath = xpathfactory.newinstance() .newxpath().compile("/*[local-name()='string']"); string json = xpath.evaluate(new ...

c++ - Eclipse/CDT cannot debug application with linked dependencies - program exits with code 0xc0000135 -

i have 2 c++ projects in eclipse, "amp" , "amp_auditions" the first creates library, c:\users\jared\eclipseworkspace\amp\debug\libamp.dll the second, test program ( 'c:\users\jared\eclipseworkspace\amp_auditions' ), depends on first, , has directory c:\users\jared\eclipseworkspace\amp\debug listed under project properties > library dependencies to use amp library created, thought needed link library file , include headers, apparently isn't simple. everything compiles, when go debug, application terminates. gdb trace tells me: 488,262 19^error,msg="during startup program exited code 0xc0000135." if run test program directly in terminal , complains missing dependencies. if place libamp.dll file in c:\users\jared\eclipseworkspace\amp_auditions directory, works fine. tells me issue debugger can't find libamp.dll what did miss? why won't test program run within eclipse debug perspective? gcc -v collect_gcc=gcc...

asp.net mvc - Orchard error to create home route -

Image
i had enable aliases , aliases ui module in orchard.then changed module start module using / module link works fine.some unfortunately deleted home route path in aliases module try recreate home route path again orchard cms not allows me create home path again.when recreate gives me following error

wso2 - Error when try to build the VFSTransport Listener class -

i try modified vfstransportlistener class in wso2. encountered error : multiple markers @ line - cannot override final method abstracttransportlistenerex<polltableentry> - overrides org.apache.axis2.transport.base.abstracttransportlistenerex<org.apache.synapse.transport.vfs.polltableentry>.init this error happen in init method. can me how solve problem? you trying override following method in abstracttransportlistenerex class @override public final void init(configurationcontext cfgctx, transportindescription transportin) throws axisfault { super.init(cfgctx, transportin); doinit(); // create endpoint configured @ transport level (if available) e endpoint = createendpoint(); endpoint.init(this, null); if (endpoint.loadconfiguration(transportin)) { globalendpoint = endpoint; } } this cannot overridden final method.

java - Bypassing Servlets -

i wrote basic implementation of annotations bypasses servlets. try , stay away frameworks spring , faces etc due limitations , overheads. the annotations have implemented bypasses servlets , uses plain java objects delegated filter process requests , responses , returns either plain text, json or request forwarded request dispatcher. achieve had bypass filter chain. planning on using 1 filter. does know what/if there risks involved in doing this? know web , app servers pool servlets, there else pose problem?

ordering through an has_many relationship with a condition in rails 3 / active records / postgresql -

i have 2 objects, items , taxonomy nodes. i have selection of "items" want order based on alphabetical order of taxonomy_nodes attached to, 1 particular "top parent", id provided (as in "i want sort alphabetically using parent"). if understood nested sets properly, can find out if taxonomy_node belongs parent when left , right values "within" left , right values of top parent: instance top node "vegetable" of values left:1 , right: 10 has "potato" of values left: 2 , right: 8 child. an item can have several taxonomy_nodes, , using awesome_nested_set gem taxonomy_nodes behave nested sets hierarchy. thus, can have various main "taxonomies" against items tagged, identified "top node". the way, moment, identify if taxonomy_node belongs particular "top node" use lft , rght values of taxonomy_node, , hit stumbling block when trying allow users sort list of items 1 of main taxonomies. i imag...

java - Keep annotated clutter away from Domain Model -

i'm in situation have domain model clean. clean mean it's collection of private properties , getter , setters. guess that's what's ment anemic data model. this model interchangeable other applications (can shared other application code) without pulling in dependencies. this model needs serialized different data formats. can use wide range of annotations simplify life. only pull in set of dependencies in projects share domain model. i've read it's not advised clutter domain model such reasons , possibly land in jar hell. i write wrapper annotated , pass in domain model in constructor , copy properties on annotated model. way can happily use annotations while keeping clean domain model not enforce dependencies. this not serializing data model adding functionality (for example through annotations) in domain model enforces new dependencies. how handle such use cases what's safe way handle without having fear jar hell ? you have use annot...

Change FileName Download from Azure -

i using azure shared access signature create url redirect download azure, problem when download using original name of file, want change filename when user download client. anyone have solution. p/s: container on azure private permission , using asp.net mvc 4 blobs cannot renamed or aliased. thing can change base dns name (which can map custom name). that said: if wanted present unique blob download , not use current name, make blob copy (a fast operation within same data center) name desire, , offer shared access signature new blob. after reasonable amount of time (maybe beyond expiration of sas), delete blob.

c# - How to activate a ScrollBar? -

i'm starting learn how program , have problem. making application in c # wpf. want put scrollbar on grid , not activate it. searched , tried several things found, have not gotten right. window larger monitor, want put scrollbar access bottom of window. last thing tried this. <grid> <grid.rowdefinitions> <rowdefinition height="921*" /> <rowdefinition height="0*" /> </grid.rowdefinitions> <scrollbar height="921" horizontalalignment="left" margin="761,0,0,0" name="scrollbar1" verticalalignment="top" width="12" maximum="960" minimum="1" smallchange="1" /> </grid> with comes scrollbar, window not move. in advance , forgive writing. made google translator. the content wish scroll should child of scrollviewer . <scrollviewer> <grid> <grid.rowdefinitions...

wpf - Cannot find governing FrameworkElement or FrameworkContentElement for target element. GradientStop -

i have list box contains colors , each color have 7 heads choose print head color. binding variable when print head selected , color box should have styles. <setter targetname="colorselectionrectangle" property="fill"> <setter.value> <lineargradientbrush spreadmethod="repeat" startpoint="0,0" endpoint="25,25"> <lineargradientbrush.relativetransform> <scaletransform scalex="0.01" scaley="0.01" /> </lineargradientbrush.relativetransform> <gradientstop offset="0" color="white" /> <gradientstop offset="0.5" color="white" /> <gradientstop offset="0.5" color="{binding [0].item.printcolor.argb}" /> <gradientstop offset="1" color="{binding [0].item.printcolor.argb}" /> </lineargradientbrush> ...

c# - Zipping many files and upload them to FTP -

i have requirement of uploading several image files ftp. the main goal achieve here performance, speed. my approach here to, zip files @ client end, , ftp upload them , un-archive them on server. is there better approach?? and best way zip 1000 images? should use .net inbuild mechanism or external library? note : have vs 2012 development environment this. zip on client end , ftp , unzip them on server best approach in term of performance , speed. sending 1000+ files server not ideal solution. better use open source libraries zip files. may use ionic zip . can zip , unzip files using exposed api. code sample zipping files using (zipfile zip = new zipfile()) { // add map file "images" directory in zip archive zip.addfile("c:\\images\\personal\\7440-n49th.png", "images"); zip.save("myzipfile.zip"); } unzipping files public void extractzipfile(string fullzipfilename, string extractpath) ...

mocking - python mock.mock_reset() returns mock instead of resetting the mock -

while using mock library, i've encountered situation calling my_mock.reset_mock() method returns new mock instance instead of resetting my_mock . apparently i'm somehow masking mock.reset_mock() , cannot figure out how happened. sample run (python 2.7): >>> mocks.normal_mock.mock_calls out[6]: [] >>> mocks.normal_mock.reset_mock() >>> mocks.normal_mock.mock_calls out[8]: [] >>> mocks.abnormal_mock.mock_calls out[2]: [] >>> mocks.abnormal_mock.reset_mock() >>> <magicmock name='abnormal_mock.reset_mock()' id='157604104'> >>> mocks.abnormal_mock.mock_calls out[4]: [call.reset_mock()] any idea cause this? additional info: all mocks encapsulated in designated class, instantiated once, , reset between test in unittest.testcase.teardown() . all mocks created calling patch.start() on patched object/method/module both normal , abnormal mocks in example mock-out module imported uut (...

android - How to check if a timer is still running or not? -

i try send sms in service.if sms not sent means restart service after time, using timer.if sms sent means want stop timer,for stop timer use timer.cancel(); before i've check timer running or not.how check it?. int resultcode = getresultcode(); switch (resultcode) { case activity.result_ok: timer.cancel();//here want check timer running or not break; case smsmanager.result_error_generic_failure: timer_run(); break; case smsmanager.result_error_no_service: timer_run(); break; case smsmanager.result_error_null_pdu: timer_run(); break; case smsmanager.result_error_radio_off: timer_run(); break; ...

algorithm - Efficiently find the depth of a graph from every node -

i have problem find minimum possible depth of graph implies have find maximum depth each node , return least of them all. simple dfs each node trick when things crazy extremely large input, dfs becomes inefficient (time limit). tried keeping distance of each leaf node being explored in memory didn't much. how efficiently find minimum depth of large graph. worthy of note graph in question has no cycle . to find graph centre/center of undirected tree graph could: do dfs find list of leaf nodes o(n) remove these leaf nodes graph , note during deletion new nodes become leaf nodes repeat step 2 until graph deleted the node/nodes deleted in last stage of algorithm graph centres of tree. each node deleted once, whole process can done in o(n).

asp.net web api - REST API URI Design for users and sessions? -

i'm new rest design i'd pointers here. here have far: get /api/users //all users /api/users/123 //specific /api/users/me //get own profle post /api/users/me/session //start new session (login) delete /api/users/me/session //ends current session (logout) i'm wondering session / login/out stuff here. thinking correct here or should designed in other way more rest'ish? also, register user, should be: post /api/users even if starts new session? i recommend avoid term session , use auth (as in authentication). term session gives impression of server-side session goes against rest. the following good: get /api/users //all users /api/users/123 //specific /api/users/me //get own profile for authentication, may have this: post /api/auth //username/password required. auth_token sent delete /api/auth ...

Optimizing mysql group by with large linking table -

i've been reading lot on , still 30+ seconds per query, while i'm should work lot faster. the problem this: having large linking table (40 millions rows, data consisting of 650mb , index representing 1.8 gb) defined follows: create table if not exists `glossary_entry_wordlist_1` ( `idterm` mediumint(8) unsigned not null, `idkeyword` mediumint(8) unsigned not null, `termlength` smallint(6) not null, `termnumberwords` tinyint(4) not null, `termtransliteralrfc` mediumint(9) not null, `keywordlength` tinyint(3) unsigned not null, `termlanguage` tinyint(4) not null, primary key (`idkeyword`,`idterm`), key `termtransliteralrfc` (`termtransliteralrfc`), key `termlength` (`termlength`), key `secondprimary` (`idterm`,`idkeyword`) ) engine=myisam default charset=latin1 collate=latin1_general_ci and small temporary table defined follows: create temporary table if not exists `foundids` ( `searchid` int(11) not null, `searchedkeywordid` int(11) not nu...