Skip to content

Instantly share code, notes, and snippets.

View H6's full-sized avatar
🥥

H6 H6

🥥
View GitHub Profile
@H6
H6 / index.test.ts
Created February 6, 2024 21:08
Faking System Time using Jest Fake Timers and Luxon Settings
import { Settings, DateTime } from 'luxon';
import { theFutureIsNow, theFutureIsNowWithLuxon } from './index';
describe("Fake Timer", () => {
describe("Testing with Jest fake timers", () => {
test('theFutureIsNow should return the time in two hours', () => {
jest.useFakeTimers();
jest.setSystemTime(new Date('2021-01-01T00:00:00Z').getTime());
expect(theFutureIsNow()).toEqual(new Date('2021-01-01T02:00:00Z'));
})
@H6
H6 / PS1.sh
Created February 15, 2018 09:09 — forked from markrendle/PS1.sh
Git Prompt
export PS1='\n[\e[0;32m\u@\h\e[m \e[1;33m\w\e[m\e[0;31m$(__git_ps1 " (%s)")\e[m]\n\$ '

Keybase proof

I hereby claim:

  • I am h6 on github.
  • I am happycoding (https://keybase.io/happycoding) on keybase.
  • I have a public key ASCDHBtxwy3Df7uzFGc09azbLExGpBRwl_xDkvjbYN034wo

To claim this, I am signing this object:

@H6
H6 / .profile
Created February 9, 2017 09:49 — forked from bmhatfield/.profile
Automatic Git commit signing with GPG on OSX
# In order for gpg to find gpg-agent, gpg-agent must be running, and there must be an env
# variable pointing GPG to the gpg-agent socket. This little script, which must be sourced
# in your shell's init script (ie, .bash_profile, .zshrc, whatever), will either start
# gpg-agent or set up the GPG_AGENT_INFO variable if it's already running.
# Add the following to your shell init to set up gpg-agent automatically for every shell
if [ -f ~/.gnupg/.gpg-agent-info ] && [ -n "$(pgrep gpg-agent)" ]; then
source ~/.gnupg/.gpg-agent-info
export GPG_AGENT_INFO
else
@H6
H6 / emr_bootstrap_java_8.sh
Created February 24, 2016 14:56 — forked from pstorch/emr_bootstrap_java_8.sh
Bootstrap script for installing Java 8 on an Amazon Elastic MapReduce instance (emr-4.0.0)
# Check java version
JAVA_VER=$(java -version 2>&1 | sed 's/java version "\(.*\)\.\(.*\)\..*"/\1\2/; 1q')
if [ "$JAVA_VER" -lt 18 ]
then
# Figure out how many versions of Java and javac we currently have
NR_OF_JRE_OPTIONS=$(echo 0 | alternatives --config java 2>/dev/null | grep 'There ' | awk '{print $3}' | tail -1)
NR_OF_SDK_OPTIONS=$(echo 0 | alternatives --config javac 2>/dev/null | grep 'There ' | awk '{print $3}' | tail -1)
# Silent install javac (includes jre)
@H6
H6 / .screenrc
Created February 9, 2016 20:32 — forked from nicerobot/.screenrc
.screenrc with "tabs" using hardstatus and caption options
# look and feel
caption always "%{= bb}%{+b w}%h %=%{=b rw} %l %{= db} ${USER}@%H %{= dg}%c"
hardstatus alwayslastline "%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%<"
# skip the startup message
startup_message off
# go to home dir
chdir
@H6
H6 / WholeFile.java
Created January 7, 2016 17:26 — forked from sritchie/WholeFile.java
Hadoop input format for swallowing entire files.
package forma;
import forma.WholeFileInputFormat;
import cascading.scheme.Scheme;
import cascading.tap.Tap;
import cascading.tuple.Fields;
import cascading.tuple.Tuple;
import cascading.tuple.TupleEntry;
import java.io.IOException;
import org.apache.hadoop.mapred.JobConf;
@H6
H6 / tmux-sublime.sh
Last active July 12, 2018 08:51
Allow to open SublimeText from tmux on OS X
# if you don't have it install tmux
brew install tmux
# needed as a wrapper to handle subl -w in tmux
brew install reattach-to-user-namespace
# Create file ~/.tmux.conf
# Add the folo
echo "set-option -g default-command \"reattach-to-user-namespace -l bash\"" >> ~/.tmux.conf
@H6
H6 / bash_profile
Last active December 12, 2015 15:41
Nice Color Bash Prompt with Github Branch and some aliases
# Clone to your home
# curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -o ~/.git-prompt.sh
alias g='git'
alias h='history'
alias l='ls -G'
alias ll='ls -lhG'
alias lll='ls -lahG'
# Include in ~/.bash_profile:
@H6
H6 / prevent broken ssh pipe
Created October 23, 2015 18:06
Prevent broken pipes with ssh
Add this to your .ssh/config
Host *
ServerAliveInterval 60