Skip to content

Instantly share code, notes, and snippets.

View rgorsuch's full-sized avatar

Ryan Gorsuch rgorsuch

View GitHub Profile
@rgorsuch
rgorsuch / gist:b404c658551a6a8aeb35
Created July 31, 2015 13:03 — forked from jessitron/gist:8376139
scala: print all URLs on classpath
def urlses(cl: ClassLoader): Array[java.net.URL] = cl match {
case null => Array()
case u: java.net.URLClassLoader => u.getURLs() ++ urlses(cl.getParent)
case _ => urlses(cl.getParent)
}
val urls = urlses(getClass.getClassLoader)
println(urls.filterNot(_.toString.contains("ivy")).mkString("\n"))
// ==UserScript==
// @name Splunk
// @namespace https://splunk:8000/en-US/account/
// @include https://splunk:8000/en-US/account/*
// @version 1
// @grant none
// ==/UserScript==
// perl -ne 'chomp; print join("", map { sprintf "\\%o", ord } split("", $_)) . "\n"'
// Run this, type your password, then ctrl+d
use Term::ReadKey;
ReadMode 2;
print "# ";
chomp(my $phrase = <STDIN>);
print "\n" . join("", map { sprintf "\\%o", ord } split("", $phrase)) . "\n"
# PUPPET CONFIG MANIFEST FOR IRF (Installs LAMP stack, tomcat8 and memcached)
# If you are running this locally on an agent, place this file in /etc/puppet/manifests and run puppet appy irf.pp --test
# execute 'apt-get update'
exec { 'apt-update': # exec resource named 'apt-update'
command => '/usr/bin/apt-get update' # command this resource will run
}
# install apache2 package
package { 'apache2':
function trunclog {
# Truncate a log file and leave N lines of tail remaining.
if [ "$*" = "" ]
then
echo "Usage: trunclog [lines] [log-file]"
else
REQUESTED_LINES=$1
LOG=$2
TEMP=/tmp/`basename $LOG`.tmp.$$
tail -$REQUESTED_LINES $LOG > $TEMP
; IMPORTANT INFO ABOUT GETTING STARTED: Lines that start with a
; semicolon, such as this one, are comments. They are not executed.
; This script has a special filename and path because it is automatically
; launched when you run the program directly. Also, any text file whose
; name ends in .ahk is associated with the program, which means that it
; can be launched simply by double-clicking it. You can have as many .ahk
; files as you want, located in any folder. You can also run more than
; one ahk file simultaneously and each will get its own tray icon.
#!/usr/bin/perl -w
# Tiny script to color your output green for stdout, red for stderr
# Use it like this: color [app] [args ...]
use strict;
use warnings;
use Term::ANSIColor;
use IPC::Open3;
no warnings 'once';
user www-data;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
multi_accept on;
"===============================================================================
"VIM Configuration File
"==============================================================================
set printoptions=paper:letter,syntax:n
syntax on
"turn on doxygen syntax hilighting. Works for C, C++, C#, and IDL files.
let g:load_doxygen_syntax=1
function count_rows {
# Count the rows in all the tables in a sqlite db
# Usage: count_rows my-sqlite.db
DB=$1
TABLES=`echo "SELECT name FROM sqlite_master WHERE type='table';" | sqlite3 $DB`
for TABLE in $TABLES
do
printf "%10d %s\n" `echo "SELECT count(*) from $TABLE;" | sqlite3 $DB` $TABLE