Skip to content

Instantly share code, notes, and snippets.

View asimjalis's full-sized avatar

Asim Jalis asimjalis

View GitHub Profile
; Note: This script requires lein exec
; Follow instructions for installing lein and lein-exec
; Then run this as lein exec snipr.clj FILE.md
(require '[clojure.string :as str])
(require '[clojure.java.io :as io])
(defn load-script [script]
(load-file
(->> [(System/getenv "HOME") "Dropbox" "Env" "clj" script] (str/join "/"))))
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.crunch.DoFn;
import org.apache.crunch.Emitter;
import org.apache.crunch.PipelineResult;
import org.apache.crunch.io.From;
import org.apache.crunch.io.To;
import org.apache.crunch.types.writable.Writables;
import org.apache.crunch.util.CrunchTool;
@asimjalis
asimjalis / README.md
Last active August 29, 2015 14:19
R bar plots for time series of HBase region server writes

Region Server Writes

Uses R to create bar plots of region server writes.

Steps

  1. Save the sample data into ~/tmp/region-data.csv

  2. Install R and start R console

# Build and run then open browser to http://localhost:9000/hello.html.
# Then open browser console. It has an error message like this:
# Uncaught TypeError: Cannot read property 'Jf' of undefined hello.js:6587
# Also the REPL hangs.
# If I replace :advanced with :whitespace in project.clj then the browser
# console reports no errors. Also the REPL works fine.
# Make test directory.
mkdir -p $HOME/tmp/cljs-test
@asimjalis
asimjalis / TotalOrderPartitionerExample.java
Created September 25, 2014 07:50
Demonstrates how to use Total Order Partitioner on Word Count.
import java.io.*;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.fs.*;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapreduce.*;
import org.apache.hadoop.mapreduce.lib.input.*;
import org.apache.hadoop.mapreduce.lib.output.*;
import org.apache.hadoop.mapreduce.lib.partition.*;
import org.apache.hadoop.mapreduce.lib.reduce.*;
# To run a command on all 4 hosts type: ethm COMMAND
# For example: ethm hostname
# You can also type:
#
# eth COMMAND # Run COMMAND on elephant, tiger, horse
# thm COMMAND # Run COMMAND on tiger, horse, monkey
# h COMMAND # Run COMMAND on horse
# m COMMAND # Run COMMAND on monkey
#
# And so on.
@asimjalis
asimjalis / myLib.js
Created August 6, 2013 00:26
JavaScript library by Jeremy Osborne which implements a light-weight version of some ideas from jQuery.
(function() {
/**
* My JavaScript library.
*
* @author [your name here]
*/
/**
* @class A namespace is a collection of functions and classes.
@asimjalis
asimjalis / Util.java
Last active February 1, 2016 09:47
Useful Java utility functions.
package core;
import java.io.*;
import java.net.*;
/**
* Useful utility functions.
*/
public class Util {
@asimjalis
asimjalis / perl-shell.md
Created December 8, 2012 15:34
How to run Perl in an interactive shell

How to run Perl in an interactive shell

by Asim Jalis, MetaProse.com

An interactive shell is useful for quickly trying out different commands. While Ruby, Python, and Clojure come with interactive shells, Perl does not. However, it is easy to create one using this one-liner on Unix systems:

perl -e 'do{print("perl> ");$_x=<>;chomp $_x;print(eval($_x)."\n")}while($_x ne "q")'
@asimjalis
asimjalis / csbat.md
Created December 8, 2012 02:01
How to use C# in bat and cmd files

How to use C# in bat and cmd files

by Asim Jalis, MetaProse.com

Here are the steps for how to write bat and cmd files with C#.

Here is the problem this solves: Frequently I just want to write a short C# snippet. I don't want to write it as a source file, compile it, and run it. I'd rather just put the snippet in a bat file and run the bat file. I want to shorten the code-compile-execute loop to just code-execute.

The following steps show you how to create CSBat.exe which solves this problem. Note: The in-memory compiler code was taken from Don Box's CSRepl from his blog.