Skip to content

Instantly share code, notes, and snippets.

Nathan Youngman nathany

Block or report user

Report or block nathany

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nathany
nathany / checksum.go
Created Aug 11, 2016
Using MultiWriter to do two things at once
View checksum.go
// 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
}
View git_test.go
package main
import (
"os"
"testing"
)
func TestGetSHA(t *testing.T) {
sha, err := getSHA1()
if err != nil {
@nathany
nathany / luhn.ex
Last active Dec 28, 2016
Luhn algorithm to checksum credit cards.
View luhn.ex
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 Nov 15, 2015
blue light reduction and f.lux
View flux.md

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 Sep 11, 2015
Go environment
View zshenv
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 Apr 28, 2015
Go / Ruby bridge with Sidekiq
View README.md
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 Oct 4, 2014
Atom conversion of GoSublime-next.tmLanguage
View go.cson
'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': '\\*/'
View keybase.md

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 Aug 21, 2014
Test case for bug in Rails 4.0.10.rc
View rails-4.0.10.rc1.rb
# 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 Nov 6, 2013
iOS 7.0.3 multiple select issue minimal test case
View multiselect.html
<!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">
You can’t perform that action at this time.