Skip to content

Instantly share code, notes, and snippets.

View madeinfree's full-sized avatar
🐱
Focusing

Whien_Liou madeinfree

🐱
Focusing
View GitHub Profile
/*******************************************************************************/
/*
* Get Touch Event For Android
* record 4 coordinate
* 1. Touch_old_x -> touchstart x
* 2. Touch_old_y -> touchstart y
* 3. Touch_new_x -> touchmove x
* 4. Touch_new_x -> touchmove y
*/
var Touch_old_x = 0,
@madeinfree
madeinfree / inspect_helper.rb
Last active August 29, 2015 14:04
inspect_helper :D
###
# helper_name:inspect_helper
# author: Whien_Liou
# time: 2014/07/23
#
# usage
# 請在增加 config/initializers/inspect_helper.rb
# 加入下列幾行代碼
# 在 controller 使用
#
class Cart < ActiveRecord::Base
has_many :cart_items, :dependent => :destroy
has_many :items, :through => :cart_items, :source => :product
def add_product_to_cart(product)
items << product
end
def update_quantity_to_cart(product_id, quantity, current_cart_id)
## do something..
end
@madeinfree
madeinfree / package.json
Last active April 15, 2016 17:50
generator the initial React Project with webpack, babel, es2015, webpack-dev-server
{
"name": "map-note",
"version": "1.0.0",
"description": "the map note project",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
var path = require('path');
var webpack = require('webpack');
module.exports = {
entry: {
app: [ './app/main.react.js' ],
vendors: [ 'webpack-dev-server/client?http://localhost:8080', 'webpack/hot/only-dev-server' ]
},
output: {
path: path.resolve(__dirname, 'build'),
{
"parser": "babel-eslint",
"extends": "eslint-config-airbnb",
"plugins": ["react"],
"env": {
"browser": true,
"node": true,
"es6": true,
"jest": true
},
class Api::BaseController < ActionController::API
respond_to :json
# before_action :set_origin
# before_action :set_headers
before_filter :set_cors_header
after_filter :cors_set_access_control_headers
def cors_set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, PUT, DELETE, GET, OPTIONS'
import Im from 'immutable';
export default class ImUtil {
/*
* new Map()
*/
setEmptyMap = (obj, cursor) => {
return obj.setIn(cursor, new Im.Map());
}
{
"presets": ["react", "es2015"]
}
const path = require('path');
module.exports = {
entry: [
'./src/index.react.js'
],
output: {
path: path.resolve(__dirname, 'build'),
filename: 'bundle.js',
publicPath: 'build'