Skip to content

Instantly share code, notes, and snippets.

View DataKinds's full-sized avatar
💖
new blog theme! check it out at https://datakinds.github.io/

Tyler DataKinds

💖
new blog theme! check it out at https://datakinds.github.io/
View GitHub Profile
template<std::vector<std::string>* arg, std::string_view* flag, std::function<void()>* f>
struct CommandLineLambda {
//returns whether or not the argument was called
static inline bool runArg() {
auto iter = std::find(arg->begin(), arg->end(), *flag);
if (iter != arg->end()) {
(*f)();
return true;
}
return false;
@DataKinds
DataKinds / CLN.hs
Last active March 2, 2018 06:24
Interface to the C-L Prime Construction of the Naturals
module CLN where
import Data.List
data CLNElem = Dot | Parens [CLNElem]
instance (Show CLNElem) where
show Dot = "."
show (Parens clnes) = "(" ++ (concatMap show clnes) ++ ")"
newtype CLN = CLN [CLNElem]
instance (Show CLN) where
@DataKinds
DataKinds / racket_mandelbrot.rkt
Last active February 13, 2018 02:05
Racket program to output a mandelbrot fractal
#lang racket
(require racket/draw)
(define HEIGHT 200)
(define WIDTH 400)
(define UNIT_PER_PIXEL 0.012)
(define HEIGHT/2 (/ HEIGHT 2))
(define WIDTH/2 (/ WIDTH 2))
@DataKinds
DataKinds / periodic_table.rb
Created January 30, 2018 16:55
Computes the atomic mass of an equation
table = {}
DATA.read.split(?\n).each do |line|
ps = line.split(/\s+/)
table[ps[2]] = ps[0].to_f
end
loop do
i = gets.chomp
input = i.scan(/([A-Z][a-z]?)([0-9]?)/)
mass = 0
input.each do |element|
@DataKinds
DataKinds / chain-mail.rb
Last active December 31, 2016 01:28
Simulate the sending of chain mail that depends on generations
#a person will have, averagely, around double the specified value
#because when it's generated, everyone has to be friends with those
#who are friends with them
AMOUNT_OF_FRIENDS = 1
FRIEND_VARIANCE = 4
POPULATION = 7400 #7.4 billion in 1000's
def a(n)
if n <= 1
1
@DataKinds
DataKinds / average.rb
Last active December 24, 2016 00:31
the ultimate font generator
#!/bin/ruby
`mkdir mean-letters`
`mkdir final-letters`
('a'..'z').each do |letter|
puts "layering #{letter}"
`convert letters/#{letter}/* -evaluate-sequence mean mean-letters/#{letter}.png`
`convert mean-letters/#{letter}.png -threshold 65% final-letters/#{letter}.png`
end
@DataKinds
DataKinds / markov.rb
Created July 7, 2016 20:38
random word generator (with multiple methods, based off of a previous markov generator)
require 'json'
TRUELOOKFORWARD = true
LOOKFORWARD = 2 #how many words forward it generates from a seed word
def prepareString(str)
#return str.downcase.split(/(\W)+/).map{|word| word.gsub(/\s+/, "")}.reject{|word| word == ""} to remind you what it was
return str.split("").push("").unshift("")
end
@DataKinds
DataKinds / Makefile
Last active June 23, 2016 04:10
math notation calculator
all:
gcc -o expression -std=c11 main.c
@DataKinds
DataKinds / Makefile
Last active June 20, 2016 05:10
controls kbd+mouse with a controller
all:
gcc -lX11 -lpthread -lXtst -std=gnu11 main.c
@DataKinds
DataKinds / coderunner.rb
Last active June 15, 2016 08:50
just my lil discord bot
module CodeRunner
def self.runCode(code, interpreter)
badKeywords = ["\`", "popen", "gets", "STDIN", "interact", "input", "system", "File", "file", "IO", "eval", "exec", "open", "write", "read", "Socket"]
malicious = false
badKeywords.each do |word|
if code.include? word then
malicious = true
end
end