Posts

Showing posts from January, 2011

javascript - Switch between .bind() and .on() - dynamically -

i want this, because working third-party scripts releated internet marketing. of them may contain jquery library included within , interfere recent or latest jquery library included on website. hence, i'd switch between .on() , .bind() dynamically upon website load of variable. for example, let's have global variable: var incjs = false; and depending of third-party script, know if have older lib included i'd use this. function tpnetwork () { incjs = true; startgateway('xxxxx'); $('#fancybox-outer') .delay(1000) .fadeto(300, 1); preventgtw(); widgetstyle(); } now may see there's function @ bottom widgetstyle() that function contain loads of things, important part following: $(window).on('resize', function () { if ($('.widget_wrap').length) widgetcenter_horizontal(); }); it has .on() method there. not supported in old jquery that's been used third-party network. i'd sw...

php - Daily Average for 1 Week -

i attempting daily averages in query below, each day in 1 week period. select avg(`carbs`) carbs, avg(`sugar`) sugar, avg(`units`) units, date_format(`trackedon`, '%m/%d/%y') date `tracking` `trackedon` between adddate(now(), interval -7 day) , now() however, returning me 1 days worth of averages (but think it's averaging in 1 week, , displaying first day) can me achieve this? here dummy data, table structure: -- -- table structure table `tracking` -- drop table if exists `tracking`; create table if not exists `tracking` ( `trackid` bigint(20) not null auto_increment, `userid` bigint(20) not null, `tracktype` int(11) not null, `carbs` decimal(10,3) not null, `sugar` decimal(10,3) not null, `units` decimal(10,3) not null, `trackedon` datetime not null, `tracklocation` geometry not null, primary key (`trackid`) ) engine=myisam default charset=latin1 auto_increment=11 ; -- -- dumping data table `tracking` -- insert `tracking` (`trackid`, `us...

angularjs - How to stub out a controller method called during object construction -

i have angularjs controller calls own refresh() method while being constructed. method in question accesses template elements not present during unit testing. function listcontroller($scope) { /// ... $scope.refresh = function() { var tabid = angular.element('#id li.active a').attr('href'); //etc } //initialise $scope.refresh(); } the refresh method causes unit tests fail while controller being constructed. work irrelevant tests, want override method stub , test has been called. jasmine's spy functionality looks way go, can't find way of setting 1 object before constructed. how this? you should move directive's link function. link function result of compile know sure element compiled , ready, , make "refresh" function unnecessary. in general, should never access dom via jqlite or jquery controller. also, link function provides direct access element, scope, , attributes (even href) nice. ...

javascript - strange "not defined" error -

i have below code in viewmodel: ca = function (clientnum) { this.caname = null; this.caadress = null; this.caidnum = null; this.cacontact = null; this.canote = null; this.catype = null; this.clnum = clientnum; }, viewmodelnewcredit = function () { var creditrows = ko.observablearray(), showview = ko.observable(), sessionticket = ko.observable(), loggeduser = ko.observable() newcreditrows = function () { console.log(this.clientnum()); this.creditrows.push(new ca(this.clientnum())); console.log(creditrows()); }, remove = function (ca) { this.creditrows.remove(ca); }; return { creditrows: creditrows, showview: showview, sessionticket: sessionticket, loggeduser: loggeduser, viewmodelnewcredit: viewmodelnewcredit, remove: remove }; }, and in html have: <tbody data-bind="foreach: ...

asp.net - Dynamically changing the connection string for a gridview with a button? -

i have log file in several sql databases. i want have grid on asp page bound 1 of them. i want have several buttons on page change table fills gridview. this asp vb web site project. can help? thanks! just have buttons bind data through different methods. example, button calls method uses connection string fill gridview.

html - Safari transform rotatex bug -

i have weird bug safari... i have 3 divs captions, hidden rotatex(-91deg) . on :hover caption comes down via rotatex(0deg) . works in chrome etc. when hover in safari works on first div. when hover on 2. or 3. animation doesn't work. check out demo: http://jsbin.com/aseced/28/edit html: <article class="tile2x1"> <section class="caption"></section> </article> <article class="tile2x1"> <section class="caption"></section> </article> <article class="tile2x1"> <section class="caption"></section> </article> css: [class*="tile"] > section.caption { padding-top: 20px; width: 100%; background-color: blue; height: 100px; transform-origin: top; -o-transform-origin: top; -moz-transform-origin: top; -webkit-transform-origin: top; transform: perspective( 600px ) rotatex( -91deg ); -o-tr...

python - Search and replace in current file with Sublime Text plugin -

i trying port sublime text build system plugin. the build system receive current file , go through code: for line in fileinput.input(inplace=1): sys.stdout.write(makereplacements(line)) now, in plugin syntax go fact way current file's content is: input = self.view.substr( sublime.region(0, self.view.size()) ) but i'm not sure should next operation. for line in input(inplace=1): how make replacements in file on-the-fly , save it? i don't think sublime text plugin api can save buffer, use file_name() method in sublime.view class , work file directly. as noted @mattdmo, file can saved using view.run_command('save') . it may easier use file name if old build file worked that.

javascript - ng-repeat empty on load when applying ng-model filter -

i have code : <input type="text" placeholder="search..." ng-model="query" /> <table ng-controller="employees" ng-init="init()"> <tr ng-repeat="employee in employees | filter:{ name: query }"> <td>{{employee.name}}</td> </tr> </table> the problem when page loads, there nothing in table, until type in search input. matching appears, , if clear input, employees displayed (as should on load). i don't have problem if write filter: query instead of filter:{ name: query } . how can have data displayed on load filter:{ name: query } ? add line employees controller: $scope.query = '';

python - What's the way of record traceback info into a file using LOGBOOK -

i'm new python 3rd party logging module logbook. after reading documents provided auther, not find equivalence to: logging.exception which record traceback info me. am missing information docs? , how can implement this? thanks in advance! logging.exception convenience method calls .exception method of root logger instance. logbook doesn't seem have such method on module itself, you'll have initialize new logger (in respect, api compatible). from logbook import logger log = logger('exceptions') try: raise exception() except: log.exception()

c# - Resetting Context for Entity Framework 5 so it thinks its working with a initialised Database - Code First -

linked question: cannot split table ef 5 - code first - existing database but think answer question not problem code first did whilst developing. the scenario this: had existing database , used begin creating data context began working realised naming conventions poor , tables needed remodelling. decided create new database better conventions existing tables taken across , remodelled new bits updated context @ new database even though migrations not enabled, getting errors database being out of sync (even though until morning still pulling data) i enabled migrations (comment in other question) , output script. , can see sync changes things table names , id properties etc. i can't move forwards, context seems not when switch databases on (which point brittle). need somehow reset context doesn't think changes have been made database , thinks working initial database again. i have deleted migrations folder, nothing. there sort of way can happen? ...

java - Ajax Post request to a Jax-rs service -

i'm trying simple post request browser , 415 unsupported media show in browser's console, in console says type is text/html , maybe i'm mising stupid here i'm doing post request android client , find server side, guess (since i'm not familiar js) it's javascript problem i'm having here, here portions of interest of code: ajax (this function called send , things before create json, part it's ok , tested, json being genereated successfully): $.ajax({ url: 'webresources/serverconfig/save/', type: 'post', datatype:'json', data: jsonobj }); how call javascript in html form: <form action="javascript:send()" method="post"> jax-rs service: @path("serverconfig/") public class configurationsaverservice { @post @path("save/") @consumes(mediatype.application_json) public void save(configuration configuration){ //config stuffs ...

null - If you nullify spent objects in javascript, are you saving possible silly garbage collections? -

if nullify spent objects in javascript, saving possible silly garbage collections? for example. if iterate through users in javascript: var users = [ { firstname: "chris", lastname: "pearson" }, { firstname: "kate", lastname: "johnson" }, { firstname: "josh", lastname: "sutherland" }, { firstname: "john", lastname: "ronald" }, { firstname: "steve", lastname: "pinkerton" } ]; // data, perhaps put in table users = null; is worth nullifying list? have science behind performance gains or if it's waste of time etc? it's quite hard explain people why way, know it's saved bacon on many occasions in, ofcourse, c++, in javascript, there experiment find out if it's worth in javascript? find sizeof function can trust, making me cry... if has done kind of experiment, i'd grateful see have come with! it depends on situation. example, he...

bash - Using variable with sed -

first of apologise in case has been answered before couldn't solve problem. i need search pattern , replace line of text comprising of both text , variable.btw using bash.. say $var = "stacko.ver/rulz=" **note: $var contain double quotes & = & dot , /** i want follow 1.search ;te.xt = note: value search contain ; & = , dot 2.replace textnum=$var of course $var should replaced actual value my attempts sed -i "s/;te.xt =/textnum=$var/" file sed -i "s/;te.xt =/textnum="$var"/" file sed -i "s/";te.xt ="/"textnum=$var"/" file none of these worked , either sed giving me error or value of $var not shown in file thanks regards quoting doesn't since sed issue, not bash issue. pick sed s-expression delimiter doesn't appear in text: sed -i "s|;te.xt =|textnum=$var|" file you can pick delimiter s doesn't appear in input. sed -e 'streetlight...

c# - Publishing ASP.NET vs. copying files -

i want know sure if there possible issues not publishing asp.net solution. in company current policy (strangely) copy web project dll, , needed references dlls, web.config , global.asax , image files on existing ones on iis web server(virtual directory created). do see issue above? your feedback appreciated. don't see problem this. it's sort of do. publish folder - folder, check web.config against live, zip up. create change request, referencing zip file & pass hosting team deploy. this works great us, has different views & circumstances. don't see technical issue, more of business process issue.

c++ - How to set up use of camera on Android with OpenCV + Qt5 -

there numerous questions around here, qt sites , opencv sites, none of them quite match case. (and lot unanswered anyway.) i'm using opencv android 2.4.6 (the prebuilt version downloadable official site) build native app android (4.1.2) on samsung galaxy note 2 qt 5.0.1 android (using qtcreator 2.7.2) on x86_64 linux host. i've linked against libraries in ../sdk/native/libs/armeabi-v7a folder. (i haven't built opencv source, i'm using in downloaded package). includes libopencv_androidcam.a library. (and i've tried libnative_camera_r4.1.1.so shared lib.) i've downloaded market app "opencv manager". the sample .apks samples directory work on phone, haven't tried build them on own, don't have java development environment set up. starting application, contains cv::videocapture inputcapture(cv_cam_android); statement, following error , no camera input: e/opencv::camera(15299): camerawrapperconnector::connecttolib error: cannot dlopen ...

model - How to store variables in all pages requestScopes within Spring -

i add objects in jsp requestscopes using controllers. for example, if need list categories in "localhost/products/viewall", change productscontroller adding like @requestmapping("/products/viewall") public void viewcategories(model model) { list<category> categories = service.findallcategories(); model.addattribute("categories", categories); } so, method adds list of categories requestscope. i need same, pages of website (since variable need used in layout of site). how can add pages requestscopes spring? i think have @ least 2 possible options this: using mvc interceptor . interceptor can perform common operations requests. can extend handlerinterceptoradapter , add common model data in posthandle using @modelattribute annotation within controller. can use add common data request mappings within controller. can use @controlleradvice (with @modelattribute annotated methods inside) if want provide model data con...

loops - Python: Looping over 2mln lines -

i have loop on large file 2mln lines, looks p61981 1433g_human p61982 1433g_mouse q5rc20 1433g_ponab p61983 1433g_rat p68253 1433g_sheep currently have following function, take every entry in list, , if entry in large file - took row occurence, it's slow (~10min). due looping scheme, can please suggest optimization? up = "database.txt" def mplist(somelist): newlist = [] open(up) u: row in u: in somelist: if in row: newlist.append(row) return newlist example of somelist somelist = [ 'p68250', 'p31946', 'q4r572', 'q9cqv8', 'a4k2u9', 'p35213', 'p68251' ] if somelist contains values found in first column, split line , test first value against set , not list : def mplist(somelist): someset = set(somelist) open(up) u: return [line line in u if line.split(none, 1)[0] in someset] t...

ORM Entities vs. Domain Entities under Entity Framework 6.0 -

i stumbled upon following 2 articles first , second in author states in summary orm entities , domain entities shouldn't mixed up. i face problem @ moment code ef 6.0 using code first approach. use poco classes entities in ef domain/business objects. find myself in situation define property public or navigation property virtual because ef framework forces me so. i don't know take bottom line of 2 articles? should create example customeref class entity framework , customerd domain. create repository consumes customerd maps customeref queries , maps received customeref customerd. thought ef mapping domain entities data. so please give me advice. overlook important thing ef able provide me with? or problem can not solved ef? in latter case way manage problem? i agree general idea of these posts. orm class model part of data access layer first , foremost (even if consists of so-called pocos). if conflict of interests arises between persistence , business logic ...

c# - How to have application use different databases via wcf dataservice -

we building c# .net application sold clients, sql server database hosted us. have database each client. not sure if can use 1 wcf data service access different databases. using entity framework build database. how can accomplish client can pass in correct database name or connection string? this different databases using wcf dataservice said possible, doesn't specifics. this wcf service multiple clients database(each client) looks same question, has no answers. make wcf-service session based, provide login-method , in method have decide database use, can either change connectionstring edmx if datamodel same or if have differnt datamodels each client have create edmx instance each client! here simple pseude-code, entityid identifies client for creating entityconnectionstring check out link to create session-based wcf service have define service interface that [servicecontract(sessionmode = sessionmode.required)] public interface isampleservice { [o...

c++ - Double pointer of Mat initialization -

i trying make mat array using opencv. array store number n of region of interest, , each region have store information of last 5 frames. i'm trying use double pointer mat . question how initialize it? i'm trying this: in header of class: mat *objs_avgwb[25]; and initialize in source file: vseg.objs_avgwb = new mat[vseg.avgw][25]; instead of mucking around pointers , new , better option use containers provided standard library. don't need worry how you'll initialize them, since can resized dynamically. for each set of features in frame, create std::vector of cv::mat objects, 1 each region of interest. then, use std::deque hold features each frame. std::deque<std::vector<cv::mat>> roi_history; on each new frame, push_back each roi onto std::vector representing rois in frame: std::vector<cv::mat> new_rois; new_rois.push_back(roi1); new_rois.push_back(roi2); // etc... you pop off oldest frame , push new data keep 5 frames ...

java - Problems with migration from WAS 6.1 to WAS 7.0 cookie is always null -

i have problem: i migrate applications 6.1 7.0 using migration tool in c:\program files\ibm\sdp\runtimes\base_v7\bin\migration the application running fine in 6.1 server when migrated there problem 1 cookie need getting division user. after debugging while realize cookie getting created reason don't know cookie not getting put httpservletresponse , when try retrieve value cookie says null . here's snippet of code used this: public static void setdivisioncookie( string div, httpservletresponse res ){ cookie cookie = new cookie(user_division_cookie_name, div); cookie.setmaxage(integer.max_value); cookie.setpath("/"); res.addcookie( cookie ); } i have application running struts (these jar's i'm using struts-1.2.9 , struts2-core-2.1.8.1 , struts-taglib-1.3.8 ) each web application get/put cookies under servlet context path. example cookie.setpath(request.getcontextpath());

sql server - How to run a Sum on a DateTime Field in SQL with join on Single Column -

using ssms ( sql server management studio ) - 2012 please me finish building sql query. first table sites client,market,project,sitenumber grum , lad , aaa , 12345 gla , daa , h11 , 56789 second table sitesstatus sitenumber,statusname,date(datetime),byuser 12345 , sta1 , 8/7/13 15:33:22, hec 12345 , sta1 , 8/7/13 15:43:22, hec 12345 , sta2 , 8/7/13 15:53:22, hec 12345 , sta2 , 8/7/13 16:03:22, hec 12345 , sta2 , 8/7/13 16:13:22, hec 56789 , sta1 , 8/7/13 15:22:22, hec 56789 , sta2 , 8/7/13 15:32:22, hec desired results client,market,project,totalsites, sta1 ,totstattime, sta2 ,totstat2time,byuser grum , lad , aaa , 5 , 2 , 10 , 3 , 20 , hec gla , daa , h11 , 2 , 1 , inprogress, 1 , inprogress , hec it have show hours of row of date column in table 2 correspond sitenumber table 1, place inprogress column/row of result if didn't fin...

c# - Abuse using and Dispose() for scope handling of not to be released objects? -

for convenience , safety reasons i'd use using statement allocation , release of objects from/to pool public class resource : idisposable { public void dispose() { resourcepool.releaseresource(this); } } public class resourcepool { static stack<resource> pool = new stack<resource>(); public static resource getresource() { return pool.pop(); } public static void releaseresource(resource r) { pool.push(r); } } and access pool like using (resource r = resourcepool.getresource()) { r.dosomething(); } i found topics on abusing using , dispose() scope handling of them incorporate using (blah b = _new_ blah()) . here objects not freed after leaving using scope kept in pool. if using statement expands plain try dispose() should work fine there more happening behind scenes or chance won't work in future .net versions? this not abuse @ - common scope-handling idiom of c#. examp...

r - Find quantiles of gamma like distribution -

Image
the data gamma distributed. to replicate data this: a) first find distrib. parameters of true data: fitdist(datag, "gamma", optim.method="nelder-mead") b) use parameters shape, rate, scale simulate data: data <- rgamma(10000, shape=0.6, rate=4.8, scale=1/4.8) to find quantiles using qgamma function in r, just: edit: qgamma(c(seq(1,0.1,by=-0.1)), shape=0.6, rate =4.8, scale = 1/4.8, log = false) how can find quantiles true data (not simulated rgamma)? please note quantile r function returns desired quantiles of true data (datag) these understand assuming data distributed. can see not. quantile(datag, seq(0,1, by=0.1), type=7) what function in r use or otherwise how obtain statistically quantiles highly skewed data? in addition, make sense somewhat? still not getting lower values! fn <- ecdf(datag) fn(seq(0.1,1,by=0.1)) quantiles returned "q" functions, in case qgamma . data eyeball integration suggests of dat...

javascript - jQuery - TypeError: "".match is not a function -

(function( $ ) { $(function() { $( '.addrow' ).delegate( 'click', function() { var $this = $( ), $tbody = $this.parents( '.tbody' ); $tbody.find( 'td:nth-child(-2)' ).css( 'background', 'red' ); }); }); })( jquery ); i'm getting following error : timestamp: 07/08/2013 21:02:49 error: typeerror: "".match not function source file: file:///c:/program%20files/wamp/www/kbd-creator/v5/jquery-1.10.2.min.js line: 5 i tried changing .delegate .on , error doesn't appear anymore. doing wrong .delegate ? you're missing parameter .delegate() . should use .on() anyway, though note if call 2 parameters it's not going delegated handler setup.

Python in C++: Unresolved external -

i try embed python in c++ application, linker keeps saying error: [ilink32 error] error: unresolved external '_pymodule_create2tracerefs' referenced e:\cpp projects\anderlicht\win32\debug\anderlicht.obj i'm using embarcadero c++ builder xe2, converted python33.lib coff2omf.exe. this code in main.cpp: #include "anderlicht.c" #pragma comment(lib, "python33_omf.lib") // in main(): pyimport_appendinittab("anderlicht",pyinit_anderlicht); py_setprogramname(programname.w_str()); py_initialize(); in anderlicht.c python.h included. have fix error? the problem you're using different compiler flags in building code used in building python dll. in particular, pymodule_create2tracerefs defined if have -dpy_trace_refs (which passed in via extra_cflags in make command on unix; have no idea how embarcadero c++ builder on windows). usually, isn't defined—in particular, if you're using dll pre-build python binary, won'...

c# - Sending mail and pulling data from app.config -

i have situation. html code standard 3 text boxes , 1 button: <add key="cma_contact_form_email" value="somec@gmail.com"/> <add key="cma_contact_to_address" value="some@gmail.com"/> <add key="smtpserver" value="smtp.gmail.com" /> <add key="enablessl" value = "true"/> <add key="smtpport" value="993" /> <add key="smtpuser" value="some@gmail.com" /> <add key="smtppass" value="pass" /> code behind: protected void imagebutton_click(object sender, eventargs e){ mailmessage msg = new mailmessage(); msg.to.add(configurationmanager.appsettings["cma_contact_form_email"]); msg.from = new mailaddress(configurationmanager.appsettings["cma_contact_to_address"]); msg.body += "name: " + txtname.text + "\n"; msg.body += "em...

php - highcharts JSON google earth -

i show pie chart (using highcharts library) inside placemark's popup box (google earth desktop) data taken mysql database residing on live server. the chart intended dynamic , realtime. from research found can using json formatted data taken php script in server , sent html file pre-processed. i put html code (highcharts.html) inside placemark popup , refers retrieve_data.php file residing in server . the php file fetching dummy data (if access address of php script referenced inside html code can see them) seems json encoding done. the thing how send them @ google earth placemark (or google earth placemark fetch them).... am missing in communication server or wrong?? note: first contact json data transfer! below files use. thank in advance help <!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/...

sql - alternate for IN operator -

i have below query question alternate way use in clause in where clause, taking lot of time pull records. there 1000 records in table need 64 records few of them in clause below. query effecting performance. select distinct t6.name ord_job_code t6 t6.name in ('g23.08', 'g10.01', 'g10.02', 'g10.03', 'g10.04', 'g10.05', 'g10.06', 'g10.07', 'g10.08','g10.09', 'g8.01','g8.02','g8.03','g8.04') please me in solving performance issue.

android - Establishing if a device is connected to a particular site -

i trying establish if device has connection particular site. if should start intent, if doesn't should throw toast. it seems throw toast though if device can see site:- public void gotostation(view v) { try { inetaddress ina = inetaddress.getbyname("http://www.lisbury.co.uk"); ina.isreachable(10000); { intent myintent = new intent(mainactivity.this, customizedlistviewstation.class); startactivityforresult(myintent, 0); } } catch (ioexception ioe) { toast.maketext(this, "you need data connection view safety zones", toast.length_long).show(); } } inetaddress ina = inetaddress.getbyname("www.lisbury.co.uk"); but isreachable doesn't guarantee device can connect site - isreachable using icmp echo , tcp port 7, both can filtered out, yet host available, , vice versa - host can available, web server down

obfuscation - Hide user input in Ruby -

i'm looking read in data user, however, not want input show directly on screen. rather, i'd leave blank or better yet, obfuscate characters input astericks. for example: print "password: " pass = stdin.gets.chomp assuming using @ least ruby 1.9, can use noecho method on io : http://www.ruby-doc.org/stdlib-2.0/libdoc/io/console/rdoc/io.html#method-i-noecho so: require 'io/console' print "password: " stdin.noecho(&:gets).chomp this not obfuscate characters, leave input terminal blank.

android - installation-like form dialog box -

Image
i've got problem dialog box. i'd installation-like form asks question type / choose option. @ moment did simple dialog box shows layout spinner. ideas should create new dialog box on "next" button (or maybe somehow change layout of current dialog box?) asks next question? picture: my code: public class dialog_box extends sherlockdialogfragment { @override public dialog oncreatedialog(bundle savedinstancestate) { final alertdialog.builder builder = new alertdialog.builder(getactivity()); final layoutinflater inflater = getactivity().getlayoutinflater(); builder.setview(inflater.inflate(r.layout.my_layout, null)); builder .settitle("question i") .setpositivebutton(r.string.next, new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { } }) .setnegativebutton(r.string.cance...

android - Wallpaper application size too big? -

i'm creating high quality wallpaper app samsung galaxy s4 resolution(1080x1920) picture size 1.5-3.5 mb each. i'm wondering, how come of wallpaper apps smaller 1 mb if mine 100++. if save pictures on sd card doesn't count in play store? or save on internet , load pictures it? probably because app downloads wallpaper files server after it's installed...

java - Atom:link in RSS using Rome -

it recommended add rss 2.0. i wondering if there rome module available add tag? developed content, media, etc . the blog post adding atom links rss feed generated rome answers question: there no build-in immediate support atom elements inside rss feed ... i’ve implemented atomcontent class holds list of com.sun.syndication.feed.atom.link easy extensible. the code published https://github.com/michael-simons/java-syndication .

.htaccess - Improving blocking user from downloading video -

i need advice in blocking user download video site. i knw impossible but still things have done - rename htaccess of /video.mp4 /video (because have renamed video name random numbers takes little time find it.) blocking htaccess of mp4 rewritecond %{http_referer} !^http(s)?://(www\.)?yourdomain\.com/ [nc] rewriterule \.(mp4)$ - [nc,f,l] anymore tips guys can improve ?? imp. question- blocking htaccess blocking url directly computer genius/crackers ? info- using mediaelement.js simple basic html5 code player thank you i honest, if client has view it, there no way stop it. thing possibly use custom player accepts encrypted traffic.

php - Sort by date from different table -

i need help. please me out work. i have these 2 tables, relation between them user_id . accomplished select follow , display images wall. however, have strange issue: photos sorted desc want, sorted user_id . means whoever follow first, image sorted first desc . i tried every possible way photos sorted base on desc newest photo top, couldn't. here tables , i'll show every possible thing tried: create table if not exists `photos` ( `id` int(11) not null auto_increment, `img` varchar(255) not null, `about` text not null, `date` varchar(222) not null, `user_id` varchar(255) not null, `likes` int(255) not null, `down` int(255) not null, primary key (`id`) ) ; create table if not exists `follow` ( `id` int(11) not null auto_increment, `followers` varchar(255) not null, `following` varchar(255) not null, primary key (`id`) } one followers_photo.php, retrieve following id from: $the_user = mysql_query("select * users username = '$g...

html - padding in one div affects other divs -

this question has answer here: using display inline-block columns move down 2 answers i have 3 inline-block divs this: <div style="display:inline-block">div1</div> <div style="display:inline-block; padding-top:5px">div2</div> <div style="display:inline-block">div3</div> i added padding second div display little lower, makes others divs go down well. how make second div display lower? here jsfiddle: http://jsfiddle.net/my6hp/ the same thing asked here , accepted answer suggests using absolute positioning, not do. change alignment on other divs allign @ top (via vertical-align:top; ): <div style="display:inline-block; vertical-align:top;">div1</div> <div style="display:inline-block; padding-top:5px">div2</div> <div style="display:in...

database performance - SQL Server Compact 4 Startup - LoadNativeBinaries Slow -

Image
we trying switch application serializes data files use database. basic windows form application. i noticed on start-up of our application there significant lag when initializing database connection through entity framework. have no idea causing , google skills failing me. i did dottrace performance profile on , showed: the performance profile shows 14 seconds of sql server ce running loadnativebinaries . missing? how speed up? update i created test database project , deployed device testing on. first time ran test program, took 17 seconds. after first time, took less second. tried running actual application , lag has disappeared. reinstalled application, , first time ran application, took 17 seconds, subsequent runs took less second. different original issue took 10+ seconds every launch. i've uploaded test project using here . i'm curious if else gets similar results. the following config file using <?xml version="1.0" encoding="utf-8...

mysql - Auto creation of database tables using JDO -

i new jdo , mysql. in project, want entities should converted in table automatically. i had start using jdo , defined properties this, javax.jdo.persistencemanagerfactoryclass=org.datanucleus.api.jdo.jdopersistencemanagerfactory datanucleus.autocreateschema=true datanucleus.validatetables=false datanucleus.validateconstraints=false datanucleus.query.sql.allowall = true javax.jdo.option.connectiondrivername=com.mysql.jdbc.driver javax.jdo.option.connectionurl=jdbc:mysql://127.0.0.1:3306/db_name javax.jdo.option.connectionusername=user javax.jdo.option.connectionpassword=123456 javax.jdo.option.mapping=hsql sample entity: @persistencecapable(identitytype = identitytype.application, table = "heartbeat") public class heartbeat implements serializable{ @primarykey @column(length=128) private string userid; ....... } now, when compile or run application tables not being auto created. not sure property should use auto creation of tables based on entities...

fortran - Is there something wrong in my MPI algorithm? -

i setup algorithm share data between different processors, , has worked far, i'm trying throw larger problem @ , i'm witnessing strange behavior. i'm losing pieces of data between mpi_isend's , mpi_recv's. i present snippet of code below. comprised of 3 stages. first, processor loop on elements in given array. each element represents cell in mesh. processor checks if element being used on other processors. if yes, non-blocking send process using cell's unique global id tag. if no, checks next element, , on. second, processor loops on elements again, time checking if processor needs update data in cell. if yes, data has been sent out process. current process blocking receive, knowing owns data , unique global id cell. finally, mpi_waitall used request codes stored in 'req' array during non-blocking sends. the issue i'm having entire process completes---there no hang in code. of data being received of cells isn't correct. ...

vba - Why does this Worksheet_change loop crash if row insert causes number of rows > 100? -

Image
the purpose of below code number rows 6 rowcount 1 rowcount in numerical order in col b. when user inserts row, numbers automatically adjust. example, if user inserts new row between rows 6 , 7, new row numbered 7 in col b, previous row 7 renumbered 8, , remaining rows renumbered 9 rowcount. works fine until rowcount >= 100. when user inserts new row, program crashes. why? what's special 100 , above? there better method auto re-renumbering rows when user inserts new row? private sub worksheet_change(byval target range) dim long, rowcount long rowcount = usedrange.rows.count = 6 rowcount if me.cells(i, 2) <> - 5 me.cells(i, 2) = - 5 end if next works fine here, option explicit private sub worksheet_change(byval target range) application.enableevents = false dim long = 6 usedrange.rows.count if me.cells(i, 2) <> - 5 me.cells(i, 2) = - 5 end if next application.enableevents = true end sub '[![screenshot][1]][2]

performance - nodejs v0.10.15 windows 8 - slow start -

i have same version on ubuntu , windows 8 - v0.10.15, same script express.js. nodejs on ubuntu restarts (when use supervisor, or run debug phpstorm). in windows 8 it's writes console server started, when check in browser page loaded delay.

javascript - Making a POST HttpRequest (XMLHttpRequest) in Dart -

i try submit simple post httprequest in dart. according docs, method should request.onload.add instead of request.onload.listen , 1 using. yet arrived here because `onload.add' did not exist. :o issue: no errors, no submit, no success message. void main() { query("#sample_text_id") ..text = "click me!" ..onclick.listen(submithttprequest('test.php')); } void submithttprequest(string phpfile, [json, callback(int status)]) { print('yeeep'); var request = new httprequest(); request.open('post', 'php/$phpfile'); request.onload.listen((event) { print('event'); }, ondone: () { print('loaded'); handleresponse(request.status); if(callback != null) { callback(request.status); } }, onerror: (e) { print('err' + e.tostring()); }); } the output is invalid css property name: -webkit-touch-callout yeeep i have no idea first line comes from, pretty sure...

mongodb - narrowing down mongo db query result -

so have mongo query: {"r_rid" : "cr_448630" } which when execute find() returns { "_id" : { "$oid" : "soaifusladfjlasfjdkl2222"} , "mg" : 1 , "r_rid" : "cr_448630" , "users" : { "5" : { "duration" : 15305 , "last_ts" : 99999999} , "33455" : { "duration" : 1563835 , "last_ts" : 1375826968} , "33606" : { "duration" : 4230245 , "last_ts" : 1375914301} , "33651" : { "duration" : 0 , "last_ts" : 1373305133} } } what if want user index 33455 how go modifying mongo query sorry, mongo n00b here... i have few comments here, in general can not sub document out of document it's sole return value. best can straight out of mongodb johnnyhk writesis with: db.test.find({"r_rid" : "cr_44863...

javascript - jScrollPane and relative width? -

i experimenting jscrollpane ( http://jscrollpane.kelvinluck.com/index.html ) wonderfull piece of art. no have problem, div want scroll jscrollpane has absolute position , dynamic width height: .scroll-pane { text-transform: none; text-align: left; background: rgba(40,40,40,0.5); position: absolute; top: 250px; left: 100px; min-width: 50%; max-width: 70%; min-height: 40%; text-transform: none; bottom: 40px; overflow: auto; } if change windows-size, jscrollpane breaks. if reload page in new size, scrollbar works again perfectly. is there way trigger reinitialization of jscrollpane if windows-size changing? it nice if me this. try this: $(window).resize(function(){ $('.scroll-pane').jscrollpane(); });

jquery - Backbone fetch() always returns same model -

Image
for reason, code returning same model though can see correct id being passed in after select item in listview page. // main.js (relavent function) venuedetails: function (id) { // here, id correct var venue = new venue({_id: id}); venue.fetch({success: function(){ // here, id of venue changed reason console.log(venue.id); $("#content").html(new venueview({model: venue}).el); }}); this.headerview.selectmenuitem(); }, the model, // model.js (relavent model) var base = 'http://localhost:3000'; window.venue = backbone.model.extend({ urlroot: base+"/venues", idattribute: "_id", }); window.venuecollection = backbone.collection.extend({ model: venue, url: base+"/venues?populate=true" }); in picture, can see model.id different whats in url edit: added router mapping var approuter = backbone.ro...

vba - Finding and Outputing multiple entries in an excel array -

i have more complicated spreasheet explain trying simpler spreadsheet. have 2 columns, first column has first names , second column has last names. for example: column1 michael; michael; michael; george; michael; henry; column 2 keaton; douglas; jackson; washington; jordan; ford; i create either excel formula or vba function search column 1 rows match "michael" , return last names associated "michael" first names. preferably, concatenating last names space in between. vlookup, index, match, , array functions in excel won't work because return first "michael" last name. have tested vba function below , seems work feedback on function or suggestions on formula work. so output of function above columns be: " (keaton) (douglas) (jackson) (jordan)" any or suggestions welcome. vba code. sourcearray first names, id "michael", targetarray last names. public function drawid(arrinput variant, id string, arrout...

powershell v2.0 - Escaping quotes and double quotes -

i'm new powershell...and wondering how escape quotes in -param value. $cmd="\\server\toto.exe -batch=b -param="sort1;parmtxt='security id=1234'"" invoke-expression $cmd this of course fails, tried escape quotes (single , double) using escape character ` , did various combination nothing working. please help escaping parameters source of frustration , feels lot time wasted. see you're on v2 suggest using technique joel "jaykul" bennet blogged while ago long story short: wrap string @' ... '@ : start-process \\server\toto.exe @' -batch=b -param="sort1;parmtxt='security id=1234'" '@ (mind assumed quotes needed, , things attempting escape) if want work output, may want add -nonewwindow switch. btw: important issue since v3 can use --% stop powershell parser doing parameters: \\server\toto.exe --% -batch=b -param="sort1;paramtxt='security id=1234'" ... should wo...

r - How to delete rows from a dataframe that contain n*NA -

i have number of large datasets ~10 columns, , ~200000 rows. not columns contain values each row, although @ least 1 column must contain value row present, set threshold how many na s allowed in row. my dataframe looks this: id q r s t u v w x y z 1 5 na 3 8 9 na 8 6 4 b 5 na 4 6 1 9 7 4 9 3 c na 9 4 na 4 8 4 na 5 na d 2 2 6 8 4 na 3 7 1 32 and able delete rows contain more 2 cells containing na get id q r s t u v w x y z 1 5 na 3 8 9 na 8 6 4 b 5 na 4 6 1 9 7 4 9 3 d 2 2 6 8 4 na 3 7 1 32 complete.cases removes rows containing na , , know 1 can delete rows contain na in columns there way modify non-specific columns contain na , how many of total do? alternatively, dataframe generated merging several dataframes using file1<-read.delim("~/file1.txt") file2<-read.delim(file=args[1]) file1<-merge(file1,file2,by="chr.pos",all=true) perhaps me...

assembly - arm thumb mode 4byte instructions -

Image
thumb mode instructions 2 bytes , arm mode instructions 4 bytes. screenshot disassembly of thumb mode instructions. why see 4 byte instructions mixed 2byte instructions?? can explain this? thank in advance. cortex m micros can run in thumb-2 mode, in between thumb , arm modes. thumbs-2 instruction set includes 16 , 32 bit instructions , processor don't need switch modes execute both tipes of instructions.

sass - Make a variable from a list item -

this question has answer here: creating or referencing variables dynamically in sass 5 answers i'm want make variable list item, can't find method paste dollar sign front of it. beneath methods tried. $hoi: yellow; $test: hoi; helpme{ background: $#{$test}; //error background: $$test; //error background: $nth($test, 1); //error background: unquote("$")#{$test}; //output: $hoi background: unquote("$")nth($test, 1); //output: $ hoi }; is there method paste dollar sign before variable , still recognized variable? with pure sass, can't declare variables names taken other variables. you can using template generate sass code , parse it. here's example of how compass generating sprite variables: https://stackoverflow.com/a/16129685/901944 bun advise against it. poor practice leads spaghetti code that's di...

django - Trying to add like functionality to my Photo Resource using Tastypie -

i have website people can photographs. created photoresource , photolikeresource (code below). able add photo, want return number of total likes photo , whether current user likes already. tried returning information in hydrate function (commented out in code, broke api calls). how can accomplish this? class photoresource(modelresource): tags = fields.manytomanyfield(tagresource, 'tags', null=true, blank=true) primary_image = fields.foreignkey(imageresource, 'primary_image', null=true, blank=true, full=true) user = fields.foreignkey(userresource, 'user') class meta: queryset = photo.objects.all() resource_name = 'photos' authorization = djangoauthorization() allowed_methods = ['get', 'post', 'put'] filtering = { 'primary_image': all, 'featured': } # dehyrdate below breaks photo_like call # def dehydrate(self, bundle): # num_likes = photolike.objects.filter(photo=b...

jasper reports - Border Artifacts in JasperReport PDF Designed with iReport 5.1.0 -

Image
when generating report jasperreports, seeing weird borders drawn reporting engine. borders drawn lines jut out @ 100% zoom level, seen in image. means when attempt draw square textbox, not square unless zoom in 150% more. here image showing issue. am doing wrong when setting border settings in ireport? how can fix problem? i had same problem. when exporting tables pdf , using thin table borders, lines of cell borders seem overstrike borders of table 1 pixel. visual artifacts visible in pdf viewers (they visible in adobe reader) , @ zoom levels. appearance of artifacts changes when line art smoothing turned on or off in pdf viewer. if zoom on overstrike @ maximal level, see lines drawn correctly - artifacts made pdf viewer when scaling document. when checking jasperreports code, i've found pdf export draws table border 4 single lines. drawn no caps (the line cut off @ end). when drawing square border way, corners not connect completely, each line drawn longer bord...