Skip to content

Instantly share code, notes, and snippets.

View tonytonyjan's full-sized avatar
🪲
Making bugs

簡煒航 (Weihang Jian) tonytonyjan

🪲
Making bugs
View GitHub Profile
@tonytonyjan
tonytonyjan / indexer.rb
Created May 1, 2012 05:07
A plugin for Octopress to generate IDs in header tags and index list aside. It helps you easily build a tutorial page with many chapters.
=begin
## Description
A tool for Octopress to generate IDs in header tags and index list aside. It helps you easily build a tutorial page with many chapters.
## Features
* Support all languages.
## Syntax
@tonytonyjan
tonytonyjan / Rakefile
Created May 2, 2012 07:25
A useful rake task of Octopress for listing published or unpublished posts.
# usage rake new_page[my-new-page] or rake new_page[my-new-page.html] or rake new_page (defaults to "new-page.markdown")
desc "List all posts with an asterisk if it's published. Advanced usage: 'rake list_posts[pub|unpub]'"
task :list_posts, :type do |t, args|
type = args.type
result = ""
Dir.glob("#{source_dir}/#{posts_dir}/*.markdown").sort.each do |post|
file = File.read(post)
file =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
data = YAML.load($1)
@tonytonyjan
tonytonyjan / tj_rails_template.rb
Last active October 12, 2015 10:07
tonytonyjan's rails template
# Usage:
# > rails new myapp -m https://gist.github.com/raw/4010690/d9106a1c3af695d1ed4ef8d16e3c8a06b5e3c7f3/tj_rails_template.rb
config = {}
puts "Gems:"
config[:install_devise_cancan_rolify] = yes? "install devise, cancan, rolify?"
config[:install_form_helpers] = yes? "install simple_form, dynamic_form, nested_form?"
config[:install_bootstrap_tjstyle] = yes? "install bootstrap, tjstyle?"
config[:install_rspec_spork] = yes? "install rspec, spork?"
@tonytonyjan
tonytonyjan / README.md
Last active December 17, 2015 03:49
Retrieve download URL from YouTube.
  1. Go to YouTube to find the video that you want to download.
  2. Copy the script to your browser navigation bar, then you'll get the download URL.
  3. You can save it to your bookmark.

Note: This script does not support HTML5 player since it's much easier to retrieve the source URL by viewing the source page.

  1. 到 YouTube 瀏覽你要下載的的影片網址。
  2. 將程式碼貼到網址列上(含前面的 javascript:),你將得到一個載點。
  3. 你可以將此程式碼存到你的書籤。
@tonytonyjan
tonytonyjan / speech-control.js
Last active December 19, 2015 06:59
Speech control plugin for Reveal.js.
var recognition = new webkitSpeechRecognition();
recognition.continuous = true;
recognition.lang = 'cmn-Hant-TW';
recognition.onerror = function(event){console.error(event)}
recognition.onresult = function(event){
str = event.results[event.resultIndex][0].transcript
switch(true){
case /下一?頁$|next page$|next$/.test(str):
Reveal.next();
console.info(str);
@tonytonyjan
tonytonyjan / rails-on-windows.md
Last active December 27, 2015 00:19
一些 Rails 在 Windows 環境的拆地雷方法。

安裝 sqlite3 gem

  1. 官方網站下載兩個東西:
    1. Source Code (for header file)

    2. Precompiled Binaries for Windows (for DLL file)

      給 64 bit 使用者

由於 SQLite3 官方沒有提供 64 位元的 DLL,我們得自己編譯,好消息是當我們按照 DevKit 安裝手冊完成安裝後就有編譯器可用,以筆者為例,位置在 C:\DevKit\mingw\bin\gcc.exe

專案名稱:Logdawn 部落格網站

主旨:打造一個給理工人使用的部落格網站

基本功能

  • 使用者可以使用 FB、G+、GH 登入

發表文章

@tonytonyjan
tonytonyjan / hooks.md
Created September 5, 2014 08:04
All hook in Rails 4.2.0
run_load_hooks(:action_mailer, self)
run_load_hooks(:action_controller, self)
run_load_hooks(:action_view, self)
run_load_hooks(:active_record, Base)
run_load_hooks(:i18n)
run_load_hooks(:active_record, ActiveRecord::Base)
run_load_hooks(:basic_hook)
run_load_hooks(:basic_hook_with_two, FakeContext.new(2))
run_load_hooks(:basic_hook_with_two, FakeContext.new(5))
@tonytonyjan
tonytonyjan / rails_env.sh
Last active August 29, 2015 14:07
OSX Rails 環境配置懶人包
#!/usr/bin/env bash
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install caskroom/cask/brew-cask rbenv ruby-build
brew tap caskroom/versions
brew cask instal iterm2 sublime-text3
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
rbenv install 2.1.3
rbenv global 2.1.3
gem update --system
@tonytonyjan
tonytonyjan / Vagrantfile
Last active August 29, 2015 14:10
Vagrantfile Rails development.
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.provision :shell, path: "bootstrap.sh"
config.vm.network :forwarded_port, guest: 3000, host: 3000
end