Skip to content

Instantly share code, notes, and snippets.

View pfeiffer's full-sized avatar

Mattias Pfeiffer pfeiffer

View GitHub Profile
@kneath
kneath / _README.md
Created November 18, 2009 21:42 — forked from defunkt/bundle.rake
Intelligent asset bundling for Rails (GitHub's asset bundling)

GitHub Javascript Strategy

Unless otherwise necessary (such as mobile development), the GitHub javascript codebase is based off jQuery. You can safely assume it will be included on every page.

File naming

  • All jquery plugins should be prefixed with jquery, such as jquery.facebox
  • All github-specific jquery plugins should be prefixed with jquery.github. Like jquery.github.repo_list.js
  • All page-specific files (that only run on ONE page) should be prefixed with page. page.billing.js
class ArticlesController < ApplicationController
before_filter :load_temp_upload, :only => ["create", "update"]
def update
if params[:ajaxupload]
if @article.update_attributes(:picture => params[:article][:picture])
render(:text => {:response => 'success', :url => @article.picture.url(:thumb)}.to_json)
else
render(:text => {:response => 'failure', :message => @article.errors.full_messages.join('\n')}.to_json)
end
@iwarshak
iwarshak / devise_migration.rb
Created August 24, 2011 16:02 — forked from Bertg/devise_migration.rb
Migrating to a new password encryption in devise, coming from authlogic
class MigrateUserToDevise < ActiveRecord::Migration
def self.up
change_table :users do |t|
t.string :encrypted_password, :null => false, :limit => 128
# ...
end
end
def self.down
end
@xdite
xdite / gist:3072362
Created July 8, 2012 19:10
deploy/asset.rb
# -*- encoding : utf-8 -*-
set :assets_dependencies, %w(app/assets lib/assets vendor/assets Gemfile.lock config/routes.rb)
namespace :deploy do
namespace :assets do
desc <<-DESC
Run the asset precompilation rake task. You can specify the full path \
to the rake executable by setting the rake variable. You can also \
@RSpace
RSpace / feature.rb
Created August 15, 2012 19:55
Browser testing with Test::Unit, Capybara, Poltergeist and PhantomJS
class Feature < Test::Unit::TestCase
include Capybara::DSL, FactoryGirl::Syntax::Methods
def teardown
Capybara.reset_sessions!
Capybara.use_default_driver
end
add_teardown_hook do |context|
context.instance_eval do
@jkotchoff
jkotchoff / google_play_verification.rb
Last active July 6, 2023 17:57
Verifying an Android subscription in a Ruby on Rails app using the Google Play API
class GooglePlayVerification
require 'google/api_client'
# Refer:
# https://code.google.com/p/google-api-ruby-client/issues/detail?id=72
# and
# http://jonathanotto.com/blog/google_oauth2_api_quick_tutorial.html
# and
# http://milancermak.wordpress.com/2012/08/24/server-side-verification-of-google-play-subsc/
GOOGLE_KEY = 'xxx-xxx.apps.googleusercontent.com'
@rummelonp
rummelonp / yokkyu.rb
Last active October 1, 2019 09:12
ActiveRecord で Enumerize と StateMachine 使うやつ
class Yokkyu < ActiveRecord::Base
extend Enumerize
enumerize :status, scope: true, default: :awaiting in: {
awaiting: 1,
approved: 2,
rejected: 3,
}
state_machine :status do
@ChrisTM
ChrisTM / block-grid.less
Last active August 25, 2022 19:53
Foundation 5's block grids for Bootstrap 3.
// # Block Grid
//
// Technique adapted from Foundation 5 for Bootstrap 3.0.3 to at least 3.3.1.
// https://github.com/zurb/foundation/blob/f755d8704123f86c281ede0b171881e2672f150d/scss/foundation/components/_block-grid.scss
//
// # Example Usage
//
// To produce a grid of 2 items per row on an extra-small screen, and 3 items
// per row on a small screen:
//
# config/routes.rb
resources :documents do
scope module: 'documents' do
resources :versions do
post :restore, on: :member
end
resource :lock
end
end
.
├── actions
├── stores
├── views
│   ├── Anonymous
│   │   ├── __tests__
│   │   ├── views
│   │   │   ├── Home
│   │   │   │   ├── __tests__
│   │   │   │   └── Handler.js