Skip to content

Instantly share code, notes, and snippets.

View lobrien's full-sized avatar
💭
About 7,000 miles away from lounge access.

Larry O'Brien lobrien

💭
About 7,000 miles away from lounge access.
View GitHub Profile
@lobrien
lobrien / demo.cs
Created August 21, 2019 17:42
Simple layout anchor example
faceContainingImage.Image = UIImage.FromFile("docs.jpg");
//Put it on the screen
View.AddSubview(faceContainingImage);
faceContainingImage.TranslatesAutoresizingMaskIntoConstraints = false;
var dpConstraints = new[]
{
faceContainingImage.LeadingAnchor.ConstraintEqualTo(View.LayoutMarginsGuide.LeadingAnchor),
faceContainingImage.TrailingAnchor.ConstraintEqualTo(View.LayoutMarginsGuide.TrailingAnchor),
faceContainingImage.TopAnchor.ConstraintEqualTo(View.LayoutMarginsGuide.TopAnchor, 40.0f),
@lobrien
lobrien / inner.fs
Created August 13, 2019 22:31
InnerXML in F#
let innerXml (node : XNode ) =
use rdr = node.CreateReader()
rdr.MoveToContent() |> ignore
rdr.ReadInnerXml()
@lobrien
lobrien / xor.py
Created August 13, 2019 22:29
Keras XOR
import numpy as np
from keras.models import Sequential
from keras.layers.core import Activation, Dense
from keras.optimizers import SGD
# Allocate the input and output arrays
X = np.zeros((4, 2), dtype='uint8')
y = np.zeros(4, dtype='uint8')
# Training data X[i] -> Y[i]
@lobrien
lobrien / fizzbuzz.py
Created August 13, 2019 22:28
TensorFlow fizzbuzz
import numpy as np
import tensorflow as tf
def binary_encode(i, num_digits):
return np.array([i >> d & 1 for d in range(num_digits)])
def fizz_buzz_encode(i):
if i % 15 == 0: return np.array([0, 0, 0, 1])
elif i % 5 == 0: return np.array([0, 0, 1, 0])
elif i % 3 == 0: return np.array([0, 1, 0, 0])
@lobrien
lobrien / regex.fs
Created August 13, 2019 22:27
Regex template for F#
open System.Text.RegularExpressions
// Seems to be a good capturing pattern, it's "Capture everything not in the list (that is ['?']) until the closing )
/*
\(([^?]+)\)
*/
Regex.Matches (cref, "(([^?=&]+))") |> Seq.head |> fun mtch -> mtch.Value
@lobrien
lobrien / test.ipynb
Created August 13, 2019 22:24
Proper way to install via pip in Jupyter notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lobrien
lobrien / README.md
Created August 7, 2019 19:17 — forked from mzabriskie/README.md
Check git status of multiple repos

If you're like me you have a dir like ~/Workspace/Github where all your git repos live. I often find myself making a change in a repo, getting side tracked and ending up in another repo, or off doing something else all together. After a while I end up with several repos with modifications. This script helps me pick up where I left off by checking the status of all my repos, instead of having to check each one individually.

Usage:

git-status [directory]

This will run git status on each repo under the directory specified. If called with no directory provided it will default to the current directory.

@lobrien
lobrien / combinators.js
Created March 27, 2019 19:11 — forked from Avaq/combinators.js
Common combinators in JavaScript
const I = x => x;
const K = x => y => x;
const A = f => x => f(x);
const T = x => f => f(x);
const W = f => x => f(x)(x);
const C = f => y => x => f(x)(y);
const B = f => g => x => f(g(x));
const S = f => g => x => f(x)(g(x));
const P = f => g => x => y => f(g(x))(g(y));
const Y = f => (g => g(g))(g => f(x => g(g)(x)));
@lobrien
lobrien / gist:fdc2492764a65939c53e259e64ffb7bf
Created December 23, 2018 18:55
Robert Reich, Jan 21 2017
I had breakfast recently with a friend who's a former Republican member of Congress. Here's what he said:
Him: Trump is no Republican. He’s just a big fat ego.
Me: Then why didn’t you speak out against him during the campaign?
Him: You kidding? I was surrounded by Trump voters. I’d have been shot.
Me: So what now? What are your former Republican colleagues going to do?
@lobrien
lobrien / xor.py
Created October 12, 2018 21:47
"Hello, World" Keras Neural Net (XOR)
import numpy as np
from keras.models import Sequential
from keras.layers.core import Activation, Dense
from keras.optimizers import SGD
# Allocate the input and output arrays
X = np.zeros((4, 2), dtype='uint8')
y = np.zeros(4, dtype='uint8')
# Training data X[i] -> Y[i]