This file contains 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
Passenger `rails server` | |
\ / | |
\ / | |
\ / | |
\ / | |
\ / | |
\ / | |
| | |
MAGIC HAPPENS HERE | |
| |
This file contains 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
"————————————————————————————————————————————————————————————————————————————————————————————————————————————————————" | |
" Full colors reset | |
"————————————————————————————————————————————————————————————————————————————————————————————————————————————————————" | |
" Base colors | |
hi ColorColumn guifg=#000000 guibg=#ffffff gui=none ctermfg=16 ctermbg=231 cterm=none | |
hi Conceal guifg=#000000 guibg=#ffffff gui=none ctermfg=16 ctermbg=231 cterm=none | |
hi Cursor guifg=#000000 guibg=#ffffff gui=none ctermfg=16 ctermbg=231 cterm=none | |
hi CursorIM guifg=#000000 guibg=#ffffff gui=none ctermfg=16 ctermbg=231 cterm=none |
This file contains 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
# A small DSL for helping parsing documents using Nokogiri::XML::Reader. The | |
# XML Reader is a good way to move a cursor through a (large) XML document fast, | |
# but is not as cumbersome as writing a full SAX document handler. Read about | |
# it here: http://nokogiri.org/Nokogiri/XML/Reader.html | |
# | |
# Just pass the reader in this parser and specificy the nodes that you are interested | |
# in in a block. You can just parse every node or only look inside certain nodes. | |
# | |
# A small example: | |
# |
This file contains 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
# Simple JOIN | |
User.joins(:account) # User -> Account | |
# Will produce | |
# SELECT `users`.* FROM `users` INNER JOIN `accounts` ON `accounts`.`user_id` = `users`.`id` | |
# Complicated JOIN | |
Trait.joins(:user => :account) # Trait -> User -> Account | |
# Will produce | |
# SELECT `traits`.* FROM `traits` INNER JOIN `users` ON `users`.`id` = `traits`.`user_id` INNER JOIN `accounts` ON `accounts`.`user_id` = `users`.`id` |
A template engine in 42 lines of code.
I was thinking of a way to generate HTML without using strings as embedding strings in Javascript is a pain if they are multi-lined. There isn't a nice triple quote like there exists in Python.
So I took my inspiration from Lisp HTML generators that use S-expressions to generate HTML. I thought, hell, S-expressions are just a bunch of nested lists, I could do the same thing in Javascript.
This file contains 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
# Bulk API design | |
# | |
# resources :posts | |
class PostsController < ActiveController::Base | |
# GET /posts/1,4,50,90 | |
# post_url([ @post, @post ]) | |
def show_many | |
@posts = Post.find(params[:ids]) | |
end |
This file contains 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
{ | |
"use_simple_full_screen": false, | |
// calculates indentation automatically when pressing enter | |
"auto_indent": true, | |
// sets the colors used within the text area (default) | |
// see https://github.com/olivierlacan/monokaim to download | |
// the customized Monokai I use. | |
"color_scheme": "Packages/Color Scheme - Default/Monokaim.tmTheme", |
This file contains 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
require 'thread' | |
require 'watir-webdriver' | |
def test_google | |
3.times do | |
browser = Watir::Browser.start 'http://www.etsy.com', :chrome | |
browser.text_field(:name, 'search_query').set 'hat' | |
start_time = Time.now | |
browser.button(:text, 'Search').click | |
end_time = Time.now |
This file contains 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
load 'deploy' if respond_to?(:namespace) # cap2 differentiator | |
Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) } | |
load 'config/deploy' # remove this line to skip loading any of the default tasks | |
load 'config/node' |