Skip to content

Instantly share code, notes, and snippets.

🏄

Wayne Chu wayne5540

🏄
Block or report user

Report or block wayne5540

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jlauemoeller
jlauemoeller / phoenix-and-vue-with-brunch.md
Last active Jul 14, 2019
Setting up a Basic Phoenix+Vue+Brunch project
View phoenix-and-vue-with-brunch.md

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+https://github.com/nblackburn/vue-brunch.git#dev --save-dev
@benlinton
benlinton / multiple_mysql_versions_for_development.md
Last active Sep 16, 2019
Multiple MySQL Versions with Homebrew
View multiple_mysql_versions_for_development.md

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
xuqingfeng / .zshrc
Created Jun 3, 2015
add emoji to git commit message automatically.
View .zshrc
function gcme(){
message=$1
message_with_emoji=$message
if [[ $message == *"add"* ]]
then
message_with_emoji="$1 :beer:"
elif [[ $message == *"remove"* ]]
then
message_with_emoji="$1 :mask:"
elif [[ $message == *"fix"* ]]
@albertstill
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.merge!(Plugboard.invert)
Plugboard.default_proc = proc { |_, key| key }
def build_a_rotor
Hash[('A'..'Z').zip(('A'..'Z').to_a.shuffle)]
end
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
end
resource :lock
end
end
@jjmu15
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 (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || html.clientHeight) &&
rect.right <= (window.innerWidth || html.clientWidth)
);
View rails-102.md

專案名稱: Rails新手村網站

主旨:收集 Rails 有用 Link

基本功能

@bf4
bf4 / polymorphic_many_to_many_in_rails.md
Last active Nov 26, 2018
a polymorphic many-to-many association in Rails
View polymorphic_many_to_many_in_rails.md

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
end

class Title < ActiveRecord::Base
  has_many :countries, :through => :item_countries, :as => :locatable
@jexchan
jexchan / multiple_ssh_setting.md
Created Apr 10, 2012
Multiple SSH keys for different github accounts
View multiple_ssh_setting.md

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 "your_email@youremail.com"
View gist:57285
require 'feedzirra'
# fetching a single feed
feed = Feedzirra::Feed.fetch_and_parse("http://feeds.feedburner.com/PaulDixExplainsNothing")
# feed and entries accessors
feed.title # => "Paul Dix Explains Nothing"
feed.url # => "http://www.pauldix.net"
feed.feed_url # => "http://feeds.feedburner.com/PaulDixExplainsNothing"
feed.etag # => "GunxqnEP4NeYhrqq9TyVKTuDnh0"
You can’t perform that action at this time.