Skip to content

Instantly share code, notes, and snippets.

View marcelaraujo's full-sized avatar

Marcel Araujo marcelaraujo

  • Lisbon/PT
  • 02:41 (UTC +01:00)
View GitHub Profile
@marcelaraujo
marcelaraujo / gist:f25b5839d0617e591323
Created October 1, 2015 03:24 — forked from saetia/gist:1623487
Clean Install – OS X 10.11 El Capitan Developer Preview 2

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
(function () {
'use strict';
function PubSubService() {
var Topics = function () {
this.topics = {};
};
Topics.prototype.subscribe = function (topic, listener) {
@marcelaraujo
marcelaraujo / sinon-chai-expect.md
Created November 25, 2015 12:18 — forked from patocallaghan/sinon-chai-expect.md
Sinon Chai assertions in expect style.Examples from http://chaijs.com/plugins/sinon-chai #sinon #chai #javascript

Sinon JS

##Spies

//Anonymous function
var spy = sinon.spy();

//Provided Function
var spy = sinon.spy(myFunc);
@marcelaraujo
marcelaraujo / chai-expect.md
Created November 25, 2015 12:19 — forked from patocallaghan/chai-expect.md
Chai Expect Assertion library examples. From http://chaijs.com/api/bdd/ #chai #javascript #expect

##Chai Expect

##Language Chains

  • to
  • be
  • been
  • is
  • that
  • and
  • have
@marcelaraujo
marcelaraujo / apple developer
Created December 22, 2015 17:18
Apple Developer Mode
sudo xcodebuild -license
sudo DevToolsSecurity -disable
@marcelaraujo
marcelaraujo / memcache.py
Created December 23, 2015 11:43
Memcache list keys
#!/usr/bin/python
import re, telnetlib, sys, pprint
class MemcachedStats:
_client = None
_key_regex = re.compile(ur'ITEM (.*) \[(.*); (.*)\]')
_slab_regex = re.compile(ur'STAT items:(.*):number')
_stat_regex = re.compile(ur"STAT (.*) (.*)\r")
@marcelaraujo
marcelaraujo / main.js
Created April 26, 2016 20:31
Faster object create
// This constructor is used to store parsed query string values. Instantiating
// this is faster than explicitly calling `Object.create(null)` to get a
// "clean" empty object (tested with v8 v4.9).
function ParsedQueryString() {}
ParsedQueryString.prototype = Object.create(null);
@marcelaraujo
marcelaraujo / proxy.js
Created May 4, 2016 18:49
Proxy calls
function proxy(fn, context) {
var args = [].slice.call(arguments, 2);
return function () {
return fn.apply(context, args.concat([].slice.call(arguments)));
}
}
function handler(data) {//expect data.id = 1}
(function(p, h) {
@marcelaraujo
marcelaraujo / create-multi-host-swarm-digitalocean.sh
Created July 23, 2016 15:10 — forked from jmshal/create-multi-host-swarm-digitalocean.sh
Setup a Docker Swarm multi-host cluster on DigitalOcean
docker-machine create \
--driver=digitalocean \
--digitalocean-access-token=$DO_TOKEN \
--digitalocean-size=512mb \
--digitalocean-region=nyc3 \
--digitalocean-private-networking=true \
--digitalocean-image=ubuntu-15-04-x64 \
docker-swarm-kv-store
docker $(docker-machine config docker-swarm-kv-store) run -d \
@marcelaraujo
marcelaraujo / destructuring.js
Created August 12, 2016 15:00 — forked from mikaelbr/destructuring.js
Several demos and usages for ES6 destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => {
return [1, 2, 3];