Skip to content

Instantly share code, notes, and snippets.

View dgrahn's full-sized avatar

Dan Grahn dgrahn

View GitHub Profile
@dgrahn
dgrahn / core_ext.rb
Last active December 28, 2015 10:49
My favorite Ruby Core Extensions.
class Object
# Check to see if a the object exists within an array. This is a reflexion of
# {Array#include?} to make conditionals more readable.
#
# @param array [Array(Object)] The array to check
#
# @example
# 'Draper'.in? ['Sterling', 'Cooper', 'Draper', 'Pryce']
# # => true
#
@dgrahn
dgrahn / step.overrides.import.less
Last active May 23, 2017 01:15
Add '.unstackable' option to steps. (Also includes '.padless' option in case you need to shrink the steps on a mobile device)
.ui.unstackable.steps {
flex-direction: row;
}
.ui.unstackable.steps .step {
width: auto !important;
}
@media only screen and (max-width: (@largestMobileScreen)) {
.ui.unstackable.padless.steps .step {
#!/bin/bash
# Install the latest Google Cloud SDK version - https://cloud.google.com/sdk
#
# To run this script on Codeship, add the following
# command to your project's setup commands:
# source /dev/stdin <<< "$(curl -sSL https://raw.githubusercontent.com/codeship/scripts/master/packages/google-cloud-sdk.sh)"
#
# Add the following environment variables to your project configuration
# * GOOGLE_CLOUD_KEY
# * GOOGLE_CLOUD_PROJECT_ID
@dgrahn
dgrahn / NestedAttributesToJSON
Created April 19, 2018 12:34
NiFi Attributes to JSON with Support for JSON Attributes
/*
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE
* file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
* to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
#!/bin/bash
# This is just everything in compile.md
# turned into a script
# you should be able to run it, type in
# sudo passwd and have it install all of panda.
# Verified that this script works
# from a clean install of deb7.
#
#
@dgrahn
dgrahn / keras_metrics.py
Created October 25, 2018 11:24
Metrics removed from Keras in 2.0.
"""Keras 1.0 metrics.
This file contains the precision, recall, and f1_score metrics which were
removed from Keras by commit: a56b1a55182acf061b1eb2e2c86b48193a0e88f7
"""
from keras import backend as K
def precision(y_true, y_pred):
"""Precision metric.
0x42232b: mov qword ptr [rsp + 0x48], rcx
0x422330: pcmpeqd xmm1, xmm1
0x422334: movq xmm0, qword ptr [rsp + 0x48]
0x42233a: mov qword ptr [rsp + 0x48], rdi
0x42233f: movhps xmm0, qword ptr [rsp + 0x48]
0x422344: mov dword ptr [rsp + 0x60], r11d
0x422349: mov dword ptr [rsp + 0x58], r10d
0x42234e: mov byte ptr [rsp + 0x120], r9b
0x422356: mov r10, qword ptr [r13 + 0x470]
0x42235d: mov rcx, rax
@dgrahn
dgrahn / full-mnist-single-image.ipynb
Last active February 3, 2020 15:30
Full MNIST Single Image.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dgrahn
dgrahn / max_metrics.py
Created June 26, 2020 12:16
Callback to report max of a metric for the Tensorboard HParams plugin
import numpy as np
import tensorflow as tf
from collections import defaultdict
class MaxMetrics(tf.keras.callbacks.Callback):
"""Adds the max metric to the logs at the end of each epoch."""
def __init__(self, metrics):
"""Creates a new MaxMetrics callback
@dgrahn
dgrahn / pallete.ts
Created July 24, 2020 16:00
More Colors for Tensorboard
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,