Skip to content

Instantly share code, notes, and snippets.

@frnkst
frnkst / git-change-commit-messages.md
Created October 2, 2018 20:15 — forked from nepsilon/git-change-commit-messages.md
How to change your commit messages in Git? — First published in fullweb.io issue #55

How to change your commit messages in Git?

At some point you’ll find yourself in a situation where you need edit a commit message. That commit might already be pushed or not, be the most recent or burried below 10 other commits, but fear not, git has your back 🙂.

Not pushed + most recent commit:

git commit --amend

This will open your $EDITOR and let you change the message. Continue with your usual git push origin master.

@frnkst
frnkst / .bash_profile
Created August 26, 2018 21:31 — forked from natelandau/.bash_profile
Mac OSX Bash Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
function handleReply(ip, symbolicAddress) {
if (timeout) {
clearTimeout(timeout);
}
if (ip) {
const elapsedTime = `${(process.hrtime(startTime)[1] / 1000000).toFixed(3)} ms`;
if (ip === previousIP) {
process.stdout.write(` ${elapsedTime}`);
icmpSocket.on('message', async function (buffer, ip) {
let p = buffer.toString('hex').substr(100, 4);
let portNumber = parseInt(p, 16);
if (port === portNumber) {
try {
let symbolicAddress;
if (!NO_REVERSE_LOOKUP) {
symbolicAddress = await getSymbolicAddress(ip);
}
handleReply(ip, symbolicAddress)[0];
@frnkst
frnkst / M2.js
Last active June 19, 2018 11:29
M2
function sendPacket() {
port++;
if (tries >= 3) {
tries = 0;
ttl++;
}
tries++;
udpSocket.setTTL(ttl);
@frnkst
frnkst / M1.js
Last active July 1, 2018 16:55
Medium Import
const dgram = require('dgram');
const raw = require('raw-socket');
const dns = require('dns-then');
const icmpSocket = raw.createSocket({ protocol: raw.Protocol.ICMP });
const udpSocket = dgram.createSocket('udp4');
@frnkst
frnkst / pre-commit
Created March 19, 2018 15:34
Run eslint on all staged files before committing
#!/bin/bash
for file in $(git diff --diff-filter=d --cached --name-only | grep -E '\.js$')
do
git show ":$file" | node_modules/.bin/eslint --stdin --stdin-filename "$file" # we only want to lint the staged changes, not any un-staged changes
if [ $? -ne 0 ]; then
echo "ESLint failed on staged file '$file'. Please check your code and try again."
exit 1 # exit with failure status
fi
done
@frnkst
frnkst / ThirdPartyNoticesExample.md
Created September 1, 2017 09:41 — forked from Radagaisus/ThirdPartyNoticesExample.md
Markdown Table from Yarn Licenses (YMMV)
@frnkst
frnkst / angular_service_from_dev_console.js
Last active January 22, 2018 13:41
Angular service from developer console
// Replace $window with any other injected service
var win = angular.element(document.querySelector('html')).injector().get('$window');
// Or access the scope over a DOM element (fix .the-css-class and ctrlName. Maybe $parent is not needed either
var a = angular.element('.the-css-class').scope().$parent.ctrlName;
@frnkst
frnkst / prepare-commit-msg
Last active February 26, 2019 09:23
Add the branch name in uppercase at the beginning of your commit messages
#!/usr/local/bin/bash
# Instructions: Rename .git/hooks/prepare-commit-msg.sample to
# .git/hooks/prepare-commit-msg and add the contents of this file.
# Make the file executable by typing "chmod u+x .git/hooks/prepare-commit-msg"
# This way you can customize which branches should be skipped when
# prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)