This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
if ARGV.empty? | |
puts "No arguments provided." | |
end | |
until ARGV.empty? do | |
case ARGV[0] | |
when '-q' | |
ARGV.shift |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
"""A simple tool to document how to control AWS resources. | |
AWS AUTHENTICATION | |
------------------- | |
In order to run any of the code below, you need a profile with AWS credentials | |
set up on your computer. It's very easy to do this. Google how to configure | |
your profile with boto3, or visit the docs: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
"""A simple tool for making command line tools in python.""" | |
import os | |
import sys | |
class CLI(object): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# An events block is required for Nginx to run, even if it's empty. | |
events {} | |
# HTTP processing. | |
http { | |
# Note: log formats only apply to access_logs, not error_logs. | |
# Error logs always start with time stamp and then the level, | |
# e.g., [emerg] or [alert] or whatever. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
"""Find the number of ways to build a wall with different sized bricks. | |
Command line usage: | |
python brickwalls.py <width> <height> | |
Examples: | |
python brickwalls.py 12 3 | |
python brickwalls.py 27 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Utility for parsing command line arguments. | |
# | |
# To use it, declare the allowed flags, options, and arguments, | |
# then run the `parse_args()` function. | |
# | |
# To declare flags, e.g., `--verbose` and `--fail-fast`: | |
# | |
# flag__id__0="--verbose" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(** Compile with: | |
[ocamlc -c simpleproc.ml] | |
[ocamlc -o simpleproc.byte unix.cmo simpleproc.cmo] | |
Run it: | |
[./simpleproc.byte "ls -la"] | |
*) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Compile with unix.cma(x). *) | |
type timetrial = { | |
time : float; | |
result : string; | |
} | |
let time_one f x = | |
let start = Unix.gettimeofday () in | |
let result = f x in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let int_of_status s = | |
match s with | |
| Unix.WEXITED n -> n | |
| Unix.WSIGNALED n -> n | |
| Unix.WSTOPPED n -> n | |
let psshell ?exe:(exe="/bin/sh") cmd = | |
match Unix.fork() with | |
| 0 -> Unix.execvp exe [| exe; "-c"; cmd |] | |
| child_pid -> child_pid |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Proc = struct | |
let int_of_status s = | |
match s with | |
| Unix.WEXITED n -> n | |
| Unix.WSIGNALED n -> n | |
| Unix.WSTOPPED n -> n | |
let shell cmd out err = | |
match Unix.fork () with |