Skip to content

Instantly share code, notes, and snippets.

View montyanderson's full-sized avatar

Monty Anderson montyanderson

View GitHub Profile
@montyanderson
montyanderson / colors.h
Created March 28, 2015 23:26
A C include file for all the terminal colors!
#define KRED "\x1B[31m"
#define KGRN "\x1B[32m"
#define KYEL "\x1B[33m"
#define KBLU "\x1B[34m"
#define KMAG "\x1B[35m"
#define KCYN "\x1B[36m"
#define KWHT "\x1B[37m"
apt-get install apache2 php5 libapache2-mod-php5 curl php5-curl git emacs lm-sensors build-essential ruby xchat gparted python2.7 chromium-browser filezilla vlc terminator quiterss bleachbit unity-tweak-tool p7zip-full
npm install -g less grunt grunt-cli bower express less request
int led = 12;
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
function binarytodecimal(binary) {
var decimal = 0;
for(var i = 0; i < binary.length; i++) {
if(binary.charAt(binary.length - i -1) == "1") {
decimal += Math.pow(2, i);
}
}
return decimal;
int pwmPin = 9; // output pin supporting PWM
int inPin = 3; // voltage connected to analog pin 3, e.g. a potentiometer
int val = 0; // variable to store the read value
float volt = 0; // variable to hold the voltage read
float analogToVolt(int val) {
return (5.0 * val) / 1023;
}
int voltToPWM(float volt) {
@montyanderson
montyanderson / memory leak.c
Created June 17, 2015 15:14
Rest in peace, RAM.
#include <stdio.h>
#include <stdlib.h>
int main() {
while(1 > 0) {
int *number = malloc(sizeof(int));
}
return 0;
}
@montyanderson
montyanderson / gulpfile.js
Created June 28, 2015 13:27
Gulp Template
/* montyanderson's gulp template */
/* https://gist.github.com/montyanderson/5b71df07dbc9fc118837 */
var gulp = require("gulp"),
less = require("gulp-less"),
streamify = require("gulp-streamify"),
uglify = require("gulp-uglify"),
rename = require("gulp-rename"),
minify = require("gulp-minify-css"),
source = require("vinyl-source-stream"),
@montyanderson
montyanderson / SprungDigi
Created July 12, 2015 14:17
Cardboard City JSON Dumps
{
"buildings":[
{
"id":"Youth Center",
"votes":3,
"approved":true
},
{
"id":"Meditation Centre",
"votes":2,
@montyanderson
montyanderson / gist:09dd6e53b32a399c573d
Created July 16, 2015 12:22
Convert a ratio to an array of percentages.
function rtp(ratios) {
var total = 0;
ratios.forEach(function(ratio) {
total += ratio;
});
var percentages = [];
ratios.forEach(function(ratio) {
for D in ~/bin/*; do
if [ -d "${D}" ]; then
export PATH=$PATH:${D}
if [ -d "${D}/bin" ]; then
export PATH=$PATH:${D}/bin
fi
if [ -d "${D}/src" ]; then
export PATH=$PATH:${D}/src