Skip to content

Instantly share code, notes, and snippets.

View zsimic's full-sized avatar

Zoran Simic zsimic

  • Netflix
  • Los Gatos, CA
  • 14:22 (UTC -07:00)
View GitHub Profile
// Settings in here override those in "Default/Base File.sublime-settings", and
// are overridden in turn by file type specific settings. Place your settings
// here, to ensure they're preserved when upgrading.
{
"tab_completion": false,
"rulers": [140], // Columns in which to display vertical rulers
"word_wrap": false,
"highlight_line": false,
"caret_style": "wide", // Valid values are "smooth", "phase", "blink", "wide" and "solid".
"line_padding_top": 1,
@zsimic
zsimic / bitcount.java
Created October 12, 2011 01:33
Bit counting
public static int countBits1(long x) {
int c = 0;
long v = x;
while (v!=0) {
v &= v - 1;
c++;
}
return c;
}
@zsimic
zsimic / obfuscated-python
Created November 13, 2011 19:25
obfuscated python hack writing 'python'
def m(x): return -1 if x%3 else 1
def g(x): return cmp(2.5-x, 0)
print ''.join(chr(ord('a') + x)
for x in reduce(
lambda x,y: x+[x[-1]+y*m(len(x)-1)] if isinstance(x,list) else [x,x+y],
reduce(
lambda x,y: x+[x[-1]+g(y-2)*(y-2+cmp(g(y-2)+m(y-1),0)*cmp(6-y,0))+(8-y)*m(y-1)] if x else [15],
range(7)
)
)
@zsimic
zsimic / DefaultKeyBinding.dict
Last active April 22, 2024 14:40
OSX key bindings
{
/* ~/Library/KeyBindings/DefaultKeyBinding.dict
See https://gist.github.com/zsimic/1367779, prefix cheatsheet:
Char Short Key
$ S- Shift ⇧
^ C- CTRL ⌃
~ O- Option ⌥ (⊞ Win key position on PC)
@ M- Command ⌘ (Alt position on PC)
# Numeric Keypad
@zsimic
zsimic / inputrc
Last active April 26, 2024 11:29
inputrc
# Use Home/End keyboard keys to navigate current line (same as CTRL+A or E), listing all variants for those keys here
"\e[1~": beginning-of-line # Home
"\e[H": beginning-of-line # Home
"\eOH": beginning-of-line # Home
"\0001": beginning-of-line # Home
"\e[4~": end-of-line # End
"\e[F": end-of-line # End
"\eOF": end-of-line # End
"\0005": end-of-line # End
unbind-key -a
set -g prefix C-b
# Auto scroll with mouse wheel or page up/down, but only if no other process took the screen (such as vi or less)
set -g mouse on
set -s set-clipboard off
bind -n PageUp if-shell -F "#{alternate_on}" "send-keys PageUp" "copy-mode -e; send-keys PageUp"
bind -n PageDown if-shell "test #{pane_in_mode} -gt 0 -o #{alternate_on} -gt 0" "send-keys PageDown"
bind -n WheelUpPane if-shell -F "#{alternate_on}" "send-keys -M" "select-pane -t= \; copy-mode -e \; send-keys -M"
bind -n WheelDownPane if-shell -F "#{alternate_on}" "send-keys -M" "select-pane -t= \; send-keys -M"
"""
Support for understanding files/folders to ignore (from .gitignore or .svnignore)
These classes should be reusable, can be moved to a library
Example usage:
ignored_file = IgnoredFiles(mypath)
for root, dirs, files in os.walk(mypath):
ignored_files.remove_ignored_folders(root, dirs)
; -- Remap Alt -> Ctrl on Windows (to behave like ⌘CMD+key on mac)
; Via https://www.autohotkey.com/docs/misc/Remap.htm
; Alt+key on Windows is just a general shortcut to application menu...
; I find that undesirable/annoying, and prefer to simply have all Alt+key combinations be CTRL+key instead
; Benefits:
; - CMD is much more natural to hit (less finger stretching to reach CTRL)
; - no UI menu distractions while using keyboard
; - makes it easy to configure many dev tools in the same way on mac/Windows
; -- Remap Alt -> Ctrl on Windows (to behave like ⌘CMD+key on mac)
; Via https://www.autohotkey.com/docs/misc/Remap.htm
; This remaps Alt -> Ctrl completely, except for Alt+Tab and Alt+F4
#SingleInstance ignore
SetCapsLockState, AlwaysOff ; disable caps lock entirely
CapsLock::return
RAlt::RCtrl ; Right Alt key is simply mapped to Ctrl, RAlt+Tab won't work as usual (only LAlt+Tab will)
{
"Key Mappings": {
"0x2a-0x200000": {
"Action": 12,
"Text": "*"
},
"0x2b-0x200000": {
"Action": 12,
"Text": "+"
},