Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View penland365's full-sized avatar

Jeffrey N. Davis penland365

View GitHub Profile
@penland365
penland365 / Because git
Created October 23, 2013 18:22
The world's smallest script to delete files from git control.
git status | grep deleted | awk '{print $3}' | xargs git rm
@penland365
penland365 / gist:7892746
Created December 10, 2013 15:44
*.bz2 example
tar -jvcf email-xml-pairs.tar.bz2 /path/to/base
@penland365
penland365 / create-tar.bz2.sh
Created December 10, 2013 15:46
Email / XML tar command
tar -jvcf email-xml-pairs.tar.bz2 /path/to/base
@penland365
penland365 / knuth_anagrams.rb
Created January 8, 2014 15:44
This is a simple ( though not very Ruby idiomatic ) example of how to determine what anagrams exist in a dictionary. The algorithm used is Knuth's anagram algorithm. Idiomatic Ruby has been replaced with an attempt to make the algorithm as readable as possible. Algorithm is O(n), with an additional pass to display / count the number of anagrams.…
def load_words
formatted_words = []
File.readlines(ARGV[0]).each{|line| formatted_words << line.chomp.downcase}
formatted_words
end
def sort_word_alphabetically(unsorted_word)
unsorted_word.chars.sort.join
end
@penland365
penland365 / PercentEncoder
Created March 16, 2014 03:27
A Scala Object to do simple RFC3986 URL encoding.
package com.sabrelabs.twitter.auth
import scala.collection.BitSet
import scala.annotation.tailrec
import scala.runtime.RichInt
import scala.collection.mutable.ListBuffer
object PercentEncoder {
def encodeRFC3986(str: String): String = {
@penland365
penland365 / ScalaTuples
Created April 28, 2014 21:03
While I understand the benefits of creating the named portions of a Tuple via OpenStruct, It's 5 lines to create versus one, and in most cases the extra information created by using named parameters isn't beneficial, since I'm wanting to use the Tuple as a dumb ( simple) data container.
// what I'd like to do
def primaryOperation(): Unit = {
// blah
// blah
val triforce = makeTriforce
val complexObject = new ComplexObject(
firstParam = somethingelse
secondParam = triforce._1
thirdParm = snakes
@penland365
penland365 / Curl output
Created September 19, 2014 14:29
SportsData LLC MLB Trial
curl -v https://api.sportsdatallc.org/mlb-t4/schedules/2014.json\?api_key\=[VALID_API_KEY]
* Adding handle: conn: 0x7fdb3b804000
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fdb3b804000) send_pipe: 1, recv_pipe: 0
* About to connect() to api.sportsdatallc.org port 443 (#0)
* Trying 23.23.158.219...
* Connected to api.sportsdatallc.org (23.23.158.219) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
@penland365
penland365 / SomeController.swift
Created May 15, 2015 15:43
Swift Either for handling mock data from Remote Api
class SomeController {
private func loadOfferSummaries() -> Void {
api.fetchOfferSummaries( { either in
switch either {
case let .Failure(boxedError):
NSLog("Failure fetching games, code --> \(boxedError.value.code)")
// mock out test data
self.offers = self.mockOfferSummaries()
self.loadTable()
case let .Success(boxed):
@penland365
penland365 / tmux-up
Created May 19, 2015 22:09
Basic Tmux Script
#! /usr/bin env bash
SESSION_NAME=""
tmux has-session -t $SESSION_NAME &> /dev/null
if [ $? -ne "0" ]
then
tmux new-session -d -s $SESSION_NAME
tmux split-window -h -p 40
tmux split-window -v -p 40
tmux send-keys -t 0 "vim" C-m
@penland365
penland365 / package.scala
Last active August 29, 2015 14:22
Super basic finch-client type layout.
package io.finch
import argonaut._, Argonaut._
import com.twitter.finagle.httpx.path.Path
package object client {
implicit def decodeStrResource: DecodeResource[String] = new DecodeResource[String] {
def apply(r: Resource): String = r.body
}