This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>TDD Practice</title> | |
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.20.0.css"> | |
</head> | |
<body> | |
<div id="qunit"></div> | |
<div id="qunit-fixture"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActiveAdmin.register Product do | |
permit_params :name, :category_id, :description, :text, :slug, :in_slider, :tag_ids => [] | |
filter :category | |
filter :base_tags | |
filter :name | |
filter :text | |
filter :created_at | |
filter :updated_at |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :db do | |
desc 'Pull staging db to development' | |
task :pull => [:dump, :restore] | |
task :dump do | |
dumpfile = "#{Rails.root}/tmp/latest.dump" | |
puts 'PG_DUMP on staging database...' | |
staging = Rails.application.config.database_configuration['staging'] | |
system "ssh user@server 'PGPASSWORD=\"#{staging['password']}\" pg_dump -U postgres #{staging['database']} -h #{staging['host']} -F t' > #{dumpfile}" | |
puts 'Done!' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Dojo | |
A = "Dojo - A" | |
B = "Dojo - B" | |
class Dojo_child | |
def print_a | |
p "Dojo_child print_a - A: #{A}" | |
end | |
end | |
module Kata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(reshape2) | |
library(dplyr) | |
library(vegan) | |
library(ggplot2) | |
library(ggdendro) | |
Taipower <- read.csv(("https://johnsonhsieh.github.io/DSC2016-R/data/Taipower_top100.csv"),fileEncoding = "big5") | |
aop = Taipower$attr_of_procurement | |
T = mutate(Taipower, category = substr(aop,1,5), category_detail = unlist(lapply(strsplit(as.character(aop), split = ">"),"[",2))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
before_action :set_locale | |
private | |
def set_locale | |
if current_user | |
if !current_user.locale.present? | |
set_i18n_locale_from_browser | |
current_user.update(locale: I18n.locale.to_s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SystemLogger | |
def initialize | |
@sys_logs = [] | |
end | |
def add(msg) | |
timestamp = Time.now.strftime('%Y%m%d_%H%M%S_%N') | |
@sys_logs << [timestamp, msg] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 原本的,會出現origin is not allowed by Access-Control-Allow-Origin 的錯誤 | |
config.middleware.insert_before 0, Rack::Cors do | |
allow do | |
origins /amazingtalker.com\z/ | |
resource '*', | |
headers: ['AtToken', 'AtLocale'], | |
methods: [:get, :post, :delete, :put, :patch, :options], | |
credentials: true | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A | |
def hi | |
action_1 | |
action_2 | |
action_3 | |
end | |
private | |
def action_1 |