Skip to content

Instantly share code, notes, and snippets.

@troygnichols
troygnichols / run phoenix on amazon linux.sh
Last active October 21, 2016 18:36 — forked from eikes/run phoenix on amazon linux.sh
run phoenix on amazon linux
cd ~
# app deps
sudo yum -y install git
# erlang deps
sudo yum -y groupinstall "Development Tools"
sudo yum -y install ncurses-devel
sudo yum install -y fop
sudo yum install -y openssl-devel
@troygnichols
troygnichols / read-ctrl.c
Last active October 29, 2015 17:59
Uses the hidapi library to read analog stick inputs from a Logitech Dual Action USB controller
#include <stdio.h>
#include <stdlib.h>
#include <hidapi.h>
#include <signal.h>
void printctrl(unsigned char * buffer);
signed short throttle(unsigned char *byte);
void cleanup(int signum);
function datatable(el, opts, callback) {
if (typeof(el) === 'undefined' || null === el) return;
var dt = $(el),
inputFilters = dt.find("tfoot input"),
selectFilters = dt.find("tfoot select"),
dateFilters = dt.find(".datepicker"),
allFilters = dt.find("tfoot input,select");
var defaultOpts = {
@troygnichols
troygnichols / nested_form.html
Created November 12, 2014 14:58
Nested form with Javascript
<html>
<head>
<title>Nested Form Example</title>
</head>
<body>
<center>
<h1>Order a pizza</h1>
<form id="pizza-form" method="POST" action="/pizzas">
<div>
@troygnichols
troygnichols / try-catch.py
Created August 25, 2014 01:41
Example of exception handling logic in python
#!/usr/bin/env python
def get_user_input():
user_input = raw_input("Type in a number: ")
print ("You typed: %s") % user_input
convert_user_input_to_number(user_input)
def convert_user_input_to_number(user_input):
try:
user_input_as_integer = int(user_input)
@troygnichols
troygnichols / alert_disk_space.sh
Created August 7, 2014 20:49
Check disk space, send email when low. Put this in a cron job.
#!/bin/sh
EMAILS=foo@example.com bar@example.com
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while
read output;
do
echo $output
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
parition=$(echo $output | awk '{ print $2 }' )
if [ $usep -ge 75 ]; then
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void clear();
int main (void) {
printf("GET READY! This program is gonna blow your mind...");
fflush(stdout);
usleep(1750000);
@troygnichols
troygnichols / id_ecdsa.pub
Last active August 29, 2015 14:00
Public Key
ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBDU3I+6QDd2MtoVvy0llGsA2thciAJVxfCG3Wx0xRZmE+yHcuzJWs1SYXiZw9mH0EOCFTrj5pXtcnhHYNfiYkF2TJCDxM3GbkTlXvW/OyCojHH5i86peEAPh6rAiSzHaPg== troynichols@Troys-MacBook-Pro.local
#!/bin/sh
# --------------------------------------
# Copyright 2013 Jon Riddle
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions: