Skip to content

Instantly share code, notes, and snippets.

View gaga5lala's full-sized avatar
🐈

Gaga Pan gaga5lala

🐈
  • Tokyo
View GitHub Profile
@gaga5lala
gaga5lala / gaga_map.rb
Created May 19, 2017 03:03
Reimplement ruby map
class Array
def gaga_map(&blk)
puts "---method #{__method__} start---"
output = []
if block_given?
self.each do |item|
output << blk.call(item)
end
output = output.to_enum :gaga_map
# 175梯教育役服勤處所分配表
# http://maseduc.moe.gov.tw/board/upload/175%E6%A2%AF%E5%BD%99%E6%95%B4%E6%9C%8D%E5%8B%A4%E8%99%95%E6%89%80%E9%A0%90%E6%93%AC%E5%88%86%E9%85%8D%E8%A1%A8.xls
require 'spreadsheet'
workbook = Spreadsheet.open './175t.xls'
worksheets = workbook.worksheets
worksheets.each do |worksheet|
puts "Reading #{worksheet.name}"
@gaga5lala
gaga5lala / .vimrc
Created February 7, 2017 06:56
vim config file
set nocompatible " be iMproved, required
filetype off " required
"// --- vim-plugin --- //
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
#!/bin/bash
# Install docker and add permission your user.
bash <(curl -s https://get.docker.com)
# Add user to docker group
sudo usermod -aG docker `whoami`
@gaga5lala
gaga5lala / crontab
Created December 29, 2016 15:37
Send cron log to stdout (debian jessie)
* * * * * echo "Hello world" > /proc/$(cat /var/run/crond.pid)/fd/1 2>&1
@gaga5lala
gaga5lala / check_line_store.sh
Created November 8, 2016 03:53
Check whether sticker is ready for sale.
#!/bin/bash
result=$(curl -i https://store.line.me/stickershop/product/1343605 2>/dev/null | head -n 1 | cut -d$' ' -f2)
while [ $result -ne "200" ]
do
echo $result
sleep 60
done
@gaga5lala
gaga5lala / application_controller.rb
Created July 13, 2016 14:01 — forked from joe11051105/application_controller.rb
Get a list of all the filters on a given Rails 3 controller.
# Add these methods to your ApplicationController. Then, any controller
# that inherits from it will have these methods and can programmatically
# determine what filters it has set.
class ApplicationController < ActionController::Base
def self.filters(kind = nil)
all_filters = _process_action_callbacks
all_filters = all_filters.select{|f| f.kind == kind} if kind
all_filters.map(&:filter)
end
@gaga5lala
gaga5lala / myToReadBookLists.md
Created July 13, 2016 13:59 — forked from chusiang/myToReadBookLists.md
凍仁的讀書清單
@gaga5lala
gaga5lala / how_to_concerns.md
Created February 14, 2016 16:44 — forked from jhjguxin/how_to_concerns.md
how to concerns with rails 3
@gaga5lala
gaga5lala / ex25_ans.rb
Last active October 31, 2015 16:11
Learn Ruby The Hard Way http://lrthw.github.io/ex26/
module Ex25
# This function will break up words for us.
def Ex25.break_words(stuff)
words = stuff.split(' ')
return words
end
# Sorts the words.
def Ex25.sort_words(words)