Skip to content

Instantly share code, notes, and snippets.

View wildjcrt's full-sized avatar
🦀
have a nice day!

Jerry Lee wildjcrt

🦀
have a nice day!
View GitHub Profile
@wildjcrt
wildjcrt / learning english.md
Last active December 24, 2015 03:19
英文學習書籍整理
@wildjcrt
wildjcrt / gbrt
Created September 14, 2013 16:53
#!/usr/bin/env ruby
# forked from https://github.com/benhoskings/dot-files/blob/master/files/bin/gbrt
def format_commit_info timestamp, time_desc, commit_id, message, ref_name
[
"#{timestamp.strftime("%y %b %d")}, #{timestamp.strftime("%l:%M%p").downcase}",
"(#{time_desc})",
commit_id,
message,
ref_name
@wildjcrt
wildjcrt / check_bot.rb
Created August 6, 2013 16:18
自動檢查 registrano 報名資訊,讓我在 10 小時前成功加入台灣零時政府第壹次公地放領黑客松的小程式。
# encoding: utf-8
# $ ruby check_bot.rb
require 'open-uri'
@url = 'https://registrano.com/events/handlino-new-opening/registrations/new'
def check?
open(@url) do |f|
f.each_line do |line|
if line.include? '抱歉,目前本活動已額滿。'
# ~/.irbrc
# Requires the following gems: wirble, hirb
#
# Hirb: http://tagaholic.me/hirb/doc/index.html
# Wirble: http://pablotron.org/software/wirble/
require 'irb/completion'
require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 100
  • foo
  • bar
  • temp
  • [v] check

Security is Hard

Massive Assignment

  • watch for ActiveRecord Relation, like has_many, has_many :through
  • watch for user_roles, `group_users
  • UPDATE action

Admin

交通 transportation
工作 work
輔具 assistivedevice
購屋租屋 living
醫療照護 medical
急難救助 emergency
生活津貼 allowance
稅捐減免 tax
社會保險補助 socialinsurance
個案諮詢 consoult
var q = {'category': ['living']};
q = JSON.stringify(q);
$.ajax({
type: "GET",
url: '/api/search',
data: {q: q},
dataType: 'json'
}).success(function(data){
console.log(data);
})
# fix code from https://github.com/bcardarella/client_side_validations/issues/499
unless "indexOf" of Array::
Array::indexOf = (find, i) ->
i = 0 if i is `undefined`
i += @length if i < 0
i = 0 if i < 0
n = @length
while i < n
likes = Article.likes
hash = Hash.new(0)
likes.each do |like|
hash[like.type] += 1
end
hash