Skip to content

Instantly share code, notes, and snippets.

View robertmaxwilliams's full-sized avatar
💭
student

Robert robertmaxwilliams

💭
student
View GitHub Profile
@robertmaxwilliams
robertmaxwilliams / typewriter
Created April 21, 2021 15:10
A typewriter in ncurses. Don't worry just write. It'll all be okay.
// Fair use for whatever, don't need no license 'cause it's not useful.
// Compile with gcc -lncurses typewriter.c
// Also if you haven't installed ncurses-dev you'll need that, I used
// sudo apt-get install libncurses5-dev libncursesw5-dev
// output is written to foo.txt
#include <ncurses.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
// Pipe in random bytes, and it outputs alternting x and y ints of where to draw a low opacity point.
// Call from command line with an integer specifiying the output scale
#include "stdio.h"
#include <stdlib.h>
#include <stdint.h>
typedef struct {
float x;
float y;
} pair_t;
@robertmaxwilliams
robertmaxwilliams / mers_min.c
Last active February 2, 2021 22:25
Simple and mildly ugly (and not very fast) implementation of 32 bit Mersenne Twister MT19937. mers_min.c is a shortened verion, mersenne_twister.c is the longer, parameterized version.
// Compile with gcc -std=c99 mersenne_twister.c -o /dev/random
// ps the -o /dev/random part is a joke, it's not actually meant to be a random device.
// Absolutely no warranty, Kopyleft I guess who gives a shit
#include <stdint.h>
#include <stdio.h>
uint32_t x[624];
uint32_t index = 0;
void twist() {
for (int k = 0; k < 624; k++) {
x[k] = x[(k+397)%624]
'''Minimal example demonstrating that code still runs even if variable names are terrible.'''
import itertools
import random
def swippy_swap(set1, set2, item1, item2):
a = set1.copy()
a.discard(item1)
a.add(item2)
b = set2.copy()
int shift(int x, int s) {
if (s > 0) {
return x<<s;
} else if (s < 0) {
return x>>s;
} else {
return x;
}
}
@robertmaxwilliams
robertmaxwilliams / oo-in-common-lisp.lisp
Created November 10, 2018 00:18
How to do basic object oriented in common list. Only for fun, if you actually want OO, use CLOS.
(defun inverse-collatz (n)
"returns a list with one or two values that collatz to n"
(cons (* 2 n)
(let ((other-result (/ (- n 1) 3)))
(if (integerp other-result)
(list other-result)
nil))))
;; use lambda closure to access lexically scoped variable "starting-list"
@robertmaxwilliams
robertmaxwilliams / dotmaker.py
Last active June 28, 2018 17:48
makes dot file from project dir
import os
import os.path as p
import random
import sys
# TODO: DO TO
PACKAGE_NAME = "mastml" #TODO
#pure_print = print
#def make_myprint(leader):
# def myprint(*args):
$ cowsay 'hello world' | cowsay -n | cowsay -n | cowsay -n | cowsay -n
__________________________________________
/ ______________________________________ \
| / __________________________________ \ |
| | / ______________________________ \ | |
| | | / _____________ \ | | |
| | | | < hello world > | | | |
| | | | ------------- | | | |
| | | | \ ^__^ | | | |
| | | | \ (oo)\_______ | | | |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

How to Classify a sklearn classifier

from sklearn.ensemble import RandomForestRegressor, ExtraTreesRegressor, AdaBoostRegressor, ExtraTreesClassifier, RandomForestClassifier, AdaBoostClassifier
from sklearn.gaussian_process import GaussianProcessRegressor
from sklearn.kernel_ridge import KernelRidge
from sklearn.linear_model import LinearRegression, Lasso, LogisticRegression
from sklearn.neural_network import MLPRegressor, MLPClassifier
from sklearn.svm import SVC, SVR
from sklearn.tree import DecisionTreeRegressor, DecisionTreeClassifier