Skip to content

Instantly share code, notes, and snippets.

💭
About 7,000 miles away from lounge access.

Larry O'Brien lobrien

💭
About 7,000 miles away from lounge access.
Block or report user

Report or block lobrien

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
@lobrien
lobrien / action.yml
Created Oct 24, 2019
Inline Python Action
View action.yml
on: push
name: Inline Python Action
jobs:
my-job:
name: My job
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
@lobrien
lobrien / demo.cs
Created Aug 21, 2019
Simple layout anchor example
View demo.cs
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 / capture.cs
Last active Aug 13, 2019
High Performance CVPixelBuffer capture in Xamarin
View capture.cs
Video Capture
previewLayer = new AVCaptureVideoPreviewLayer(captureSession);
//previewLayer.VideoGravity = AVLayerVideoGravity.ResizeAspectFill;
previewView.Layer.AddSublayer(previewLayer);
previewView.TranslatesAutoresizingMaskIntoConstraints = false;
var previewConstraints = new[]
{
previewView.LeftAnchor.ConstraintEqualTo(View.LeftAnchor),
previewView.RightAnchor.ConstraintEqualTo(View.RightAnchor),
@lobrien
lobrien / inner.fs
Created Aug 13, 2019
InnerXML in F#
View inner.fs
let innerXml (node : XNode ) =
use rdr = node.CreateReader()
rdr.MoveToContent() |> ignore
rdr.ReadInnerXml()
View xor.py
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 / kmeans.py
Created Aug 13, 2019
k-means clustering 1d data
View kmeans.py
from sklearn.cluster import KMeans
import numpy as np
data = np.array([101, 107, 106, 199, 204, 205, 207, 306, 310, 312, 312, 314, 317, 318, 380, 377, 379, 382, 466, 469, 471, 472, 557, 559, 562, 566, 569])
kmeans = KMeans(n_clusters=5).fit(data.reshape(-1,1))
kmeans.predict(data.reshape(-1,1))
# array([4, 4, 4, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 3,
# 3, 3, 3, 3], dtype=int32)
@lobrien
lobrien / fizzbuzz.py
Created Aug 13, 2019
TensorFlow fizzbuzz
View fizzbuzz.py
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 Aug 13, 2019
Regex template for F#
View regex.fs
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 Aug 13, 2019
Proper way to install via pip in Jupyter notebook
View test.ipynb
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 Aug 7, 2019 — forked from mzabriskie/README.md
Check git status of multiple repos
View README.md

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.

You can’t perform that action at this time.