Skip to content

Instantly share code, notes, and snippets.

@kates
kates / yamlstr.py
Created August 12, 2013 04:05
Double quoting YAML keys and scalar values
import argparse
from yaml import load, dump, add_representer
try:
from yaml import CDumper as Dumper
except ImportError:
from yaml import Dumper
def rep(dumper, data):
return dumper.represent_scalar('tag:yaml.org,2002:str', data, style=None)
@kates
kates / crosshair.vim
Created September 6, 2013 09:34
Hide cursorcolum and cursorline in inactive window
augroup CrossHair
au!
au VimEnter * setlocal cursorline
au WinEnter * setlocal cursorline
au BufWinEnter * setlocal cursorline
au WinLeave * setlocal nocursorline
au VimEnter * setlocal cursorcolumn
au WinEnter * setlocal cursorcolumn
au BufWinEnter * setlocal cursorcolumn
@kates
kates / copypaste.vim
Created September 6, 2013 09:38
vim copy/paste to system clipboard
let os = substitute(system('uname'), "\n", "", "")
if os == "Darwin"
vmap <C-c> y:call system("pbcopy", getreg("\""))<CR>:echo "copied to system clipboard"<CR>
nmap <C-v> :call setreg("\"", system("pbpaste"))<CR>p:echo ""<CR>
end
class User < ActiveRecord::Base
define_index do
set_property enable_star: true
indexes :name
indexes :phone
indexes :address
end
def self.query(options)
@kates
kates / assets.rake
Created April 24, 2014 09:56
Detect modified assets in a gemified rails engine
task :fix_precompile_hook do
module Fixassets
module Assets
extend ActiveSupport::Concern
included do
def dependency_fresh_with_path_fix?(environment, dep)
path = dep.pathname.to_s
return false unless environment.paths.find { |env_path| path.starts_with? env_path }
dependency_fresh_without_path_fix?(environment, dep)
end
@kates
kates / media
Last active August 29, 2015 14:02
controlling media in macosx terminal
$ media [TAB] [TAB]
pause   play    skip    volume

$ media play [TAB] [TAB]
itunes spotify

$ media pause [TAB] [TAB]
itunes spotify
@kates
kates / Makefile
Last active August 29, 2015 14:02
lock macosx screen from terminal
TARGET=lockscreen
all: clean compile
compile:
clang -framework Foundation -framework IOKit main.m -o ${TARGET}
clean:
rm -f ${TARGET}
@kates
kates / pip_update_all.sh
Created July 21, 2014 08:10
pip update all packages in virtualenv
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs pip install -U
@kates
kates / keybase.md
Created September 23, 2014 08:55
keybase.md

Keybase proof

I hereby claim:

  • I am kates on github.
  • I am kates (https://keybase.io/kates) on keybase.
  • I have a public key whose fingerprint is 4F22 399E A2EF AC24 2E69 B88E 9166 6DC5 BB54 2901

To claim this, I am signing this object:

@kates
kates / tlc.rs
Created October 16, 2014 00:59
toy vm bytecode compiler
use std::os;
use std::io;
use std::fmt;
struct Compiler {
source: String
//bytecode: String
}
enum Instruction {