Skip to content

Instantly share code, notes, and snippets.

View yorzi's full-sized avatar
🏠
Working from home

Andy Wang yorzi

🏠
Working from home
  • Xi'an, China
  • 18:36 (UTC +08:00)
View GitHub Profile
@yorzi
yorzi / fork_me_on_github.html
Created August 14, 2011 14:23
add a fork me on github corner flag
<a href="https://github.com/yorzi"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://assets0.github.com/img/e6bef7a091f5f3138b8cd40bc3e114258dd68ddf?repo=&url=http%3A%2F%2Fs3.amazonaws.com%2Fgithub%2Fribbons%2Fforkme_right_red_aa0000.png&path=" alt="Fork me on GitHub"></a>
@yorzi
yorzi / application.rb
Created August 25, 2011 07:42
config a rails3.1 application with pre-defined technologies.
config.generators do |g|
g.test_framework :rspec, :fixture => true, :view_specs => false, :routing_specs => false, :helper_specs => false, :integration_specs => false
g.integration_tool :cucumber
g.stylesheets false
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
g.form_builder :simple_form
g.template_engine :haml
end
@yorzi
yorzi / .bash_profile
Created August 31, 2011 01:01 — forked from bcardarella/.bash_profile
Git Autocompletion
source ~/.git-completion.sh
alias gco='git co'
alias gci='git ci'
alias grb='git rb'
def random_token(number=10)
Digest::SHA1.hexdigest(Time.now.to_i.to_s)[1..number]
end
@yorzi
yorzi / 01. Gemfile
Created February 3, 2012 13:30 — forked from schleg/01. Gemfile
Setup for Devise + Omniauth
gem 'pg'
group :development do
gem 'ruby-debug'
end
gem 'rake', '~> 0.8.7'
gem 'devise'
gem 'oa-oauth', :require => 'omniauth/oauth'
gem 'omniauth'
gem 'haml'
gem 'dynamic_form'
@yorzi
yorzi / command_output.rb
Created February 15, 2012 01:45
get command output in ruby code
require 'pty'
cmd = "rake -T"
begin
PTY.spawn( cmd ) do |stdin, stdout, pid|
begin
# Do stuff with the output here. Just printing to show it works
stdin.each { |line| print line }
rescue Errno::EIO
puts "Errno:EIO error, but this probably just means " +
"that the process has finished giving output"
@yorzi
yorzi / xhtml-validation.md
Created March 15, 2012 03:38
XHTML validation on pew county#show page

Validation Output: 32 Errors

Line 6, Column 13: there is no attribute "class"

✉ You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).

This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information.

How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chos

@yorzi
yorzi / command.sh
Created April 3, 2012 13:26
pull data from heroku to local postgres
# make sure you have latest version of below gems
gem install heroku taps sequel
# run command
# heroku db:pull postgres://db_username:@localhost/db_name
heroku db:pull postgres://andy:@localhost/newsite_development
@yorzi
yorzi / Limit chosen select count
Created June 12, 2012 01:19
limit_chosen_count.coffee
$(".chzn").change ->
el = $(@)
if el.val()? == false or el.val().length < 3
exists = 0
exists = el.val().length if el.val()?
$(".metro-stations-counter").html("You can add <strong>#{2 - exists}</strong> more metro station(s) to this organization.</span>")
else
el.val(el.val().slice(0, el.val().length - 1))
el.trigger("liszt:updated")
@yorzi
yorzi / dummy image place holder in rails
Created June 12, 2012 12:56
dummy_image_helper.rb
module DummyImageHelper
def dummy_image wxh
image_tag "http://dummyimage.com/#{wxh}/999/eee.png",size: wxh
end
end