Skip to content

Instantly share code, notes, and snippets.



View GitHub Profile
smac89 / chain.ts
Created Jun 29, 2017
Chained callbacks
View chain.ts
interface ChainedCallback {
(): void;
class ChainedCallback {
private chain: Callback[];
public static fromCallbacks( Callback[]): ChainedCallback {
let chained = new ChainedCallback();
smac89 /
Last active Dec 1, 2018
Updating all packages installed by various package managers (brew, sdkman, gem, pip, etc)


brew update && brew upgrade $(brew outdated)


sdk selfupdate && sdk upgrade <package>


gem update $(gem list | cut -d' ' -f1)


smac89 / disjoint.hpp
Created May 9, 2017
Implementation of a disjoint_set data structure
View disjoint.hpp
#include <algorithm>
#include <iterator>
#include <unordered_set>
#include <vector>
class disjoint_set {
struct ranked { int root, rank, size; };
explicit disjoint_set(int n): cc(n + 1) {
smac89 / range.hpp
Last active May 9, 2017
C++ range implementation
View range.hpp
#include <iostream>
#include <type_traits>
#include <limits>
#include <stdexcept>
template <typename I>
class range_t {
static_assert(std::is_integral<I>::value, "Integer type required");
class offset {
smac89 / immutable-stack.scala
Last active Apr 27, 2017 — forked from lambda-hacker/immutable-stack.scala
Stack using List [Scala]
View immutable-stack.scala
// Immutable Stack Type using List
case class Stack[A] (elems: Seq[A] = List.empty[A]) {
def push(v: A) : Stack[A] = Stack(v +: elems)
def pushAll(xs: Iterable[A]) : Stack[A] =
xs.foldLeft (this) ((accStack, e) => accStack.push(e))
def pop(): Either[String, (A, Stack[A])] = {
if (isEmpty) Left("Cannot pop from empty stack")
smac89 /
Last active Jun 8, 2017
Windows administrative Commands (Powershell)
smac89 /
Last active May 28, 2020
Linux Fix Fastboot "no permissions, verify udev rules"

Determine your device id

  1. Unplug your device from the computer and type lsusb in the terminal. You should get an output similar to this:
Bus 002 Device 002: ID 8087:8000 Intel Corp. 
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:8008 Intel Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 005: ID 0bda:0129 Realtek Semiconductor Corp. RTS5129 Card Reader Controller
smac89 /
Last active May 10, 2020
Floating point regex: A regular expression to match any valid python floating point value.
# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
# See it in action
import re
regex = r"""
smac89 /
Created Jun 27, 2016
Converts drawable image to BitmapDrawable
import android.content.Context;
public static final class BitmapDrawableFromDrawable {
public static BitmapDrawable drawableToBitmapDrawable (Context ctx, Drawable drawable) {
Bitmap bitmap;
if (drawable instanceof BitmapDrawable) {
You can’t perform that action at this time.