Skip to content

Instantly share code, notes, and snippets.

Muammar El Khatib muammar

View GitHub Profile
@sbarratt
sbarratt / torch_jacobian.py
Created May 9, 2019
Get the jacobian of a vector-valued function that takes batch inputs, in pytorch.
View torch_jacobian.py
def get_jacobian(net, x, noutputs):
x = x.squeeze()
n = x.size()[0]
x = x.repeat(noutputs, 1)
x.requires_grad_(True)
y = net(x)
y.backward(torch.eye(noutputs))
return x.grad.data
@saleph
saleph / slider.py
Created Sep 5, 2015
[qt5] slider - volume contorl
View slider.py
import sys
from PyQt5.QtWidgets import (QWidget, QSlider,
QLabel, QApplication)
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPixmap
class Example(QWidget):
def __init__(self):
super().__init__()
@duggan
duggan / cast.py
Last active Dec 13, 2018
Using pychromecast to headlessly stream youtube videos
View cast.py
#!/usr/bin/env python
"""
Requires pychromecast.
Install with `pip install pychromecast`
usage: cast.py [-h] -d DEVICE -v VIDEO
Cast YouTube videos headlessly.
@jossef
jossef / colors.py
Last active Sep 17, 2019
python coloring for linux, based on this answer http://stackoverflow.com/a/26445590/3191896
View colors.py
def color(text, **user_styles):
styles = {
# styles
'reset': '\033[0m',
'bold': '\033[01m',
'disabled': '\033[02m',
'underline': '\033[04m',
'reverse': '\033[07m',
@rubo77
rubo77 / download-mozilla-portable.sh
Last active Mar 24, 2020
a script that downloads a certain Firefox or Thunderbird version and installs it in an extra folder to create an independent and portable App for Linux. source: http://portableapps.com/node/16344
View download-mozilla-portable.sh
#!/bin/sh
# Configure the following default variables according to your requirements
language="en-US" # e.g. "de" or "en-US"
if [ ! "$1" ]; then
# default if no argument is set:
version="73.0" # chose from http://download.cdn.mozilla.net/pub/mozilla.org/firefox/releases/
application="firefox" # "thunderbird" or "firefox" but file extension, archive extraction, and binary
fi
@cobookman
cobookman / gist:c1a9856a4588496b021a
Last active Apr 14, 2016
HTML5 Audio (mp3) and Video (webm) live transcoding streams
View gist:c1a9856a4588496b021a

The following two functions will stream just about any audio or video file to any browsers supporting mp3 and/or webm. Due to the unknown number of bytes, a custom html5 audio/video player will have to be written (my next step) to allow seeking.

For w/e reason node.js didn't want to spawn a child process with a unix pipe in it. This could be so that they can keep support for windows computers. As such I've created the following bash script:

#!/bin/bash
START_TIME=${2:-0}
VARIABLE_BIT_RATE=${3:-4}
ABSOLUTE_PATH=$1
@mharsch
mharsch / gist:5144208
Last active Jan 31, 2017
transcode video streams using node.js Streams and avconv (aka ffmpeg)
View gist:5144208

The avconv utility can be made to work in 'the Unix way' by specifying stdin and/or stdout instead of filenames for the input and output respectively. See: http://libav.org/avconv.html#pipe

Example:

cat input.ts | avconv -i pipe:0 -f mp4 -movflags frag_keyframe pipe:1 | cat > output.mp4

Using node's require('child_process').spawn(), we can pipe streams of video data through avconv's stdin and stdout and thus Stream All The Things.

var fs = require('fs');
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active Jul 9, 2020
OS X Screencast to animated GIF
View GIF-Screencast-OSX.md

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@kyleturner
kyleturner / Remove Submodule
Created Jan 5, 2012
How to remove a submodule from a Github project
View Remove Submodule
To remove a submodule you need to:
Delete the relevant line from the .gitmodules file.
Delete the relevant section from .git/config.
Run git rm --cached path_to_submodule (no trailing slash).
Commit and delete the now untracked submodule files.
You can’t perform that action at this time.