Skip to content

Instantly share code, notes, and snippets.

Muammar El Khatib muammar

View GitHub Profile
sbarratt /
Created May 9, 2019
Get the jacobian of a vector-valued function that takes batch inputs, in pytorch.
def get_jacobian(net, x, noutputs):
x = x.squeeze()
n = x.size()[0]
x = x.repeat(noutputs, 1)
y = net(x)
saleph /
Created Sep 5, 2015
[qt5] slider - volume contorl
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):
duggan /
Last active Dec 13, 2018
Using pychromecast to headlessly stream youtube videos
#!/usr/bin/env python
Requires pychromecast.
Install with `pip install pychromecast`
usage: [-h] -d DEVICE -v VIDEO
Cast YouTube videos headlessly.
jossef /
Last active Sep 17, 2019
python coloring for linux, based on this answer
def color(text, **user_styles):
styles = {
# styles
'reset': '\033[0m',
'bold': '\033[01m',
'disabled': '\033[02m',
'underline': '\033[04m',
'reverse': '\033[07m',
rubo77 /
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:
# 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
application="firefox" # "thunderbird" or "firefox" but file extension, archive extraction, and binary
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:

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:


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 /
Last active Jul 9, 2020
OS X Screencast to animated GIF

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


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

View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:


start new with session name:

tmux new -s myname
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.