Skip to content

Instantly share code, notes, and snippets.

View zackexplosion's full-sized avatar
🏠
Working from home

Zack zackexplosion

🏠
Working from home
View GitHub Profile
@zackexplosion
zackexplosion / yeee.erb
Created January 29, 2019 08:42
安安,這可能是一封信喔
<p><%= @supplier.name %>您好:</p>
下列連結是小院<%= @month %>月份的平台服務費金額,煩請依連結付款:
<p>付費流程如下:</p>
<a href="<%= @payment_link %>" target="_blank"><%= @payment_link %></a>
<ol>
<li>點選連結,確認資料無誤,送出資料,系統會產生一組轉帳帳號。</li>

migration

class AddUploadableToUploadFile < ActiveRecord::Migration[5.2]
  def change
    add_reference :upload_files, :uploadable, index: true
  end
end

models/upload_file.rb

1
00:00:28,600 --> 00:00:38,390
如果世上有一種眼神能比說話更能令人互相諒解
2
00:00:38,400 --> 00:00:48,300
那麼所有人便能不再迷惘和平地活下去
3
00:00:48,310 --> 00:00:51,490
@zackexplosion
zackexplosion / mysql_convert_to_utf8mb4.rb
Created November 10, 2016 17:25
轉換資料庫編碼成 utf8mb4
# copy from https://ruby-china.org/topics/24693
desc "Database related tasks"
namespace :database do
desc "Convert to utf8mb4"
task convert_to_utf8mb4: :environment do
connection = ActiveRecord::Base.connection
database = connection.current_database
connection.execute "ALTER DATABASE #{database} CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;"
// reference http://stackoverflow.com/questions/3653065/get-local-ip-address-in-node-js
var express = require('express');
var app = express();
var os = require('os');
var ifaces = os.networkInterfaces();
app.get('/', function (req, res) {
res.send('Hello World!');
});
@zackexplosion
zackexplosion / model.rb
Last active October 14, 2015 02:19 — forked from minjindang/請問要怎麼實作Model?
Ruby on Rails
# Try to create a "Person" model,that we can use the "children" method below.
tom = Person.create(name: "Tom")
may = Person.create(name: "May", parent: tom)
syd = Person.create(name: "Syd", parent: tom)
tom.children.map(&:name)
# => ["Syd", "May"]
# Furthermore,can you design "grandchildren" method that we can use it like this?
wen = Person.create(name: "Wen", parent: syd)
jon = Person.create(name: "Jon", parent: may)
tom.grandchildren.map(&:name)
@zackexplosion
zackexplosion / echo_branches
Created September 25, 2015 03:27
echo git branches with json
function echo_branches(){
// branches, bs
$bs = shell_exec('git branch');
$bs = explode(PHP_EOL, $bs);
// output
$o = array();
foreach ($bs as $k => $b) {
if( strlen($b) <= 0 ){
@zackexplosion
zackexplosion / sample.js
Created September 11, 2015 07:11
Sample javascript object params
var init = function(options){
if(typeof options !== 'object'){
options = {};
}
options.a = options.a || '';
options.b = options.b || '';
options.c = options.c || '';
}
var my_init = new Init({
@zackexplosion
zackexplosion / Setting up Google Cloud Storage with CORS for Web Fonts.md
Last active September 16, 2015 02:44 — forked from mhulse/Setting up Google Cloud Storage with CORS for Web Fonts.md
Setting up CORS on Google Cloud Storage: An unofficial quick start guide to serving web fonts from Google's cloud. (I'm sure a lot of this info could be improved... Please leave comments if you have tips/improvements.)

Login:

Google Cloud Storage

You'll want to login using an official Google account (i.e. if this is for your company, use the comapany Gmail account vs. a personal one.)

When logging in, you might be prompted to verify the account; if so, enter your cell number to get a verification e-mail or phone call.

Once verified, you'll have to agree to the terms of service; do that, and click continue.

var is_android = navigator.userAgent.toLowerCase().indexOf('android') !== -1;
var is_ios = /iphone|ipad|ipod/i.test( navigator.userAgent);
var link;
var links = {
android : 'https://play.google.com/store?hl=zh-TW',
ios: 'https://itunes.apple.com/tw/genre/ios/id36?mt=8',
default: 'http://google.com'
};