Mensch font, Webkit, Chrome, Firefox, Kaleidoscope, iTerm, Transmit, Coda, Sublime Text, Sequel Pro,
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Types | |
{ | |
public static class Option | |
{ | |
public static Option<T> ToOption<T>(this T @this) | |
{ | |
if (@this == null) | |
return Option<T>.None; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @hexstring varchar(max) | |
declare @bin varbinary(max) | |
set @hexstring = '0x10.....' | |
set @bin = ( | |
select cast('' as xml).value('xs:hexBinary(substring(sql:variable("@hexstring"), sql:column("t.pos")))', 'varbinary(max)') | |
from (select case substring(@hexstring, 1, 2) when '0x' then 3 else 0 end) as t(pos) | |
) | |
select @bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function withinRange(sourceLong, sourceLat, targetLong, targetLat, range) { | |
var nauticalMilesPerStatuteMile = 0.868976; | |
// Latitude is always the same distance. Divide degrees by 60 to get arcminutes | |
var milesPerMinLat = 69.047 / 60; | |
// Distance in miles per arcminute longitude depends on the cosine of the arcminutes of latitude | |
var milesPerMinLong = (1 * Math.cos(sourceLat)) / nauticalMilesPerStatuteMile; | |
// Get delta in minutes between source and target longitude, convert to statute miles | |
var deltaLong = Math.abs((sourceLong * 60) - (targetLong * 60)); | |
// Convert `deltaLong` to statute miles, rounding to 2 decimal places | |
var deltaLong = Math.round((milesPerMinLong * deltaLong) * 100) / 100; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Extracts values from a string using a pattern mask. | |
* | |
* Example: | |
* var greetFormat = 'Hello {{name}}! My name is {{greeter}}!' | |
* extract(greetFormat, 'Hello Paul! My name is Robotron!') => { name: 'Paul', greeter: 'Robotron'} | |
*/ | |
function extract(format, s) { | |
var parser = getParser(format); | |
var parsed = parser.mask.exec(s); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Dead Center an element with display: inline-block | |
*/ | |
html, | |
body { margin: 0; height: 100%; } | |
.container { | |
letter-spacing: -0.31em; | |
text-rendering: optimizespeed; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# AUTHOR: Paul Schoenfelder | |
# | |
# This post-receive hook validates that committed files use proper (LF) line endings. | |
verify_lf() | |
{ | |
echo "Validating line endings..." | |
oldrev=$(git rev-parse $1) | |
newrev=$(git rev-parse $2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.util.parsing.combinator._ | |
/** | |
* This trait provides the mathematical operations which the calculator can perform. | |
*/ | |
trait Maths { | |
def add(x: Float, y: Float) = x + y | |
def sub(x: Float, y: Float) = x - y | |
def mul(x: Float, y: Float) = x * y | |
def div(x: Float, y: Float) = if (y > 0) (x / y) else 0.0f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* JavaScript Module Pattern Example with "Passive Attachment" | |
*/ | |
(function (root, builder, undefined) { | |
if (typeof define === 'function') { | |
// CommonJS AMD | |
define('MyModule', ['jQuery', 'DependencyA', 'DependencyB'], function($, a, b) { | |
return builder(root, $, a, b, null); | |
}); | |
} |
Have you ever had to write code that made a complex series of succesive modifications to a single piece of mutable state? (Almost certainly yes.)
Did you ever wish you could make the compiler tell you if a particular operation on the state was illegal at a given point in the modifications? (If you're a fan of static typing, probably yes.)
If that's the case, the indexed state monad can help!
Motivation
NewerOlder