Skip to content

Instantly share code, notes, and snippets.

View yakjuly's full-sized avatar

Ankun Yu yakjuly

View GitHub Profile
@yakjuly
yakjuly / custom.js
Created October 9, 2012 08:52 — forked from drewjoh/custom.js
Dynamic (AJAX) loaded Bootstrap Modal (Bootstrap 2.1)
$(document).ready(function() {
// Support for AJAX loaded modal window.
// Focuses on first input textbox after it loads the window.
$('[data-toggle="modal"]').click(function(e) {
e.preventDefault();
var url = $(this).attr('href');
if (url.indexOf('#') == 0) {
$(url).modal('open');
} else {
@yakjuly
yakjuly / rails31init.md
Created September 11, 2012 06:09 — forked from samnang/rails31init.md
Rails 3.1 with Rspec, Factory Girl, Haml, Simple Form, Database Cleaner, Spork, and Guard

Install Rails 3.1

gem install rails

generate new app, skipping Test::Unit file generation

rails new my_app -T

Set up Gemfile

@yakjuly
yakjuly / each_object
Created August 9, 2012 10:10 — forked from hooopo/each_object
each_object
[8] pry(main)> class A;;end
=> nil
[9] pry(main)> a1 = A.new
=> #<A:0xab50838>
[10] pry(main)> a2 = A.new
=> #<A:0xa8871b0>
[11] pry(main)> ObjectSpace.each_object(A){|object| p object}
#<A:0xa8871b0>
#<A:0xab50838>
@yakjuly
yakjuly / README.markdown
Created August 9, 2012 10:07 — forked from hooopo/README.markdown
RAILS 3: nav_link helper for adding 'selected' class to navigation elements

#Behold, the nav_link:

The nav_link helper works just like the standard Rails link_to helper, but adds a 'selected' class to your link (or its wrapper) if certain criteria are met. By default, if the link's destination url is the same url as the url of the current page, a default class of 'selected' is added to the link.

For full usage details, see: http://viget.com/extend/rails-selected-nav-link-helper

Drop nav_link_helper.rb into app/helpers in your Rails 3.x app and enjoy.

@yakjuly
yakjuly / rvm-ruby-dependencies
Created April 13, 2012 02:49 — forked from HungYuHei/rvm-ruby-dependencies
rvm ruby dependencies
# For RVM
yum install -y bash curl git libxslt # NOTE: For git you need the EPEL repository enabled
apt-get install bash curl git-core
# OS => Redhat/CentOS/Fedora
yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel
yum install -y make bzip2
yum install -y iconv-devel # NOTE: For centos 5.4 final iconv-devel might not be available :(
# OS => Debian/Ubuntu
@yakjuly
yakjuly / .gitignore
Created December 27, 2011 09:45 — forked from dkubb/.gitignore
Test Feedzirra w/VCR using an HTTP proxy
cassettes
@yakjuly
yakjuly / missing_template_fix.rb
Created December 26, 2011 10:14 — forked from hlxwell/missing_template_fix.rb
Patch to fix MissingTemplate issue in Rails 3
module ActionController
module ImplicitRender
def default_render
# lookup template exist? go to render it
render and return if template_exists?(action_name.to_s, _prefix)
has_template = begin
old_formats, @lookup_context.formats = @lookup_context.formats, Mime::SET.symbols
template_exists?(action_name.to_s, _prefix)
@yakjuly
yakjuly / createdb
Created December 14, 2011 02:55 — forked from alvin2ye/createdb
#!/usr/bin/env ruby
#curl https://raw.github.com/gist/1206310 --output create_mysql_db.rb && chmod +x create_mysql_db.rb
require 'rubygems'
require 'optparse'
require 'mysql'
options = {}
OptionParser.new do |opts|
@yakjuly
yakjuly / sphinx.yml
Created December 12, 2011 09:44 — forked from IceskYsl/sphinx.yml
sphinx in chinese setup
production:
listen: 0.0.0.0:9312
address: 0.0.0.0 # 对应的安装了searchd(sphinx)的mysql服务器ip
port: 9312 # 对应的安装了searchd(sphinx)的mysql服务器端口
bin_path: '/usr/local/bin'
searchd_file_path: '/data/sphinx/production'
query_log_file: '/data/sphinx/log/searchd.query.log'
searchd_log_file: '/data/sphinx/log/searchd.log'
exceptions: '/data/sphinx/log//exception.log'
enable_star: true # 支持通配符匹配