Skip to content

Instantly share code, notes, and snippets.

View ernestohs's full-sized avatar
🐙
coding in progress

Ernesto Herrera Salinas ernestohs

🐙
coding in progress
View GitHub Profile
@ernestohs
ernestohs / Save for later without loose local changes
Created December 27, 2016 23:27
Stash without revert/reset your local changes
$ git stash && git stash apply
@ernestohs
ernestohs / remove.sugested.facebook.js
Created December 12, 2016 03:50
Delete all Suggested Post
( [].slice.call(document.getElementsByClassName('_5g-l')) ).forEach(function (item) { item.parentNode.remove(); });
git config --global diff.tool bc3
git config --global difftool.bc3 trustExitCode true
git config --global merge.tool bc3
git config --global mergetool.bc3 trustExitCode true
ln -s /usr/local/bin/bcomp /usr/local/bin/bc3
@ernestohs
ernestohs / alias.sh
Last active December 27, 2023 19:21
how lazy I am
alias push='git push origin $(git rev-parse --abbrev-ref HEAD)'
alias pull='git pull --recurse-submodules origin $(git rev-parse --abbrev-ref HEAD)'
alias s="git status -s"
alias c="git commit -m "
alias a='git add . && git status -s'
alias l='git log --oneline --all --graph --decorate'
alias gb='git fetch && git checkout '
alias undo='git checkout --'
alias reset='git reset --hard HEAD~1'
alias clean='git clean -dnx'
@ernestohs
ernestohs / couchbd.dump.sh
Last active July 11, 2016 04:22
CouchDB quick and dirty dump script
#!/usr/bin/env bash
set -o errexit
set -o nounset
LOG_LEVEL=5
NO_COLOR=false
set -o pipefail
read -r -d '' usage <<-'EOF' || true # exits non-zero when EOF encountered
-u --username [arg] username (admin) couchdb.
[alias]
# one-line log
l = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
a = add
ap = add -p
c = commit --verbose
ca = commit -a --verbose
cm = commit -m
cam = commit -a -m
@ernestohs
ernestohs / tmux.conf
Last active May 27, 2016 20:33 — forked from spicycode/tmux.conf
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
# Set prefix key to Ctrl-a
unbind-key C-b
set-option -g prefix C-a
@ernestohs
ernestohs / mongo.convert2date.js
Created February 20, 2016 21:59
MongoDB (function): Convert a field from String to Date
db.MyCollection.find({ MyFieldDate: { $type: 'string' }}).forEach(function (item) {
item.MyFieldDate = new Date(item.MyFieldDate);
db.MyCollection.save(item);
});
@ernestohs
ernestohs / housekeeping.sh
Created February 8, 2016 17:57
House Keeping for Ubuntu
#!/bin/bash
apt-get update #resync package index
apt-get upgrade #newest versions of all packages, update must be run first
apt-get autoremove #removes depenancies no longer needed
# Removes .deb files that are no logner used
apt-get autoclean # only removes files that cannot be downloaded anymore (obsolete)
apt-get dist-upgrade #updates dependancies
@ernestohs
ernestohs / docker-dump-image.sh
Created November 19, 2015 19:01
Build a docker file from an image
#!/bin/bash
docker history --no-trunc "$1" | \
sed -n -e 's,.*/bin/sh -c #(nop) \(MAINTAINER .*[^ ]\) *0 B,\1,p' | \
head -1
docker inspect --format='{{range $e := .Config.Env}}
ENV {{$e}}
{{end}}{{range $e,$v := .Config.ExposedPorts}}
EXPOSE {{$e}}
{{end}}{{range $e,$v := .Config.Volumes}}
VOLUME {{$e}}