This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# "THE BEER-WARE LICENSE": | |
# <truemped at goggle.com> wrote this file. As long as you retain this notice you | |
# can do whatever you want with this stuff. If we meet some day, and you think | |
# this stuff is worth it, you can buy me a beer in return Daniel Truemper | |
# | |
import time | |
import zmq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#How to load the model | |
def build_model(img_width=224, img_height=224): | |
from keras.models import Sequential | |
from keras.layers import Convolution2D, ZeroPadding2D, MaxPooling2D, Activation | |
model = Sequential() | |
model = Sequential() | |
model.add(ZeroPadding2D((1,1),input_shape=(3,img_width,img_height))) | |
model.add(Convolution2D(64, 3, 3, activation='relu', name='conv1_1')) | |
model.add(Activation('relu')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zmq | |
from zmq.eventloop import zmqstream, ioloop | |
import threading | |
import logging | |
logging.basicConfig(level=logging.DEBUG) | |
logger = logging.getLogger() | |
# run ioloop in separate thread | |
def threaded_loop(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Originally from: http://stackoverflow.com/a/27663998/432509 | |
* | |
* With following modifications: | |
* - Use a pointer to the tail (remove 2x conditional checks, reduces code-size). | |
* - Avoid re-assigning empty values the size doesn't change. | |
* - Corrected comments. | |
*/ | |
static void *listbase_sort_impl(struct Link *head, int (*cmp)(const void *, const void *)) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def DepthConversion(PointDepth, f): | |
H = PointDepth.shape[0] | |
W = PointDepth.shape[1] | |
i_c = np.float(H) / 2 - 1 | |
j_c = np.float(W) / 2 - 1 | |
columns, rows = np.meshgrid(np.linspace(0, W-1, num=W), np.linspace(0, H-1, num=H)) | |
DistanceFromCenter = ((rows - i_c)**2 + (columns - j_c)**2)**(0.5) | |
PlaneDepth = PointDepth / (1 + (DistanceFromCenter / f)**2)**(0.5) | |
return PlaneDepth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
path=/sys/class/backlight/intel_backlight | |
luminance() { | |
read -r level < "$path"/actual_brightness | |
factor=$((max / 100)) | |
ret=`printf '%d\n' "$((level / factor))"` | |
if [ $ret -gt 100 ]; then | |
ret=100 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from matplotlib import pyplot as plt | |
class LivePlotNotebook(object): | |
""" | |
Live plot using %matplotlib notebook in jupyter notebook | |
Usage: | |
``` | |
import time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Inspired by https://keon.io/deep-q-learning/ | |
import random | |
import gym | |
import math | |
import numpy as np | |
from collections import deque | |
from keras.models import Sequential | |
from keras.layers import Dense | |
from keras.optimizers import Adam |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
conda uninstall --force pillow -y | |
# install libjpeg-turbo to $HOME/turbojpeg | |
git clone https://github.com/libjpeg-turbo/libjpeg-turbo | |
pushd libjpeg-turbo | |
mkdir build | |
cd build | |
cmake .. -DCMAKE_INSTALL_PREFIX:PATH=$HOME/turbojpeg | |
make | |
make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ell clock https://twitter.com/cwillmore/status/1353435612636803073 | |
// developed with processing 3.5.4 (processing.org) | |
// TODO: | |
// - motion blur | |
// - ripple update of ells - one only starts rotating when it has room to (<< ... <> ... >>) | |
static final int DEPTH = 3; | |
static final int N = 1 << (DEPTH + 1); | |
static final int FRAME_RATE = 30; | |
static final float DT = 1 / (float)FRAME_RATE; |
OlderNewer