Skip to content

Instantly share code, notes, and snippets.

View nathany's full-sized avatar
🙃

Nathan Youngman nathany

🙃
View GitHub Profile
@nathany
nathany / checksum.go
Created August 11, 2016 23:09
Using MultiWriter to do two things at once
// copyAndChecksum calculates a checksum while writing to another output
func copyAndChecksum(w io.Writer, r io.Reader) (string, error) {
h := md5.New()
mw := io.MultiWriter(w, h)
if _, err := io.Copy(mw, r); err != nil {
return "", err
}
return hex.EncodeToString(h.Sum(nil)), nil
}
package main
import (
"os"
"testing"
)
func TestGetSHA(t *testing.T) {
sha, err := getSHA1()
if err != nil {
@nathany
nathany / luhn.ex
Last active December 28, 2016 08:10
Luhn algorithm to checksum credit cards.
defmodule Luhn do
@moduledoc """
Luhn algorithm to checksum credit cards.
"""
@doc """
Check if a credit card number is valid based on luhn.
"""
def valid?(cc) when is_integer(cc) do
Integer.digits(cc)
@nathany
nathany / flux.md
Last active November 15, 2015 22:23
blue light reduction and f.lux

https://www.apple.com/feedback/ipad.html

To modify screen colour temperatures during evening hours, I have been using the f.lux app on my Macs for years.

I was quite looking forward to using it on my iPad, particularly for reading, but it seems Apple has not provided the necessary documented APIs, nor is Apple allowing side loading of apps using Xcode 7. https://justgetflux.com/sideload/

This is why iPad will never replace the PC.

Hopefully you will open up the capabilities needed to make f.lux a first class app, or work with them to build the features into a future revision of iOS.

@nathany
nathany / zshenv
Last active September 11, 2015 17:07
Go environment
export GOPATH=$HOME
export PATH=$PATH:$HOME/src/go.googlesource.com/go/bin:$HOME/bin
export GOROOT_BOOTSTRAP=$HOME/src/go.googlesource.com/go1.4
export GO15VENDOREXPERIMENT=1
@nathany
nathany / README.md
Created April 28, 2015 17:53
Go / Ruby bridge with Sidekiq
brew install redis
gem install sidekiq
go get -u github.com/jrallison/go-workers

redis-server /usr/local/etc/redis.conf
@nathany
nathany / go.cson
Created October 4, 2014 04:36
Atom conversion of GoSublime-next.tmLanguage
'comment': 'Based on work from github.com/frou/GoFeather and github.com/DisposaBoy/GoSublime'
'fileTypes': [
'go'
]
'firstLineMatch': '-[*]-( Mode:)? Go -[*]-'
'name': 'GoSublime-next'
'patterns': [
{
'begin': '/\\*'
'end': '\\*/'

Keybase proof

I hereby claim:

  • I am nathany on github.
  • I am nathany (https://keybase.io/nathany) on keybase.
  • I have a public key ASDQMnXaH02CR8BQhuy4A0xJpt8RfQDOIkGAJFX9QuNlIAo

To claim this, I am signing this object:

@nathany
nathany / rails-4.0.10.rc1.rb
Created August 21, 2014 20:36
Test case for bug in Rails 4.0.10.rc
# Activate the gem you are reporting the issue against.
# gem 'activerecord', '4.0.9' # works
gem 'activerecord', '4.0.10.rc1'
# gem 'activerecord', '4.1.5' # works
# gem 'activerecord', '4.1.6.rc1'
gem 'pg'
require 'active_record'
@nathany
nathany / multiselect.html
Created November 6, 2013 00:05
iOS 7.0.3 multiple select issue minimal test case
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>iOS Test</title></head>
<body>
<div data-role="page">
<div data-role="content">