Skip to content

Instantly share code, notes, and snippets.

View glossawy's full-sized avatar
🍂
its autumn

Autumn Winter glossawy

🍂
its autumn
  • New York
  • 13:23 (UTC -04:00)
View GitHub Profile
@glossawy
glossawy / gist:d4632f595cab9fbf27a0
Created October 25, 2014 05:27
Sentence Reversal Exercise Quick Solution
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
public class SentenceReversal {
public static void main(String[] args){
// Initialize Scanner using Try-With-Resources to AutoClose Scanner
// Opens file at ./inputs/SentenceRev.in
try(Scanner scanner = new Scanner(new File("inputs", "SentenceRev.in"))){
@glossawy
glossawy / Fractions.java
Last active August 29, 2015 14:08
Quickest Simplified Fraction
import java.io.IOException;
import java.math.BigInteger;
import java.nio.file.Paths;
import java.util.Scanner;
// Method using BigInteger's built in BigInteger.gcd(BigInteger) method
public class Fractions {
public static void main(String[] args) {
try(Scanner scan = new Scanner(Paths.get("Inputs", "nofluff", "Fractions.in"))) {
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.
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)
@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
(* 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
(* 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
{
"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"
@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

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: