Skip to content

Instantly share code, notes, and snippets.

View zeekay's full-sized avatar
💎
👋

z zeekay

💎
👋
View GitHub Profile
@zeekay
zeekay / open-in-vim.scpt
Last active August 29, 2015 14:01
Edit Finder selection in terminal Vim.
-- Meant to be used as part of Automator service. Create a new service in
-- Automator and send files or folders to this AppleScript. Supports multiple files.
on run {input, parameters}
tell application "Finder"
activate
try
set this_folder to (the target of the front window) as alias
on error
set this_folder to home folder
@zeekay
zeekay / .xmodmap
Created May 7, 2014 11:30
Map capslock to escape (control when used as a modifier) with xmodmap.
clear Lock
clear mod1
clear mod4
keycode 66 = Escape
keycode 64 = Super_L
keycode 108 = Super_R
keycode 133 = Alt_L Meta_L
keycode 135 = Alt_R Meta_R
add mod4 = Super_L Super_R
add mod1 = Alt_L Alt_R Meta_L Meta_R
@zeekay
zeekay / app.py
Last active September 9, 2019 12:57
Management command for Flask + uWSGI , restarts uWSGI on file changes.
from flask import Flask
def configure_uwsgi(app):
# Setup debugging, logging for uwsgi.
try:
import uwsgi
except ImportError:
return
from time import strftime
@zeekay
zeekay / fast-escape.vim
Last active August 29, 2015 13:58
Prevent lag when hitting escape in Vim,
augroup fastescape
au!
set notimeout
set ttimeout
set timeoutlen=10
au InsertEnter * set timeout
au InsertLeave * set notimeout
augroup END
@zeekay
zeekay / ex2.go
Last active August 29, 2015 13:55
Python vs Go round 2.
package main
import "fmt"
func ping(c chan string) {
fmt.Println("starting ping")
for {
c <- "ping"
pong := <-c
fmt.Println(pong)
@zeekay
zeekay / ex.go
Created January 30, 2014 08:49
Python vs Go round 1.
package main
import "fmt"
func ping(c chan string) {
for {
c <- "ping"
}
}
@zeekay
zeekay / errorhandling.go
Last active August 29, 2015 13:55
Go error handling using switch statement to "pattern match" against return value(s) of function.
package main
import "fmt"
// Error
type notSquared struct {
number int
}
func (e notSquared) Error() string {
@zeekay
zeekay / go-vs-nodjs.sh
Created January 28, 2014 09:19
Lies, damned lies, and benchmarks.
$ ab -k -c 100 -n 10000 http://go.dev:1337/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
@zeekay
zeekay / hoodoo.py
Created January 17, 2014 15:15
Old task management app I wrote years ago.
#!/usr/bin/env python2.7
"""
description
hoodoo is a task management app. tasks can be tagged, searched, sorted.
commands available
add <name> #<tag> add a new task
alias: +
opt: created=<date> due=<date> done=True/False, tags
@zeekay
zeekay / create_bound_session.py
Last active January 1, 2016 03:58
Bind request sessions to an IP address.
import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.connection import HTTPConnection, HTTPSConnection
from requests.packages.urllib3.connectionpool import HTTPConnectionPool, HTTPSConnectionPool
from requests.packages.urllib3.poolmanager import PoolManager
def create_bound_session(source_address):
'''
Creates a requests session bound to a given source address. Proving once