Skip to content

Instantly share code, notes, and snippets.

View omnisis's full-sized avatar

Clifford James omnisis

View GitHub Profile
@omnisis
omnisis / gist:9755326
Created March 25, 2014 04:32
Start Jetty SSL with HTTP redirect
package com.nextinstruction;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.nio.SelectChannelConnector;
import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.webapp.WebAppContext;
@omnisis
omnisis / goodies.py
Last active August 29, 2015 13:55
Pandas / Matplotlib Goodies
# Creating a new plot with no spacing
fig, axes = plt.subplots(2, 2, sharex=True, sharey=True) for i in range(2):
for j in range(2):
axes[i, j].hist(randn(500), bins=50, color='k', alpha=0.5)
plt.subplots_adjust(wspace=0, hspace=0)
# useful bar graph
series.value_counts().plot(kind='bar/barh')
{
"metadata": {
"name": "Random Walks"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
/**
* Write key and value to baseOutputPath using the namedOutput.
*
* @param namedOutput the named output name
* @param key the key
* @param value the value
* @param baseOutputPath base-output path to write the record to.
* Note: Framework will generate unique filename for the baseOutputPath
*/
@SuppressWarnings("unchecked")
@omnisis
omnisis / PartitionFunctionSnippet.java
Last active December 13, 2015 17:48
Weekly Partitioner for M/R Text keys with prefix long timestamps
package examples.mapred.partitioning;
import org.apache.commons.lang.time.DateUtils;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;
import java.util.Calendar;
import java.util.TimeZone;
public class PartitionFunctionSnippet {
@omnisis
omnisis / solo.sh
Last active December 12, 2015 10:29
Bash script for avoid parallel executions
#!/bin/bash
#####################################################################
# Script to ensure that a cmd does not have parallel executions.
#####################################################################
unset LOCKFILE
while getopts l: flag; do
case $flag in
l)
@omnisis
omnisis / find_leftovers.py
Last active December 12, 2015 08:39
Python script for finding all leftovers in a series of N CSV files whose records are in sorted order
#!/usr/bin/python
#############################################################################
# This script finds the "leftover records" between files containing arbitrary
# linesplits of a very large sorted CSV file. These types of files would exist
# if for example, one ran the UNIX 'split' program (breaking on line boundaries)
# on a large sorted CSV file to break it into smaller sorted CSV files but did
# not bother to ensure that no logical records (assumming records can span text lines)
# were split across files. Generally, it's impossible for a generic utility
# like 'split' to make such application-specific decisions at the time the
@omnisis
omnisis / sml_spec.sml
Last active January 18, 2017 23:53
Simple unit testing framework for SML
(* helper functions *)
exception AssertionFailure;
fun println(msg) = print(msg ^ "\n");
fun printStatusWithWidth(label, msg, width) = println("\t- " ^ (StringCvt.padRight #" " width msg) ^ label);
fun printStatus(label, msg) = printStatusWithWidth(label,msg,80)
fun msg_pass(msg) = printStatus("[ PASS ]", msg);
fun msg_fail(msg) = printStatus("[ FAIL ]", msg);

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@omnisis
omnisis / gist:4591335
Last active December 11, 2015 11:08
SML/SublimeREPL Configuration files

Contents of [~/Library/Application Support/Sublime Text 2/Packages]

  • SML
    • SML/README.md
    • SML/SML.JSON-tmLanguage
    • SML/SML.tmLanguage
    • SML/Son of Obsidion.tmTheme
  • SublimeREPL/config/SML
    • SublimeREPL/config/SML/Default.sublime-commands
      [{