Skip to content

Instantly share code, notes, and snippets.

View tastycode's full-sized avatar

Sasha Devol tastycode

  • Elsewhere Labs
  • New Orleans, LA
View GitHub Profile
@tastycode
tastycode / vimrc.after
Last active December 14, 2015 09:39
~/.vimrc.after for use with janus
if has("gui_running")
set guioptions=egmrt
endif
" so we don't have to use that extra key when we use commands
map ; :
" molokai colorscheme
colo molokai
url = "http://www.google.com"
rex = %r{^(\w+)*://(\w+)?\.(\w+).?\.(\w+)}
url.match(rex)
url_data = {:host => $1, :hostname => $2, :domain => $3, :tld => $4}
p url_data # {:host=>"http", :hostname=>"www", :domain=>"google", :tld=>"com"}
@tastycode
tastycode / terminal.markdown
Created January 25, 2013 12:02
Terminal Safe JSON

If you could use JSON in the terminal, then applications would have a uniform way of passing in options.

ls [long, {sort: {size: -1}}]

grep [recursive, color]

If we could intercept arguments to commands, we could translate them into the corresponding flags.

The problem is that terminals don't like these characters.

@tastycode
tastycode / nested_regex.rb
Created September 9, 2012 16:22
blog_snips
require 'english'
main_path = %r{/status/(?<code>\d+)}
format_path = %r{#{main_path}\.?(?<format>html|json)}
format_path =~ "/status/500.json"
$LAST_MATCH_INFO[:code] # => "500"
$LAST_MATCH_INFO[:format] # => "json"
matches = format_path.match "/status/500.json"
matches[:code] # => "500"
require 'set'
def search(&block)
query_config = Object.new
class << query_config
def method_missing method_name, *args, &block
sym_variable = "@#{method_name}".to_sym
return dynamic_set("@#{$1}", args.first) if method_name.to_s =~ /(.*)=$/
return dynamic_get(sym_variable) if user_variables.include? sym_variable
@tastycode
tastycode / gfm.markdown
Created March 13, 2012 02:14
GFM Preview

GitHub Flavored Markdown

View the source of this content.

Let's get the whole "linebreak" thing out of the way. The next paragraph contains two phrases separated by a single newline character:

Roses are red Violets are blue

@tastycode
tastycode / gist_a.markdown
Created February 13, 2012 04:24
@pivotaltracker/story/show/24829297

foo bar

  • baz
  • boo
@tastycode
tastycode / vimcopy.scpt
Created January 13, 2012 03:56
Vimcopy
-- with shell execution from http://neverblog.net/run-unix-commands-in-an-applescript/
tell application "System Events"
set front_app to item 1 of (get name of processes whose frontmost is true)
end tell
tell application "Terminal"
-- take the clipboard contents, pass through tr to remove odd newlines, write to vimcopy.txt, open vimcopy with vim,
-- the once closed, write vimcopy.txt contents to clipboard and exit
# create a shortcut for all applications
# shortcuts are launch_ e.g. to launch iPhoto = launch_iphoto
for app in /Applications/*.app
do
shortcut=`echo $app | ruby -ne 'puts "launch_"+File.basename($_).downcase.gsub(/.app/,"").gsub(/\s+/,"")'`
alias "$shortcut"="open $app"
done
on runme(message)
if (item 1 of message = 176) and (item 2 of message = 19) then
tell application "System Events" to keystroke return
end if
if (item 1 of message = 176) and (item 2 of message = 20) then
tell application "System Events" to keystroke space