Posts

angularjs - Angular: access ngResources from a directive -

i'd access ngresources directive possible? basically directive $scope has object points other via ids, other objects can populated via existing ngresource. i'd load them render them correctly. you can pass $resource, or own $resource-based service directive. .directive('mydirective', function($resource, myservice) { });

mysql - Shell script extract data from a file -

i started programming in shell script , have file looks this: stuff doesn't matter doesn't matter matter *line 35*school: xxxxx -> name: xxxxx age: xxx description: xxxxxxxxxx school: yyyyy -> name: yyyyy age: yyy description: yyyyyyyyyy school: zzzzz -> name: zzzzz age: zzz description: zzzzzzzzzz school: aaaaa -> name: aaaaa age: aaa description: aaaaaaaaaa 6 lines of stuff after important information my main goal in migrate students mysql database, code this: nstudents=(( $(wc -l file | cut -d ' ' -f1) - 41) #41 comes 35+6 i=1 while [ $i != $nstudents ] $school=[i don't know how extract school number $i] $name=[i don't know how extract name number $i] $age=[i don't know how extract age number $i] $desc=[i don't know how extract description number $i] mysql #upload $i= (( $i + 1 )) done i know need use sed or it, can't figure out how. in advance. just point in shell-ish solution problem basd on best guess @ data lo...

drupal - Conditional display of field in Views -

i have custom (i.e. view) menu based on taxonomy vocabulary, in wich each term has image field. so far, each term displayed picture, want know if possible display image field relative active term, while maintaining label+link whole vocabulary. result have illustrative picture in top of menu, changing according item clicker. is there way directly inside view configuration ? with use of contextual filter, can display information term passed argument/ in url.

sitecore6 - Sitecore: Programmatically Exit Edit Mode in Page Editor -

when in sitecore's page editor mode clicks edit button, have div's style set top: 0; so appears on top of page editor buttons (save, save , close, insert, etc..). div prevents content editor using normal page editor buttons , forces them use custom save, save , close, , close buttons have added div. is there way programmatically exit edit mode whenever click on custom close or save , close button? not want log them out of page editor (just exit them out of edit mode). have 1 page doing this, rather not changing configurations in sitecore achieve this. check out post: in sitecore, how change or set pagemode it looks can do: context.site.setdisplaymode(sitecore.sites.displaymode.normal, sitecore.sites.displaymodeduration.resetafterrequest); or, can add sc_mode=normal or sc_mode=preview url's query string.

ruby on rails - ActiveRecord includes not doing what I expect -

class program attr_accessible :open, ... has_many :rounds has_many :open_rounds, :class_name => 'round', :conditions => ['open = ?', true] end class round belongs_to :program attr_accessible :open, :status, :begin ... end [64] pry(main)> = program.includes(:rounds) program load (0.2ms) select "programs".* "programs" round load (0.2ms) select "rounds".* "rounds" "rounds"."program_id" in (4, 6) +----+-------------+-------------+------------+-------+--------+-------------+------------+-------------+ | id | name | moderato... | descrip... | open | locked | suppress... | created_at | updated_at | +----+-------------+-------------+------------+-------+--------+-------------+------------+-------------+ | 4 | advanced... | | summer ... | false | true | false | 2013-04... | 2013-04-... | | 6 | introduc... | | summer ... | false | true | false ...

angularjs ng-repeat list not updated when element is added/removed -

there list of users retrieved rest api. here template <div ng:controller="usercontroller"> <a ng-click="createuser()">create user</a> <div ng-view> <ul> <li ng-repeat="user in users"> {[{user.first_name}]} {[{user.last_name}]} </li> </ul> </div> </div> the js: function usercontroller($scope, user, group){ $scope.users = user.query(); $scope.createuser = function(){ //$scope.users = null; //$scope.users.pop(); //$scope.users.push(new user({id:'5'})); console.log($scope.users); } } the service: http://dpaste.com/1065440/ all users retrieved , listed correctly. problem cannot manipulate rendered list @ all. no matter push, pop or set null. list not change in template. last log statement shows changes, prints e.g. null when users array set null. any ideas probl...

c# - Generics explicit conversion -

i implemented explicit conversion string object called foo. so => foo f = (foo)"foo data"; works i need implement function cast string generic t, t in case foo datatype. public t get<t>(object o){ // return false if (typeof(t).isassignablefrom(typeof(string))) { // when pass if above throws invalid cast exception return (t)(object)str; } return null; } // when call this, generated error // invalid cast 'system.string' foo foo myobj = get<foo>("another foo object"); // when use dynamic keyword works c# 4.0+ feature, function in older framework return (t)(dynamic)str; an example uses reflection: class program { static void main(string[] args) { foo myobj = typeresolver.get<foo>("foo data"); } } class typeresolver { public static t get<t>(object obj) { if (typeof(t).canexplicitlycast...