Skip to content

Instantly share code, notes, and snippets.

# convert a unix timestamp into a readable date
date -d @1252374518
@sritchie
sritchie / WholeFile.java
Created February 2, 2011 17:32
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;
@mtigas
mtigas / gist:952344
Last active June 20, 2024 11:22
Mini tutorial for configuring client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.


Updated Apr 5 2019:

because this is a gist from 2011 that people stumble into and maybe you should AES instead of 3DES in the year of our lord 2019.

some other notes:

@dln
dln / avro.sh
Created May 5, 2011 09:01
Avro tools script
#!/bin/sh
AVRO_TOOLS_JAR=$(dirname $(readlink $0))/avro-tools-1.5.0.jar
exec java -cp $AVRO_TOOLS_JAR org.apache.avro.tool.Main $@
@gigamonkey
gigamonkey / oranges.py
Created June 2, 2011 21:25
My solution to @bramcohen's coding puzzle from a week or two ago
#!/usr/bin/env python3
# Two solutions to http://www.bittorrent.com/company/about/developer_challenge
from itertools import combinations
bowls = 40
oranges = 9
def brute_force():
@jesperfj
jesperfj / embedded_jetty.md
Created June 29, 2011 17:43
Embedded Jetty Archetype

A better way to set up Java web apps

If you're building a Java web app that you yourself or your organization will be deploying then you can save yourself a lot of trouble by avoiding the whole build-to-war + deploy-to-server approach. Instead, you should build your web app as a normal Java application with an embedded web app server. Don't build a WAR, just compile the code and serve the files out of their source location. This has the following advantages:

  • You can code and test iteratively because you don't have to copy files and create war packages every time you make a change. This is similar to what the mvn jetty:run command is being used for by many developers today.
  • You run the same exact code in production as you do in development. Hopefully I don't have to elaborate on the advantages of that. Most developers today use mvn jetty:run or similar to achieve a quick, iterative dev cycle. But come time for deployment, they build a WAR and throw it over the wall to be deployed in some app server
@stuartsierra
stuartsierra / phone_code.clj
Created July 25, 2011 23:46
Phone number coding program in Clojure
;; Adapted from "An empirical comparison of C, C++, Java, Perl,
;; Python, Rexx, and Tcl for a search/string-processing program"
;; by Lutz Prechelt
;; This was a 15-minute effort while listening to a talk. It's *not*
;; well thought-out or designed.
;; By Stuart Sierra,
;; @stuartsierra on Twitter
$ tar -cvzf [target_filename.tar.gz] [source_folder]
$ tar -xvzf [tar_file]
@simme
simme / Install_tmux
Created October 19, 2011 07:55
Install and configure tmux on Mac OS X
# First install tmux
brew install tmux
# For mouse support (for switching panes and windows)
# Only needed if you are using Terminal.app (iTerm has mouse support)
Install http://www.culater.net/software/SIMBL/SIMBL.php
Then install https://bitheap.org/mouseterm/
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/
@gnp
gnp / archiveme
Created December 13, 2011 18:41
Generate source tarball of Maven + Git project
#!/bin/bash
echo "Determining Git branch..."
BRANCH=`git branch | grep '^[*] ' | sed -e 's/^[*] //'`
echo "Determining Maven project artifactId..."
ARTIFACT=`mvn help:evaluate -Dexpression=project.artifactId | grep -v '^\[INFO\]'`
echo "Determining Maven project version..."
VERSION=`mvn help:evaluate -Dexpression=project.version | grep -v '^\[INFO\]'`