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
@rye
rye / userlist.sh
Last active August 29, 2015 13:55
Get the users on a nix box and dump them out into a pretty table.
#!/bin/bash
cat /etc/passwd | cut -d: -f1,3,5,6 | grep "1[0-9][0-9][0-9]" | cut -d: -f1,3,4 | grep "/home" | cut -d: -f1,2 | column -t -s : | sort
@rye
rye / datasync.rb
Last active August 29, 2015 14:00
My data synchronization system.
#!/usr/bin/env ruby
require "json"
module DataSync
EXAMPLE_CONFIGURATION_FILE_NAME = "z_datasync-configuration.sample.json"
CONFIGURATION_FILE_NAME = "configuration.json"
OutputProperties = {
@rye
rye / porto.rb
Last active August 29, 2015 14:01
A small ruby module for determining if ports are open.
require 'socket'
require 'timeout'
module Porto
class PortoPort
def self.in_use?(ip, port)
begin
Timeout::timeout(1) do
begin
s = TCPSocket.new(ip, port)
@rye
rye / stddev.rb
Last active August 29, 2015 14:01
A handy little Array class extension for calculating standard deviation of an array
class Array
def mean
return ((self.map{|x| x.to_f}
.inject(:+)) /
(self.count))
end
def standard_deviation
m = self.mean
@rye
rye / wat.txt
Created June 23, 2014 14:10
lol wat
neonatestail
penrumings
unisi
gooproach
destoolsnant
lopdurablee
falsenalhen
govnobsis
intenlog
loottylows
@rye
rye / kiosk-install.sh
Last active August 29, 2015 14:02
An installer for the Kiosk system for the WLCSC libraries.
#!/bin/sh
echo ">>>> Copying archive to home directory!"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cp $DIR/zz_config-diffs.tar.gz $HOME
echo ">>>> Changing to home directory!"
@rye
rye / print-request-body.patch
Created July 22, 2014 17:22
This patch to FReCon prints out the request body.
diff --git a/lib/frecon/server.rb b/lib/frecon/server.rb
index 5a524de..06b6435 100644
--- a/lib/frecon/server.rb
+++ b/lib/frecon/server.rb
@@ -13,6 +13,8 @@ module FReCon
before do
content_type "application/json"
+
+ p request.body.read.to_s
@rye
rye / streaming_server.rb
Created December 16, 2014 16:14
Messing around with HTTP Streaming responses.
require "date"
require "json"
require "sinatra"
require "time"
module StreamMessageFormatter
def self.format(object)
return JSON.generate(object) << "\r\n"
end
end
@rye
rye / ruby-xflux.rb
Last active August 29, 2015 14:14
A simple startup script for XFlux, written in Ruby, of course.
#!/usr/bin/env ruby
require "net/http"
require "json"
require "pry"
# Uncomment this line and put in your default location if
# you want to have a default location (in case of network
# errors).
# $default_latlon = [90.0, 90.0]
@rye
rye / example_command.md
Created February 12, 2015 02:48
An example command to grab images from a webcam.

Example Command

This is the example command that will take pictures periodically:

$ ffmpeg -f v4l2 -i {{device, e.g. /dev/video1}} -ss 0:0:2 -s 120x90 -vsync 2 -r 4 -updatefirst 1 stream.png
  • -f v4l2 uses the standard linux /dev/video decoder thing.