Skip to content

Instantly share code, notes, and snippets.

View rye's full-sized avatar
🦀
wranglin' Cow<T>'s

Kris Rye rye

🦀
wranglin' Cow<T>'s
View GitHub Profile
require "net/http"
require "pry"
# Parameters for episode looping.
#
# Note that 404 seems to be reserved for whining.
MIN_EPISODE_NUMBER = 001
MAX_EPISODE_NUMBER = 417
FORMAT = ".ogv"
@rye
rye / bezier.rb
Created May 7, 2015 17:45
A Ruby script to calculate Bézier curves.
require "matrix"
require "pry"
class Integer
# Method to compute binomial coefficient nCk (where n is this object,
# and k is some other integer.
def choose(k)
# n! / (n-k)!
top = (((self-k)+1)..(self)).inject(1, &:*)
@rye
rye / defunct.sh
Created June 15, 2015 16:18
Print out a list of PID's that are defunct
#!/bin/sh
ruby -e "\"`ps -ef|grep \<defunct\>`\".split(/$/).each{|l|puts(l.match(/^(?<user>\w+)\W+(?<pid>\d+)\W+(?<ppid>\d+)/)[:pid])}"
@rye
rye / formatting.patch
Created December 2, 2012 18:52
samercier/riversDiary formatting fix
From a4024c35295c0d7375ce87ff666f0dffe75f4aa1 Mon Sep 17 00:00:00 2001
From: Kristofer Rye <krye97@gmail.com>
Date: Sun, 2 Dec 2012 13:48:36 -0500
Subject: [PATCH] moved javascript code to /js/ directory
---
Diary.html | 6 +-
jquery-1.8.3.min.js | 2 -
jquery-ui-1.9.2.custom.min.js | 6 --
jquery.easing.1.3.js | 205 --------------------------------------
@rye
rye / monoid-firehose.rb
Last active November 26, 2015 20:45
Drink from the Monoid firehose! (Downloads the latest Monoid release)
require 'uri'
require 'net/http'
module Monoid
class Site
attr_accessor :base_uri
def initialize(base_uri = URI.parse('https://larsenwork.com'))
@base_uri = base_uri
end
\documentclass[12pt,letterpaper]{article}
\usepackage{amsmath}
\usepackage{setspace}
\begin{document}
\begin{center}
{\Huge{\textbf{Prevent Memory Errors}}}
@rye
rye / say_time.sh
Last active December 31, 2015 22:49
This is something that just says the time.
#!/bin/sh
DEFAULT_MODE="HOURLY"
case $1 in
"" | "--hourly")
MODE="HOURLY"
;;
"--quarterly")
MODE="QUARTERLY"
@rye
rye / output.txt
Created December 8, 2016 18:26
Output from Make when I compile @shyouhei's ruby version
CC = clang
LD = ld
LDSHARED = clang -dynamic -bundle
CFLAGS = -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Werror=implicit-int -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=shorten-64-to-32 -Werror=implicit-function-declaration -Werror=division-by-zero -Werror=deprecated-declarations -Werror=extra-tokens -pipe
XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT -fPIE
CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I. -I.ext/include/x86_64-darwin16 -I./include -I. -I./enc/unicode/data/8.0.0
DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -fstack-protector -Wl,-u,_objc_msgSend -Wl,-pie -framework CoreFoundation
SOLIBS = -lgmp
Apple LLVM version 8.0.0
@rye
rye / vomit.ru
Last active January 30, 2017 11:38
A Ruby web server to act like Python's SimpleHTTPServer module.
#!/usr/bin/env rackup
#\ -E deployment
use Rack::ContentLength
app = Rack::Directory.new Dir.pwd
run app
@rye
rye / check_machine_status.sh
Created June 12, 2017 20:28
Checks the status of a list of machines using SSH blank firing.
#!/bin/bash
function check_user_and_host {
_ssh_result=$(ssh -o ConnectTimeout=5 -o BatchMode=yes -o StrictHostKeyChecking=no $1@$2 "echo \"\`who | grep -c . \`\"; true" 2>/dev/null)
}
function check_and_output_host {
check_user_and_host $1 $2 && echo "$2: up, $_ssh_result users logged in" || echo "$2: down"
}