Skip to content

Instantly share code, notes, and snippets.

@FeipingHunag
FeipingHunag / Days Until Christmas.markdown
Created December 24, 2015 04:05
Days Until Christmas

Days Until Christmas

Apples 12 Days of Christmas style created using html5 canvas and css3, and instead counting down the days until christmas :D

A Pen by Lennart Hase on CodePen.

License.

@FeipingHunag
FeipingHunag / Four Seasons (playing with filters).markdown
Created December 24, 2015 04:03
Four Seasons (playing with filters)
require 'strong_parameters'
class ActiveRecord::Base
include ActiveModel::ForbiddenAttributesProtection
end
class ActionController::Base
# Use this with CanCan's load_resource to permit a set of params before
# it tries to build or update a resource with them.
#!/bin/sh
# if you're using ZSH, change the shebang above to "#!/bin/zsh -i"
if [ ${#} -ne 2 ]; then
echo >&2 Usage: $(basename ${0}) old-version new-version
exit 1
fi
home_path=$(cd ~; pwd -P)
old_version=${1}
@FeipingHunag
FeipingHunag / dci_alt.rb
Created December 4, 2012 14:26 — forked from elight/dci_alt.rb
DCI with delegation instead of extension
class User < ActiveRecord::Base
# ... lots of persistence stuff
end
class GitHubUserProvisioner < SimpleDelegator
def provision_with!(user_info, extra_user_hash)
self.github_login = extra_user_hash['login']
self.name = user_info['name']
self.email = user_info['email']
self.github_url = user_info['urls']['GitHub']
@FeipingHunag
FeipingHunag / gist_tag.rb
Created November 30, 2012 07:34 — forked from imathis/gist_tag.rb
A Liquid tag for Jekyll sites that allows embedding Gists and showing code for non-JavaScript enabled browsers and readers.
require 'cgi'
require 'digest/md5'
require 'net/https'
require 'uri'
module Jekyll
class GistTag < Liquid::Tag
def initialize(tag_name, text, token)
super
@text = text
@FeipingHunag
FeipingHunag / 0-readme.md
Created November 27, 2012 02:04 — forked from burke/0-readme.md
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

@FeipingHunag
FeipingHunag / passwords_controller.rb
Created November 20, 2012 02:22 — forked from guilleiguaran/passwords_controller.rb
StrongParameters with Devise
# app/controllers/users/password_controller.rb
class Users::PasswordsController < Devise::PasswordsController
def resource_params
params.require(:user).permit(:email, :password, :password_confirmation)
end
private :resource_params
end
@FeipingHunag
FeipingHunag / registrations_controller.rb
Created November 19, 2012 09:19 — forked from evanbeard/registrations_controller.rb
API JSON authentication with Devise
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else
@FeipingHunag
FeipingHunag / gist:4077725
Created November 15, 2012 09:48 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt