Skip to content

Instantly share code, notes, and snippets.


Wayne Chu wayne5540

  • Taiwan
View GitHub Profile
jlauemoeller /
Last active Jul 14, 2019
Setting up a Basic Phoenix+Vue+Brunch project

Work in Progress: Phoenix + Vue + Brunch

This documents how I integrate Vue 2.0 with Phoenix 1.x using the default brunch pipeline.

The toolchain

Start out by adding the vue-brunch plugin. You will need a version later than 1.2.3 in order to be able to use the extractCSS option (see later). At the time of writing, 1.2.3 was still the version fetched by npm so I suggest just getting the tip of the dev branch for now (this branch is for Vue 2.0 compatibility anyway):

npm install git+ --save-dev
benlinton /
Last active Jun 22, 2020
Multiple MySQL Versions with Homebrew

Multiple MySQL Versions for Development

Options included below:

  • Using Docker docker-compose
  • Using Homebrew brew

Using Docker (recommended)

This gist was originally created for Homebrew before the rise of Docker, yet it may be best to avoid installing mysql via brew any longer. Instead consider adding a barebones docker-compose.yml for each project and run docker-compose up to start each project's mysql service.

xuqingfeng / .zshrc
Created Jun 3, 2015
add emoji to git commit message automatically.
View .zshrc
function gcme(){
if [[ $message == *"add"* ]]
message_with_emoji="$1 :beer:"
elif [[ $message == *"remove"* ]]
message_with_emoji="$1 :mask:"
elif [[ $message == *"fix"* ]]
albertstill / enigma_machine.rb
Last active Jun 1, 2017
Understand how the Enigma machine works with 30 lines of Ruby
View enigma_machine.rb
Plugboard = Hash[*('A'..'Z').to_a.sample(20)]
Plugboard.default_proc = proc { |_, key| key }
def build_a_rotor
ROTOR_1, ROTOR_2, ROTOR_3 = build_a_rotor, build_a_rotor, build_a_rotor
View documents.rb
# config/routes.rb
resources :documents do
scope module: 'documents' do
resources :versions do
post :restore, on: :member
resource :lock
jjmu15 / in_viewport.js
Created Jan 27, 2014
check if element is in viewport - vanilla JS. Use by adding a “scroll” event listener to the window and then calling isInViewport().
View in_viewport.js
// Determine if an element is in the visible viewport
function isInViewport(element) {
var rect = element.getBoundingClientRect();
var html = document.documentElement;
return ( >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || html.clientHeight) &&
rect.right <= (window.innerWidth || html.clientWidth)

專案名稱: Rails新手村網站

主旨:收集 Rails 有用 Link


bf4 /
Last active Nov 26, 2018
a polymorphic many-to-many association in Rails

This was my solution for a polymorphic many-to-many association

class ItemCountry < ActiveRecord::Base
  belongs_to :locatable, :polymorphic => true
  belongs_to :country
  # fields are :locatable_id, :locatable_type, :country_id

class Title < ActiveRecord::Base
  has_many :countries, :through => :item_countries, :as => :locatable
acook / keypress.rb
Created Dec 2, 2012
Read keypresses from user in terminal, including arrow keys using pure Ruby. This has since been folded into a much more robust gem called Remedy. &
View keypress.rb
require 'io/console'
# Reads keypresses from the user including 2 and 3 escape character sequences.
def read_char
STDIN.echo = false
input = STDIN.getc.chr
if input == "\e" then
input << STDIN.read_nonblock(3) rescue nil
jexchan /
Created Apr 10, 2012
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C ""
You can’t perform that action at this time.