Skip to content

Instantly share code, notes, and snippets.

View ncammarata's full-sized avatar

Nick Cammarata ncammarata

View GitHub Profile
a { color: red !important; }
(function () {
var root = $($0);
var watchers = [];
var f = function (element) {
if (element.data().hasOwnProperty('$scope')) {
angular.forEach(element.data().$scope.$$watchers, function (watcher) {
watchers.push(watcher);
});
}
// in body ng-controller="MainCtrl as main"
this.app.controller('MainCtrl', function($scope) {
this.first = "willy";
this.last = "wonka";
self = this;
$scope.$watch('first + last', function(val) {
self.fullName = self.first + ' ' + self.last
});
return this;
/**
* x is a value between 0 and 1, indicating where in the animation you are.
*/
var duScrollDefaultEasing = function (x) {
if(x < 0.5) {
return Math.pow(x*2, 2)/2;
}
return 1-Math.pow((1-x)*2, 2)/2;
};
data = {
Users: [
{ name: 'Chris Young', id: 'xchris' }
{ name: 'Andrew Hsu', id: 'xandrew' }
{ name: 'Grant Lee Crilly', id: 'xgrant' }
{ name: 'Michael Natkin' }
{ name: 'Huy Nguyen' }
]
Recipes: [
{ name: 'Sous Vide Steak' }
$('.message').map(function() { return { author: $(this).find('.nickname').text(), likes: +$(this).find('.likes .count').text() } })
allGrouped = _.groupBy(all, function(val) { return val.author; })
fellas = _.map(allGrouped, function(val, key) {
likeTotal = val.map(function(val) { return val.likes; }).reduce(function(a, b) {return a + b;}, 0)
return {
who: key,
likeTotal: likeTotal,
likeAverage: likeTotal / val.length,
messageTotal: val.length
}
<div ng-if="!imageSrc">
<filepicker ng-model="imageSrc"></filepicker>
</div>
<div ng-if="imageSrc">
<display-image image="imageSrc"></display-image>
</div>
match (comment:Comment {id:'xyz'})<-[:created]-(author:Person)
return extend(comment, { author: author.name })
str = "hello [nick] youre a baler [coder] and u [hot] how is this [possible]"
strings = [] // this is an array of all the results
newStr = '' // this is the current string we're keeping
foundLeft = false // are we in a bracket
for i in str
if (i is '[') foundLeft = true
if (i is ']') {
foundLeft = false
strings.push(newStr)
newString = ''
def extractTags(s):
new = ""
str = []
foundLeft = False
for letter in s:
if(s == '['):
foundLeft = True
if(s == ']'):
foundLeft = False