Posts

java - Hibernate Criteria division inside sum -

i have 3 tables: route(number, frequency ..), operator(name, ..) , route_operator(route_number, operator_name) . assume have following records in route_operator table +--------------+----------------+ | route_number | operator_name | +--------------+----------------+ | 100 | ok travel | | 111 | ok travel | | 111 | venture travel | +--------------+----------------+ and route table: +--------+-----------+ | number | frequency | +--------+-----------+ | 100 | 4 | | 111 | 4 | +--------+-----------+ now, using hibernate criteria want return sum of routes' frequency operated ok travel but, if there more operators taking route, frequency has divided number of operators take route. thus, returned result must 6 (4 route 100 + 4/2 route 111 because taken venture travel well). i have written raw sql this: select sum(r.frequency / (select count(*) route_operator ro2 ro2.route_number = r.number)) route r inner join...

curl - Procure particular product details through Flipkart API using PHP? -

what trying: have default products, based on title/name of product, need the similar products flipkart. what did far: have managed total list of products flipkart using curl request through api in php. unable specific product details in efficient way. note using json you can use flipkart api fetch data based on query search. flipkart api documentation .

ruby - How can I enable gzip file creation in Rails 4.2? -

as of april 14, 2015 looks .gz file compilation removed sprockets in latest version of rails. https://github.com/rails/sprockets/issues/26 i used these files on s3 server speed page loads, since compilation of gzip files have been removed per above thread there big question looming in mind. if using asset host, new solution having compiled .gz files? if serving files server relatively easy, static assets hosted elsewhere , need precompilation. anyway, has figured 1 out. temp solution if can't asset pipeline generate , upload .gz files once did manually create them using grunt-contrib-compress( https://github.com/gruntjs/grunt-contrib-compress ). know manual solutions don't scale , rather have asset pipeline take care of 1 @ deploy time. thanks help. :) as rake not override chains tasks, declare assets:precompile . following solution should work without changing deployment-scripts: #/lib/tasks/assets.rake namespace :assets # make use of rake's beh...

numpy - Slow Stochastic Implementation in Python Pandas -

i new pandas , need function calculating slow stochastic. think should possible without difficulty not familiar advanced apis in pandas. my data frame contains, 'open', 'high', 'low' , 'close' prices , indexed on dates. information should enough calculate slow stochastic. following formula calculating slow stochastic: %k = 100[(c - l14)/(h14 - l14)] c = recent closing price l14 = low of 14 previous trading sessions h14 = highest price traded during same 14-day period. %d = 3-period moving average of %k you can rolling_* family of functions. e.g., 100[(c - l14)/(h14 - l14)] can found by: import pandas pd l, h = pd.rolling_min(c, 4), pd.rolling_max(c, 4) k = 100 * (c - l) / (h - l) and rolling mean can found by: pd.rolling_mean(k, 3) moreover, if you're stuff, can check out pandas & econometrics .

C# Substring() stops string at & symbol -

c# substring() doesn't work, stops before & symbol: var name = "my_company_&_friends"; var sub = name.substring(2); // sub should string starting symbol index 2 // sub should "_company_&_friends" // "_company_" is bug ? how fix ? it expecting http://csharppad.com/gist/f38e23c03c66664698a7 what doing after causing issue.

c# - Programatically start a process independent of platform -

situation i trying run command-line tool, dism.exe, programmatically. when run manually works, when try spawn following: var systempath = environment.getfolderpath(environment.specialfolder.system); var dism = new process(); dism.startinfo.filename = path.combine(systempath, "dism.exe"); dism.startinfo.arguments = "/online /get-features /format:table"; dism.startinfo.verb = "runas"; dism.startinfo.useshellexecute = false; dism.startinfo.redirectstandardoutput = true; dism.start(); var result = dism.standardoutput.readtoend(); dism.waitforexit(); then result comes out as: error: 11 you cannot service running 64-bit operating system 32-bit version of dism. please use version of dism corresponds computer's architecture. problem i'm aware of causes this: project set compile x86 platform. (see this question example, although none of answers mention this). however, unfortunately requirement @ moment continue targeting pla...

c++ - Segmentation fault in LIS solution for Cracking the Coding interview 11.7 -

there problem in cracking coding interview -part v question 11.7 , solution trying implement here solution in java converted c++.but facing issue of segmentation fault. #include<iostream> #include<vector> #include<algorithm> using namespace std; class htwt { public: int ht; int wt; htwt(int ht,int wt):ht(ht),wt(wt){} htwt(const htwt &other) { this->ht=other.ht; this->wt=other.wt; } bool operator<(const htwt& obj) const { cout << __func__ << std::endl; return (this->ht<obj.ht && this->wt<obj.wt); } }; typedef vector<htwt> vhtwt; typedef vector<vhtwt > vvhtwt; vhtwt& getseqwithmaxlen(vhtwt& seq1,vhtwt& seq2) { cout << __func__ << std::endl; if(seq1.empty()) return seq2; if(seq2.empty()) return seq1; return (seq1.size()...