Skip to content

Instantly share code, notes, and snippets.

Alex Girard grabcode

Block or report user

Report or block grabcode

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@grabcode
grabcode / FPSMonitor.js
Last active Aug 29, 2015
Snippet adding a surface showing the Famo.us engine FPS - written during Hello Famo.us 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'
View backbone_fetch_monkeypatch.js.coffee
root = exports ? this
# Overloading backbone fetch method
previousFetch = Backbone.Collection.prototype.fetch
root.Backbone.Collection.prototype.fetch = (options={})->
asyncUniqId = _.uniqueId 'time_'+@constructor.name+'_'
console.time asyncUniqId
previousSuccess = if options? then options.success else undefined
options = _.extend(options,
success: =>
@grabcode
grabcode / _log.js.coffee
Created Feb 8, 2015
Isomorphic javascript helper - custom log
View _log.js.coffee
root = exports ? this
root._log = ->
args = [new Date()].concat Array.prototype.slice.apply(arguments)
console.log.apply console, args
View counter.scss
.custom-counter{
list-style-type: none;
&>li{
counter-increment: step-counter;
&:before{
content: counter(step-counter);
}
}
@grabcode
grabcode / stub.js.coffee
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)
View stub.js.coffee
# Usage: window.myObject = _.stub('myObject', {error: null, print: null})
_.mixin
stub: (objectName, props)->
res = {};
for prop of props
if props[prop]?
res[prop] = props[prop]
else
res[prop] = ((method)->
->
@grabcode
grabcode / snippets.cson
Last active Dec 28, 2015
ReactNative Component and Styles Snippet
View snippets.cson
'.source.js':
'ReactNative Component':
'prefix': 'rnc'
'body': """
'use strict';
import React, {
Text,
} from 'react-native';
@grabcode
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 https://twitter.com/grabthecode
*/
;(function(scope, defaults){
@grabcode
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?
https://aws.amazon.com/blogs/compute/nodejs-packages-in-lambda/
How to figure out the amount of memory needed?
https://github.com/berezovskyi/lambda-test
How does my lambda consume external APIs?
https://aws.amazon.com/blogs/aws/aws-ip-ranges-json/
When a lambda fails, does it retry itself?
You can’t perform that action at this time.