Skip to content

Instantly share code, notes, and snippets.

@pranavraja
pranavraja / transcode.go
Created April 21, 2017 05:02
Stream/transcode video in real time with ffmpeg for chromecast
package main
import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
"log"
# Pytorch implementation of LSHHash from https://github.com/kayzhu/LSHash
# Homework: Try to implement LSHHash in pytorch to speed up meanshift.
# Motivation: i.e. why calculate all distances when you need only a few.
import numpy as np
import importlib
import torch_utils
importlib.reload(torch_utils)
from torch_utils import *
@idanori
idanori / my_stateFarm.ipynb
Last active November 9, 2017 12:03
Score: 0.715 - State Farm Distracted Driver Detection
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stuart-warren
stuart-warren / TDD-README
Last active October 18, 2024 10:59
Monitor files for changes and run test command (TDD)
$ brew install fswatch
$ alias pywatch='fswatch -r -0 --monitor=poll_monitor $(find . -name *.py) | xargs --null -n1 -I{}'
$ alias gowatch='fswatch -r -0 --monitor=poll_monitor $(find . -name *.go) | xargs --null -n1 -I{}'
$ pywatch python setup.py test
$ gowatch go test -cover
@bzamecnik
bzamecnik / one_hot_lambda_layer_keras.py
Last active October 22, 2020 18:02
One-hot encoding in a Keras Lambda layer
"""
When traing ML models on text we usually need to represent words/character in one-hot encoding.
This can be done in preprocessing, however it may make the dataset file bigger. Also when we'd
like to use an Embedding layer, it accepts the original integer indexes instead of one-hot codes.
Can be move the one-hot encoding from pre-preprocessing directly into the model?
If so we could choose from two options: use one-hot inputs or perform embedding.
A way how to do this was suggested in Keras issue [#3680](https://github.com/fchollet/keras/issues/3680).
@krtx
krtx / imgcat
Created November 27, 2016 02:48
fix imgcat to be able to display images on tmux https://gitlab.com/gnachman/iterm2/issues/3898#note_14097715
#!/bin/bash
# tmux requires unrecognized OSC sequences to be wrapped with DCS tmux;
# <sequence> ST, and for all ESCs in <sequence> to be replaced with ESC ESC. It
# only accepts ESC backslash for ST.
function print_osc() {
if [[ -n $TERM ]] ; then
printf "\033Ptmux;\033\033]"
else
printf "\033]"
@tpruvot
tpruvot / xorg.conf
Last active October 20, 2020 10:29
Fake plugged monitor to allow coolbits on maxwell and pascal cards
# To allow nvidia powermizer settings, we need to define dummy monitors for each card
# Edit the PCI BusId for each cards (lspci | grep VGA)
# Also, you need to dump an EDID file from your monitor
# Here is my dell.edid (2560x1440)
# it's stored in text, hexdump -C format, not binary:
# 00 ff ff ff ff ff ff 00 10 ac 7e 40 4c 54 41 41
# 15 17 01 03 80 3c 22 78 ea 4b b5 a7 56 4b a3 25
# 0a 50 54 a5 4b 00 81 00 b3 00 d1 00 71 4f a9 40
# 81 80 d1 c0 01 01 56 5e 00 a0 a0 a0 29 50 30 20
@dswah
dswah / layers_tied.py
Last active September 17, 2021 22:45
Tied Convolutional Weights with Keras for CNN Auto-encoders
from keras import backend as K
from keras import activations, initializations, regularizers, constraints
from keras.engine import Layer, InputSpec
from keras.utils.np_utils import conv_output_length
from keras.layers import Convolution1D, Convolution2D
import tensorflow as tf
class Convolution1D_tied(Layer):
'''Convolution operator for filtering neighborhoods of one-dimensional inputs.
When using this layer as the first layer in a model,
@Brainiarc7
Brainiarc7 / VAAPI-hwaccel-encode-Linux-Ffmpeg&Libav-setup.md
Last active July 15, 2025 09:25
This gist contains instructions on setting up FFmpeg and Libav to use VAAPI-based hardware accelerated encoding (on supported platforms) for H.264 (and H.265 on supported hardware) video formats.

Using VAAPI's hardware accelerated video encoding on Linux with Intel's hardware on FFmpeg and libav

Hello, brethren :-)

As it turns out, the current version of FFmpeg (version 3.1 released earlier today) and libav (master branch) supports full H.264 and HEVC encode in VAAPI on supported hardware that works reliably well to be termed "production-ready".

@plurch
plurch / upsert.js
Created March 2, 2016 05:29
PostgreSQL 9.5 Upsert using Knex.js
exports.knex = require('knex')({
client: 'pg',
connection: {
host : '127.0.0.1',
user : 'your_database_user',
password : 'your_database_password',
database : 'myapp_test'
}
});