Skip to content

Instantly share code, notes, and snippets.

@jeffesp
jeffesp / Program.fs
Created August 8, 2013 17:29
Efficiency of Morse code
open System.IO
type MorseCodePoint = Dit | Dah
type MorseEncodedWord = { word: string; total: int; efficiency: float }
let codePointLength point =
match point with
| Dit -> 1
| Dah -> 3

Keybase proof

I hereby claim:

  • I am jeffesp on github.
  • I am jeffesp (https://keybase.io/jeffesp) on keybase.
  • I have a public key whose fingerprint is C62D 0D76 200A D1E9 12C1 37A4 C8DB 7F3F 451B AEFF

To claim this, I am signing this object:

function Find-StringInFiles
{
param ([string][PSDefaultValue(Help="*.*")]$files = "*.*", [string]$query )
Get-ChildItem -file -recurse $files | Select-String $query
}
import Graphics.Element exposing (..)
import Text
type Tree a
= Empty
| Node a (Tree a) (Tree a)
-- declaring type of function named `empty`
empty : Tree a
@jeffesp
jeffesp / JavascriptSingleton.js
Created August 31, 2016 15:14
Javascript Singleton
class Singleton {
static get instance() {
if (!this._instance) {
this._instance = Date();
}
return this._instance;
}
}
def get_results(client, session_id):
# First wait on the results to be complete by checking periodically
while True:
current = client.sessions.get(session_id)
if current.status == session.Status.completed or current.status == session.Status.failed:
break
# waiting to not exhaust the call per minute limit on the API
time.sleep(5)
# Then get results and find the model_id that was generated
@jeffesp
jeffesp / pycon.md
Created November 20, 2017 21:12
Markdown of the PyCon Talk Proposal Form
@jeffesp
jeffesp / DockerCleanup.md
Last active September 11, 2018 12:53
Docker Cleanup

Not knowing that docker rm would just skip running containers I came up with the following:

docker ps -a | grep -v "Up" | cut -f 1 -d ' ' | tail -n +2 | xargs docker rm

but the [docker docs][1] say:

docker rm $(docker ps -a -q)

which is probably better as it doesn't depend on inverse grepping for "Up".

#!/bin/bash
SCHEME_DIR=${XDG_CONFIG_HOME:-~/.config}/calico
_create_config_dir() {
if [[ ! -d $SCHEME_DIR ]]; then
mkdir -p $SCHEME_DIR
fi
}
open System
open System.IO
open System.Text.RegularExpressions
open System.Linq
open MarkdownDeep
module Seq =
let sortByDesc f s = System.Linq.Enumerable.OrderByDescending(s, new System.Func<'a, 'b>(f))
type Header = {date:DateTime; author:string; title:string; published:bool; layout:string; permalink:string }