Skip to content

Instantly share code, notes, and snippets.

@neilvallon
neilvallon / randHex.php
Last active August 29, 2015 14:01
ranHexColor - May 15 2009
<?php
function ranHex(){
$i = rand(0, 15);
switch ($i) {
case 0: $a = "0"; break;
case 1: $a = "1"; break;
case 2: $a = "2"; break;
case 3: $a = "3"; break;
@neilvallon
neilvallon / piglatin.scpt
Created May 13, 2014 19:44
Applescript mail action to translate texts to piglatin and send them back - Jul 24 2009
using terms from application "Mail"
on perform mail action with messages theMessages
tell application "Mail"
repeat with theMessage in theMessages
set theText to content of theMessage
set theSender to sender of theMessage
set TempTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to space
set theText to text items of theText
@neilvallon
neilvallon / codelog.rb
Created July 27, 2014 07:45
Count total line changes in a git repository.
#!/usr/bin/env ruby
log = `git log --oneline --shortstat`
puts log
i = 0
d = 0
log.each_line { |l|
ii = /([0-9]+) insertion/.match(l)
@neilvallon
neilvallon / stream.php
Created February 18, 2015 23:03
PHP Streams
<?php
// Now I remember why I don't use PHP anymore.
function repeat($n) {
return function() use ($n) {
return [$n, repeat($n)];
};
}
function countFrom($n) {
@neilvallon
neilvallon / staticserve.go
Last active August 29, 2015 14:16
dead simple file server that will host the current dir on port 8000
package main
import (
"net/http"
"github.com/zenazn/goji"
)
func init() {
goji.Get("/*", http.FileServer(http.Dir("./")))
@neilvallon
neilvallon / rdp.go
Last active August 27, 2020 15:15
In-place Ramer–Douglas–Peucker for Go & TypeScript
package rdp
import "math"
type point [2]float64 // [x, y]
// RDPSimplify is an in-place implementation of Ramer–Douglas–Peucker.
func RDPSimplify(points []point, epsilon float64) []point {
return points[:rdpCompress(points, epsilon)]
}
@neilvallon
neilvallon / polygo.go
Created August 19, 2015 12:05
Generic ideas on peppering on some polymorphism
// I don't personally care about generics but everyone and their dog yells about them so
// it was impossible not to give some thought to how they might work in a go-ish way.
// this is just playing around with some syntax and seeing what semantics fall out.
// no idea what I'm doing. comments may be contradictory or idiotic.
// polygo is a dialect of go that live in a world free of angle bracketed capital letters.
package polygo
// enforce sameness of the method receiver and argument

Keybase proof

I hereby claim:

  • I am neilvallon on github.
  • I am neilvallon (https://keybase.io/neilvallon) on keybase.
  • I have a public key whose fingerprint is 95B0 DF16 5940 962A A3BC 04FA E464 E651 C9DE 7819

To claim this, I am signing this object:

class Fakecoin < Formula
homepage "https://fakco.in/"
url "https://github.com/Fake-Coin/FakeCoin-Qt.git"
#head do
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
#end