Skip to content

Instantly share code, notes, and snippets.

View John-Appleseed's full-sized avatar

John-Appleseed

View GitHub Profile
-- AppleScript doesn't load shell's environment variables
-- in "do shell script", so here goes a nasty workaround
on shell_cmd(command)
do shell script "source ~/.profile; " & command
end shell_cmd
do shell script "echo $EDITOR" -- => ""
shell_cmd("echo $EDITOR") -- => "mate"
@sr
sr / Markdown in awk(1)
Created May 21, 2009 14:14
Markdown in awk(1)
#!/bin/awk -f
# md2html.awk
# by: Jesus Galan (yiyus) <yiyu.jgl@gmail>, May 2009
# Usage:
# md2html file.md > file.html
# Options: -v esc=false to not escape html
function newblock(nblock){
if(text)
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
function! s:align()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
Tabularize/|/l1
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
@hintjens
hintjens / git bash prompt
Created March 11, 2011 16:24
git bash prompt, by Pieter Hintjens
export PROMPT_COMMAND=__git_prompt
__git_prompt ()
{
txtblk='\e[0;30m' # Black - Regular
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtblu='\e[0;34m' # Blue
txtpur='\e[0;35m' # Purple
txtcyn='\e[0;36m' # Cyan
@enlavin
enlavin / gist:1023074
Created June 13, 2011 16:08
screenrc alt + 1 -> screen 1, alt + 2 -> screen 2, etc
caption always "%{+b gk}%c %{rk}%d/%m/%Y | %?%{yk}%-Lw%?%{wb}%n*%f %t%?(%u)%?%?%{yk}%+Lw%?"
bind f eval "caption splitonly"
bind F eval "caption always"
hardstatus string "%{.kc}%-w%{.kw}%n*%t%{-}%+w %= %2` %3`/%4` %6`/%7` %5`/%9` %c%a %m/%d/%Y" #black+cyan+normal+white selected
bindkey "\033\060" select 0
bindkey "\033\302\272" select 0
bindkey "\033\061" select 1
bindkey "\033\062" select 2
@tomjnixon
tomjnixon / paswitch.sh
Last active May 28, 2024 13:27
PulseAudio output switcher script
#!/bin/bash
# Script to switch all programs to a specific sink. Why this isn't easy, i
# don't know.
# This script takes a single argument, the sink name, index, or alias (defined
# below).
# To make this work, you will need to:
# - In /etc/pulse/default.pa:
@amacdougall
amacdougall / focus.vim
Created March 6, 2012 23:38
Simple vim script for a single centered text column.
" Name: focus.vim
" Author: Alan MacDougall <smoke@alanmacdougall.com>
" License: Public Domain
"
" Focus on a single column of text, showing it in a distraction-free format.
" Save this as ~/.vim/scripts/focus.vim (or whatever you please), and invoke
" it with :source <filename>. Of course, you could certainly hook that up to a
" :command, or a macro, or a Vimscript function...
" collapse current splits and divide screen in three
@sansumbrella
sansumbrella / create-sparsebundle.sh
Created November 1, 2012 22:49
Sparse bundle creation for time machine on NAS.
# creates a sparsebundle disk image with a 128MB band size
MACHINE_NAME=your-machine-name
echo $MACHINE_NAME
hdiutil create -size 900g -type SPARSEBUNDLE -nospotlight -volname "Backup of $MACHINE_NAME" -fs "Case-sensitive Journaled HFS+" -imagekey sparse-band-size=262144 -verbose ./$MACHINE_NAME.sparsebundle
@jdkanani
jdkanani / notepad.html
Last active June 16, 2024 13:44 — forked from jakeonrails/Ruby Notepad Bookmarklet
This bookmarklet gives you a code editor in your browser with a single click.
data:text/html, <style type="text/css">.e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div class="e" id="editor"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("editor");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
<!--
For other language: Instead of `ace/mode/ruby`, Use
Markdown -> `ace/mode/markdown`
Python -> `ace/mode/python`
C/C++ -> `ace/mode/c_cpp`
Javscript -> `ace/mode/javascript`
Java -> `ace/mode/java`
Scala- -> `ace/mode/scala`
@kvnsmth
kvnsmth / example-subtree-usage.md
Last active March 5, 2023 21:58
A real world usage for git subtrees.

Let's say you have an iOS project, and you want to use some external library, like AFNetworking. How do you integrate it?

With submodules

Add the project to your repo:

git submodule add git@github.com:AFNetworking/AFNetworking.git Vendor/AFNetworking

or something to that effect.