Skip to content

Instantly share code, notes, and snippets.

View samatjain's full-sized avatar

uıɐɾ ʞ ʇɐɯɐs samatjain

View GitHub Profile
samatjain / du-cpp17.cpp
Created March 12, 2021 23:03
du ioring comparison
#include <iostream>
#include <fstream>
#include <filesystem>
#include <chrono>
using namespace std;
using Timer = std::chrono::high_resolution_clock;
using TimePoint = std::chrono::time_point<Timer>;
samatjain / lowest_bits_set.cpp
Created November 13, 2019 21:38
#include <bitset>
#include <cassert>
#include <iostream>
using MaskType = uint64_t;
static int LowestBitSet(const MaskType v)
return __builtin_ffsl(v);
samatjain /
Created February 22, 2019 04:01
wakeonlan wrapper script w/ pre-programmed hostnames and MAC addresses
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
Send a magic packet to a list pre-programmed hostnames. is the old shell-based version; please use this program instead.
Requires the "wakeonlan" program is installed, i.e.
#include <algorithm>
#include <chrono>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <random>
#include <set>
#include <unordered_set>
#include <thread>
samatjain /
Last active May 18, 2017 18:50
Setting up a encrypted drive on Amazon Cloud Drive w/ EncFS and acd_cli


export ACD_LOCAL=$HOME/.cache/Amazon-Cloud-Drive

# To use this file later
export ENCFS6_CONFIG=$ACD_LOCAL/encfs6.xml


mkdir -p \

samatjain /
Last active January 4, 2022 16:01
Dump all the previous events for a group. See
#!/usr/bin/env python3
import collections
import datetime
import pprint
import click
import jinja2
import requests
# GUI-related packages
xserver-xorg xinit
gstreamer1.0-x gstreamer1.0-omx gstreamer1.0-plugins-base
gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-alsa
samatjain /
Created March 25, 2014 00:00

Keybase proof

I hereby claim:

  • I am SamatJain on github.
  • I am SamatJain ( on keybase.
  • I have a public key whose fingerprint is E95D 7465 5B35 C5F6 B3B6 68CC 20C6 F0A6 4A45 6FBA

To claim this, I am signing this object:

samatjain /
Last active July 12, 2017 19:59 — forked from vsajip/
Set VIRTUAL_ENV, which appears to be needed on Ubuntu's Python for distribute/pip to install properly
# Copyright (C) 2013 Vinay Sajip. New BSD License.
import os
import os.path
from subprocess import Popen, PIPE
import sys
from threading import Thread
from urllib.parse import urlparse
from urllib.request import urlretrieve
samatjain /
Created September 23, 2012 22:59
Print the YouTube URLs for a videos RSS feed
#!/usr/bin/env python3
# Take a RSS feed (usually found on channel pages) and print all the YouTube links available for the video. Said list can be fed into youtube-dl so videos can be watched offline
# Author: Samat Jain <>
# License: GPLv3
import re
import sys
import feedparser