Skip to content

Instantly share code, notes, and snippets.

View levskaya's full-sized avatar

Anselm Levskaya levskaya

View GitHub Profile
@glasser
glasser / flycheck-top-window.el
Last active September 16, 2015 00:34
Preserving Emacs flycheck's error window
(defconst top-window-height 10 "Height to set top window to when splitting")
(defun ensure-top-window ()
(interactive)
(let* ((w (selected-window))
(is-top (and
(eq (window-parent w) (frame-root-window))
(eq (window-top-child (frame-root-window)) w))))
; Make sure we're the top window, and default our height to
; top-window-height. This is a little destructive (loses all window state)
; but generally only happens once per session.
@karpathy
karpathy / min-char-rnn.py
Last active May 25, 2024 03:02
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@GreenLightning
GreenLightning / 19392494.lua
Created June 16, 2015 19:00
TIS-100 PRIME DETECTOR SPECIFICATION
-- For anyone who liked the PRIME DETECTOR puzzle included in some of the early access
-- builds of TIS-100...
-- INSTALLATION: Copy everything in this file. Open TIS-100. Go to the SPECIFICATION
-- EDITOR. Click on IMPORT SPECIFICATION FROM CLIPBOARD. Done!
-- The function get_name() should return a single string that is the name of the puzzle.
--
function get_name()
return "PRIME DETECTOR"
anonymous
anonymous / bin.py
Created February 4, 2014 14:39
#!/usr/bin/env python
import fileinput, re, sys, binascii, struct
hexword = '([A-Fa-f0-9]{4})'
pattern = '%(hexword)s:' + 8*'\s*%(hexword)s'
pattern = pattern % locals()
write = sys.stdout.write
unhex = binascii.unhexlify
word = lambda b: struct.unpack('!H', b)[0]
@lokkju
lokkju / find_system_python_dylibs.sh
Last active December 31, 2023 23:08
This script prints the filenames of any libs in your /usr/local/lib that depend on the System Python. It is especially useful if you use a non-system Python, but have previously compiled extensions against the System Python - it will tell you which need to be recompiled.
#!/bin/bash
echo "This script prints the filenames of any dylibs in your /usr/local/ that depend on the System Python"
for f in `find /usr/local/lib`; do
otool -L "$f" 2> /dev/null| grep Python | grep System &> /dev/null
status=$?
if [ $status -eq 0 ]; then
echo "$status: $f"
fi
done
@waylan
waylan / foo.sh
Created November 15, 2012 18:39
Simple bash subcommands. Each subcommand is implemented as a function. For example, `sub_funcname` is called for `funcname` subcommand.
#!/bin/sh
ProgName=$(basename $0)
sub_help(){
echo "Usage: $ProgName <subcommand> [options]\n"
echo "Subcommands:"
echo " bar Do bar"
echo " baz Run baz"
echo ""
@jordelver
jordelver / gist:3073101
Created July 8, 2012 22:06
Set the Mac OS X SOCKS proxy on the command line

Set the Mac OS X SOCKS proxy on the command line

a.k.a. what to do when your ISP starts blocking sites :(

Set the SOCKS proxy to local SSH tunnel

networksetup -setsocksfirewallproxy "Ethernet" localhost 8080

To clear the domain and port

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@sixtenbe
sixtenbe / analytic_wfm.py
Last active May 1, 2024 02:29 — forked from endolith/peakdet.m
Peak detection in Python
#!/usr/bin/python2
# Copyright (C) 2016 Sixten Bergman
# License WTFPL
#
# This program is free software. It comes without any warranty, to the extent
# permitted by applicable law.
# You can redistribute it and/or modify it under the terms of the Do What The
# Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See
@netj
netj / memusg
Last active May 17, 2024 21:28
memusg -- Measure memory usage of processes
#!/usr/bin/env bash
# memusg -- Measure memory usage of processes
# Usage: memusg COMMAND [ARGS]...
#
# Author: Jaeho Shin <netj@sparcs.org>
# Created: 2010-08-16
############################################################################
# Copyright 2010 Jaeho Shin. #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #