Skip to content

Instantly share code, notes, and snippets.

View tomchentw's full-sized avatar

Tom Chen tomchentw

View GitHub Profile
@tomchentw
tomchentw / devise.zh-TW.yml
Created April 18, 2012 03:49
devise.zh-TW.yml
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
zh-TW:
errors:
messages:
expired: "已經過期,請重新申請一個"
not_found: "找不到"
already_confirmed: "已經驗證,請直接登入"
not_locked: "被鎖定了"
not_saved:
@tomchentw
tomchentw / comment_policy.rb
Created January 23, 2014 14:42
Implementation of ActiveAdmin::PunditAdapter and usage of Pundit with ActiveAdmin. A PR is opened here : https://github.com/gregbell/active_admin/pull/2857
# app/policies/active_admin/
module ActiveAdmin
class CommentPolicy < ApplicationPolicy
class Scope < Struct.new(:user, :scope)
def resolve
scope
end
end
end
end
@tomchentw
tomchentw / ng-bem.ls
Last active August 29, 2015 14:02
ng-bem proposal
# http://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/
#
# .site-search {} /* Block */
# .site-search__field {} /* Element */
# .site-search--full {} /* Modifier */
#
#
angular.module 'ng-bem' []
.directive 'bem-block' ->
BemBlockCtrl.$inject = [
@tomchentw
tomchentw / include.js
Last active August 29, 2015 14:02
Mixin include that would respond to changes
function mixinChanged (changes) {
changes.forEach(function (change) {
switch (change.type) {
case "add":
case "update":
this[change.name] = change.object[change.name];
break;
case "delete":
delete this[name];
break;
@tomchentw
tomchentw / .travis.yml
Last active September 15, 2016 09:21
React.js + Bootstrap.scss + Webpack configuration files
language: node_js
node_js:
- '0.10'
install: npm run dev_install
env:
global:
secure: CODECLIMATE_TOKEN
@tomchentw
tomchentw / walk.js
Created February 12, 2015 21:13
listing directory
/*
* This is a synchronized vesion. Please rewrite in async version using Promise.
* Note: You may directly use https://github.com/normalize/mz
*
*/
var walkSync = function(dir, filelist) {
var fs = fs || require('fs'),
files = fs.readdirSync(dir);
filelist = filelist || [];
files.forEach(function(file) {
'use strict';
var AppDispatcher = require('../dispatcher/AppDispatcher');
var Constants = require('../constants/AppConstants');
exports.addToCart = function (product) {
AppDispatcher.handleViewAction({
type: Constants.ActionTypes.ADD_TO_CART, // it's just "ADD_TO_CART"
product: product
});
'use strict';
module.exports = function (context, payload, done) {
context.dispatch('ADD_TO_CART', {product: payload.product});
done();
};
'use strict';
var Reflux = require('reflux');
var ActionCreators = Reflux.createActions([
'receiveProducts',
'addToCart',
'cartCheckout',
'finishCheckout'
]);