Posts

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, ...