Skip to content

Instantly share code, notes, and snippets.

View czj's full-sized avatar

Clément Joubert czj

View GitHub Profile
@czj
czj / .gitconfig
Created October 5, 2012 07:18
GIT aliases
[alias]
a = add
b = branch
c = commit
co = checkout
cob = checkout -b
d = diff --word-diff
l = log --oneline --decorate
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %Cblue(%an)%Creset' --abbrev-commit --date=relative
phcs = push hcsgit
@czj
czj / encode_720p.rb
Created August 5, 2012 07:35
Handbrake MP4 H264 ultra optimized 720p/1080p encoding
#!/usr/bin/env ruby
# encoding: utf-8
# x264 presets guide : https://forum.handbrake.fr/viewtopic.php?f=6&t=19426
X264 = "b-adapt=2:rc-lookahead=50:me=umh:bframes=5:ref=6:direct=auto:trellis=2:subq=10:psy-rd=1.0,0.10:analyse=all"
FORMAT = "--optimize --format mp4"
QUALITY = "--ab 64 --mixdown mono --quality 23 -e x264 -x '#{X264}'"
SIZE = "--width 1280 --height 720"
ARGV.each do |param|
@czj
czj / Gemfile
Created August 1, 2012 15:54
Puma.io on Heroku
group :production do
# Many instances of an app on a single Dyno
gem 'puma'
end
//scroll to top
function scrollToTop(){
$('.goTop').hide();
$(window).scroll(function () {
if ($(this).scrollTop() > 100) {
$('.goTop').fadeIn();
} else {
$('.goTop').fadeOut();
}
});
@czj
czj / minitest_validations.rb
Created May 22, 2012 11:19
Testing validations with MiniTest + Factory Girl
require "minitest_helper"
describe User do
it "rejects a bad password in validation" do
user = Factory.build(:user, :password_confirmation => 'Not my password')
user.invalid?(:password_confirmation).must_equal true
user.errors[:password_confirmation].must_equal "Password doesn't match confirmation"
end
end
@czj
czj / minitest_spec_helper.rb
Created May 4, 2012 14:54
Rails 3+ minitest file attachement helper (for upload)
def sample_file(extension)
path = Rails.root.join('spec', 'files', "sample.#{extension}")
type = Mime::Type.lookup_by_extension(extension)
Rack::Test::UploadedFile.new(path, type)
end
@czj
czj / ajax_jquery_file_upload.js.coffee
Created April 20, 2012 10:37
AJAX form submit with file upload (HTML5) using only jQuery
$('#my_form').submit (event) ->
event.preventDefault()
$.ajax
url: $(@).attr("action")
data: new FormData(@)
type: "POST"
cache: false
contentType: false
processData: false
@czj
czj / Guardfile.rb
Created March 8, 2012 20:25
Sample Guardfile for spork+guard+rails+livereload
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'livereload' do
watch(%r{app/.+\.(erb|haml)})
watch(%r{app/helpers/.+\.rb})
watch(%r{(public/|app/assets).+\.(css|js|html)})
watch(%r{(app/assets/.+\.css)\.s[ac]ss}) { |m| m[1] }
watch(%r{(app/assets/.+\.js)\.coffee}) { |m| m[1] }
watch(%r{config/locales/.+\.yml})
@czj
czj / test_helper_minitest_spork.rb
Created March 8, 2012 20:25
Sample TestHelper file to use with minitest+spork+shoulda+capybara
ENV["RAILS_ENV"] = "test"
require 'rubygems'
require 'spork'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'
Spork.prefork do
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
@czj
czj / ribbon.sass
Created January 25, 2012 19:21
Pure CSS 3 ribbons
.ribbon
overflow: hidden
// top left corner
position: absolute
right: -3.5em
top: 2.5em
// 45° clockwise rotation
+rotate(45deg)
+box-shadow(0 0 1em #888)
+background-image(linear-gradient(left, #050, #080, #090, #080, #050))