Skip to content

Instantly share code, notes, and snippets.

View v2e4lisp's full-sized avatar

Yan Wenjun v2e4lisp

View GitHub Profile

Intro

Description: Setup GitHub Pages "gh-pages" branch and "master" branch as subfolders of a parent project folder ("grandmaster").

Author: Chris Jacob @_chrisjacob

Tutorial (Gist): https://gist.github.com/833223

The Result

@v2e4lisp
v2e4lisp / shift-left.el
Created April 29, 2014 13:55
shift text to left
(defun shift-left (n)
;; shift a block of text by n space
(interactive "nHow many spaces? :")
(save-excursion
(save-restriction
(narrow-to-region (region-beginning)
(region-end))
(beginning-of-buffer)
(while (< (point) (point-max))
(beginning-of-line)
@v2e4lisp
v2e4lisp / hookable.rb
Last active August 29, 2015 14:00
before/after filter
# Include this module
# to add :before and :after hooks for instance method
#
# Example
#
# class User
# include Hookable
#
# def initialize
# @name = "wenjun.yan"
@v2e4lisp
v2e4lisp / basic.rb
Last active August 29, 2015 13:57
How rack works
# Pseudo app
use M1
use M2
use M3
run app
# middle ware are stored in order
[M1, M2, M3]
# Then Rack call #to_app method to make a rack app containing

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@v2e4lisp
v2e4lisp / _test.rb
Created February 28, 2014 16:48 — forked from jcoglan/_test.rb
$VERBOSE = nil
require File.expand_path('../rooby', __FILE__)
Person = Rooby::Class.new 'Person' do
define :initialize do |name|
@name = name
end
define :name do
@v2e4lisp
v2e4lisp / razz.rb
Last active April 28, 2020 11:12
ruby dsl for css
css {
[nav, a, id(:user)].define {
}
group nav, a, id(:user) {
}

Directory Builder

syntax

DirectoryBuider.new(root) do
  dir("sample-dir") {
    file("file-name") {
      "file-content"
 }

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 "[email protected]"
# Ways to execute a shell script in Ruby
# Example Script - Joseph Pecoraro
cmd = "echo 'hi'" # Sample string that can be used
# 1. Kernel#` - commonly called backticks - `cmd`
# This is like many other languages, including bash, PHP, and Perl
# Returns the result of the shell command
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111