Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
let secs=$((${upSeconds}%60))
let mins=$((${upSeconds}/60%60))
let hours=$((${upSeconds}/3600%24))
let days=$((${upSeconds}/86400))
UPTIME=`printf "%d days, %02dh%02dm%02ds" "$days" "$hours" "$mins" "$secs"`
IP4=`ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}'`
# get the load averages
#include <Servo.h>
#include "I2Cdev.h"
#include "MPU6050_6Axis_MotionApps20.h"
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
#include "Wire.h"
#endif
Servo botServo;
Servo topServo;
@epylinkn
epylinkn / COLORS.md
Created October 3, 2017 02:15
Dope color resources
int led_pin = 8;
int switch_pin = 9;
int pot_pin_1 = A1;
int pot_pin_2 = A2;
int pot_pin_3 = A3;
int last_switch_state = LOW;
void setup() {
pinMode(led_pin, OUTPUT);
pinMode(pot_pin_1, INPUT);
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
# Change bash prompt emoji by time.
time_emoji() {
CURRENT_HOUR=`date +"%-H"`
if [ "$CURRENT_HOUR" -ge 17 ] && [ "$CURRENT_HOUR" -le 23 ]; then
echo $'\xF0\x9F\x8D\xBA' # beer
else
#!python
"""Bootstrap distribute installation
If you want to use setuptools in your package's setup.py, just include this
file in the same directory with it, and add this to the top of your setup.py::
from distribute_setup import use_setuptools
use_setuptools()
If you want to require a specific version of setuptools, set a download
#!/usr/bin/env ruby
# List all keys stored in memcache.
# Credit to Graham King at http://www.darkcoding.net/software/memcached-list-all-keys/ for the original article on how to get the data from memcache in the first place.
require 'net/telnet'
headings = %w(id expires bytes cache_key)
rows = []
(defadvice ruby-indent-line (after unindent-closing-paren activate)
(let ((column (current-column))
indent offset)
(save-excursion
(back-to-indentation)
(let ((state (syntax-ppss)))
(setq offset (- column (current-column)))
(when (and (eq (char-after) ?\))
(not (zerop (car state))))
(goto-char (cadr state))
@epylinkn
epylinkn / gist:6052086
Created July 22, 2013 07:58
underscorify on a directory
for i in *.png; do [[ "$i" = *-* ]] && mv -nv -- "$i" "${i//-/_}"; done
@epylinkn
epylinkn / ssh-config
Created July 18, 2013 03:07
ssh-config => a ruby script for easily managing your ssh config shortcuts so that you don't need to type beasts like: ssh -i ~/.ssh/thisisapemkey.pem ubuntu@ec2-amazon-has-really-difficult-hostnames.amazonaws.com
#!/usr/bin/env ruby
require 'thor'
class SSHConfig < Thor
desc "list", "list all hosts"
def list()
f = File.open("/Users/#{ENV['USER']}/.ssh/config", 'r')
hosts = f.select { |line| line =~ /Host\s/ }
hosts.map { |host| host[4..-1].strip }.each do |host|