Posts

javascript - tweenMax 'staggerFrom' and 'From' broken with requestAnimationFrame? -

for reason when use or staggerfrom requestanimationframe, animation jumps , acts if it's doing "to" tween. when use code outside of requestanimationframe, works fine. why this? need use within requestanimationframe because trigger tween when scroll @ position , need requestanimationframe determine position (i advised that's correct way instead of attaching scroll). here's tween: tweenmax.staggerfrom(".box", 1, { x:100, autoalpha: .5}, .5); i made quick codepen demonstrating issue.

javascript - If removeClass doesn't affect source code, what's the point? -

i have bunch of forms pattern: <form action="/go/special" method="post" target="_blank"> <input name="a" type="hidden" value="something"/> <input type="submit" class="general effect" value="click me"></form> for each form has special inside action, want remove effect class using jquery code: <script src="/js/colorbox.js"></script> <script> jquery(function($) { // find forms have "special" in action, find input, , add class $('form[action*="special"] input[type="submit"]').removeclass('effect'); }); </script> edit: effect class code: (jquery, document, window), $(document).ready(function() { $(".effect").click(function(t) { t.preventdefault(); var e = $(this).closest("form"); return $.colorbox({ href: e.attr(...

ruby on rails - Access to top domain cookies from subdomain application -

my vbulletin forum sets cookies on domain-name.com , , i'd read these cookies within rails app on beta.domain-name.com . how can this? if set cookie's domain to: .domain-name.com (dot @ beginning), can access it's cookies subdomains, if domain domain-name.com (withouth dot @ beginning) can access it's cookies domain.

About Javascript output in Google App Script -

i got problem output of code weird. wanna sum number. var reserve_num =0 var sheets = spreadsheet.getsheets(); for(var in sheets){ var reserve_sheet = sheets[i]; var num = reserve_sheet.getrange("d1").getvalue(); reserve_num += num; } //insert sheet("c6") 確認済 sheet.getrange("c6").setvalue(reserve_num); in code need calculation of variable 'num' got string. i'd know how fix it if line: var num = reserve_sheet.getrange("d1").getvalue(); is returning number string, can convert number string number number number() : var num = reserve_sheet.getrange("d1").getvalue(); var num = number(num); logger.log('typeof num: ' + typeof num);

python - How to convert neatly 1 size numpy array to a scalar? Numpy "asscalar" gives error when input is not a 1 size array. -

i have silly interest in how avoid following error in smart way (possibly using right numpy functions). in many ocasions need use numpy function find single item. however, item present more once, use indeces function in way in output simple variable (if appears once, either string or float) or array (if mutiple instances). of course, use len() in boolean check , perform conversion. however, know if there 1 step approach. had tought use asscalar however, function returns , error if input not 1 value array (i had hope return input value unchanged :/). here reproduction of error on second part of code import numpy np inventory = np.array(['eggs', 'milk', 'ham', 'eggs']) drinks = 'milk' food = 'eggs' index_item_searched = np.where(inventory == drinks) items_instore = np.asscalar(inventory[index_item_searched]) print 'the shop has', items_instore index_item_store = np.where(inventory == food) items_instore = ...

c# - How to create empty-conditional operator for collections similar to null-conditional operator? -

c# 6.0 introduced null-conditional operator, big win. now have operator behaves it, empty collections. region smallestfittingfreeregion = freeregions .where(region => region.rect.w >= width && region.rect.h >= height) .minby(region => (region.rect.w - width) * (region.rect.h - height)); now blows if where returns empty ienumerable , because minby (from morelinq ) throws exception if collection empty. before c# 6.0 solved adding extension method minbyordefault . i re-write this: .where(...)?.minby(...) . doesn't work because .where returns empty collection instead of null . now solved introducing .nullifempty() extension method ienumerable . arriving @ .where(...).nullifempty()?.minby() . ultimately seems awkward because returning empty collection has been preferable returning null . is there other more-elegant way this? imho, "most elegent" solution re-write minby make in minb...

ruby on rails - Empty? fails on ActiveRecord with a default_scope( :order) -

occasionally want check whether person model has organizations. straightforward enough; use @person.organizations.empty? . however, coupled default_scope ( default_scope { order(:name) } ), error: activerecord::statementinvalid (pg::invalidcolumnreference: error: select distinct, order expressions must appear in select list line 1: ... "relationships"."person_id" = $1 order "organizat... ^ : select distinct 1 one "organizations" inner join "contracts" on "organizations"."id" = "contracts"."organization_id" inner join "relationships" on "contracts"."id" = "relationships"."contract_id" "relationships"."person_id" = $1 order "organizations"."name" asc limit 1): i'm using postgres db , (abbreviated) model setup looks follows: ...