Skip to content

Instantly share code, notes, and snippets.


Alex Girard grabcode

View GitHub Profile
grabcode / FPSMonitor.js
Last active Aug 29, 2015
Snippet adding a surface showing the engine FPS - written during Hello lesson
View FPSMonitor.js
(function(target, engine, interval) {
var surface = new Surface({
size: [50, 35],
content: '',
properties: {
color: 'white',
textAlign: 'center',
backgroundColor: '#FA5C4F',
border: '1px solid black'
root = exports ? this
# Overloading backbone fetch method
previousFetch = Backbone.Collection.prototype.fetch
root.Backbone.Collection.prototype.fetch = (options={})->
asyncUniqId = _.uniqueId 'time_''_'
console.time asyncUniqId
previousSuccess = if options? then options.success else undefined
options = _.extend(options,
success: =>
grabcode /
Created Feb 8, 2015
Isomorphic javascript helper - custom log
root = exports ? this
root._log = ->
args = [new Date()].concat Array.prototype.slice.apply(arguments)
console.log.apply console, args
View counter.scss
list-style-type: none;
counter-increment: step-counter;
content: counter(step-counter);
grabcode /
Created Aug 21, 2015
Underscore.js Mixin to stub an object methods - Useful when libraries are meant to work on a live environment (login exception for instance, with window.Rollbar)
# Usage: window.myObject = _.stub('myObject', {error: null, print: null})
stub: (objectName, props)->
res = {};
for prop of props
if props[prop]?
res[prop] = props[prop]
res[prop] = ((method)->
grabcode / snippets.cson
Last active Dec 28, 2015
ReactNative Component and Styles Snippet
View snippets.cson
'ReactNative Component':
'prefix': 'rnc'
'body': """
'use strict';
import React, {
} from 'react-native';
grabcode / scope_explorer.js
Last active Feb 2, 2016
Explore or Spy the global variables available, or any given scope. By default, it run in the global browser scope `window`, and exclude its default properties.
View scope_explorer.js
* Explore/Spy App Global variables, excluding defaults (defaults comes down a scope)
* > Run me in your dev tool console via copy/pasting
* > In return, I provide a list of keys, and copy in your clipboard (how sweet is that!)
* Follow my creator
;(function(scope, defaults){
grabcode / validCandidate.js
Last active Apr 12, 2016
validCandidate function
View validCandidate.js
function validCandidate(languages) {
let validCandidate = false
let languageRegex = /script$/
if(Array.isArray(languages)) {
validCandidate = !!languages.filter( (language)=> languageRegex.test(language) ).length
} else if (typeof languages == 'string') {
validCandidate = languageRegex.test(languages)
return validCandidate
View AWS Serverless Architecture notes.txt
Using native nodejs packages?
How to figure out the amount of memory needed?
How does my lambda consume external APIs?
When a lambda fails, does it retry itself?