This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const quips = [ | |
"NaN days since last JS incident!", | |
"function funCallFun() { funCallFun(); }", | |
"Will code for food!", | |
"In a love/hate relationship with JS since 2012!", | |
"If you see this, the JS didn't load!", | |
"Natural 20!" | |
]; | |
function randQuip() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# An implementation of Haskell's arrow library in Python, done as an exercise | |
from __future__ import annotations | |
from typing import Callable | |
class Arrow: | |
def __init__(self, func): | |
self.func = func | |
def __call__(self, *args): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; Haskell's arrow library implemented in common lisp as an exercise | |
;;; date: 2019-09-17 | |
;;; author: Niko L. | |
(defstruct arrow func) | |
(defmacro arr (args &body body) | |
`(make-arrow :func (lambda ,args ,@body))) | |
(defun run (arrow arg) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! python | |
import os, sys, mimetypes, pprint | |
from typing import Optional, Dict | |
# Lists the file types and their associated line endings in a file tree | |
types: Dict[str, list] = {} | |
def guess_filetype(path: str) -> Optional[str]: | |
"""Returns just the type returned by mimetypes.guess_type, not its encoding""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! python | |
import os, sys, mimetypes | |
from typing import Optional | |
# Attempts to fix the line endings in all files in a given folder and its subfolders. | |
ALLOWED_FILETYPES = [ | |
'text/plain', 'application/json', 'text/html', 'application/xml', 'text/xml', | |
'application/xhtml+xml', 'application/vnd.ms-excel', 'text/css', 'application/javascript' | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use specs::prelude::*; | |
use specs_derive::*; | |
#[derive(Component)] | |
#[storage(VecStorage)] | |
struct Position { | |
x: i32, | |
y: i32, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use specs::prelude::*; | |
use specs_derive::*; | |
#[derive(Component)] | |
#[storage(VecStorage)] | |
struct Position { | |
x: i32, | |
y: i32, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Inspired by the Razzle Dazzle scam on YouTube: https://www.youtube.com/watch?v=527F51qTcTg | |
# Note that this always assumes fair play | |
## | |
# Keeps track of the outcome of any given dice roll | |
# +points+ is how many points a given field is worth | |
# +prize+ is how many prizes are being added to your current pool of prizes | |
# +cost_mult+ is the cost multiplier of a given spot | |
class Outcome | |
attr_reader :points, :prize, :cost_mult |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/ruby | |
require './prompt' | |
# Exit early if a file name hasn't been provided | |
if ARGV.length < 1 then | |
puts "Please provide an identifier" | |
exit | |
end | |
# Gets all the strings that include the provided identifier |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/ruby | |
# Somewhat counter-intuitively, Ruby's ARGV doesn't include the file name, | |
# so the vector is 1 shorter than normal. | |
# Typically writing ./mkcpp.rb foo would give a vector like ARGV = ["mkcpp.rb", "foo"], but not here. | |
if ARGV.length < 1 then | |
puts "Please provide a sufficient number of arguments" | |
exit | |
end |