Skip to content

Instantly share code, notes, and snippets.

View nowk's full-sized avatar

Yung Hwa Kwon nowk

  • damncarousel
  • New York, NY
View GitHub Profile
@nowk
nowk / _pagination_partial.html.haml
Created July 4, 2012 16:24
Knockout pagination
/ ko with: paginate
.will_paginate
%span.per_page_options
Show rows
%select.per_page{:name => "per_page", 'data-bind' => 'options: per_page_limits, value: per_page'}
 
%span.go_to_page_options
Go to
%input{:name => 'page', :type => 'text', :size => "2", 'data-bind' => 'value: page, valueUpdate: "afterKeyDown"'}
 
@nowk
nowk / capybara_wysiwyg.rb
Created July 15, 2012 15:38
Capybara + Selenium wysiwyg interaction
def is_js?
Capybara::Selenium::Driver == page.driver.class
end
page.execute_script('$("#selector").tinymce().setContent("Test goes here")')
# this does not work (or does not work anymore)
# it asks to switch the to the frame
within_frame("#{name}_ifr") do
" My Bundles here:
"
" themes
Bundle 'railscasts'
Bundle 'molokai'
Bundle 'tpope/vim-vividchalk'
Bundle 'nowk/vim-flog'
" 'fousa/vim-flog' fork
" Bundle 'mbadran/headlights'
@nowk
nowk / .bashrc
Created August 27, 2012 22:58
Setup local ENV variables for 3rd party credentials
# ~/.bashrc
# add this line so keep .bashrc cleaner, if you don't already have it in there somewhere
[ ! -f "$HOME/.bashrc.local" ] || . "$HOME/.bashrc.local"
@nowk
nowk / application_controller.rb
Created September 19, 2012 14:51
save and redirect
def after_sign_in_path_for(resource)
if resource.is_a?(User)
redirect_after_login = session[:redirect_after_login]
if redirect_after_login
clear_redirect_after_login
return redirect_after_login
end
else
super
end
@nowk
nowk / drag_and_drop_simulator.rb
Created September 27, 2012 20:45
A basic wrapper for drag and drop simulation
class DragAndDropSimulator
def initialize(page, drag)
@page = page
@drag = drag
end
def up(num)
drag_and_drop(num)
end
@nowk
nowk / juggernaut.rb
Created October 29, 2012 14:50 — forked from maccman/juggernaut.rb
Sinatra Server Side Event streaming.
# Usage: redis-cli publish message hello
require 'sinatra'
require 'redis'
conns = []
get '/' do
erb :index
end
@nowk
nowk / cmd
Created November 13, 2012 19:26
Git log graph
git log --graph --decorate --pretty=oneline --abbrev-commit --all
@nowk
nowk / application_controller.rb
Created November 27, 2012 19:55
Dynamic default url options
class ApplicationController < ActionController::Base
protect_from_forgery # See ActionController::RequestForgeryProtection for details
before_filter lambda {
ActionMailer::Base.default_url_options = {:host => request.host_with_port}
}
end
@nowk
nowk / Gemfile
Last active December 12, 2015 02:09
Spork reloads
group :development, :test do
# require false fixes ActiveRecord::AssociationTypeMismatch
# gem 'factory_girl', :require => false
gem 'factory_girl_rails', :require => false
end