Skip to content

Instantly share code, notes, and snippets.

@bdesham
bdesham / keybase.md
Last active August 29, 2015 14:02
Keybase verification for GitHub

Keybase proof

I hereby claim:

  • I am bdesham on github.
  • I am bdesham (https://keybase.io/bdesham) on keybase.
  • I have a public key whose fingerprint is E663 1535 1E9B 2ACF 357F 5C34 F533 D909 7997 4D79

To claim this, I am signing this object:

@bdesham
bdesham / bigfoot-and-mathjax.html
Last active August 29, 2015 14:03
MathJax and Bigfoot test
<!DOCTYPE html>
<html>
<head>
<title>MathJax and Bigfoot test</title>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<link rel="stylesheet" href="bigfoot-default.css"/>
<script src="https://raw.githubusercontent.com/lemonmade/bigfoot/master/dist/bigfoot.js"></script>
@bdesham
bdesham / Obfuscate.hs
Last active August 29, 2015 14:15
Obfuscate text for use in web pages
{-
Replaces each character with an HTML (or XML) escape code like "&#x20;". This is
useful as lightweight protection against email-address harvesting.
Example:
ghci> obfuscate "a@example.co"
"&#97;&#x40;&#101;&#x78;&#97;&#109;&#x70;&#x6c;&#101;&#x2e;&#99;&#111;"
Compare to the Clojure version: https://gist.github.com/bdesham/3327022
-}
@bdesham
bdesham / 2015-03-10-test.md
Last active August 29, 2015 14:16
A minimal Jekyll site showing a behavior I can’t explain
title date layout
Test post
2015-03-10 11:32:13 -0400
standard

This is one paragraph.

{% myblock %} This paragraph is in a custom block. {% endmyblock %}

@bdesham
bdesham / lines.cc
Created June 13, 2011 20:35
Read lines from a file in C++
// <iostream> and <fstream> have been included
void lines() {
ifstream in_file;
in_file.open("input.txt");
string line;
while (in_file.getline(line, 256)) {
cout << "line: \"" << line << "\"\n";
}
@bdesham
bdesham / gist:1023802
Created June 13, 2011 21:47
Calling a function on the values in a map
(defn modify-vals
[f m]
(zipmap
(keys m)
(for [item (vals m)] (f item))))
@bdesham
bdesham / transpose.clj
Created July 6, 2011 16:50
Transpose a matrix in Clojure
(defn square-matrix?
[mat]
(apply =
(count mat)
(for [r mat] (count r))))
(defn transpose
[mat]
{:pre [(square-matrix? mat)]}
(loop [res [],
@bdesham
bdesham / gist:1074160
Created July 10, 2011 02:03
Clojure implementation of Project Euler problem 12
;; Utility functions that will be used later
(def naturals (iterate inc 1))
(defn all-factors
[n]
(filter #(= (mod n %) 0)
(take-while #(<= % (sqrt n))
(rest naturals))))
@bdesham
bdesham / slideshow.css
Created September 2, 2011 20:37
Animate through a series of images with jQuery
ul.slideshow {
list-style: none;
width: 294px;
height: 286px;
float: right;
overflow: hidden;
position: relative;
margin: 0;
padding: 0;
padding-left: 0.5em;
@bdesham
bdesham / gist:1293792
Created October 17, 2011 21:00
Get the Mac OS X version from a Dashcode (JavaScript) app
// return the version of OS X in an array, e.g. a[0] = 10, a[1] = 2, a[2] = 2
function get_macosx_version()
{
var re = new RegExp(".+Mac OS X (\\d+)_(\\d+)_(\\d+)\\).+");
var match = re.exec(navigator.appVersion);
return [parseInt(match[1]), parseInt(match[2]), parseInt(match[3])];
}