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
  • 12:48 (UTC +08:00)
View GitHub Profile
def random_token(number=10)
Digest::SHA1.hexdigest(Time.now.to_i.to_s)[1..number]
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'
@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 / 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 / sass.rb
Created August 3, 2011 02:32 — forked from denmarkin/sass.rb
Rails 3 initializer for Heroku/SASS setup
# see http://forrst.com/posts/Setting_up_SASS_on_Heroku-4dZ
# You can put this in config/initializers/sass.rb
# Setup directory in tmp/ to dump the generated css into
require "fileutils"
FileUtils.mkdir_p(Rails.root.join("tmp", "stylesheets", "generated"))
# Tell SASS to use the .sass files in public/stylesheets/sass and
# output the css to tmp/stylesheets/generated
@yorzi
yorzi / datetime_picker.js
Created July 22, 2011 01:34
a simple improvement on jqueryUI datepicker to enable the time setting.
$(document).ready(function(){
date_obj = new Date();
date_obj_hours = date_obj.getHours();
date_obj_mins = date_obj.getMinutes();
if (date_obj_mins < 10) { date_obj_mins = "0" + date_obj_mins; }
if (date_obj_hours > 11) {
date_obj_hours = date_obj_hours - 12;
date_obj_am_pm = " PM";
@yorzi
yorzi / error.log
Created July 11, 2011 01:45
full trace on group creation
RuntimeError in GroupsController#create
ProfilePhoto#content_type delegated to photo.content_type, but photo is nil: #<ProfilePhoto id: nil, user_id: 6, owner_id: 5, owner_type: "Group", title: nil, description: nil, upload_id: nil, status: "processed", created_at: nil, updated_at: nil, size: nil, height: nil, width: nil, filename: nil, content_type: nil, parent_id: nil, photo_id: nil>
Rails.root: /Users/andy/intridea.workspace/recnation
Application Trace | Framework Trace | Full Trace
vendor/gems/ss_photos/app/models/profile_photo.rb:26:in `rescue in content_type'
vendor/gems/ss_photos/app/models/profile_photo.rb:23:in `content_type'
(eval):25:in `image_content_type'
activemodel (3.1.0.rc4) lib/active_model/validator.rb:151:in `block in validate'
@yorzi
yorzi / pageless_style_pagination_helper.rb
Created July 6, 2011 08:39
create a pageless page, click "more" for new paginated results.
# usage:
# link_to_next_page(@items)
# link_to_next_page(@items, :remote => true) # Ajax
def link_to_next_page(scope, name, options = {}, &block)
param_name = options.delete(:param_name) || Kaminari.config.param_name
link_to_unless scope.last_page?, name, {param_name => (scope.current_page + 1)}, options.merge(:rel => 'next') do
block.call if block
end
end
@yorzi
yorzi / jquery.myplugin.coffee
Created July 1, 2011 14:42 — forked from jimeh/jquery.myplugin.coffee
Example jQuery plugin written in CoffeeScript, and the resulting compiled JavaScript file.
$.fn.extend
myplugin: (options) ->
self = $.fn.myplugin
opts = $.extend {}, self.default_options, options
$(this).each (i, el) ->
self.init el, opts
self.log el if opts.log
$.extend $.fn.myplugin,
default_options:
function signInModal(){
$( "#sign_in" ).dialog({
modal: true,
autoOpen: $("body").hasClass("show_login"),
resizable: false,
minWidth: 400
});
$("a.login, a#login_link").click(function(){
$( "#sign_in" ).dialog("open");