Skip to content

Instantly share code, notes, and snippets.

View smac89's full-sized avatar

Nobleman smac89

View GitHub Profile
@smac89
smac89 / gulp-typescript-compile-queue.ts
Last active July 6, 2017 21:13
Solution to "Error: gulp-typescript: A project cannot be used in two compilations * at the same time. Create multiple projects with createProject instead."
import {Project, CompileStream} from 'gulp-typescript';
import {Duplex, PassThrough, Readable} from 'stream';
import {Reporter} from 'gulp-typescript/release/reporter';
type Callback = () => void;
/**
* This is used to ensure that each project object is not busy when it is to be used
* This prevents the annoying:
* "Error: gulp-typescript: A project cannot be used in two compilations
@smac89
smac89 / chain.ts
Created June 29, 2017 02:15
Chained callbacks
interface ChainedCallback {
(): void;
}
class ChainedCallback {
private chain: Callback[];
public static fromCallbacks(...cbs: Callback[]): ChainedCallback {
let chained = new ChainedCallback();
cbs.forEach(chained.attach);
@smac89
smac89 / ubuntu wireless adapter rtl8812au.md
Last active May 22, 2023 06:52
BrosTrend wireless card adapter (Linux installation) #wireless
@smac89
smac89 / upgrade_packages.md
Last active May 14, 2021 20:22
Updating all packages installed by various package managers (brew, sdkman, gem, pip, etc)

Brew

brew update && brew upgrade $(brew outdated)

SDKMAN

sdk selfupdate && sdk upgrade <package>

Gem

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

Pip

@smac89
smac89 / disjoint.hpp
Created May 9, 2017 17:04
Implementation of a disjoint_set data structure
#include <algorithm>
#include <iterator>
#include <unordered_set>
#include <vector>
class disjoint_set {
struct ranked { int root, rank, size; };
public:
explicit disjoint_set(int n): cc(n + 1) {
@smac89
smac89 / range.hpp
Last active May 9, 2017 17:04
C++ range implementation
#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
smac89 / immutable-stack.scala
Last active May 4, 2021 18:28 — forked from lambda-hacker/immutable-stack.scala
Stack using List [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
smac89 / WinAdminCommands.md
Last active June 8, 2017 06:38
Windows administrative Commands (Powershell)
@smac89
smac89 / fbootfix.md
Last active January 25, 2024 03:27
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
smac89 / fpr.py
Last active May 10, 2020 08:01
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 https://regex101.com/r/ObowxD/5
import re
regex = r"""
(?xm)
(?:\s|^)
([-+]*(?:\d+\.\d*|\.?\d+)(?:[eE][-+]?\d+)?)