Skip to content

Instantly share code, notes, and snippets.

View rewinfrey's full-sized avatar
🏄‍♂️
fix f = let x = f x in x

Rick Winfrey rewinfrey

🏄‍♂️
fix f = let x = f x in x
View GitHub Profile
@rewinfrey
rewinfrey / ex.rb
Last active January 21, 2022 00:05
Shows examples of Ruby 3.1's new hash value omission syntax
# Hash value omission in Ruby 3.1: https://bugs.ruby-lang.org/issues/14579
x = 1
y = 2
a = {x:, y:}
p a # => {:x=>1, :y=>2}
module XY
def x; 10; end
{
"a": null,
"b": true,
"c": false,
"d": 123,
"e": "string",
"f": [1,2,3],
"g": { "h": true },
}

Ingredients

  • 1 can 28oz whole or crushed tomatoes (Scalfani tomatoes are the best)
  • 1 small white onion (can also substitute green onion)
  • half a bundle of cilantro
  • handful fresh oregano
  • 2-4 garlic cloves
  • 1-2 jalepenos
  • juice from 1/2 lime
  • 2 tsp sea salt or kosher salt
package VoltIJ.gui.layers;
import VoltIJ.core.Font;
import com.sun.opengl.util.texture.Texture;
import com.sun.opengl.util.texture.TextureIO;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.media.opengl.GL;
@rewinfrey
rewinfrey / example.java
Created February 1, 2018 07:25
Difference in instantiation semantics in Java for String.
class Playground {
public static void main(String[ ] args) {
String[] ex1 = new String[] { new String("a"), "b" };
String[] ex2 = new String[] { new String("a"), "b" };
evaluateReferenceEquality(ex1, ex2);
evaluateValueEquality(ex1, ex2);
}
@rewinfrey
rewinfrey / friday.md
Last active August 4, 2017 01:30
Schedule
@rewinfrey
rewinfrey / Thing.hs
Created July 12, 2017 07:10
What do you do when you have a Thing but no db id?
#!/usr/bin/env stack
-- stack script --resolver lts-8.12
{-# LANGUAGE OverloadedStrings #-}
import Data.Text
import System.Random
data Thing = Thing { id :: Int, name :: Text } deriving Show
main :: IO ()
@rewinfrey
rewinfrey / Thing.hs
Created July 12, 2017 07:10
What do you do when you have a Thing but no db id?
#!/usr/bin/env stack
-- stack script --resolver lts-8.12
{-# LANGUAGE OverloadedStrings #-}
import Data.Text
import System.Random
data Thing = Thing { id :: Int, name :: Text } deriving Show
main :: IO ()
@rewinfrey
rewinfrey / decorator.md
Created July 7, 2017 19:19
What is a Python Decorator?

Decorators in Python

Given a function:

def example():
  return

Given a function that takes as one of its inputs a function (we'll call this our decorator):

@rewinfrey
rewinfrey / maybe.rb
Created June 13, 2017 16:59
Maybe in Ruby
class Maybe
attr_reader :run_maybe
def initialize(result)
@run_maybe = construct(result)
end
def construct(result)
if result == ""
Nothing.new