Skip to content

Instantly share code, notes, and snippets.

View sytelus's full-sized avatar

Shital Shah sytelus

View GitHub Profile
@truemped
truemped / zmq_tornado_download.py
Created January 13, 2011 14:06
Toy example demonstrating the usage of pyzmq and tornado's AsyncHTTPClient
#
# "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
@hasnainv
hasnainv / loadvgg.py
Last active December 4, 2018 03:33
Convert Caffe models to Keras models
#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'))
@minrk
minrk / gist:3213317
Created July 31, 2012 03:43 — forked from spenthil/gist:3211707
pyzmq: ioloop in separate thread
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():
@ideasman42
ideasman42 / linked_list_sort.c
Created May 23, 2015 06:10
Mergesort single linked list (improvements from SE answer)
/* 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 *))
{
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
@joel-wright
joel-wright / monitor-backlight.sh
Created January 9, 2017 23:26
AW13 OLED Monitor Brightness
#!/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
@wassname
wassname / live_plot_notebook.py
Created September 27, 2017 06:14
Live plot using %matplotlib notebook in jupyter notebook
import numpy as np
from matplotlib import pyplot as plt
class LivePlotNotebook(object):
"""
Live plot using %matplotlib notebook in jupyter notebook
Usage:
```
import time
# 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
@soumith
soumith / gist:01da3874bf014d8a8c53406c2b95d56b
Last active March 28, 2022 16:53
Install PillowSIMD+libjpeg-turbo on Conda
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
@cwillmor
cwillmor / ells.pde
Created January 25, 2021 02:50
ells.pde (L-tiling clock in processing)
// 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;