Posts

Showing posts from May, 2011

angularjs - angular $resource GET item is generating wrong api request -

whenever i'm calling item in angular api url not expect, , can't find wrong it. my resource angular.module('app').factory('mvcourse', function($resource) { var courseresource = $resource('/api/courses/:id', {_id: "@id"}); return courseresource; }); which can see expect call http://localhost/api/courses/53f05bb649d473da3fb83b59 getting http://localhost:1337/api/courses?_id=53f05bb649d473da3fb83b59 my api call follow angular.module('app').controller('mvcoursedetailctrl', function ($scope,$routeparams,mvcourse) { $scope.course = mvcourse.get({_id:$routeparams.id}); }); i'm using "angular-resource": "~1.2.21", "angular": "~1.2.21", it seems changing _id id trick, found in in comments

Yii-framework Encoding -

why when unpacking archives yii framework of archive console prompt: cd c: \ cd webservers \ home \ y1 \ www \ framework php -f yiic webapp c: \ webservers \ home \ y1 \ www encoding files ansi, when should utf-8? it's because windows uses an ansi-like encoding . shouldn't cause trouble unless start writing special charaters like: ñ,á,è... , upload files non-windows server. a workaround use text-editor, notepad++ or sublime text, , force encoding utf-8.

type conversion - Interfacing Ada enumerations and C enums -

let in c code defined: typedef enum { a=1, b=2 } option_type; void f(option_type option); let have ada code: type option_type (a, b); option_type'size use interfaces.c.int'size; option_type use (a=>1, b=>2); x: option_type := a; which of following code correct (accordingly rm)? -- first code declare procedure f (option: option_type) import, convention=>c, external_name=>"f"; begin f(x); end; or -- second code declare procedure f (option: interfaces.c.unsigned) import, convention=>c, external_name=>"f"; function conv new ada.unchecked_conversion(option_type, interfaces.c.unsigned); begin f(conv(x)); end; i think both first , second ada fragments correct not sure. neither 100% correct. in c: typedef enum { a=1, b=2 } option_type; in ada: type option_type (a, b); option_type'size use interfaces.c.int'size; option_type use (a=>1, b=>2); the ada code assumes c

asp.net - How do I use EntityDatasource (Or LinqDatasource) with a Union clause -

how combine records 2 tables in entitydatasource control? have googled , searched on no luck. sql of need is select distinct username (select s.username project_stakeholders s union select t.username project_team_members t) my entities structure follows: project_stakeholders ---------------------- project_stakeholders.record_id (pk) project_stakeholders.username project_stakeholders.project project_stakeholders.project_id (fk) project_stakeholders.status project_team_members --------------------- project_team_members.record_id (pk) project_team_members.username project_team_members.project project_team_members.project_id (fk) project_team_members.status i found question provides answer question mine more advanced because subqueries entities not related primary entity. i have changed datasource liqdatasource control , added code below in code behind of onselecting event of linqdatasource control: protected void taskprofileds_selecting(object sender, linqdatasources

jQuery: keydown replicating text one character behind -

the objective of this jsfiddle snippet display in <p/> text entered in <input/> every time user keys in character. works exception <p/> 1 character behind. what's wrong code? the jquery code: var $input = $('<input />'); $('body').append($input); var $p = $('<p/>'); $('body').append($p); $input.keydown(function() { $p.text ($input.val()); }); keydown fires key pressed, , before value updated pressed key. may wish use keyup() instead: $input.keyup(function() { $p.text ($input.val()); }); or simplify to: $input.keyup(function() { $p.text (this.value); }); you manually append last character (which works, long last keypress isn't backspace or delete: $input.keydown(e){ $p.val( this.value + string.fromcharcode(e.which)); }); but, frankly, starts become silly when have account special characters (using shift, ctrl, alt or backspace , delete).

sql - Select all items from the top N categories -

can please suggest how write sql query ms sql server select items top n categories following scenario? table of categories |idctegory|strname ------------------ |1 |cat 1 |2 |cat 2 |3 |cat 3 |4 |cat 4 table of items |iditem|idcategory ------------------ |1 |1 |2 |1 |3 |3 |4 |2 let's want select items top 2 categories, therefore expect this |iditem|idcategory ------------------ |1 |1 |2 |1 |4 |2 i have tried join tables, don't know exact number of items. thanks edit: got idea join table of items select top(n) idcategory categories group idcategory hope work. if not want keep ties: with tops (select top 2 i.idcategory, count(*) num_items items group i.idcategory order num_items desc) select i.* items join tops t on i.idcategory = t.idcategory fiddle: http://sqlfiddle.com/#!6/3bebb/7/0 if want keep ties: with tops (select top 2 ties i.idcategory, count(*) num_items ite

javascript - Is there a way to guess if some global variables have been assigned? -

in javascript, if declare constructor this: var pmfont = function(text, font, size) { this.text = text; this.font = font; this.size = size; /* ... ton of code ... */ x = 15; }; var test = new pmfont('dd', 'arial', 92); and create global variable example above: x = 15; , there way know, once object has been created, if there new global variables have been created? i've downloaded code, , i'd know if there useless variables in example stay in memory. may run far worse problems, example: imgd = ctx.getimagedata(0, 0, this.basewidth, this.baseheight) ...gets data of html5 canvas 2d context, , if it's not freed takes lot of ram. since js variables default undefined , if term assigned, previous answers not precise: function isgloballydefined(varname) { return window[varname] !== undefined } if variable has null or false value, has been assigned piece of code. since didn't specify context,

command line - Print script content (Python) -

using python 2.7 on windows 8.1, i have python script (stuff.py) i want open command line , type command going print content of script, in text format. what options? in typical *nix system, printing contents of file be cat stuff.py and edited critierion, windows 8: type stuff.py or if question restricted python, can write script similar: with open("stuff.py", "r") f: print "\n".join(f.readlines())

What does "deceptive request routing" mean in the new HTTP spec (RFC 7231)? -

in rfc 2616 , 400 response code syntax errors. the request not understood server due malformed syntax. client should not repeat request without modifications. rfc 7231 broadens applicability of 400. spec gives few other examples of client errors, i'm not sure mean. the 400 (bad request) status code indicates server cannot or not process request due perceived client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). in particular, constitute "deceptive request routing"? as 1 example, relevant cdn. see rfc 3568 . section 4.1.2 stands out me: this technique involves task of using http [4] such cookie, language, , user-agent, in order select surrogate. in [20] examples of using technique provided. the relevancy of cited example ("deceptive request routing") comes in when system relies on information including custom http headers decision making. when such header absent, stal

visual studio - Why doesn't Resharper's Assembly Explorer show anything? -

i trying decompile assembly resharper extension visual studio, when go resharper → windows → assembly explorer , explorer blank. when have project open, tool behaves way meant to, creating empty project in order able decompile awful. avoid using standalone decompiler dotpeek. the assembly explorer window intended show assemblies want decompile, aren't referenced in solution. if assembly referenced somewhere in solution, resharper's normal navigation decompile classes , methods on fly. in other words, it's intended used in conjunction open solution, means doesn't work without solution open (also, believe list of assemblies in assembly explorer stored in solution settings. without solution, there's no list display). what's issue using dotpeek? it's same codebase, compiled standalone components rather visual studio plugin?

Intercept incoming SMS samsung - Android -

i'm intercepting sms using following code in java public class smsreceiver extends broadcastreceiver { @override public void onreceive(context context, intent intent) { bundle extras = intent.getextras(); if (extras == null) return; object[] pdus = (object[]) extras.get("pdus"); (int = 0; < pdus.length; i++) { smsmessage smessage = smsmessage.createfrompdu((byte[]) pdus[i]); string sender = smessage.getoriginatingaddress(); string body = smessage.getmessagebody().tostring(); log.i("tag", body); //... whatever message here } } } with following receiver in manifest.xml </receiver> <receiver android:name="com.example.test.smsreceiver" > <intent-filter> <action android:name="android.provider.telephony.sms_received

php - .htaccess rewrite conflict issue -

please have problem .htaccess file rewriteengine on rewritebase /subdomain #make sure it's actual file rewritecond %{request_filename} -f [or] #make sure directory rewritecond %{request_filename} -d rewriterule ^ - [l] #rewrite request index.php rewriterule ^([^/]+)/([^/]+)/?$ index.php?mode=$1&s=$2 [l,qsa] #rewrite request index.php rewriterule ^([^/]+)/?$ index.php?mode=$1 [l,qsa] this .htaccess me access url http://domain.com/subdomain/index.php?mode=page http://domain.com/subdomain/page/ now want access url http://domain.com/subdomain/checkout.php http://domain.com/subdomain/checkout/ not working online, when test on localhost work fine. can changes on .htaccess resolve ? appreciated. thank in advance. in moment of luck, solved :) before trying specify special checkout.php in .htaccess that rewriterule checkout/ checkout.php in fact, solution, instead of putting after previous code "in question", put directly after line rewriteb

Do I have to reset all camera paramters if I change one [Android Camera Parameters]? -

i couldn't find information in android docs. here question: when change 1 parameter of camera, have reset parameters have set before or can sure not affected call mcamera.setparameters(params) ? for instance, when update zoom value calling params.setzoom(zoomvalue); mcamera.setparameters(params); will things white balance or auto focus stay untouched? , if so, can sure case android devices? thanks! right, camera.setparameters() don't support defaults. that's why use following sequence: camera.parameters params = mcamera.getparameters(); params.setzoom(zoomvalue); mcamera.setparameters(params); often, people try avoid multiple calls getparameters() using member: private camera.parameters mparams; ... mcamera = camera.open(); mparams = mcamera.getparameters(); ... params.setzoom(zoomvalue); mcamera.setparameters(params); but there 1 catch: result of setparameters() , seemingly unrelated parameters may change; next time, if use same mparam

execv multiple executables in single python script? -

from can tell, execv overtakes current process, , once called executable finishes, program terminates. want call execv multiple times within same script, because of this, cannot done. is there alternative execv runs within current process (i.e. prints same stdout) , won't terminate program? if so, it? yes, use subprocess . os.execv* not approporiate task, doc: these functions execute new program, replacing current process; not return. on unix, new executable loaded current process, , have same process id caller. so, want external exe print same output, might do: import subprocess output = subprocess.check_output(['your_exe', 'arg1']) by default, check_output() returns output written standard output. if want both standard output , error collected, use stderr argument. output = subprocess.check_output(['your_exe', 'arg1'], stderr=subprocess.stdout)

oauth 2.0 - How to Insert a Document to google drive using java without user interaction Oauth2 -

my requirement upload files google drive without having user interaction.i need use oauth2 .i have tried services account can upload files , share .uploaded files go "shared me" section .has 1 come across such issue. there solution. if understand question, want upload files drive account owned application, rather owned end user> you can either using regular account or using service account. to use regular account, (as account owner) need one-off auth refresh token, store. can use time generate access token needed invoke actual drive api. can generate refresh token using oauth playground, no need write code. answer how authorise app (web or installed) without user intervention? (canonical ?)

javascript - for loop for 0 to n number with digits specification -

how can write loop 16 digit number 0 n i want output like: 0000000000000000 0000000000000001 0000000000000002 0000000000000003 0000000000000004 0000000000000005 tried isn't working: for(i = 0000000000000000; < 0000000000000010; i++){ $("#testdiv").append(i); } check out jsfiddle <!doctype html> <html> <head lang="en"> <meta charset="utf-8"> <title></title> </head> <body> <script> function writenumber(n){ var nlen = n.tostring().length; var zerolen = 16-nlen; var arr = []; var str = "0"; for(var z=0;z<zerolen;z++){ arr.push(str); } arr.push(n.tostring()); return arr.join(''); } window.onload = function () { var arr = []; for(i=0;i<11;i++){ var str = writenumber(i);

python - Install packages failed: Error occurred when installing package tornado -

when trying install python packages on pycharm got error: install packages failed: error occurred when installing package tornado i have no idea for. here details: install packages failed: error occurred when installing package tornado. following command executed: packaging_tool.py install --build-dir c:\users\ehsan\appdata\local\temp\pycharm-packaging7844946454948740003.tmp tornado error output of command: downloading/unpacking tornado cleaning up... exception: traceback (most recent call last): file "c:\python27\lib\site-packages\pip-1.4.1-py2.7.egg\pip\basecommand.py", line 134, in main status = self.run(options, args) file "c:\python27\lib\site-packages\pip-1.4.1-py2.7.egg\pip\commands\install.py", line 236, in run requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle) file "c:\python27\lib\site-packages\pip-1.4.1-py2.7.egg\pip\req.py", line 1085, in prepare_files url = finder.find_r

javascript - Convert Time to ISO to Angular Format -

i hitting api , json data. i need change format json angular filter. format date getting is: 10/07/2014 , format of time is: 0745 . i wrote angular function called converted date iso: appcontroller.filter('datetoiso', function(){ return function(input) { input = new date(input).toisostring(); return input; }; }); then use angular filter render (date = 10/07/2014 : {{outboundflights.departure_day | datetoiso | date: 'mediumdate'}} and out puts this: oct 7, 2014 unfortunately, not work time (time = 0745 ): {{outboundflights.arrival_time | datetoiso | date: 'shorttime'}} it outputs: 6:00pm any idea why date works, time doesn't , possible solution? i need convert time iso can use filter correctly. so figure id it. had convert "normal" time out put custom filter: appcontroller.filter('timetonormal', function(){ return function(input) { var splittime = input.split(""); var time

internet explorer - Multiple min-width in CSS media query on IE10 -

multiple min-width linked 'and' on ie10 behaves not in usual way think , operator should do: when window width 500px, @media (min-width: 400px) , (min-width: 600px) { not applying } @media (min-width: 600px) , (min-width: 400px) { applything this! } see jsfiddle the question is: anyway make both work on ie10? [edited here] means 'not applying this' on both, in way , operator should behave. chrome works in expected way. suppose code written in second line, tested except ie because of issue. how make ie not applying second line, while not affecting other browsers? here background not directly related issue: need clumsy multiple min-width because use scss mixin make general small, medium , large layouts. @mixin respond($view) { if $view == m { @media (min-width: mmm) , (max-width: lll) { ... } } } on pages medium layout splits 2 layouts, need @include respond(m) { @media (min-width: m2) { ... } } which compiled multiple

html - Style control in jQuery tabs UI -

i'm using jquery ui tabs. how specify colour tab button , text when it's selected , in normal state? i tried this. did not work. .ui-tabs .ui-tabs-selected { background: #ff0000; } try this: .ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { background: yellow; } or change color on ui css file open css file search about .ui-tabs .ui-tabs-nav li.ui-tabs-active { margin-bottom: -1px; padding-bottom: 1px;} change .ui-tabs .ui-tabs-nav li.ui-tabs-active { margin-bottom: -1px; padding-bottom: 1px; background-color:yellow;} ref link: customizing jquery ui tabs

jquery - how to prepend a textfield to a existing textfield and transfer the contents to the appended field -

i'm working on add/remove textfields have textfield , when enter add textfield, contents of current textfield should transferred textfield , current textfield should should empty. suppose have textfield textfield contains hello text, when click on "add option" , new textfield should appended top of existing textfield , contents of textfield should transferred b. how can ? have tried below code - $(function () { $('.addscnt').on('click', function (event) { event.preventdefault(); var row = $(this).closest('.row'); var div_id = parseint($(row).find('input:text').first().attr('id').split('_id_')[1])||0; var div_name= $(row).find('input:text').first().attr('id'); var div_value= $(row).find('input:text').last().val(); }); function createinput(i,vv,name) { var p = $('<p />'), label = $('<label />&#

javascript - The element is clicked, but Page is not reloaded accordingly -

using phantom js, trying click <li> element(target_element) , render page loads after it. element clicked successfully. but, on rendering, refreshed page not seen in output. have given enough wait item. code is: page.open(address, function (status) { if (status !== 'success') { console.log('unable load address!'); phantom.exit(); } else { window.settimeout(function () { page.evaluate(function() { document.getelementbyid('custom_filters').style.visibility = "hidden"; var = document.getelementbyid('target_element'); var e = document.createevent('mouseevents'); e.initmouseevent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); console.log(a.dispatchevent(e)); waitforload = true; }); page.render(output); phantom.exi

r - Eliminate some value from a matrix -

i want eliminate value of matrix t3 <=2 without using if, for, while, repeat. need use on larger matrix, use simple example t1=matrix(1:3,nr=3,nc=3,byrow=false) t2=matrix(1:3,nr=3,nc=3,byrow=true) t3=matrix(t1^2+t2^2,nr=3,nc=3) what mean "eliminate"? want change single value(s)? or want remove entire row? this shows how change values of t3 less or equal 2 na indexing assignment function [<- > t3[t3 <= 2] <- na > t3 # [,1] [,2] [,3] #[1,] na 5 10 #[2,] 5 8 13 #[3,] 10 13 18

c# - WP8 Parse send push notification with custom Param -

from here , see can send toast notification opens specific page when user taps it, want. push message should this: string message = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<wp:notification xmlns:wp=\"wpnotification\">" + "<wp:toast>" + "<wp:text1>title</wp:text1>" + "<wp:text2>message</wp:text2>" + "<wp:param>/page2.xaml?navigatedfrom=toast</wp:param>" + "</wp:toast>" + "</wp:notification>"; equivalently in parse (i'm not 100% sure): push.data = new dictionary<string, object>{ {"title", "title"}, {"alert", "message"}, {"param", "/p

ios - Core data exception: initWithCoder:]: unrecognized selector sent -

i'm experiencing issue using core data. coredata: error: exception during fetchrowforobjectid: -[pharmaceuticalcomp initwithcoder:]: unrecognized selector sent instance 0x9ab1920 userinfo of (null) 2014-08-18 07:56:55.784 horizonmemory[1357:60b] coredata: error: serious application error. exception caught during core data change processing. bug within observer of nsmanagedobjectcontextobjectsdidchangenotification. -[pharmaceuticalcomp initwithcoder:]: unrecognized selector sent instance 0x9ab1920 userinfo (null) 2014-08-18 07:56:55.786 horizonmemory[1357:60b] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[pharmaceuticalcomp initwithcoder:]: unrecognized selector sent instance 0x9ab1920' *** first throw call stack: ( 0 corefoundation 0x021981e4 __exceptionpreprocess + 180 1 libobjc.a.dylib 0x01f178e5 objc_exception_throw + 44 2 corefoundation

javascript - AngularJS ng-model $scope in ng-repeat is undefined if update from outside ng-repeat $scope is also undefined -

i looking example angularjs ng-model $scope in ng-repeat undefined in question first answered @gloopy here http://jsfiddle.net/vnqqh/128/ my question can update ng-model values in ng-repeat scope outside of ng-repeat scope this: <div ng-app="myapp"> <div ng-controller="postctrl"> <div ng-repeat="post in posts"> <strong>{{post}}</strong> <input type="text" ng-model="posttext"> </div> /*update ng-model values (in ng-repeat scope) using single click*/ <a href="#" ng-click="savepost(posttext)">save post</a> </div> </div> here controller: angular.module('myapp',[]); function postctrl($scope) { $scope.posts = ['tech', 'news', 'sports', 'health']; $scope.savepost = function(post){ alert( 'post stuff in textbox: ' + post); } } i tried got undef

java - how to insert/update multiple rows into database without firing insert/ update query multiple times? -

if (!knowledge.isempty()) { iterator<entry<string, string>> classnmvalsitrkw = knowledge .entryset().iterator(); while (classnmvalsitrkw.hasnext()) { entry<string, string> p1 = classnmvalsitrkw.next(); string nm = p1.getkey(); string val = p1.getvalue(); string query3 = "insert namevalue(seqid, name, value) values(" + seqid + ",'" + nm + "','" + val + "')"; //system.out.println("insert query: " + query3); st = connect.createstatement(); st.executeupdate(query3); } } "knowledge" hashtable have stored name value pairs want insert database. every iteration of while loop insert query getting fired. think inefficient. how insert multiple rows f

vb6 - How to open/switch to a process in task manager -

i tried google-ing results ending process... want switch vb application process... i'm using appactivate program title name not unique i'm getting error... can use * sign? appactivate statement activates application window. syntax appactivate title[, wait] the appactivate statement syntax has these named arguments: part description title required. string expression specifying title in title bar of application window want activate. the task id returned shell function can used in place of title activate application. use wmi pid or toolhelper library. private declare function process32next lib "kernel32" (byval hsnapshot long, lppe processentry32) long private declare function closehandle lib "kernel32.dll" (byval handle long) long private declare function process32first lib "kernel32" (byval hsnapshot long, lppe processentry32) long private declare function createtoolhelp32snapshot lib "kernel32" (byva

c# - Freezes waiting process -

i write code, call powershell script execute. problem on windows 7, works perfectly. in windows 8.1 1 start of 5 freezes. code: processstartinfo startinfo = new processstartinfo(); startinfo.filename = @"powershell.exe"; startinfo.arguments = pathunistallscript; startinfo.redirectstandardoutput = true; startinfo.redirectstandarderror = true; startinfo.useshellexecute = false; startinfo.createnowindow = true; process process = new process(); process.startinfo = startinfo; process.start(); string output = process.standardoutput.readtoend();//here code freezes at moment put crutch, think temporary solution. process process = new process(); process.startinfo = startinfo; process.start(); thread.sleep(5000);//wait approximate number of seconds complete script process.kill(); how write code, not freezes in windows 8.1?

unit testing - Why we need to test fake code? -

maybe question sound silly someone, anyway: why need test fake code? i read this book , can not understand why need test units initialize ourself including returning values , e.t.c. if use fake object return want (if use aaa pattern) , if logic of real code change , wrong, unit test mock or stub don`t show that. wrong? or unit-tests need documenting how need work classes or libraries? the point in mocking not mock objects going test mock objects object under test depends on, like: testrunner -> objectundertest -> mockedobject1..n here test behavior of objectundertest needs other objects work. latter objects not subject current test, , mocked test instance.

Can't delete Azure Web Sites Web Hosting Plans -

i'm trying delete web hosting plan on new azure portal. when click on delete link, see message: "failed delete web hosting plan default2: storage usage quota exceeded. cannot update or delete server farm." there no websites linked web hosting plan. if try change web hosting plan 'shared', message: "storage usage quota exceeded. cannot update or delete server farm." this standard web hosting plan, i'm paying this, , need delete it. someone knows how delete it? thanks.

c# - ASP.NET MVC 5, bootstrap modal popup Not hit Controller method -

i'm using asp.net mvc 5 development. i'm try popup modal data crud operations. i'm try popup modal javascript method. after click link controller method not hit. screen transform dark screen. view : <td class="text-right"> <a class="btn btn-info btn-xs" href="javascript:loadedituser(@item.id)"> <i class="fa fa-pencil"></i> </a> </td> <div class="modal fade" id="modaledituser" tabindex="-1" role="dialog" aria-labelledby="mymodallabel" aria-hidden="true"> </div> javascript : function loadedituser(userid) { debugger; var remoreurl = "/useradmin/index"; $('#modaledituser').modal({ remote: remoreurl }); } partial view : this partial view i'm going popup @using (ajax.beginform("create", "useradmin", new ajaxo

c# - How can I load checkboxes with dynamic names in a listbox, the names are populated from an XML having a <NAME> tag -

Image
i have following xml, <?xml version="1.0" encoding="utf-8"?> <test> <name>testrun</name> <syncbyte>ff</syncbyte> <som>53</som> <pdadd>7e</pdadd> <lenlsb>08</lenlsb> </test> i have defined listbox in wpf , have added single checkbox inside hoping can manage checkboxes dynamically. requirement that, can have multiple xmls 1 above different tag in them. need load listbox value of tag each xml, checkbox. design: as first need create test class public class test { public string name { get; set; } public string pdadd { get; set; } } you can load xml file xml serializer: test obj; xmlserializer xs = new xmlserializer(typeof(test)); using (xmlreader xr = xmlreader.create("yourxmlfile.xml")) { obj = (test)xs.deserialize(xr); } after that, attach obj datasource of checkbox-list , use databind() of finally. markup of checkbox-list should set desir

java - Update score android sdk -

i have problem code, i update score positiv , negative score no update. thank help. int score = 5; if(v == findviewbyid(r.id.bottomlinear)) { view view = (view) event.getlocalstate(); viewgroup viewgroup = (viewgroup) view.getparent(); viewgroup.removeview(view); //change text string scr = string.valueof(score++); textview score1 = (textview) findviewbyid(r.id.score); score1.settext(scr); } else if(v == findviewbyid(r.id.bottomlinear2)) { view view = (view) event.getlocalstate(); viewgroup viewgroup = (viewgroup) view.getparent(); viewgroup.removeview(view); //change text string scr = string.valueof(score--); textview score2 = (textview) findviewbyid(r.id.score); score2.settext(scr); } try set variable , set score int x = score++; textview score1 = (textview) findviewbyid(r.id.score); score1.settext(integer.tostring(score)); if still not work - you're sure, code going if or else? anothe

jquery - Scale an image if the browser height or width changes but stay in proportion -

i'm trying make first responsive website, i'm trying design landing page text , images resize depending on browser size. i have done text can't figure out how image. here's fiddle site far: http://jsfiddle.net/581eg1cx/1/ you'll notice text gets smaller depending on height , width, need same image. i.e if browser height goes smaller image scale down while not overlapping or going under text , staying centre, same goes width. here's css image part, rest can found in fiddle. .big-logo { max-width:auto; height:auto; position: absolute; top: 20%; left:50%; font-size:18px; background:blue; -webkit-transform: translatey(-50%) translatex(-50%); -ms-transform: translatey(-50%) translatex(-50%); transform: translatey(-50%) translatex(-50%); } .big-logo img { width:100% !important; height:100% !important; display:block; } updated jsfiddle , think meant. the image , container css should be: .big-logo {

opencv - How to know total number of Frame in a file with cv2 in python -

how know total number of frame in file ( .avi) through python using open cv module. if possible information (resolution, fps,duration,etc) can of video file through this. import cv2 cap = cv2.videocapture(fn) if not cap.isopened(): print "could not open :",fn return length = int(cap.get(cv2.cv.cv_cap_prop_frame_count)) width = int(cap.get(cv2.cv.cv_cap_prop_frame_width)) height = int(cap.get(cv2.cv.cv_cap_prop_frame_height)) fps = cap.get(cv2.cv.cv_cap_prop_fps) see here more info. also, of grain of salt, not props mandatory, might not available capture / video codec

typo3 - How to download files from tx_news listView? -

i'm working on typo3 6.2 site using tx_news. my goal user can use listview directly download related file , possible in tt_news type download. the problem in tx_news type news, internal page, external page available. dont want extend news generate new news type. i got two possible solutions : use external page link file problem: i dont want user type external file link these fields, since bigger project many files. use sys_category , link "more" field related file problem: i need hardcoded check in template files "file download category" uid. if changes, or in year new people need maintain this. this possible template this, said before, ugly hardcoded check in template file: <f:for each="{newsitem.categories}" as="category" iteration="catiterator"> </f:for> any appreciated, if knows better, cleaner solution. to clarify: 'listview' mean list of news it

javascript - Creating form to apply get variable -

i have number html 5 field , button next it. after typing in number, user clicks button, , number set $_get['number'] variable on same website. how can that? i don't wanna using redirections (form tag etc.). possible aria controls here? like: <select userid="select_user_type" name="dyntable_length" size="1" aria-controls="dyntable" onchange="location = this.options[this.selectedindex].value;"> <option value="path1"></option> <option value="path2"></option> </select> but number field , after clicking button? you like: $("#button").click(function(e) { var number = $('#number').val(); $.ajax({ url : 'http://example.com', type: "post", data : { number : number }, success:function(data, textstatus, jqxhr) { // handle request success //data conta

ios - Different navigation bar style in different controllers? -

i've got question setting different styles of navigationbar in different uiviewcontrollers. i've got 4 different controllers , want last 1 totally transparent white navigationitems , other 1 white black navigationitems. is there quick , easy solution this? thinking setting style each view in appdelegate what need save navigation bar tintcolor , bartintcolor before view appears , change whatever need. when view disappears, restore previous ones. @interface myviewcontroller () @property (strong, nonatomic) uicolor *navigationbartintcolor; @property (strong, nonatomic) uicolor *navigationtintcolor; @end @implementation myviewcontroller - (void)viewwillappear:(bool)animated { [super viewwillappear:animated]; // save current colors self.navigationbartintcolor = self.navigationcontroller.navigationbar.bartintcolor; // background color self.navigationtintcolor = self.navigationcontroller.navigationbar.tintcolor; // items color self.navigat

share video on android 4.4 -

i want share video whats app.on android 4.4 code not work , give me exception work on android 4.2. my code is: intent var4 = new intent("android.intent.action.send"); var4.putextra("android.intent.extra.subject", "choice pic"); var4.putextra("android.intent.extra.text", "text"); var4.putextra("android.intent.extra.stream", uri.fromfile(new file(filepath))); var4.settype("video/*"); startactivity(intent.createchooser(var4, "select whatsapp share")); i haven't device android 4.4 test app on https://www.manymo.com can't logcat.

Flask with create_app, SQLAlchemy and Celery -

i'm struggling proper setup flask, sqlalchemy , celery. have searched extensively , tried different approaches, nothing seems work. either missed application context or can't run workers or there other problems. structure general can build bigger application. i'm using: flask 0.10.1, sqlalchemy 1.0, celery 3.1.13, current setup following: app/__init__.py #empty app/config.py import os basedir = os.path.abspath(os.path.dirname(__file__)) class config: @staticmethod def init_app(app): pass class localconfig(config): debug = true sqlalchemy_database_uri = r"sqlite:///" + os.path.join(basedir, "data-dev.sqlite") celery_broker_url = 'amqp://guest:guest@localhost:5672//' config = { "local": localconfig} app/exstensions.py from flask.ext.sqlalchemy import sqlalchemy celery import celery db = sqlalchemy() celery = celery() app/factory.py from extension

debian - apt-get upgrade one repository only -

i have few mashines running on debian system added own packages repository. want set auto system packages upgrade, repository. don't want automatically upgrade official packages - if needed mine packages. i have tried change priority in /etc/apt/preferences. can block there official repositories upgrade, block upgrade when of packages depend on official packages (needed upgrade or install). is there simple solution upgrade packages 1 repository , packages when needed?

android - How Does Navigation in xamarin.forms Works? -

as using xamarin.forms application in android have navigate 1 page another. question is, if navigating 1 page page adds navigation stack. example, if app has navigation such page1 --> page2 --> page3 --> page4 --> page1 (it behaves cycle) replace page1 when navigate page on second time or adding stack. can explain navigation in simple way?? edit what mean replace means if navigating 1 page adds stack, won't affect performance of application if navigation continues loop , keeps on adding stack?? note: don't want go previous page, want navigate 1 continously. thanks in advance can try elaborate on question bit more? mean 'replace'? it's stack, no: first page1 not 'replaced', rather 'copy' in place. example: imagine list view bound data objects. when click item, item details page. imagine details page have previous , next buttons navigate other items , press one. stack this: listviewpage -> itemspage -> ite

Google Analytics v4 in Android: Could not find class 'com.google.android.gms.analytics.Tracker' -

i desperately trying integrate ga v4 in android app. , followed guide here https://developers.google.com/analytics/devguides/collection/android/v4/ and integrated google play services lib described, gives me could not find class 'com.google.android.gms.analytics.tracker but can find classes , namespaces in project. i can't figure out what's happening here. i followed instruction on analytics android v4 . but additionally had update play services , build tools in sdk manager. had add compile 'com.google.android.gms:play-services:8.4.0' in app build.gradle (above of compile 'com.google.android.gms:play-services-analytics:8.4.0' . tracker class still unknown (red underlined) despite of pressed "run" (install app) in android studio , analytics recognized , used.

php - Create a unique random token string in Yii for users table -

i working on yii app requires 'users' table have column 'token' need unique random string based upon user in table (eg there never same token twice). can give me tips on doing this, or there yii component/extension/generator setup this. also - optimised db column type this? i suggest use hash, produces long string , use unique string hashed: sha512($username.time().rand(1000, 9999)); some php hash algorithms lengths

Paging SQL Server results -

i have 2 tables, orders , articles . want both orders , articles in same result set, sorted [datecreated] . need paging, using with. problem query below, [rownumber] separate counter each of queries. instead of getting 10 rows in following query, 20. ideas on how tackle this? i need counter encompasses whole clause. query: ;with myselectedrows ( select row_number() on (order [datecreated] desc) [rownumber] , [articleid] [id] , [datecreated] [date] , [articletext] [text] , 'articles' [rowtype] articles union select row_number() on (order [datecreated] desc) [rownumber] , [orderid] [id] , [datecreated] [date] , [ordertext] [text] , 'orders' [rowtype] orders ) select [id], [date], [text], [rowtype] myselectedrows [rownumber] between 1 , 10 you need row number on combined result set, not on each of 2 queries. therefore, can wrap union in cte/subquery, apply row_num

jQuery Get DIV Content From Another Page -

i have following code: <script> $( document ).ready(function() { $("div.imp-1 span.field-content").each(function() { var $li = $(this); var href = $li.find("a").attr("href") + ".htm"; // use in real case //console.log (href); $.ajax({ type: "post", success: function(data) { var time = $(data).find('.time-default').html(); $li.append(" - " + time); } }); }); }); </script> the html page has html follows <div class="time-default">22:15 - 23:30</div> it keeps returning "undefined" - doing wrong? thanks you need pass other page url. $.ajax({ url: href, //pass url here type: "get", //also use method success: function(data) { var time = $(data).find('.time-default').html(); $li.append(" - " + time); } });

jquery - ajax request gets images from server 20 at a time, how to stop sending request when there no images left? -

i jave function ajaxrequest retrieves images server (c# action method) how can stop sending request when there no images left? i thought sending count of images in html code , if count 0 stop sending correct ? have parse someway comments html. there better way this? the ajaxrequest function executes every 2 seconds timeout. code: ajaxfunction = function() { $.ajax({ beforesend: function() { cleartimeout(loadfromservertimeout); // clear timeout until request ends. }, type: 'get', url: '@url.action("getdata", "greekfurs")', data: { skip: value }, success: function(data) { console.log(data); // data html server loadfromservertimeout = settimeout(ajaxfunction, 3000); // start timer again. }, }); } ajax view server: @{ layout = null; var photos = (list<shoppinggalleryphoto>) viewdata["

How to set Varnish so that it doesn't cache URL -

i need export csv url: http://domain.com/nextopia/products/csv/key/5213ae8cdcb0270226dc816e3838eac0 after waiting error time out: error 503 service unavailable service unavailable varnish i have tried: if (req.http.host == "domain.com" && req.url == "/nextopia/") { return (pass); } and: if (req.url ~ "^/nextopia/") { return (pass); } and: .first_byte_timeout = 600s; .between_bytes_timeout = 600s; but not effective, how export it??!! :( the ~ matching need match url, like: if (req.url ~ "/nextopia") { return (pass); } without using regex roof. req.url == "/nextopia/" match of exact /nextopia/ /nextopia wont match.. have check logs see if there error timeouts and/or other errors? cheers

c# - Regex capturing group terminating early -

i don't ask dumb regex questions. here's 1 regex vultures.... take these strings... -this nice (show cow) *this (or that) (show mouse) -whatever -hiya (everyone) all these should match. ie lead * or - , text, can conditionally followed whitespace , (show xxx) xxx can text. want these captured separately ie... -this nice (show cow) match 1 : 'this nice' match 2 : '(show cow)' or 'cow' *this (or that) (show mouse) match 1 : 'this (or that)' match 2 : 'show mouse' or 'mouse' -whatever match 1 : 'whatever' -hiya (everyone) match 1 : 'hiya (everyone)' +hello no match i have tried variously... [\-*](.+?)(\s+\(show (.+)\))? terminates , captures 1 char of match 1 [\-*](.+)(\s+\(show (.+)\))? terminates late , captures of text match 1 including `(show....` [\-*](.+)(\s+\(show (.+)\)$)? above i'm sure should easy! don't want go negating (show within match

javascript - Handling ActiveX events in Chrome 36 -

there many threads this , far tried all of them outdated. i need method handle activex event on latest chrome versions . i have activex object named csxi using scanner on browser, , having difficulties scan multiple pages. it works on ie can handle event onacquire() writing script block in html page. <script language="javascript" for="csxi" event="onacquire();" type="text/javascript"> aftereachacquire(); </script> i looked ways make worki on chrome , found 2 other methods; handling event using syntax function csxi::onacquire(){ //do } "::" undefined usage javascript, and adding event handler activex object. unfortunately none of these methods worked.

How to make a double grouping in MongoDB? -

for first time familiar mongodb, question arose when grouping data. given data 2 days: db.test.insert({ "_id" : objectid("13edebb315d8952400407343"), "create_at" : isodate("2012-12-19t12:00:00.000z"), "item" : { "tags" : [ "aaaa" ], "event" : "accepted", } }); db.test.insert({ "_id" : objectid("13edebb39e60c73800b35727"), "create_at" : isodate("2012-12-19t12:05:00.000z"), "item" : { "tags" : [ "aaaa" ], "event" : "delivered" } }); db.test.insert({ "_id" : objectid("13edebb315d8952400407344"), "create_at" : isodate("2012-12-19t13:40:00.000z"), "item" : { "tags" : [ "bbbb" ], "

Grouped elements in a matrix in matlab -

this question has answer here: determining number of occurrences of each unique element in vector 4 answers i have matrix a = [1 2 4 4 8 8 8 4 1 7 7 8 8 9] , want create new matrix has number of same elements in a. i have 2 1, 1 2, 3 4, 2 7, 5 8 , 1 9. my new matrix should [numbers;amount of each number] newmatrix = [1 2 4 7 8 9; 2 1 3 2 5 1] how can create new matrix a? standard, recommended approach : use unique , histc : ua = unique(a); result = [ua; histc(a, ua)]; another possibility counting sparse , , use nonzeros extract values , find indices: s = sparse(1,a,1); result = [find(s); nonzeros(s).']; this second approach seems faster small a , first recommended approach in general.

osx - Node.js require becomes extremely slow after OS X has been running for a while -

when reboot mac, starting node.js apps nice , fast. later, after mac has been on few hours, gets slow. i've used process.hrtime() time various things, , seems it's require calls take time, ie loading dependencies. once loaded, apps run reasonably fast. the difference extreme: after i've rebooted, app may take 300ms through require calls, takes 30 seconds once it's been on few hours. what causing this? since how fast executing require related disk loading performance. suppose it's highly possible hdd/ssd or whatever project belongs causing that. it's working fine right after rebooted maybe background software(such virus scan or auto downloader) making io blocking you'd better start checking cpu/ram/hdd status while issue occurring , see happens if move project usb flash drive or external hdd

c++ - Why QFileDialog::getOpenFileName doesn't work? -

in string path right, doesn't put strings in table . no error or warnings. when example: meinmodel->setdata(filename, filename); it views strings : e:/test.txt i have qtableview , qabstracttablemodel. void view::openfilebuttonclicked() { qstring filename = qfiledialog::getopenfilename(0, qstring(), qstring() ,tr("data (*.txt)")); filemy = new qfile(filename); qtextstream stream (&*filemy); while (!stream.atend()) { qstring line = stream.readline(); qstringlist list = line.split(","); qstring firststring; firststring = (list.first()); qstring secondstring; secondstring = (list.last()); // strings send model witch view in tableview. meinmodel->setdata(firststring, secondstring); } } strange, becuase works: vo

php - Display Wordpress Posts as gallery with title -

for project working on have been trying set wordpress post loop on subpage woould display posts thumbnail image posts title underneath. not posts listet rather 1 link referring subpage gallery should on. me out please? here code saved page-gallery.php in childthemes folder: <?php get_header(); ?> <div id="main" class="wrapper"> <?php global $query_string; if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div class="gallery_image_container"> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"> <div class="gallery_image_thumb"> <?php the_post_thumbnail('thumbnail'); ?> </div> <h2><?php the_title(); ?></h2> </a> </div> <?php endwhile; else : ?> <p><?php _e( 'sorry, no posts matched criteria.&