Skip to content

Instantly share code, notes, and snippets.

@ganzuul
ganzuul / test.py
Last active March 7, 2021 17:52
Blender qhull stuff
import bpy
import numpy as np
from scipy.spatial import Delaunay
points = np.random.rand(20,3)
tri = Delaunay(points)
mesh = bpy.data.meshes.new("myUnrulyMess") # add the new mesh
obj = bpy.data.objects.new(mesh.name, mesh)
col = bpy.data.collections.get("Collection")
@ganzuul
ganzuul / tasks.json
Created April 29, 2020 18:56
tasks.json for VSCode to build and run C++ on Linux
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-g",
"${file}",
/*
OneLoneCoder.com - What are Cellular Automata? John Conway's Game Of Life
"Get lost..." - @Javidx9
License
~~~~~~~
Copyright (C) 2018 Javidx9
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions; See license for details.
@ganzuul
ganzuul / oled.cpp
Last active April 11, 2020 18:03
There is an error in the Adafruit GFX I2C examples for mbed
#include "mbed.h"
#include "Adafruit_SSD1306.h"
// Instantiate OLED
class I2CPreInit : public I2C
{
public:
I2CPreInit(PinName sda, PinName scl) : I2C(sda, scl)
{
frequency(400000);
@ganzuul
ganzuul / fetch.r
Last active November 3, 2019 12:52
edges case is broken
#install.packages("httr")
#install.packages("jsonlite")
#install.packages("tidyverse")
#install.packages("stringr")
require(httr)
require(jsonlite)
require(tidyverse)
require(stringr)
base <- "https://en.wikipedia.org/w/api.php?action=query&format=json&prop=linkshere&lhlimit=500"
@ganzuul
ganzuul / linkshere.r
Last active November 10, 2019 19:53
en.wikipedia.org/wiki/Special:WhatLinksHere to R via REST API
#install.packages("httr") #install.packages("jsonlite") #install.packages("tidyverse")
#install.packages("stringr") #install.packages("furrr") #install.packages("igraph")
require(httr)
require(jsonlite)
require(tidyverse)
require(stringr)
#require(furrr) #require(igraph)
url_base <- "https://en.wikipedia.org/w/api.php?action=query&format=json&prop=linkshere&lhlimit=500"
articles <- c("Maximal and minimal elements", "Maxima and minima")
@ganzuul
ganzuul / kotgombinator.kt
Last active November 25, 2018 21:59
Multiplies config files using a range of lines
// Usage: java kotgombinate.jar Dir1 Dir2 Dir3 startOfRange endOfRange
// Output: Dir1(A, B) * Dir2(C, D) = Dir3 (A_C, A_D, B_C, B_D)
// Range is line-numbers so files in Dir1 and Dir2 need to correspond 1-to-1
import java.io.File
import kotlin.system.exitProcess
data class Butt(var fileContents: MutableList<List<String>>, var fileName: MutableList<String>)
var dir1 = Butt(ArrayList(), ArrayList())
var dir2 = Butt(ArrayList(), ArrayList())
var dir3 = Butt(ArrayList(), ArrayList())
@ganzuul
ganzuul / gottaReadEmAll.kt
Last active November 21, 2018 19:29
Takes two directory names as arguments, iterates through the files in those directories, adds their content to lists of lists and prints what it has found.
import java.io.File
var file: MutableList<List<String>> = ArrayList() //list of lists
var file2: MutableList<List<String>> = ArrayList() //list of lists
fun main(args: Array<String>) {
file = readDir(args[0])
file2 = readDir(args[1])
for (e in file) println(e)
@ganzuul
ganzuul / regis.sh
Last active September 1, 2018 22:24
ReGIS pm3d bash script
#!/bin/bash
#
# For reference:
# VT330/VT340 Programmer Reference Manual
# Volume 2: Graphics Programming
#
#
# This script plots vector graphics in the terminal emulator mlterm when mlterm is compiled with ./configure --with-tools
# The graph is generated by gnuplot compiled with ./configure --with-regis
#
@ganzuul
ganzuul / a.h
Created July 20, 2017 20:51
WIP UI for setting a large number e.g. a frequency using only clockwise and CCW movements of a rotary encoder. ESP8266 with Arduino SDK.
struct TwoNibbles
{
byte v1:4;
byte v2:4;
};
union Nibble
{
TwoNibbles nibble;
byte Nibble[sizeof(TwoNibbles)];