Skip to content

Instantly share code, notes, and snippets.

View gatspy's full-sized avatar

CG.gatspy gatspy

View GitHub Profile
;; yasnippet
(add-to-list 'load-path
"~/.emacs.d/yasnippet")
(require 'yasnippet) ;; not yasnippet-bundle
(yas/initialize)
(yas/load-directory "~/.emacs.d/yasnippet/snippets")
;; scala-mode
(add-to-list 'load-path
"~/.emacs.d/scala-mode")
@gatspy
gatspy / master.vim
Last active August 29, 2015 14:11 — forked from gmccreight/master.vim
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)
@gatspy
gatspy / master.vim
Last active August 29, 2015 14:11 — forked from gmccreight/master.vim
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)
@gatspy
gatspy / .gitignore
Last active September 1, 2015 05:12 — forked from mmorey/.gitignore
.gitignore file for Xcode5
#########################
# .gitignore file for Xcode5
#
# NB: if you are storing "built" products, this WILL NOT WORK,
# and you should use a different .gitignore (or none at all)
# This file is for SOURCE projects, where there are many extra
# files that we want to exclude
#
# For updates, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
# and https://gist.github.com/adamgit/3786883
@gatspy
gatspy / installation.md
Last active September 14, 2015 18:04 — forked from guillaumevincent/installation.md
A simple guide to install PyQt5 on Mac OS X 10.9 (Maverick) and use python 3.4 on a virtualenv.

Guide to install PyQt5 on Mac OS X with python 3.4 virtualenv

Description

A simple guide to install PyQt5 on Mac OS X 10.9 (Maverick) and use python 3.4 on a virtualenv.

Requirements

  • xcode 5.1.1
  • python 3.4.0
  • Qt libraries 5.2.1
@gatspy
gatspy / colortrans.py
Created April 13, 2016 07:28 — forked from MicahElliott/colortrans.py
Convert values between RGB hex codes and xterm-256 color codes.
#! /usr/bin/env python
""" Convert values between RGB hex codes and xterm-256 color codes.
Nice long listing of all 256 colors and their codes. Useful for
developing console color themes, or even script output schemes.
Resources:
* http://en.wikipedia.org/wiki/8-bit_color
* http://en.wikipedia.org/wiki/ANSI_escape_code
@gatspy
gatspy / class_decorator.ts
Created April 20, 2016 15:36 — forked from remojansen/class_decorator.ts
TypeScript Decorators Examples
function logClass(target: any) {
// save a reference to the original constructor
var original = target;
// a utility function to generate instances of a class
function construct(constructor, args) {
var c : any = function () {
return constructor.apply(this, args);
}
@gatspy
gatspy / gist:fa1bbfebfae3cd9d598178399c3cca7d
Created April 21, 2016 19:52 — forked from datagrok/gist:2199506
Virtualenv's `bin/activate` is Doing It Wrong

Virtualenv's bin/activate is Doing It Wrong

I'm a Python programmer and frequently work with the excellent [virtualenv][] tool by Ian Bicking.

Virtualenv is a great tool on the whole but there is one glaring problem: the activate script that virtualenv provides as a convenience to enable its functionality requires you to source it with your shell to invoke it. The activate script sets some environment variables in your current environment and defines for you a deactivate shell function which will (attempt to) help you to undo those changes later.

This pattern is abhorrently wrong and un-unix-y. activate should instead do what ssh-agent does, and launch a sub-shell or sub-command with a modified environment.

Problems

@gatspy
gatspy / point.py
Created May 3, 2016 18:21
python -- point
class Point(object):
__slots__ = ('x', 'y')
def __init__(self, x=0, y=0):
self.x = x
self.y = y
def __setattr__(self, name, value):
# print self, name, value
@gatspy
gatspy / singleton.py
Last active May 4, 2016 08:36
python -- singleton
# Method 1: A decorator
def singleton(class_):
instances = {}
def getinstance(*args, **kwargs):
if class_ not in instances:
instances[class_] = class_(*args, **kwargs)
return instances[class_]
return getinstance