Skip to content

Instantly share code, notes, and snippets.

View laurence-myers's full-sized avatar

Laurence Dougal Myers laurence-myers

View GitHub Profile
@ramnathv
ramnathv / gh-pages.md
Created March 28, 2012 15:37
Creating a clean gh-pages branch

Creating a clean gh-pages branch

This is the sequence of steps to follow to create a root gh-pages branch. It is based on a question at [SO]

cd /path/to/repo-name
git symbolic-ref HEAD refs/heads/gh-pages
rm .git/index
git clean -fdx
echo "My GitHub Page" > index.html
@demoive
demoive / slugify.js
Last active February 24, 2021 08:59
Converts a string to a "URL-safe" slug
/**
* Converts a string to a "URL-safe" slug.
* Allows for some customization with two optional parameters:
*
* @param {string} Delimiter used. If not specified, defaults to a dash "-"
* @param {array} Adds to the list of non-alphanumeric characters which
* will be converted to the delimiter. The default list includes:
* ['–', '—', '―', '~', '\\', '/', '|', '+', '\'', '‘', '’', ' ']
*/
if (!String.prototype.slugify) {
@niteria
niteria / slim.hs
Created May 12, 2013 22:12
parsing binary data in haskell
module Main where
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as BL
import Data.Binary.Strict.Get
import qualified Data.Binary.Strict.BitGet as BG
import Data.Word
import Control.Monad
import Control.Applicative
import Data.Binary.Put
// Twitter Issue (Can't tweet exclamation mark with v1.1)
// https://dev.twitter.com/discussions/12378
// https://github.com/mikeal/request/issues/578
var escape = function(str) {
return encodeURIComponent(str).replace(/[!*()']/g, function(character) {
return '%' + character.charCodeAt(0).toString(16);
});
};
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
@transitive-bullshit
transitive-bullshit / image-service.js
Last active September 16, 2024 04:35
Angular service to resize images with antialiasing for use with canvas.
angular.module('demo').service('imageService', function ($http, $q, $timeout) {
var NUM_LOBES = 3
var lanczos = lanczosGenerator(NUM_LOBES)
// resize via lanczos-sinc convolution
this.resize = function (img, width, height) {
var self = { }
self.type = "image/png"
self.quality = 1.0
@nadako
nadako / Main.hx
Created June 24, 2015 19:36
Haxe + SDL = native love \o/
class Main {
static function main() {
Sdl.init(Sdl.INIT_EVERYTHING);
var win = Sdl.createWindow("Hello", 100, 100, 800, 600, Sdl.WINDOW_OPENGL);
var ren = Sdl.createRenderer(win, -1, Sdl.RENDERER_ACCELERATED);
var bmp = Sdl.loadBMP("test.bmp");
var tex = Sdl.createTextureFromSurface(ren, bmp);
Sdl.freeSurface(bmp);
for (i in 0...3) {
@smalljam
smalljam / test.js
Created August 19, 2015 09:34
xlsx library patch, so we can make bold cells and align them to the right
var XLSX = require('xlsx')
function Workbook() {
this.SheetNames = ['Report'];
this.Sheets = {};
}
var wb = new Workbook();
var ws = {
@arccoza
arccoza / callable-object-constructor.js
Last active March 6, 2023 21:38
Javascript Callable Object Class / Constructor created by arccoza - https://repl.it/EbN5/18
// This is my approach to creating callable objects
// that correctly reference their object members,
// without messing with prototypes.
// A Class that extends Function so we can create
// objects that also behave like functions, i.e. callable objects.
class ExFunc extends Function {
constructor() {
// Here we create a dynamic function with `super`,
// which calls the constructor of the parent class, `Function`.
@hraban
hraban / ensure-subset-type.ts
Last active March 24, 2017 03:19
Checked subset typing in TypeScript
// Imagine you want to explicitly define which members of a public API
// interface your implementation actually uses. Example: you implement
// a web extension, but only use a few of the members on the argument
// to the onHeadersReceived handler. Explicitly typing this is useful
// when creating mocks in your unit tests.
//
// Here's now you could do it: