This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
# adapted from Alterstep dnscrypt-proxy OSX client | |
try_resolution() { | |
exec alarmer 5 dig +tries=2 +time=3 +short github.com | egrep '^192[.]30[.]' > /dev/null 2>&1 | |
} | |
try_http_query() { | |
exec alarmer 5 curl -L --max-redirs 5 -4 -m 5 --connect-timeout 5 -s \ | |
http://icanhazip.com/ 2>/dev/null | \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
if check-hijacking; then | |
echo "The router doesn't hijack HTTP queries" | |
else | |
echo "The router hijacks HTTP queries - DNSCrypt is likely to be blocked" | |
# kill/stop DNSCrypt | |
networksetup -getcurrentlocation | |
networksetup -switchtolocation 'Captive portal' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Only do this when not done yet for this buffer | |
if exists("b:did_ftplugin") | |
finish | |
endif | |
let b:did_ftplugin = 1 | |
" safe and simple | |
setlocal nobackup | |
setlocal noswapfile | |
setlocal nowritebackup |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use Term::ExtendedColor qw(:all); | |
use strict; | |
use warnings; | |
use feature qw(say); | |
say "Throw me two numbers or two color names separated by space(s)"; | |
while (<>) { | |
# print $_; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# This simple perl scripts prints lines from mutt colorfile | |
# in actual designated colors. | |
# I have created that script for finetuning my mutt with | |
# iTerm color themes. | |
# I am using here mix of little known library Term::ExtendedColors | |
# for extended colors and escape codes for base16 colors. | |
# Term::ExtendedColors is weird with base16 | |
# It looks fuzzy but works! | |
# Actual colors depend on definitions in terminal color palette first of all |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use feature qw(say); | |
use Color::ANSI::Util qw( | |
rgb_to_ansi256 | |
); | |
say "Throw me hex# and I will throw back ansi 256 color"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
# open current folder in Finder | |
osascript -e'on run {arg} | |
set the_folder to POSIX file (POSIX path of arg) | |
tell application "Finder" | |
activate | |
if exists window 1 then | |
set target of window 1 to the_folder | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on run {input, parameters} | |
if input is not in {{}, {""}, ""} then | |
tell application "Finder" | |
set my_file to first item of input | |
set filetype to (kind of (info for my_file)) | |
-- Treats OS X applications as files. To treat them as folders, integrate this SO answer: | |
-- http://stackoverflow.com/a/6881524/640517 | |
if filetype is "Folder" or filetype is "Volume" then | |
set dir_path to quoted form of (POSIX path of my_file) | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# virtualenvwrapper | |
# lazy loading saves on shell startup time | |
workon() { | |
[ -z "$PROJECT_HOME" ] && { | |
unset -f workon; | |
export WORKON_HOME=$HOME/.virtualenvs; | |
export PROJECT_HOME=$HOME/Documents/Python; | |
source /usr/local/bin/virtualenvwrapper.sh | |
} | |
workon "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding: utf-8 | |
# python 3 | |
# This script is an editor action, called "Serve Files." It has three improvements over existing implementations: | |
# Serve every file from the directory of your script at its filename | |
# Serve a zip of the entire directory in which your script is contained at /. This is useful for copying a lot of files to a computer at once | |
# Printing your local IP to the console, to make it easier to see where you should go on your computer | |
# It will also clean up the zip it creates after you stop the server. | |
import os | |
import shutil |