Skip to content

Instantly share code, notes, and snippets.

View lunalium's full-sized avatar

Toi Dang lunalium

  • Ho Chi Minh, Viet Nam
View GitHub Profile
@lunalium
lunalium / unscoped.rb
Created February 2, 2016 04:36 — forked from lwe/unscoped.rb
Module which provides the ability to unscope associations
# Provides the ability to unscope associations, this solves problems described in
# http://stackoverflow.com/questions/1540645/how-to-disable-default-scope-for-a-belongs-to/11012633#11012633
#
# Examples
#
# class Document < ActiveRecord::Base
# default_scope where(deleted: false)
# end
#
# class Comment < ActiveRecord::Base
@lunalium
lunalium / Gemfile
Created February 2, 2016 04:07 — forked from mharris717/Gemfile
Minimal Pagination Example (Rails + Ember)
ruby '1.9.3'
source 'https://rubygems.org'
gem 'rails', '3.2.13'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
@lunalium
lunalium / solr_cap.rb
Created January 31, 2016 16:29 — forked from doitian/solr_cap.rb
sunspot solr in capistrano
namespace :deploy do
task :setup_solr_data_dir do
run "mkdir -p #{shared_path}/solr/data"
end
end
namespace :solr do
desc "start solr"
task :start, :roles => :app, :except => { :no_release => true } do
run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec sunspot-solr start --port=8983 --data-directory=#{shared_path}/solr/data --pid-dir=#{shared_path}/pids"
@lunalium
lunalium / timezones.md
Created January 14, 2016 02:02 — forked from timrwood/timezones.md
Unique timezones for 2015
Offsets Time of Change Abbr Zone Candidates
-11:00 ??? Pacific/Pago_Pago
-11:00 NUT Pacific/Niue
-11:00 BST Pacific/Pago_Pago Pacific/Midway Pacific/Samoa
-10:00 -09:00 Mar 08 03:00 Nov 01 01:00 HDT HST America/Adak America/Atka
-10:00 ??? Pacific/Honolulu
-10:00 TAHT Pacific/Tahiti
@lunalium
lunalium / dirty-helpers.js
Created January 14, 2016 02:02 — forked from timrwood/dirty-helpers.js
Ember Data Dirty Relationships Mixins
import Ember from 'ember';
export { dirtyHasMany, dirtyBelongsTo, dirtyMixin };
var dirty = 'relationshipIsDirty';
function dirtyMixin (obj) {
var args = Object.keys(obj);
var comp = Ember.computed;
args.push('isDirty');
obj[dirty] = comp.any.apply(comp, args);
@lunalium
lunalium / percy-no-animations.css
Created January 2, 2016 07:03 — forked from fotinakis/freeze-css-animations.css
Stop transitions and animations in Percy rendering
@-moz-document domain(proxyme.percy.io) {
* {
-moz-transition: none !important;
transition: none !important;
-moz-animation: none !important;
animation: none !important;
}
}
@lunalium
lunalium / usage.hbs
Created December 26, 2015 03:46 — forked from FezVrasta/usage.hbs
Wormhole for ember 1.6
{{#view SDC.WormholeView to="someElementId"}}
I'll be rendered somewhere
{{/view}}
<div id="someElementId"></div>
@lunalium
lunalium / 0Option2ConstructorSummary.md
Created December 24, 2015 19:22 — forked from allenwb/0Option2ConstructorSummary.md
New ES6 constructor features and semantics: Alternative 2 manual super in derived classes

New ES6 Constructor Semantics and Usage Examples

Manual super: Alternative Design where subclass constructors do not automatically call superclass constructors

This Gist presents a new design of class-based object construction in ES6 that does not require use of the two-phase @@create protocol.

One of the characteristics of this proposal is that subclass constructors must explicitly super invoke their superclass's constructor if they wish to use the base class' object allocation and initialization logic.

An alternative version of this design automatically invokes the base constructor in most situations.

@lunalium
lunalium / carrier_wave.rb
Created December 20, 2015 17:23 — forked from gshaw/carrier_wave.rb
CarrierWave initialization file for testing with fixtures and support S3 in staging and production.
# NullStorage provider for CarrierWave for use in tests. Doesn't actually
# upload or store files but allows test to pass as if files were stored and
# the use of fixtures.
class NullStorage
attr_reader :uploader
def initialize(uploader)
@uploader = uploader
end
@lunalium
lunalium / SCSS.md
Created December 16, 2015 06:54 — forked from jareware/SCSS.md
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso