explorers' club

explorations in dev, science, sci-fi, games, and other fun stuff!


1 Comment

AngularJS: See if Angular is Using JQuery or JQLite

It’s as easy as:

//true if angular is using jQuery, false if using jqLite
angular.element === window.jQuery
Advertisements


Leave a comment

Note to Self: Angular Directive Communication (via Isolate Scope) to Parent Scope with Object Parameter

Given the following HTML

How do we communicate the value known only to the directive but passing back to the controller’s scope?  Like so:


4 Comments

Objective-C & ActionScript 3 translation notes

[note to self]

Just some things I am learning along the way while teaching myself Objective-C and iPhone development.   Seeing existing code is rather easy to understand in a general sense but the syntax is a tad whacky looking at this point.  I will continue to add to this as I find more translations.

variables:

NSString * someString = @"foo";
=
var someString:String = "foo";

casting:

NSObject *someObject = //pretend I know how to say new();
NSString *castedAsString = (NSString *)someObject;
=
var someObject:Object = {};
var castedAsString:String = String(someObject);

strings:

Strings come in several varieties in Objective-C.  There are NSString, NSMutableString and then the C varient char.  There are probably others I have yet to discover (CSString?).  Since most of what I have seen utilizes NSString, I will stick to that unless otherwise noted.

combining string values

NSString *firstString = @"foo";
NSString *secondString = @"bar";
firstString = [firstString stringByAppendingString:secondString]; //should trace out as "foobar"
=
var firstString:String = "foo";
var secondString:String = "bar";
firstString = firstString + secondString; //wow AS3 is very simple when working with strings

class & instance methods:

+someMethodDefinition = static public function
-someMethodDefinition = public function (instance function)

method calling:

NSString * someString = @"foo";
NSArray * someArray = [someString someNSStringMethodThatReturnsAnArray];
=
var someString:String = "foo";
var someArray:Array = someString.someStringFunctionThatReturnsAnArray();
//kinda made this up since I don't understand method arguments in Objective-C yet.

more to come…


2 Comments

Note to Self: Odds, Evens, -1 & 1

[BEST]

var isOdd:Boolean = Boolean( numberToCheck & 1 );
//for random odd/even
var isOdd:Boolean = Boolean( Math.round( Math.random() ) & 1 );

[BETTER]

Math.round( Math.random() ) == 0 ? 1 : -1;

[GOOD]

odd or even  = Math.round(Math.random() * 100) % 2 == 0 ? "even" : "odd";
-1 or 1 = Math.round(Math.random() * 100) % 2 == 0 ? 1 :- 1;