Posts

Showing posts from January, 2011

php - Get category ID in Magento Footer -

i want current category id in magento footer area can create condition things not shown in specific category. example want do: if current category 111 not show social icons i tried following code: <?php$current_id= mage::getmodel('catalog/layer')->getcurrentcategory()->getid();echo $current_id;?> problem above code echo random id , doesnt change go thru different categories. please help. thank you. when don’t have access $this, can use magento registry: $category_id = mage::registry('current_category')->getid(); or get variable set on block xml $this->getlayout()->getblock('product_list')->getcategoryid()

sql - MySQL Workbench scheduled backup utility -

[i posted query below database admin stackexchange site put on hold due being off-topic, came wee surprise. hope it's not ot stackoverflow. ] my (medium-sized) organisation uses excellent mysql workbench 6.1 community db management. workbench used have scheduled backup tool built in, iirc, no longer - have buy enterprise edition this. so i've quick question: cheap/open source utilities available plugin in workbench configure , run scheduled backups of selected or db? 'backup', mean nightly sql dump of n dbs. there thread at automatic backup mysql workbench references heavy-duty tools. another thread on here refers outdated workbench version. we can use batch file (it's windoze server) schedule backups, futureproofing , sake of successor(s) nice have easy-to-use gui tool. recommendations? there's no free tool or plugin mysql workbench schedule backups. mysql enterprise backup (in short meb) can that, including management within mysql workben

Swift declare that AnyClass object implements protocol -

i writing framework creating plugins os x application. these plugins loaded nsbundle s, , bundles' principalclass es used run plugin code. however, can't figure out how declare principalclass object conforms protocol. let bundles = cfbundlecreatebundlesfromdirectory(kcfallocatordefault, nsurl(fileurlwithpath: bundledirectory), "bundle") nsarray bundle in bundles { let bundleclass = bundle.principalclass!! if (bundleclass.conformstoprotocol(myprotocol.self)) { //produces compiler error: //"cannot downcast 'anyclass' non-@objc protocol type 'myprotocol'" let loadedclass = bundleclass myprotocol } } what proper syntax declaring conforms protocol? (also, protocol declared @objc i'm not sure why says "non-@objc" protocol.) try: bundleclass myprotocol.protocol . docs here . btw, code can simplified let bundles = cfbundlecreatebundlesfromdirectory(kcfallocatordefault, nsu

python - Firefox Build does not work with Selenium -

for research, did source code modifications in firefox , build myself. in order automate testing, opted use selenium unfortunately, newly built firefox seem not support selenium. i did following: from selenium import webdriver selenium.webdriver.firefox.firefox_binary import firefoxbinary binary = firefoxbinary("/path/to/firefox/binary") d = webdriver.firefox(firefox_binary=binary) d.get("http://www.google.de") the firefox open , responsive (i can enter website in search bar). after while, python script crashes following error message: traceback (most recent call last): file "firefox.py", line 7, in <module> d = webdriver.firefox(firefox_binary=binary) file "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/firefox/webdriver.py", line 59, in __init__ self.binary, timeout), file "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__

amazon s3 - FineUploader - Error on multi-part upload to S3 -

i using fineuploader upload s3. have working including deletes. however, when upload larger files broken multi-part uploads, following error in console (debugging turned on): specific problem detected initiating multipart upload request 0: 'the request signature calculated not match signature provided. check key , signing method.'. can point me in right direction should check settings, or additional info might need? since haven't included specific setup, code, or failing request, best guess server isn't returning proper signature response uploads made s3 rest api (which used larger files). you'll need review procedure generating response type of signature request. here's relevant section fine uploader's s3 documentation : fine uploader s3 uses amazon s3’s rest api initiate, upload, complete, , abort multipart uploads. rest api handles authentication signing canonically formatted headers. signing need implement server-side.

javascript - ruby on rails: leaflet-rails not loading -

using ror 4.1.4 i trying use leaflet-rails gem . followed steps outlined in github page, when try load map, see referenceerror: l not defined in browser console. means helper gem being loaded , executed can't find leaflet.js file. however, head section of page shows /assets/leaflet.js being referenced , there. when @ generated code: <div id="map"></div> <script> var map = l.map('map') map.setview([-54.0, 6.08], 16) l.tilelayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { attribution: '&copy; <a href="http://osm.org/copyright">openstreetmap</a> contributors', maxzoom: 18, subdomains: '', }).addto(map) </script> </div> <script src="/assets/jquery.js?body=1" data-turbolinks-track="true"></script> <!-- other scripts loaded --> <script src="/assets/exif.js?body

.net - Can we type strings with use of hex codes in c# like we type integers like that int a = 0x0000cd54;? -

i think kind of unusual thing ask, need this. well, know can this: string str = "45 ac 1b 5c"; and convert meaningful, if don't want bother conversion , want set string somehow that: "0x00000045 0x000000ac 0x0000001b 0x0000005c" , automatically becomes common characters? is there way? string str = "\x45 \xac \x1b \5c" http://msdn.microsoft.com/en-us/library/aa691090%28v=vs.71%29.aspx

excel - Replace Numerical Reference of a formula VBA? -

for = 1 5 changeto = cstr(sheet15.cells(1, i).formula) newindustry = getfirstword(worksheets("industry insert template").range("c1")) 'grab index position of comma , exclamation mark intchangeto = instr(changeto, ",") finalchangeto = instr(changeto, "!") 'extract worksheet substring finalindustry = mid(changeto, intchangeto + 1, finalchangeto - intchangeto - 1) if finalindustry <> "'multiples & eps'" , finalindustry <> "technicals" finalformula = replace(changeto, finalindustry, newindustry) cells(1, i).formula = finalformula end if next currently macro adjust worksheet name. want adjust numerical reference. for example: =vlookup($b1,industrials!$ca$41:$gg$41,c$8) i want able change cells 41 in vlookup reflect correct row. how go through cells , change formula reflect this? use replace : example : cells (1, i).formula

angularjs - Can't render date in template -

i have in template: <div ng-repeat="item in mainctrl.items" class="item"> <h4 ng-bind="item.title"><small ng-bind="item.pub_date"><strong></strong></small></h4> <p ng-bind="item.content"></p> </div> the item.content , item.content shows respectively. however, item.pub_date don't show value in there. empty portion @ date should in rendered template. using batarang, realized pub_date value shows in template, doesn't render or what. this how appears when in batarang pub_date: 2014-12-05t18:27:30.939z do need add date filter make work? i'm not exposing value within pub_date item or? thanks that because h4 tag wrapping small tag overrides content. ngbind directive replaces existing content. either move small out of h4 or use double curly notation title as: <h4>{{item.title}}<small ng-bind="item.pub_date"><st

angularjs - Use scope from multiple controllers on page -

so i've split out ui subcomponents realise 1 of components requires react dropdown change caught parent controller. i can create shared service variables , have been able inject sub controller can kick off functions but. how use scope within sub controller? var ctrl1= $scope.$new(); $controller('ctrl', { $scope: ctrl1}); ctrl1.getdata(); this works fine. can see data coming in console. ui doesnt change. missing? i've edited post illustrate i'm attempting more clearly. the drop down on change caught parent controller require child controller run away , data , update ui. it's attempt split out components. possible? or have split components out far? <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.min.js"></script> <script> angular.module('app2', []) .controller('ctrl2', ['$scope', '$http', function($scope, $http){

iOS Google map SDK: Setting maxZoom level issue -

i notice when set max zoom level of example 19, zoom go 20. don't know why. it's 1 more zoom level 1 set. gmscameraposition *camera = [gmscameraposition camerawithlatitude:23.589571946369546 longitude:58.14204730042655 zoom:16]; self.mapview_.camera=camera; self.mapview_.mylocationenabled = yes; self.mapview_.maptype = kgmstypehybrid; self.mapview_.settings.compassbutton = yes; [self.mapview_ setminzoom:5 maxzoom:19]; // creates marker in center of map. gmsmarker *marker = [[gmsmarker alloc] init]; marker.position = cllocationcoordinate2dmake(23.168520, 58.008163); marker.map = self.mapview_; // ------ add layer // implement gmstileurlconstructor // returns tile based on x,y,zoom coordinates, , requested floor gmstileurlconstructor urls = ^(nsuinteger x, nsuinteger y, nsuinteger zoom) { nsstring *url = [nsstring stringwithformat:@"http://www

How long does an Instance of my appWidget exist -

my simple question: how long instance of appwidget exist? to more precise. if declare static variable in appwidget: public static int myint = 5; is time accessable other activities launch if click on button? or exist @ update defined in xml or if click on appwidget till code has been finished. static variable exists long process alive.

python - Trouble plotting pandas DataFrame -

i have pandas dataframe has 2 columns 1 of columns list of dates in format: '4-dec-14' other column list of numbers. want plot graph dates on x-axis , numbers correspond date on y-axis. either scatter plot or line graph. trying follow tutorial on matplotlib http://matplotlib.org/users/recipes.html 'fixing common date annoyances' not accept date format. when try using plot function returns error: valueerror: invalid literal float(): 4-dec-14 . how change date format work. or there other way can plot dataframe. thanks you should first convert strings in date column, actual datetime values: df['date'] = pd.to_datetime(df['date']) then can plot it, either setting date index: df = df.set_index('date') df['y'].plot() or specifying x , y in plot: df.plot(x='date', y='y')

java - Can an array be larger than physical memory? (e.g. can it be partially paged) -

let's have api provides array of strings example, , array might larger physical memory. can jvm page part of array , bring disk traverse it? or array "atomic" data type can't partially paged? assume linked list answer easier since of nodes can paged transparently , retrieved on page fault, wonder if jvm (or if major oss @ all) allow paging part of large continuous array. nope. jvm can't this. but write implementation of list handle transparently, storing values disk or in database, , retrieving them necessary. an operating system can page bits of memory disk you, want careful relying on work efficiently. whether work without grinding halt rather depends on you're doing. involves accessing random entries in quick succession not cope being paged out. hash table, instance, doesn't perform in context.

mysql - Can I use two 'JOIN's in a single call? -

i'm trying call 3 different tables @ once. table a has general data. table td & dmd have specific data data points. my call (simplified) looks this. select a.*, td.*, dmd.* activities a, tweet_activity_data td, direct_message_activity_data dmd a.activity_id in (1,2,3,4,5) , a.activity_id = dmd.id , a.activity_id = td.tweet_id those last 2 lines i'm having trouble think. i need things line in response , produces no results. am 'allowed' use 2 joins in sql call? yes, join tables use join , on keyword. specifically, stuff in clause end on clauses, telling query how join tables. query select a.*, td.*, dmd.* activities join tweet_activity_data td on a.activity_id = td.tweet_id join direct_message_activity_data dmd on , a.activity_id = dmd.id a.activity_id in (1,2,3,4,5)

PostgreSQL single query SELECT single row FROM two tables without JOIN -

the result of query need create return single row. data need pull comes 2 tables without relational columns. second table has additional rows added once per year i'll construct query via php necessary. i know how use sql sub-selects i'm not sure how select multiple columns from second table when there no relational data in performance oriented/dynamic way. here static example use multiple sub-selects visualize i'm trying do... select t1.a, t1.b, t1.c, (select t2.d table2) d, (select t2.e table2) e, (select t2.f table2) f, (select t2.g table2) g, t1.h, t1.i table1 t1; how dynamically , efficiently pull multiple columns second table has no relational columns first table? i not want create second separate query cheap solution, have some impact on performance , worst of wouldn't expand understanding of sql. sounds need cartesian join (no join) -- multiply values (ie, if table 1 has 100 rows , table 2 has 10 rows, you'll return 1000 row

javascript - KendoUI DatePicker not returning date value -

i'm using mvc wrapper kendoui datepicker widget , have situation if enter in date this: 1/4/15, i'm unable retrieve value of field via javascript i.e. null value. however, if enter 1/4/2015, value correctly retrieved. here's js code value datepicker control: $("#date").data("kendodatepicker").value() c# parses 1/4/15 value correctly 1/4/2015 hope can show me how kendoui's datepicker to: a) recognize 1/4/15 valid date b) , correctly parse 1/4/15 1/4/2015

junit4 - JUnit & EasyMock -

is possible mock class instantiated in class unit testing? class classtotest { public string methodtotest(object a, object b, object c) { //do lots of cool stuff here someotherclass someotherclass = new someotherclass(); someotherclass.domorecoolstuff(a, b, c, this); //do more cool stuff "this" updated someotherclass } i want mock someotherclass used int classtotest. using easymock , can't seem compile. ideas? going wrong? thoughts? you need way mock in there. part of testing. when find this, , "i can't test that" need refactor code can test. refactoring turn weird , strange designs beautiful art. (too deep?) for example: interface factory { public someotherclass create(); } class classtotest { factory factory; public void setfactory( factory factory ) { this.factory = factory } public string methodtotest(object a, object b, object c) { //do lots of cool stuff here

asp.net identity 2 - How to add some claims to ClaimsIdentity but do not serialize them into the cookie -

i using asp.net identity 2 cookie authentication. want add permissions of user current claimsprincipal because there many permissions , cookie limited in size don't want serialize claims of identity cookie. want load claims during login , cache them server-side. have hook in add claims current principal on each request? i found solution. interface iauthenticationsessionstore need. implementation of interface, setting instance of on cookieauthenticationoptions.sessionstore property , can decide how persist whole claimsprincipal during requests without serializing cookie. tarzan, pardon, vittorio bertocci presenting details interface here .

c# - Is there a simple way to replace &lt; and &gt; with '<' and '>' in Doxygen HTML output? -

i using doxygen read standard xml summary blocks in c# code. works quite well, except 1 issue. have custom dictionary , in documentation have following: /// <summary> /// 'add' event handler <see cref="eventeddictionary&lt;tkey, tvalue&gt;"/>. /// </summary> which appears the 'add' event handler eventeddictionary<tkey, tvalue>. in intellisense popups, expect. not work in main html output of doxygen, appearing instead the 'add' event handler eventeddictionary&lt;tkey, tvalue&gt;. this causes no issues visual studio, keeps intellisense happy (thereby keeping me happy , i'm sure successors on project happy), cause issues in doxygen's output html. because of these issues, html documentation ugly. aware doxygen has filters input, cannot seem figure them out. maybe i'm being meticulous in documentation... is there simple way replace &lt; , &gt; < , > in doxygen html outp

.net - ShortGuid with Entity Framework -

i installed shortguid nuget , use key table. store 22-char string in database rather guid, it's easier find records when debugging. how entity framework create column? i tried adding: public shortguid newcol { get; set; } but no column added. tried: [column(typename = "nvarchar")] [maxlength(22), minlength(22), stringlength(22)] public shortguid newcol { get; set; } but still no column. presumably ef doesn't understand i'm trying ignores column? works fine if use guid: public guid newcol { get; set; } i suppose use 22-char string column, ideally i'd use shortguid type. possible? i have experienced similar entity framework in past. far understand, type of column cannot complex type. limitation of entity framework (but not 100% sure this). i share in these sort of situations, though aware answer more of workaround proper answer question. i create 2 properties in class: 1) property acting column in database , 2) property intended ke

How to convert from mixed HTML-string/DOM-elements to DOM-elements in Javascript? -

i wish implement following javascript function: function alltodom(partsarray) { // magic! } // called like: var rowobject = alltodom(['<tr>', tdelem1, tdelem2, '<td>xxx</td>', '<td>', divcontents,'</td></tr>']); // tdelem1, tdelem2, divcontents dom node objects. the thing want work on kinds of combinations of dom nodes , html fragments. long produces valid html of course. unclosed html tags , disallowed element combinations (like <table><div></div> ) allowed have undefined behavior. my first idea concatenate in html string, except in place of dom elements add placeholder comment <!--snoopy--> . above result in following string: <tr><!--snoopy--><!--snoopy--><td>xxx</td><td><!--snoopy--></td></tr> this valid piece of html, next create <div> , assign innerhtml , gather produced dom nodes, , iterate through them ,

Changing struct into class C++ -

for homework assignment, supposed code struct collected information music albums. able easily. second part of assignment turn struct class, , i'm having trouble getting code compile. here 2 codes. struct code: #include <iostream> #include <vector> #include <string> using namespace std; struct date { int month; int day; int year; }; struct album { string name; string artist; vector <string> songs; date release; }; void initializealbum(album& a); void initializesongs(vector <string> & songs); void printalbum(album a); int main() { album my_album; initializealbum(my_album); printalbum(my_album); return 0; } void initializealbum(album& a) { cout << "enter album name:" << endl; getline(cin, a.name); cout << "enter artist name:" << endl; getline(cin, a.artist); cout << "enter release month (numeric format: ex. 06/

C# ASP.Net adding online web service -

Image
i trying add online soap web service web application in visual studio. tried several tutorials of tutorials focus on creating server on local host. in web application, want countries web service using following url. http://www.webservicex.net/country.asmx?op=getcountries it provides following soap request , response. request post /country.asmx http/1.1 host: www.webservicex.net content-type: application/soap+xml; charset=utf-8 content-length: length <?xml version="1.0" encoding="utf-8"?> <soap12:envelope xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:body> <getcountries xmlns="http://www.webservicex.net" /> </soap12:body> </soap12:envelope> response http/1.1 200 ok content-type: application/soap+xml; charset=utf-8 content-length: length <?xml versio

c# - How to allow IIS to use local database from ASP.NET MVC project? -

i'm going demoing asp.net mvc website on local network. application has connection database: <connectionstrings> <add name="defaultconnection" connectionstring="data source=(localdb)\v11.0;attachdbfilename=|datadirectory|\aspnet-ebc-20141127093222.mdf;initial catalog=aspnet-ebc-20141127093222;integrated security=true" providername="system.data.sqlclient" /> </connectionstrings> i if database can used both iis , whenever run application locally. i've made site on iis - running .net v4. project lives in c:\inetpub\www\ebc . can publish website recieve error upon viewing page: "a network-related or instance-specific error occurred while establishing connection sql server. server not found or not accessible. verify instance name correct , sql server configured allow remote connections. (provider: sql network interfaces, error: 50 - local database runtime error occurred. unexpected error occurred inside localdb in

dataframe - How to reshape data frame, header value to column value in R -

i have dataset similar following structure date obj obj b obj c 12/12/2001 2 3 4 11/12/2001 5 7 6 and want reshape them following structure, panel plot in ggplot2 date value factor 12/12/2001 2 obj 11/12/2001 5 obj 12/12/2001 3 obj b 11/12/2001 7 obj b 12/12/2001 4 obj c 11/12/2001 6 obj c is there easier way/package other subsetting data , rbind data 1 one? help in base r, if values reshaped not factor s, can use stack : cbind(mydf[1], stack(mydf[-1])) # date values ind # 1 12/12/2001 2 obja # 2 11/12/2001 5 obja # 3 12/12/2001 3 objb # 4 11/12/2001 7 objb # 5 12/12/2001 4 objc # 6 11/12/2001 6 objc

c# - multi-user MS Access Database- how to lock completely -

we have ms access database (accdb) out on our network, multiple users edit & read means of .net application. aware server db such sql server best choice situation, that's out of hands. the .net application use both ado.net (ie oledbconnections ) , tools inside microsoft.office.interop.access.dao namespace connect database. i have read few articles , posts multiple users connecting access, , there seems confusion , differing opinions access's capabilities in regard. how/can achieve following in application: establish connections write database, lock entire database (all records , tables) until connection ended. if other users attempting write simultaneously halted exception, okay. establish connections designated read-only, have no conflicts other user's actions. thanks. to open accdb in exclusive mode need add key/value connection string mode=share exclusive; this block other user connect same database until close , dispose connection

Swift - Load information from Core Data faster -

hey how big amount of information 1000 rows without stuck? try this: dispatch_async(dispatch_get_main_queue(), { //here code }) but when executed request self.context.executefetchrequest returns me fatal error: unexpectedly found nil while unwrapping optional value . have error , have add self. in front of function. let queue:dispatch_queue_t = dispatch_get_global_queue(dispatch_queue_priority_default, 0) dispatch_async(queue, { () -> void in //code }) but same error... i use nsfetchrequest , add results in nsarray , loop results in loop , in loop sort results in dictionaries. 1000 records not core data. fetch them on thread. i not advise "sort results in dictionaries". should think how app logic interacts data , fetch objects need core data persistent store. for example, if want display 1000 lines in table view, use `nsfetchedresultscontroller´ optimized sort of situation - avoid memory , performance issues withou

node.js - How to use PassportJS and JWT together? -

i'm building node.js app uses both passportjs , jwt since primary form of communication between front-end (angular spa) , back-end (node.js sails) via sockets. i'd allow registration both locally or using github, google, etc. i've played sails-generate-auth , scoured hundreds of documentation , tutorials keep getting frustratingly stuck. i'm using angular-sailsjs-boilerplate starting point, lacks registration endpoint non-local endpoints. i created register endpoint in authcontroller: register: function(request, response) { sails.models['user'].create(request.body).exec(function(err, user) { if (err) { response.json(err.status, {err: err}); return; } if (user) { response.json({user: user, token: sails.services['token'].issue(_.isobject(user.id) ? json.stringify(user.id) : user.id)}); } }); }, but seems app structured there passport records (credentials) , user records, , passport

c# - NHibernate doesn't update many-to-many join table -

i have 3 tables @ database: images, imagetags, tags. images , tags have many-to-many relationship via imagestags table. images entity: public class image { public virtual int id { get; set; } public virtual string name { get; set; } public virtual ilist<tag> tags { get; set; } } tags entity: public class tag { public virtual int id { get; set; } public virtual string name { get; set; } } images map: public imagemap() { table("images"); id(x => x.id).generatedby.identity(); map(m => m.name).length(100).not.nullable(); hasmanytomany(f => f.tags).table("imagetags") .lazyload().inverse().cascade.saveupdate(); } tags map: public tagmap() { table("tags"); id(x => x.id).generatedby.identity(); map(m => m.name).length(100).not.nullable(); } when i'm trying update image, join table imagestag doesn't update, other image properties (name) updates. public vo

c# - MVC 5 on Mono: Could not load file or assembly 'System.Web.Entity' or one of its dependencies -

Image
goal: startup asp.net mvc 5 project on mono via xamarain studio. error after starting server: could not load file or assembly 'system.web.entity' or 1 of dependencies. error in xamarin studio: background: project created in visual studio 2013 default web project. of configuration out of box. code can viewed here on github . have latest , greatest mono , xamarin studio of writing. .net entity framework resolved dependency , there no build issues noted in xamarin studio. how project , running? how resolve dependency? i know old thread, ran across while starting port on mvc project vs windows vs mac. found better solution delete reference system.web.entity, , add nuget package system.web.http.common. hope helps.

java - Convert JSONObject into JSONArray using Python -

i have gone through various threads, couldn't find particular answer in python. have json file { "storeid" : "123", "status" : 3, "data" : { "response" : { "section" : "25", "elapsed" : 277.141, "products" : { "prd_1": { "price" : 11.99, "qty" : 10, "upc" : "0787493" }, "prd_2": { "price" : 9.99, "qty" : 2, "upc" : "0763776" }, "prd_3": {

security - How do file hashes guarantee files haven't been altered? -

when downloading files trusted sites, provide hashes files can use authenticate file downloaded same 1 published (or if i'm wrong in this, please correct me!) my question is: if hacker capable of modifying file on site, couldn't alter page on site published hash values reflect new "modified" values? if so, added security provide? if not, why not? or ... missing obvious how works? the key attack vector you're protecting against: someone breaching main server if can in main server, can rewrite hashes appear valid (so no go). so hashes provide no protection against breaches of main server. someone breaching mirror server assuming hashes on main server, can add layer of defense against breaching mirror, can detect modifications. someone mitm in connection if can mitm connection, can modify both file , hash. so won't protect there @ all. a bit error in tcp connection this prime benefit of hashing files. in past, when error checki

java - How to represent key value in a JSON string in predefined format? -

i have json string in have key , value shown below - { "u":{ "string":"1235" }, "p":"2047935", "client_id":{ "string":"5" }, "origin":null, "item_condition":null, "country_id":{ "int":3 }, "timestamp":{ "long":1417823759555 }, "impression_id":{ "string":"2345hh*" }, "is_consumerid":true, "is_pid":false } as example, 1 key "u" , value - { "string":"1235" } similarly key "country_id" , value - { "int":3 } similarly others well. need is, need represent above key value shown below. if value string data type, represent in double quotes, otherwise don't represent in double quotes "u": "1235" "p": "2047935" "client_id": &q

c - `fork()` sons are executing in reverse order -

this question has answer here: in fork() run first, parent or child? 2 answers i have code similar this: for (i = 0; < 3; i++) { pid = fork(); if (pid == 0) { son_function(); } if (pid < 0) { exit(1); } } void son_function(void) { printf("my pid=%d\n", getpid()); printf("%d: alpha\n", getpid()); printf("%d: beta\n", getpid()); printf("%d: charlie\n", getpid()); exit(0); } for reason can't understand, order of execution of son_function() in reverse order. mean son_function() printing pid numbers largest smallest. another thing freaks me prints every son in 1 after other, there's no way 2 prints 2 different processes print screen @ same time. sample can seen here: http://ideone.com/ubyyrx multiple processes can output console @ sa

c++ - Getting time difference using a time_t converted from a string -

i trying diff between 2 dates. 1 date being right , other date converted time_t string representation of date. my code follows const char *time_details = "12/03/2014"; struct tm tm; strptime(time_details, "%m/%d/%y", &tm); time_t mytime = mktime(&tm); time_t now; time(&now); double seconds = difftime(now, mytime); logg("now = %d", now); logg("mytime = %d", mytime); logg("unsigned int mytime = %d", (int)mytime); my output looks so: now = 1417830679 mytime = -1 seconds = 1610001720 mytime comes out -1 and, value seconds not correct either. add before use (and might want pick different name variable) memset(&tm, 0, sizeof(struct tm)); see notes section in strptime(3)

elasticsearch - How to extract variables from log file path, test log file name for pattern in Logstash? -

i have aws elasticbeanstalk instance logs on s3 bucket. path logs is: resources/environments/logs/publish/e-3ykfgdfgmp8/i-cf216955/_var_log_nginx_rotated_access.log1417633261.gz which translates : resources/environments/logs/publish/e- [random environment id] /i- [random instance id] / the path contains multiple logs: _var_log_eb-docker_containers_eb-current-app_rotated_application.log1417586461.gz _var_log_eb-docker_containers_eb-current-app_rotated_application.log1417597261.gz _var_log_rotated_docker1417579261.gz _var_log_rotated_docker1417582862.gz _var_log_rotated_docker-events.log1417579261.gz _var_log_nginx_rotated_access.log1417633261.gz notice there's random number (timestamp?) inserted aws in filename before ".gz" problem need set variables depending on log file name. here's configuration: input { s3 { debug => "true" bucket => "elasticbeanstalk-us-east-1-something"

php - PHPDoc for PDO Wrapper -

while writing lightweight wrapper pdo noticed pdo::query method seems have 4 different signatures available use per documentation: http://php.net/manual/en/pdo.query.php method overloading not allowed in php , seems phpdoc doesn't scenario, @ least while using phpstorm 8.x , following code (i provided 2 signature example): <?php /** * @method \pdostatement query(string $statement) * @method \pdostatement query(string $statement, int $pdo::fetch_column, int $colno) */ class database { private $pdo; public function __construct($dsn, $user = null, $pass = null, $options = null) { $this->pdo = new \pdo($dsn, $user, $pass, $options); } public function __call($method, $arguments) { return call_user_func_array(array(&$this->pdo, $method), $arguments); } } of course second @method statement highlighted in red in phpstorm following error: "method same name defined in class" does has suggestion on how f

html - JavaScript & XML How to bring in more information? -

i have following javascript brings in data xml file: function ajaxrequest(){ var activexmodes=["msxml2.xmlhttp", "microsoft.xmlhttp"] //activex versions check in ie if (window.activexobject){ //test support activexobject in ie first (as xmlhttprequest in ie7 broken) (var i=0; i<activexmodes.length; i++){ try{ return new activexobject(activexmodes[i]) } catch(e){ //suppress error } } } else if (window.xmlhttprequest) // if mozilla, safari etc return new xmlhttprequest() else return false } var mygetrequest=new ajaxrequest() if (mygetrequest.overridemimetype) mygetrequest.overridemimetype('text/xml') mygetrequest.onreadystatechange=function(){ if (mygetrequest.readystate==4){ if (mygetrequest.status==200 || window.location.href.indexof("http")==-1){ var xmldata=mygetrequest.responsexml //retrieve result xml object var rssentries=xmldata.getelementsbytagname("tutorial") var output='

c++ - Why am I getting the "Expression is not assignable" error? -

i made class private name, units sold, , units remaining. i made 2 class methods return, units sold , units remaining ints. i want sort units sold greatest least, errors explain in comments. what doing wrong, obvious? #include <iostream> #include <string> #include <fstream> using namespace std; const int max_size = 1000; const char file_name[14] = "inventory.txt"; //make item class class item { private: string name; int sold, remain; public: void set_name(string _name); void set_sold(int _sold); int get_sold(int); void set_remain(int _remain); int get_remain(int); void print(); }; //i erased methods setting name, sold, , remaining, work though int item::get_sold(int s) { s = sold; return s; } int item::get_remain(int r) { r = remain; return r; } //greatest least units sold void sort_sold(item gl[], int ct) // ct global constant set 1000 { //local variables int smallestpos; int tem

Python:delete number in list -

this question has answer here: loop “forgets” remove items [duplicate] 10 answers i learn python.i have problem here.it simple code,but don't know why result unexpected. here code: a=[1,2,3,4,6,7,'dd','ss','gg','oo',8] in a: b in range(10): if i==b: a.remove(i) print i want delete number in a. expecting result a=['dd','ss','gg','00'] result : [2, 4, 7, 'dd', 'ss', 'gg', 'oo'] i cannot understand why result this. can me? thank you! try remove integer list = [x x in if not isinstance(x, int)]

design - How to differentiate a many-to-many relationships while designing a database? -

i have design database. , finding entities , relationships. every relationships seems have many-to-many relationships. instance, in case: 1) staff manages client here staff can manage 0 or more client. similarly, client managed 1 or more client. 2) client orders buy stock here client can order zero, 1 or more stock buy , stock can ordered zero, 1 or more client. 3) client orders sell stock here client can order zero, 1 or more stock sell , stock can ordered zero, 1 or more client sell. these of examples of situation. , confused how separate these relationships. there other numerous cases these in scenario. , having difficulty conceptualize design. so, please enlighten me regarding situation. it seems there's quite lot system developing , presumably there requirements haven't mentioned isn't possible come complete answer. of following "conceptualize design" describe it. 1) common scenario , there's pretty standard way of dealing t

Q learning computation: states unknown -

i confused how implement simple q_learning algorithm. referring nice docummentation: http://artint.info/html/artint_265.html . the given formula is q[s,a] ←q[s,a] + α(r+ γmaxa' q[s',a'] - q[s,a]) the problem states unknown because trying learn flappybird's successful moves. q[s,a] need know value of q[s',a'] if don't know next state, how q function? assuming state described distance between bird , nearest pipe, how compute current q function? thank help! s' current state. s previous state. max_a' q[s', a'] value of best action current state.