Skip to content

Instantly share code, notes, and snippets.

View petulla's full-sized avatar

Sam Petulla petulla

View GitHub Profile
import numpy as np
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
import matplotlib.pyplot as plt
from matplotlib import animation, rc
rc('animation', html='html5')
plt.style.use('seaborn-whitegrid')
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@smeschke
smeschke / gist:df2c5794287fa7044817dc3e00d61351
Last active June 24, 2024 06:51
Using Keras from the Webcam
import cv2, numpy as np, os
#parameters
working_dir = '/home/stephen/Desktop/keras_demo/'
cap = cv2.VideoCapture(0)
org, font, scale, color, thickness, linetype = (50,50), cv2.FONT_HERSHEY_SIMPLEX, 1.2, (234,12,123), 2, cv2.LINE_AA
#chromakey values
h,s,v,h1,s1,v1 = 16,0,64,123,111,187 #green
h,s,v,h1,s1,v1 = 0,74,53,68,181,157 #skin tone
#!/bin/bash
cd $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
blue=$(tput setaf 4)
green=$(tput setaf 2)
normal=$(tput sgr0)
while ./update.sh
do
printf "\n${blue}>>> sleeping a little bit before running again... ${normal}\n"
@emanuelfeld
emanuelfeld / gi-lf
Last active April 24, 2017 14:26
as pre-commit script, automatically add files larger than some size to your repository's .git/info/exclude file
#!/bin/bash
# set max file size to include (in MB)
max_size_mb=100
max_size_b="$(($max_size_mb * 1000000))c"
git_dir="$(git rev-parse --show-toplevel)"
git_exclude=$git_dir/.git/info/exclude
files="$(find $git_dir -path $git_dir/.git -prune -o -type f -size +$max_size_b -print | sed "s%$git_dir/%%g" | sed "s/\ /\\\ /g")"
@Rich-Harris
Rich-Harris / service-workers.md
Last active November 5, 2024 06:39
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@veltman
veltman / draw.js
Created July 2, 2016 04:33
D3 frames to video
// Pipe to ffmpeg with something like:
// node draw.js | ffmpeg -y -c:v png -f image2pipe -r 20 -i - -an -c:v libx264 -pix_fmt yuv420p -movflags +faststart myvideo.mp4
var Canvas = require("canvas"),
d3 = require("d3"),
topojson = require("topojson"),
rw = require("rw"),
world = require("./world-110m.json");
var width = 1280,
@alykat
alykat / gist:5fabb42475a6111ccc38591bac09550a
Created April 1, 2016 21:18
D3: Wrap label text and make SVG taller
/*
* Wrap a block of text to a given width
* via http://bl.ocks.org/mbostock/7555321
*/
var wrapText = function(texts, width, lineHeight) {
texts.each(function() {
var text = d3.select(this);
var words = text.text().split(/\s+/).reverse();
var word = null;
@kingjr
kingjr / hinge_vs_loss.py
Last active August 25, 2020 01:47
Illustrate how SVM and Logistic Regression are very similar except that SVM strictly relies on a subset of the data.
# Author: Jean-Remi King <[email protected]>
"""
Illustrate how a hinge loss and a log loss functions
typically used in SVM and Logistic Regression
respectively focus on a variable number of samples.
For simplification purposes, we won't consider the
regularization or penalty (C) factors.
"""
import numpy as np
import matplotlib.animation as animation