Skip to content

Instantly share code, notes, and snippets.

View piperchester's full-sized avatar
🏗️
Build

Piper piperchester

🏗️
Build
View GitHub Profile
1 import java.util.Scanner;
2 import java.util.*;
3
4 /**
5 * Utility class for creating a usable CLI.
6 * Provides methods to do things like prompt the user, present an options list, etc.
7 */
8 public class CLIUtilities {
9
10 /**
// How to use this:
// 1. Go to the desired profile page on coderwall, like http://coderwall.com/marcinbunsch
// 2. Paste this gist in the JS console
//
// You can also probably use this in greasemonkey and dot.js
//
// Also, it was tested in Chrome, Firefox and Safari, it probably will
// not work in IE, but I just don't care about it ;)
//
// UPDATE: Coderwall made changes to the site and I cannot retrieve the achievements, so they are hardcoded, taken from a cached version of the achievements page
@piperchester
piperchester / Centering an input label.
Created June 19, 2013 21:08
Centering an input label. Extremely simple, but potentially not obvious.
containing-div {
width: 100%;
text-align: center /* Centering the text is necessary to center the input label. */
}
-- Two dashes start a one-line comment.
--[[
Adding two ['s and ]'s makes it a
multi-line comment.
--]]
----------------------------------------------------
-- 1. Variables and flow control.
----------------------------------------------------
@piperchester
piperchester / Tail Recursive Example
Created August 15, 2013 20:26
Tail Recursive Factorial
# Termination statement must not be an expression
# Termination statement should be the last call in the function
def factorial(n, a):
if n < 0:
return 0
elif n == 0:
return 1
elif n == 1:
return a
@piperchester
piperchester / keybase.md
Created March 28, 2014 02:53
Keybase verification.

Keybase proof

I hereby claim:

  • I am piperchester on github.
  • I am piperchester (https://keybase.io/piperchester) on keybase.
  • I have a public key whose fingerprint is 155A 4961 8165 C24D CAF1 6B44 1DB5 64BC A61F B37B

To claim this, I am signing this object:

@piperchester
piperchester / 0_reuse_code.js
Created March 29, 2014 04:38
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
.cursor {
width: 30px;
height: 60px;
background: green;
-webkit-animation:blink .8s ease-in-out infinite;
}
@-webkit-keyframes blink {
from {
opacity: 1;
@piperchester
piperchester / delete_dupes.py
Last active August 29, 2015 14:22
Pythonic dupe delete
import os, re
deleted = 0
previous_filename = ''
sorted_files = sorted(os.listdir(os.curdir), reverse=True) # Sorts dir by reverse alpha, e.g. IMG_1.jpg, IMG_1 (1).jpg
for file_name in sorted_files:
if '(1)' in file_name: # TODO: extend to (1-9)
match_filename = re.search('[\S][^.|\s]*', file_name) # Check we've previous dupe filed (safe to delete)
if match_filename.group(0) in previous_filename:
uptime
dmesg | tail
vmstat 1
mpstat -P ALL 1
pidstat 1
iostat -xz 1
free -m
sar -n DEV 1
sar -n TCP,ETCP 1
top