Skip to content

Instantly share code, notes, and snippets.

View glossawy's full-sized avatar
🍂
its autumn

Autumn Winter glossawy

🍂
its autumn
  • New York
  • 16:43 (UTC -04:00)
View GitHub Profile
@glossawy
glossawy / quackquack.py
Created July 12, 2022 20:19
Demonstrating the successor function
class Duck:
def __init__(self, quacks=0):
self._quacks = quacks
def __add__(self, more_quacks):
return Duck(self._quacks + more_quacks)
def __str__(self):
return ('quack ' * self._quacks)[:-1]

Bowling Score Calculator

Goal

Write a basic bowling game scoring calculator, which accepts individual rolls and provides the correct score for them.

How bowling scoring works

A bowling game is broken down into multiple attempts to knock down 10 pins with your ball. Each turn you get two attemps to knock down all 10 pins. Each turn is called a frame during scoring.

Open frames

Keybase proof

I hereby claim:

  • I am glossawy on github.
  • I am glossawy (https://keybase.io/glossawy) on keybase.
  • I have a public key whose fingerprint is A5CF C55B 0006 7297 9C0B 3984 5215 2AC3 6BA6 2186

To claim this, I am signing this object:

@glossawy
glossawy / _example-output.txt
Created October 16, 2020 18:25
A script that takes an mustache html template file, a yaml file of template parameters, and uses wkhtmltopdf to render it out to a pdf, optionally printing json and GET param strings for postmaster. This will automatically install the gems it needs using inline bundler. wkhtmltopdf is required. Script may be updated to use the `wkhtmltopdf-binar…
<path>/hubservices_hub_only_transfer_coversheet.html
<path>/hubservices_transfer_coversheet_values.yaml
wkhtmltopdf --load-error-handling ignore <path>/hubservices_hub_only_transfer_coversheet.html.tmp.html <path>/hubservices_hub_only_transfer_coversheet.html.pdf
Loading pages (1/6)
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done
{
"id": "z05wo1jm",
"weblink": "https://www.speedrun.com/ge/run/z05wo1jm",
"game": "nj1ne1p4",
"level": "p5927w6v",
"category": "p7kjpnk3",
"videos": {
"links": [
{
"uri": "https://www.youtube.com/watch?v=uTEIliUJqHU"
(* Standard ML of New Jersey v110.91 *)
structure Cont = SMLofNJ.Cont
type 'a cont = 'a Cont.cont
val callcc = Cont.callcc
val throw = Cont.throw
(* Function application for reducing parens a la Haskell *)
infix 3 $
fun f $ x = f x
(* Standard ML of New Jersey v110.91 *)
(* Function application for reducing parens a la Haskell *)
infix 3 $
fun f $ x = f x
fun curry f x y = f (x, y)
(* List Helpers *)
fun filter f = List.filter f
@glossawy
glossawy / simpler.js
Last active August 3, 2020 03:39
Vanilla JS implementation of QuickSort that attempts to mimick ramda somewhat
/*
Vanilla js equivalent of a ramda quicksort (using ES6 features)
Note:
1. I use arrays and not lists
2. I do not implement the placeholder helper, not difficult to add but requires more thought
3. Opted for a curried ifThenElse function
4. In some places I use ES6 features to avoid further recursion, though its possible to encompass
the recursion in a foldl/foldr
5. I implement pipe to match the ramda example
import math
"""
I don't include this detail i nthe docstring for approx_sqrt since it's more than what is needed, someone
looking to understand Newton-Raphson will look it up on wikipedia after reading that docstring. But for
your sake Newton-Raphson states that to find the roots of any function f(x) we need an initial guess
called x_0. The further away this guess is from the actual root, the longer it takes. Then we get the
first approximation, x_1, using:
x_1 = x_0 - f(x0)/f_prime(x0)
import math
# CS 1 does not encourage Global variables. I only use them for this example!
# even then I use conventions indicating private variables (_ or __)
# Ignore the operators and anything you may not know yet! The documentation is the important part!
# Very descriptive because bit operations are VERY obfuscated
"""
Descriptive comments for complex/unclear operations.