Skip to content

Instantly share code, notes, and snippets.

# License: Public Domain
$crontab -l
#6 * * * * /home/philip/bin/reservation.sh
###########################################################################
$cat bin/reservation.sh
#!/bin/sh
if curl -s http://rez.urbanspoon.com/reservation/start/2086 | grep -q 'Unfortunately'; then
exit
@philz
philz / gist:6159293
Created August 5, 2013 20:25
Close your open review board requests
for x in $(curl 'http://reviewboard/api/review-requests/?status=pending&from-user=philip&last-updated-to=2013-06-01' | jsonpipe | grep links/self/href | awk '{ print $2 }' | grep -v pending | tr -d \"); do
curl -u "philip:$(cat /tmp/pass)" -v -XPUT $x -Fstatus=submitted;
done
@philz
philz / TernaryBoxing.java
Created August 13, 2013 22:24
Ternary Boxing -- Java Puzzler -- What does this print?
// License: Public Domain
//
// Java Puzzler: what does this print?
public class TernaryBoxing {
public static void main(String[] args) {
Long nullLong = null;
try {
takesLong(true ? nullLong : 1);
} catch (NullPointerException e) {
System.out.println("1");
@philz
philz / gist:6393825
Created August 30, 2013 20:11
git-above
# License: Public Domain
#
# Usage: git-above [ref]
#
# ref defaults to "origin/master" if not specified.
#
# Returns the commit directly after that commit. Useful for pushing
# the "bottom" of your stack of changes above master.
#
# Is there a better way?
@philz
philz / gist:6405044
Created September 1, 2013 15:13
Expand RPM packages
for x in *.rpm; do mkdir ${x%%.rpm}; cd ${x%%.rpm}; rpm2cpio ../$x | cpio -idmv; cd ..; done
@philz
philz / gist:6444491
Created September 5, 2013 00:18
Inefficient mechanism to find slow Surefire-executed tests. keywords: maven surefire test duration time
$paste <(xpath -q -e '//testcase/@name' $(find . -name 'TEST-*.xml') ) <(xpath -q -e '//testcase/@classname' $(find . -name 'TEST-*.xml') ) <(xpath -q -e '//testcase/@time' $(find . -name 'TEST-*.xml') ) | tr '=' ' ' | tr -d '"' | awk '{ print $6, $4, $2 }' | sort -n > testtimes
@philz
philz / README.md
Last active December 24, 2015 14:19
Bookmarklet to highlight a tab after 30 minutes.

Bookmarklet to highlight a tab after 30 minutes. Blinks the title when the timer has run out.

@philz
philz / gist:7944334
Created December 13, 2013 13:39
HDFS Tests
[0]theia:cdh5:hdfs(9781)$pwd
/Users/philip/src/smokes/hadoop/src/main/groovy/com/cloudera/itest/hadoop/hdfs
[0]theia:cdh5:hdfs(9782)$git log --oneline -n 1 HEAD
a7ff5ea CDH-16198: itests should accomodate name changes of CDK to Kite(Fixing the skipped morphline)
[0]theia:cdh5:hdfs(9783)$git grep -A1 '@Test' | grep public | sed -e 's!.*/!!' | sed -e 's/().*$//' | sed -e 's/ public void//' | sed -e 's/- /:/'
TestDFSAdmin.java:testBasic
TestDFSAdmin.java:testSafemode
TestDFSAdmin.java:testNamespace
TestDFSAdmin.java:testRefreshCommands
TestDFSAdmin.java:testUpgrades
ls -1 /var/run/cloudera-scm-agent/process/ | \
while read line; do
id=$(echo $line | cut -d "-" -f1)
process=$(echo $line | sed -e "s/^[0-9]*-//")
echo "$process $id"
done | sort -k1,1r -k2,2nr | \
while read key value; do
if [ "$cur_key" = "$key" ]; then
echo -n ",$value"
else
-- AppleScript to log into Cisco AnyConnect VPN
--
-- Based on https://gist.github.com/andrewh/7135352
--
-- 1. Edit the "vpn" variable below.
-- 2. Add your VPN password into your keychain. Use
-- "security add-generic-password -a VPN_HOST -s VPN_HOST
-- from the command line, and then edit the password using
-- the Keychain Access application.
-- 3. From AppleScript Editor, use File...Export to export