Skip to content

Instantly share code, notes, and snippets.

View jaysoo's full-sized avatar

Jack Hsu jaysoo

View GitHub Profile
# Count total memory by user
ps --no-headers -u username -o rss | (tr '\n' +; echo 0) | bc
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure id="Server" class="org.mortbay.jetty.Server">
<Get id="oldhandler" name="handler"/>
<Set name="handler">
<New id="Rewrite" class="org.mortbay.jetty.handler.rewrite.RewriteHandler">
<Set name="rewriteRequestURI">true</Set>
<Set name="rewritePathInfo">false</Set>
<Set name="originalPathAttribute">requestedPath</Set>
@jaysoo
jaysoo / pack.rb
Created August 11, 2010 18:23 — forked from sstephenson/pack.rb
#!/usr/bin/env ruby
# js1k packer
if ARGV[0] == "-n"
ARGV.shift
wrap = false
else
wrap = true
end
@echo off
REM
REM Copyright 2008-2009 LinkedIn, Inc
REM Copyright 2010 Erik Howard http://www.gonosql.com http://erikhoward.net
REM
REM Licensed under the Apache License, Version 2.0 (the "License");
REM you may not use this file except in compliance with the License.
REM You may obtain a copy of the License at
REM
@echo off
REM
REM Copyright 2008-2009 LinkedIn, Inc
REM Copyright 2010 Erik Howard http://www.gonosql.com http://erikhoward.net
REM
REM Licensed under the Apache License, Version 2.0 (the "License");
REM you may not use this file except in compliance with the License.
REM You may obtain a copy of the License at
REM
@echo off
REM
REM Copyright 2008-2009 LinkedIn, Inc
REM Copyright 2010 Erik Howard http://www.gonosql.com http://erikhoward.net
REM
REM Licensed under the Apache License, Version 2.0 (the "License");
REM you may not use this file except in compliance with the License.
REM You may obtain a copy of the License at
REM
@jaysoo
jaysoo / wibblefish.html
Created June 23, 2011 19:36
JavaScript exercise: wibblefish
<!doctype html>
<title>wibblefish</title>
<pre id="results"></pre>
<script>
window.functions = [
function(i) { return i%3 == 0 ? 'wibble' : '' },
function(i) { return i%5 == 0 ? 'fish' : '' }
]
window.wibblefish = function(n) {
@jaysoo
jaysoo / five_longest_classes_in_java_codebase.sh
Created November 12, 2011 03:57 — forked from breun/five_longest_classes_in_java_codebase.sh
Find the five longest class names in a Java codebase.
find . -name '*.java' -exec basename {} .java \; | awk '{ print length " " $0 }' | sort -n -r | head -n 5
@jaysoo
jaysoo / node-elasticsearch-service
Created February 3, 2012 03:52
elasticsearch service using node.js
var http = require('http'),
url = require('url'),
_ = require('underscore'),
elastical = require('elastical');
var client = new elastical.Client();
if (process.argv.length < 3) {
console.log('Port number is required');
return;
@jaysoo
jaysoo / TextDelimitedWithHeader.java
Created February 10, 2012 15:11
A text-delimited scheme for Cascading that will include the header (field names) in the output.
// imports
public class TextDelimitedWithHeader extends TextDelimited {
// ...
@SuppressWarnings("unchecked")
public void sinkPrepare(HadoopFlowProcess flowProcess, SinkCall<Object[], OutputCollector> sinkCall) {
super.sinkPrepare(flowProcess, sinkCall);