Skip to content

Instantly share code, notes, and snippets.

@bendc
bendc / functional-utils.js
Last active September 15, 2023 12:12
A set of pure ES2015 functions aimed to make functional JavaScript more idiomatic.
// array utils
// =================================================================================================
const combine = (...arrays) => [].concat(...arrays);
const compact = arr => arr.filter(Boolean);
const contains = (() => Array.prototype.includes
? (arr, value) => arr.includes(value)
: (arr, value) => arr.some(el => el === value)
@wuub
wuub / gtfo.py
Last active August 29, 2015 13:56
Drop into ~/.config/sublime-text-3/Packages/User + modify in_build_dir(view) acoordingly
import sublime, sublime_plugin
BUILD_COLOR_SCHEME = "Packages/Color Scheme - Default/Twilight.tmTheme"
def in_build_dir(view):
if not view or not view.file_name():
return False
return "/build/" in view.file_name()
import mock
class GeneratorMock(mock.Mock):
def __init__(self, *arg, **kw):
kw['side_effect'] = self._side_effect
super(GeneratorMock, self).__init__(*arg, **kw)
self._lookup = {}
def _side_effect(self, *arg, **kw):
if self._mock_return_value is not mock.sentinel.DEFAULT:
@howlingblast
howlingblast / gist:5814547
Created June 19, 2013 14:00
CoffeeScript: getter/setter example
Function::property = (prop, desc) ->
Object.defineProperty @prototype, prop, desc
class Person
constructor: (@firstName, @lastName) ->
@property 'fullName',
get: -> "#{@firstName} #{@lastName}"
set: (name) -> [@firstName, @lastName] = name.split ' '
p = new Person 'Leroy', 'Jenkins'
@defunctzombie
defunctzombie / browser.md
Last active April 10, 2024 17:45
browser field spec for package.json
from django.core.cache.backends.memcached import BaseMemcachedCache
class UltraMemcachedCache(BaseMemcachedCache):
"An implementation of a cache binding using python-ultramemcached"
def __init__(self, server, params):
import ultramemcache
super(MemcachedCache, self).__init__(server, params,
library=ultramemcache,
value_not_found_exception=ValueError)
@cstrahan
cstrahan / scala.rb
Created October 23, 2012 14:20
Install Scala on OSX
# to install the latest stable version:
brew install scala --with-docs
# to install scala-2.10.0-RC1:
brew install https://raw.github.com/gist/3939012/scala.rb --with-docs
# to switch versions (from https://github.com/mxcl/homebrew/wiki/External-Commands):
brew switch scala 2.9.2
brew switch scala 2.10.0-RC1
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@dholth
dholth / wheeldemo.sh
Created July 2, 2012 13:09
Python bdist_wheel (binary package format) demo
#!/bin/sh
# bdist_wheel demo
# Create environment
virtualenv /tmp/wheeldemo
cd /tmp/wheeldemo
# Install wheel and patched pip, distribute
bin/pip install -e hg+https://bitbucket.org/dholth/wheel#egg=wheel -e hg+https://bitbucket.org/dholth/distribute#egg=distribute -e git+https://github.com/dholth/pip.git#egg=pip
@silas
silas / README.md
Created March 21, 2012 03:52
Vagrant and devstack
  1. Download and install VirtualBox

  2. Download and install Vagrant

  3. Clone devstack repository

     git clone git://github.com/openstack-dev/devstack.git
    
  4. Switch to devstack directory

cd devstack