Skip to content

Instantly share code, notes, and snippets.

View johnelm's full-sized avatar
💭
I may be slow to respond.

John Elm johnelm

💭
I may be slow to respond.
View GitHub Profile
@johnelm
johnelm / current-dir-in-iterm-tab-title.sh
Created March 11, 2018 00:59 — forked from phette23/current-dir-in-iterm-tab-title.sh
Set the iTerm tab title to the current directory, not full path.
# put this in your .bash_profile
if [ $ITERM_SESSION_ID ]; then
export PROMPT_COMMAND='echo -ne "\033];${PWD##*/}\007"; ':"$PROMPT_COMMAND";
fi
# Piece-by-Piece Explanation:
# the if condition makes sure we only screw with $PROMPT_COMMAND if we're in an iTerm environment
# iTerm happens to give each session a unique $ITERM_SESSION_ID we can use, $ITERM_PROFILE is an option too
# the $PROMPT_COMMAND environment variable is executed every time a command is run
# see: ss64.com/bash/syntax-prompt.html
@johnelm
johnelm / README.md
Last active December 14, 2017 20:07
Sequence Tweaking Spock Extension

Sequence Tweaking Spock Extension

Quick and easy generation of int[] sequences for Codility and Leetcode algorithm challenge test cases

Recently I've been catching up on modern Java.. I haven't used it on the job since Java 5 came out. I've been practicing algorithms on Codility and Leetcode.

The algorithm puzzles on these sites almost always use int and/or int[] arguments and return types, and sometimes have BigO performance requirements. To test your algorithms properly, you need to generate very large input arrays, of sizes up to 100,000 with values from +/- 1 billion. My test cases weren't anywhere near as comprehensive as those run by Codility when you submit you solution, and I wanted a way to quickly create tests to cover edge cases and very large inputs.

I started using the data tables feature in the awesome Spock testing fram

@johnelm
johnelm / IdenticalPairs.java
Last active October 4, 2023 19:18
IdenticalPairs Coding Challenge
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
class IdenticalPairs {
public enum Approach {
TRIANGULAR_FORMULA_STREAM,
TRIANGULAR_FORMULA_LOOP,
COUNTING_NESTED_LOOP,
@johnelm
johnelm / git-cheat-sheet.md
Created September 10, 2016 07:48 — forked from iansheridan/git-cheat-sheet.md
A cheat sheet for GIT

Setup

git clone <repo>

clone the repository specified by ; this is similar to "checkout" in some other version control systems such as Subversion and CVS

Add colors to your ~/.gitconfig file:

@johnelm
johnelm / git
Created September 10, 2016 07:48
git tips
git diff : compare current with staged (or with last commit if no staged one)
git diff —staged : compare staged with last commit
git diff <master>…<topicbr> : show diff introduced by topicbr comparing to master (base commit in master)
git diff <sha-1> : show diff betwheen latest commit of current branch and other commit (sha-1)
git log -n : view last n commits
git log -n -p : last n commits with summary of changes (diff)
git log -n —graph : graphical view branch history
git log —pretty=oneline : each commit at one line
git log <br1> —not <br2> : list commits which are in br1 but not in br2
@johnelm
johnelm / ArchiveandLogDone.scpt
Created July 18, 2012 02:13 — forked from mreidsma/ArchiveandLogDone.scpt
Applescript to archive completed Taskpaper tasks to Google Calendar with ifttt.com
-- Archive completed Taskpaper tasks to Google Calendar with ifttt.com
-- First, set up the following recipe at ifttt.com to add completed tasks to your calendar:
-- http://ifttt.com/recipes/30256
--
-- Then use this Applescript to archive tasks. Mail.app needs to have the default account match your ifttt.com email
-- Let me know if you have any questions: reidsmam@gvsu.edu or @mreidsma
set archivedTasks to ""