Skip to content

Instantly share code, notes, and snippets.

@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;
@jclement
jclement / gpgqr.py
Created April 29, 2013 20:54
Crappy code to split a GPG key in 3 giant QR codes
#!/usr/bin/env python
import os
import sys
LINE_COUNT =40
def dumpLines(basename, segment, lines):
fn ='%s_%02d.png' % (basename, segment)
print fn
f = os.popen("qrencode -o \"%s\" " % fn,'w')
@jclement
jclement / morse.ino
Last active December 14, 2015 04:59
Blink a message in Morse Code with an Arduino
/*
************************************************************************
Blink out a message in morse code
************************************************************************
*/
const int led = 13;
const char* message = "HELLO WORLD";
const int letter_unit_delay = 500;
@jclement
jclement / segment.py
Last active December 12, 2015 01:49
Quick little algorithm to chop up an array into an array of contiguous ranges.
samples=[
# =======================================
# input, expected result pairs
# =======================================
# empty list
([], []),
# single digit
([1], [(1,1)]),
# basic range
([1,2,3], [(1,3)]),
@jclement
jclement / gist:4479168
Created January 7, 2013 22:34
Helper code to push Crystal Reports folder into Environment to help with periodic startup issues
static void SetCrystalPath()
{
string crpath;
if (Environment.Is64BitProcess)
{
crpath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + @"\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win64_x64";
}
else
{
crpath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + @"\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86";