Skip to content

Instantly share code, notes, and snippets.

View kelvin8773's full-sized avatar
🏃‍♂️
Run -> Learn -> Work from Home

Kelvin Liang kelvin8773

🏃‍♂️
Run -> Learn -> Work from Home
View GitHub Profile
xcode-select --install
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update
brew cask install iterm2
# update iterm2 settings -> colors, keep directory open new shell, keyboard shortcuts
brew install bash # latest version of bash
# set brew bash as default shell
brew install fortune
brew install cowsay
brew install git
@kelvin8773
kelvin8773 / hn_seach.js
Created June 21, 2020 06:56 — forked from kristopolous/hn_seach.js
hn job query search
function query() {
var
// HN is done with very unsemantic classes.
job_list = Array.prototype.slice.call(document.querySelectorAll('.c5a,.cae,.c00,.c9c,.cdd,.c73,.c88')),
query_list = Array.prototype.slice.call(arguments),
shown = 0, total = job_list.length;
// Traverses up the dom stack trying to find a match of a specific class
function up_to(node, klass) {
if (node.classList.contains(klass)) {
// TODO: add memo item
function $(id) {
return document.getElementById(id);
}
function renderMemo() {
const memos = JSON.parse(window.localStorage.getItem('memoItems'));
const memoLists = $('memo-items-list');
const memoItem = document.createElement('div');
@kelvin8773
kelvin8773 / gh-pages-deploy.md
Created December 20, 2019 12:16 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@kelvin8773
kelvin8773 / insertion-sort.rb
Created July 24, 2019 09:58
Insertion Sort in Ruby
def insertion_sort(array)
result = array.dup
def helper(array, index=0)
return array if array[index] > array[index-1] || index == 0
if array[index] < array[index-1]
array[index], array[index-1] = array[index-1], array[index]
end
helper(array, index-1)
end
@kelvin8773
kelvin8773 / quick-sort-advance.rb
Created July 24, 2019 09:16
Quick Sort advance in Ruby
def advanced_quicksort(array)
def helper(array, start=0, last=array.size-1)
return array if last-start < 1
pivot = array[last]
middle = start - 1
for i in start..last
array[i] <= pivot ? (middle += 1; array[i], array[middle] = array[middle], array[i] ) : array[i]
end
@kelvin8773
kelvin8773 / quick-sort.rb
Last active July 24, 2019 07:53
quick sorting method in Ruby
def quicksort(array)
def partition(array)
pivot,left, right =array[0], [], []
array[1..-1].each do |x|
x > pivot ? right << x : left << x
end
[left, pivot , right]
end
[user]
name = "Your Name"
email = your@email.com
[alias]
co = checkout
codev = checkout development
comas = checkout master
nb = checkout -b
nbd = checkout -b development
s = status
@kelvin8773
kelvin8773 / oneliners.js
Created April 3, 2019 00:29 — forked from mikowl/oneliners.js
👑 Awesome one-liners you might find useful while coding.
// By @coderitual
// https://twitter.com/coderitual/status/1112297299307384833
// Remove any duplicates from an array of primitives.
const unique = [...new Set(arr)]
// Sleep in async functions. Use: await sleep(2000).
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms)));
// Type this in your code to break chrome debugger in that line.