Skip to content

Instantly share code, notes, and snippets.

View Vetal4eg's full-sized avatar
👌
getting the right things done

Vitaliy Esaulenko Vetal4eg

👌
getting the right things done
View GitHub Profile
Passenger `rails server`
\ /
\ /
\ /
\ /
\ /
\ /
|
MAGIC HAPPENS HERE
|
"————————————————————————————————————————————————————————————————————————————————————————————————————————————————————"
" 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
@kmile
kmile / xml_parser.rb
Created February 15, 2011 12:53
A small nokogiri xml reader DSL.
# 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:
#
We couldn’t find that file to show.
@slayer
slayer / gist:935641
Created April 21, 2011 22:46
SQL JOIN via AREL in Rails 3
# 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`
@ericmoritz
ericmoritz / README.rst
Created May 13, 2011 01:17
crazy-template.js

crazy_template

A template engine in 42 lines of code.

About

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.

@dhh
dhh / gist:981520
Created May 19, 2011 19:27
bulk api
# 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
@olivierlacan
olivierlacan / sublime-text-2-settings.json
Last active January 11, 2024 15:38
Basic Sublime Text 2 settings for Rails development
{
"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",
@alisterscott
alisterscott / thread.rb
Created September 20, 2011 23:50
simple watir-webdriver threading example for load testing
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
@mashihua
mashihua / Capfile
Created October 12, 2011 10:40
Capistrano deploy script for node.js
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'