Skip to content

Instantly share code, notes, and snippets.

View Techcable's full-sized avatar
🇺🇸
Procrastinating

Techcable

🇺🇸
Procrastinating
View GitHub Profile
@Techcable
Techcable / java_asdl.py
Last active July 13, 2025 02:27
Java ASDL AST Tree Generator
import asdl
from contextlib import contextmanager
from abc import ABCMeta
from pathlib import Path
from argparse import ArgumentParser
_wrapper_types = {
"int": "Integer",
"boolean": "Boolean"
}
@Techcable
Techcable / fs.lua
Created February 10, 2017 03:25
A portable filesystem API using LuaJIT's FFI
-- A portable filesystem API using LuaJIT's FFI
--
local ffi = require("ffi")
local table = require("table")
require("string")
-- Cache needed functions and locals
local C, errno, string = ffi.C, ffi.errno, ffi.string
local concat, insert = table.concat, table.insert
-- "Standard" C99 functions
@Techcable
Techcable / bitvec.py
Created February 25, 2017 20:32
Python Bitvector
from array import array
from collections import Iterable
def _chunks(l, n):
"""Yield successive n-sized chunks from l."""
for i in range(0, len(l), n):
yield l[i:i + n]
class BitVector:
__slots__ = "_words", "size"
@Techcable
Techcable / sonardev.sh
Last active April 12, 2017 03:58
SonarPet development version auto-compiler
#!/bin/bash
REPOSITORY="https://github.com/TechzoneMC/SonarPet"
checkCommand() {
command=$1
command_name=${2:-$1}
if ! which $command >/dev/null 2>&1 ; then
echo "Missing required command: $command" 1>&2;
echo "Please install $command_name to compile SonarPet" 1>&2;
@Techcable
Techcable / permutations.rs
Created April 20, 2017 18:05
Rust Permutations
use std::mem;
pub struct Permutations<T: Ord> {
elements: Vec<T>,
times_generated: u64
}
impl<T: Ord> Permutations<T> {
#[inline]
pub fn new(mut elements: Vec<T>) -> Permutations<T> {
@Techcable
Techcable / sieve.rs
Created April 24, 2017 19:40
Rust Segmented Sieve of Eratosthenes
use std::cmp::min;
fn basicSieve(bound: usize) -> Vec<usize> {
let mut isPrime = vec![true; bound];
let top = ((bound as f64).sqrt().ceil() as usize) + 1;
assert!(top < isPrime.len());
for i in 2..top {
if isPrime[i] {
let mut j = i*i;
while j < bound {
@Techcable
Techcable / prettyPrintNumber.py
Created May 6, 2017 19:00
Python Pretty Print Numbers
from math import floor, log10
tinyNumbers = {
1: "one",
2: "two",
3: "three",
4: "four",
5: "five",
6: "six",
7: "seven",
8: "eight",
@Techcable
Techcable / quizGameController.c
Created May 6, 2017 23:54
projectnotions.com quiz game controller Arduino
/*
Game_First_to_Respond - A program for a quiz game function
Copyright 2013 by V Boyd
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@Techcable
Techcable / update.sh
Created May 23, 2017 15:05
cdnjs Kotlin Javascript Update Script
#!/bin/bash
VERSION="$1"
if [ -z "$VERSION" ]; then
echo "Please enter a version to update to!" >&2;
exit 1;
fi;
echo "Downloading kotlin $VERSION from maven"
OUTPUT_JAR=$(mktemp -t "kotlin-$VERSION-XXX.jar")
@Techcable
Techcable / risk.py
Last active June 25, 2017 22:10
Risk attack simulator
#!/usr/bin/env python3
from argh import ArghParser, arg
from random import Random
from statistics import median
class Territory:
__slots__ = "name", "troops", "random"
def __init__(self, name, troops, random=Random()):