Skip to content

Instantly share code, notes, and snippets.

@chagel
chagel / Makefile
Created April 4, 2021 18:52 — forked from isaacs/Makefile
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@chagel
chagel / vimdiff.md
Created February 16, 2021 02:23 — forked from mattratleph/vimdiff.md
vimdiff cheat sheet

vimdiff cheat sheet

##git mergetool

In the middle file (future merged file), you can navigate between conflicts with ]c and [c.

Choose which version you want to keep with :diffget //2 or :diffget //3 (the //2 and //3 are unique identifiers for the target/master copy and the merge/branch copy file names).

:diffupdate (to remove leftover spacing issues)

:only (once you’re done reviewing all conflicts, this shows only the middle/merged file)

@chagel
chagel / nginx device redirect
Created January 16, 2021 02:09 — forked from mariusom/nginx device redirect
Nginx detecting desktop, tablet or mobile by looking tat the http user agent.
# Source: http://detectmobilebrowsers.com/
set $mobile_rewrite do_not_perform;
if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino") {
set $mobile_rewrite perform;
}
if ($http_user_agent ~* "^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|t
# local
# list local branches that merged
git br --merged master | grep -v master
# delete local branches that merged
git branch --merged master | grep -v master | xargs git branch -d
# list local brances not in remote(origin)
git branch -vv | cut -c 3- | awk '$3 !~/\[/ { print $1 }'
@chagel
chagel / gist:bc338323d200bf53217495cc42afc724
Created June 14, 2020 06:39
migrate bitbucket to github
# clone bare project into a new foler
git clone --bare git@bitbucket.org:Pipihosting/pipi-web.git
# push into new remote
git push --mirror git@github.com:pipihosting/pipi-web.git
# change remote for local previous repo (or clone new one)
git remote set-url origin git@github.com:pipihosting/pipi-web.git
#!/bin/sh
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
### BEGIN INIT INFO
# Provides: redis_6379
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Redis data structure server
@chagel
chagel / puma-dev.service
Created May 3, 2019 18:58
puma-dev systemd user service
# /usr/lib/systemd/user/puma-dev.service
# systemctl --user daemon-reload
# systemctl --user enable puma-dev
# systemctl --user start puma-dev
[Unit]
After=network.target
[Service]
ExecStart=puma-dev -d pipi -sysbind

Keybase proof

I hereby claim:

  • I am chagel on github.
  • I am chagel (https://keybase.io/chagel) on keybase.
  • I have a public key ASA4MUaL9P-RavQdFhrKmf6MmU4U9lLto38xAPCIvBYPOQo

To claim this, I am signing this object:

@chagel
chagel / irc.md
Created November 25, 2018 00:40 — forked from xero/irc.md
irc cheat sheet

#IRC Reference

Not intended as a guide for newbies, more like a "cheat sheet" for the somewhat experienced IRC user, especially one who wields some power over a channel.

##The Basics

  • /join #channel
    • Joins the specified channel.
  • /part #channel
    • Leaves the specified channel.
@chagel
chagel / dmv.js
Created July 26, 2018 22:30
DRY DMV
const OFFICE_ID = "632" //santa clara, sanjose=516
const FIRST_NAME = ""
const LAST_NAME = ""
const PHONE_AREA = ""
const PHONE_PREFIX = ""
const PHONE_SUFFIX = ""
const { Chromeless } = require('chromeless')
async function run() {