Skip to content

Instantly share code, notes, and snippets.

#include "Arduino.h"
#include <Adafruit_NeoPixel.h>
#define PIN 4
#define LED_COUNT 60
// Create an instance of the Adafruit_NeoPixel class called "leds".
// That'll be what we refer to from here on...
Adafruit_NeoPixel leds = Adafruit_NeoPixel(LED_COUNT, PIN, NEO_GRB + NEO_KHZ800);
@jclement
jclement / lights.cpp
Created January 26, 2016 02:40
Arduino sketch for annoying xmas lights (ws2812b)
#include "Arduino.h"
#include <Adafruit_NeoPixel.h>
#define PIN 4
#define LED_COUNT 60
// Create an instance of the Adafruit_NeoPixel class called "leds".
// That'll be what we refer to from here on...
Adafruit_NeoPixel leds = Adafruit_NeoPixel(LED_COUNT, PIN, NEO_GRB + NEO_KHZ800);
@jclement
jclement / pretty_print_helper.js
Created July 18, 2012 20:08
Javascript function to decorate all pre/code blocks with "prettyPrint" for Google's code highlighting
function styleCode()
{
if (typeof disableStyleCode != "undefined")
{
return;
}
var a = false;
$("pre code").parent().each(function()
@jclement
jclement / parseFloatSafe.js
Last active January 3, 2016 05:49
Safer parse float function that handles commas in input and bails outright if there is text in the input
parseFloatSafe: function(v) {
// A more sane parseFloat function
// - Verifies number in a sensible format and returns NaN otherwise. Sensible format = (#,000.##..) or (#.##) or (#,000) or (#)
// - supports scientific notation (E[-+]?###)
// - null / empty string return null
// - non-string types are converted to string and parsed that way
if (v === null) {return null;}
var tmp = ('' + v).trim();
if (tmp === '') {return null;}
if (tmp.match('^[-+]{0,1}[0-9]+([,]{0,1}[0-9]{3}){0,4}([.][0-9]+){0,1}([eE][-+]{0,1}[0-9]+){0,1}$')) {
@jclement
jclement / gist:7948373
Created December 13, 2013 17:58
Firefox automatically adds a "bonus" row to textarea fields making them taller than they should be given the "row=X" attribute on the text area. This is really annoying when you want the textarea to simply be 1 row high and to have it automatically grow, as needed, with jquery-autosize. The following snippet forces a starting height on the contr…
if (navigator.userAgent.toLowerCase().indexOf("firefox") !== -1) {
// Firefox/Mozilla automatically adds a "bonus" row to textareas. Through CSS, force the height back to the number of rows specified before
// autosize sees it.
var height = parseFloat(input.css("line-height")) * opt.rows + parseFloat(input.css("padding-top")) + parseFloat(input.css("padding-bottom"));
input.css("height", height + "px");
}
_.defer(function() {
input.autosize();
});
@jclement
jclement / blink.js
Created December 2, 2013 16:51 — forked from anonymous/blink.js
@jclement
jclement / dice.py
Last active December 20, 2015 05:39
Quick little program to generate passphrases from the diceware word list. (I do realize using the computer RNG to generate the list negates part of the point of *dice*ware)
#!/usr/bin/env python
# DICEWARE WORD LIST FROM:
# http://world.std.com/~reinhold/diceware.html
lines = """11111 a
11112 a&p
11113 a's
11114 aa
11115 aaa
@jclement
jclement / otp.py
Created June 8, 2013 20:50
Basic python program for generating / decoding strings with a one-time-pad.
#!/usr/bin/env python
import os
import string
import sys
import random
# =====================================================
CMIN=0x20
CMAX=0x7E
@jclement
jclement / tfs_testcase_reformat_2012.cs
Last active December 18, 2015 01:58
When we upgraded to Visual Studio 2012 we ended up with a problem with many of our test cases which included newlines in the action/expected results fields. These steps were stored as a ParameterizedString (Plain Text) in the database and with 2012 they are now stored ParameterizedString (HTML). Unfortunately, the upgrade didn't convert this dat…
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.TestManagement.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
using System.Net;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.ServiceModel.Web;
using System.Text;