Skip to content

Instantly share code, notes, and snippets.

View edmellum's full-sized avatar

David Ed Mellum edmellum

View GitHub Profile
;;; -*- lexical-binding: t -*-
;; Package system and sources.
(require 'package)
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
(not (gnutls-available-p))))
(proto (if no-ssl "http" "https")))
;; Comment/uncomment these two lines to enable/disable MELPA and MELPA Stable as desired
;; (add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t)
(add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t)
@edmellum
edmellum / dojo-digits-recognizer.fsx
Created December 11, 2014 08:28
F# Dojo Digits Recognizer
type Image = int []
type Sample = { Label:int; Pixels:Image }
let csvToRecords (lines:string[]) =
lines.[1..]
|> Array.Parallel.map (fun x -> x.Split(','))
|> Array.Parallel.map (Array.map int)
|> Array.Parallel.map (fun x -> {Label = x.[0]; Pixels = x.[1..]})
let distance (sample1:Image) (sample2:Image) =
@edmellum
edmellum / palindromes.fs
Created December 1, 2014 14:37
Palindromes: decimal and octal
let toOctalString (x: int) = System.Convert.ToString(x, 8)
let toDecimalString (x: int) = System.Convert.ToString(x, 10)
let stringReverse (s: string) =
System.String(Array.rev (s.ToCharArray()))
let isPalindrome x =
x = stringReverse x
let candidates = seq { 1 .. 1000000 }
@edmellum
edmellum / init.el
Last active May 1, 2019 19:44
Starter Emacs init.el for web developers. Save it in your .emacs.d directory, which should be in your home directory.
;; Don't need buttons in emacs! By running this early we avoid a flash
;; of buttons before they are removed.
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(setq use-dialog-box nil)
;; BORING: Ensure everything is UTF-8 all the time
(prefer-coding-system 'utf-8)
(setq locale-coding-system 'utf-8)
@edmellum
edmellum / counter.js
Created September 28, 2012 13:43
Seaport example
var fs = require('fs');
var http = require('http');
var ports = require('seaport').connect('localhost', 5001);
try {
// Type-coerce file contents to a Number
var counter = +fs.readFileSync('count.db', 'utf8');
} catch(e) {
// If the file doesn't exist create it
var counter = 0;