Skip to content

Instantly share code, notes, and snippets.

View samatjain's full-sized avatar

uıɐɾ ʞ ʇɐɯɐs samatjain

View GitHub Profile
@samatjain
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
samatjain / lowest_bits_set.cpp
Created November 13, 2019 21:38
lowest_bits_set.cpp
#include <bitset>
#include <cassert>
#include <iostream>
using MaskType = uint64_t;
static int LowestBitSet(const MaskType v)
{
return __builtin_ffsl(v);
}
@samatjain
samatjain / wakeonlan.py
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.
wakeonlan.sh 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
samatjain / Encrypted-Amazon-Cloud-Drive.md
Last active May 18, 2017 18:50
Setting up a encrypted drive on Amazon Cloud Drive w/ EncFS and acd_cli

Environment

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

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

Setup

mkdir -p \

@samatjain
samatjain / Meetup-past-events.py
Last active January 4, 2022 16:01
Dump all the previous events for a Meetup.com group. See http://blog.samat.org/2015/10/23/Getting-All-Past-Meetup-Events/
#!/usr/bin/env python3
import collections
import datetime
import pprint
import click
import jinja2
import requests
#!/bin/bash
# GUI-related packages
pkgs="
xserver-xorg-video-fbdev
xserver-xorg xinit
gstreamer1.0-x gstreamer1.0-omx gstreamer1.0-plugins-base
gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-alsa
gstreamer1.0-libav
epiphany-browser
@samatjain
samatjain / keybase.md
Created March 25, 2014 00:00
keybase.md

Keybase proof

I hereby claim:

  • I am SamatJain on github.
  • I am SamatJain (https://keybase.io/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
samatjain / pyvenvex.py
Last active July 12, 2017 19:59 — forked from vsajip/pyvenvex.py
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
samatjain / ubicast.tv-download-feed.py
Created September 23, 2012 22:59
Print the YouTube URLs for a Ubicast.tv videos RSS feed
#!/usr/bin/env python3
# Take a Ubicast.tv 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 <samat@samat.org>
# License: GPLv3
import re
import sys
import feedparser