Skip to content

Instantly share code, notes, and snippets.

@andorx
andorx / event-delegate.js
Created October 16, 2018 07:11 — forked from gordonbrander/event-delegate.js
addEventDelegate() - easy event delegation
// Copyright 2018 Gordon Brander
// Released under MIT License https://opensource.org/licenses/MIT
const closest = (el, selector) =>
el.closest ? el.closest(selector) : null;
/**
* Delegate event handling to a parent element.
* @arg {Element} el - the parent element that we will be delegating handling to.
* @arg {string} selector - CSS selector of elements that should receive events.
@andorx
andorx / sass-7-1-pattern.scss
Created October 10, 2018 07:49 — forked from rveitch/sass-7-1-pattern.scss
Sass 7-1 Pattern
sass/
|
|– base/
| |– _reset.scss # Reset/normalize
| |– _typography.scss # Typography rules
| ... # Etc…
|
|– components/
| |– _buttons.scss # Buttons
| |– _carousel.scss # Carousel
@andorx
andorx / comment-example.js
Created July 4, 2018 08:01 — forked from brandongoode/comment-example.js
Dynamoose range and hash key example
var commentSchema = new Schema({
postId: {
type: String,
hashKey: true
},
id: {
type: String,
rangeKey: true,
default: shortId.generate
@andorx
andorx / docpad.coffee
Created March 6, 2017 23:36
Docpad.coffee - Enable livereload in Vagrant
# Define the DocPad Configuration
docpadConfig = {
watchOptions:
preferredMethods: ['watchFile', 'watch']
catchupDelay: 0
regenerateDelay: 0
# Copy third-party to out folder
plugins:
raw:
@andorx
andorx / push-subdir-into-main-repo.txt
Created July 14, 2016 11:07
Git push a sub-directory into other main repository
git clone <ORIG_REPO_DIR> <NEW_REPO_DIR>
cd <NEW_REPO_DIR>
git filter-branch --prune-empty --subdirectory-filter <THE_SUBDIR_TO_MAKE_NEW_ROOTDIR> master
git push <MY_NEW_REMOTE_ORIGIN_URL> -f .
@andorx
andorx / git-rewrite-author.sh
Created July 14, 2016 11:04
Rewrite incorrect commit author info
#!/bin/sh
git filter-branch -f --env-filter '
OLD_EMAIL="duc.pham@tiki.com"
CORRECT_NAME="Duc N. PHAM"
CORRECT_EMAIL="pngduc@lazada.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
@andorx
andorx / generated.css
Last active November 23, 2017 02:41
SCSS - Pull the selector out of its parent
a.post {
display: block;
}
@andorx
andorx / tree.sh
Last active November 23, 2017 02:05
Print out directory tree
> find . -type d | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-\1/"
Output:
.
|-bin
|-src
| |-apps
| | |-__pycache__
| | |-accounts
| | | |-__pycache__
@andorx
andorx / happy_git_on_osx.md
Created March 3, 2016 12:47 — forked from trey/happy_git_on_osx.md
Creating a Happy Git Environment on OS X

Creating a Happy Git Environment on OS X

Step 1: Install Git

brew install git bash-completion

Configure things:

git config --global user.name "Your Name"

git config --global user.email "you@example.com"

@andorx
andorx / tmux.conf
Last active November 23, 2017 02:40
Tmxu Config
set -g mouse on
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'"
unbind -t vi-copy Enter
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"