Skip to content

Instantly share code, notes, and snippets.

View Terkwood's full-sized avatar
🏳️‍⚧️

Elaine Terkwood

🏳️‍⚧️
  • Salesforce
  • Indiana, USA
  • 15:22 (UTC -05:00)
View GitHub Profile
@Terkwood
Terkwood / main.rs
Created October 16, 2022 18:54
emoji-friendly iterator over chars
/// https://stackoverflow.com/a/50396438
/// https://stackoverflow.com/questions/47193584/is-there-an-owned-version-of-stringchars
use std::io::{BufRead, BufReader, Read};
use std::vec::IntoIter;
struct Chunks {
remaining: IntoIter<char>,
}
@Terkwood
Terkwood / keybase.md
Created January 21, 2022 15:41
keybase.md

Keybase proof

I hereby claim:

  • I am terkwood on github.
  • I am terkwood (https://keybase.io/terkwood) on keybase.
  • I have a public key ASCBCEmPEZhERf6TRBFM_Ed-SX-sLAVcOEHquPb0nT0Mvgo

To claim this, I am signing this object:

@Terkwood
Terkwood / after-note.tpl
Created October 2, 2021 23:34
show timestamp in emanote
<!-- templates/hooks/after-note.tpl -->
<ema:metadata>
<span class="mr-2 text-right text-gray-600">
<value var="date" />
</span>
</ema:metadata>
# Controller option 1, implicit render selected based on format
defmodule MyApp.UserController do
use Phoenix.Controller
def show(conn, %{"id" => id}) do
render conn, :show, user: Repo.get(User, id)
end
end
# Controller option 2, explicit render with format pattern match
@Terkwood
Terkwood / install_elixir.md
Created July 12, 2021 19:44 — forked from rubencaro/install_elixir.md
Elixir installation guide

Elixir installation guide

Version numbers should be the ones you want. Here I do it with the last ones available at the moment of writing.

The simplest way to install elixir is using your package manager. Sadly, at the time of writing only Fedora shows the intention to keep its packages up to date. There you can simply sudo dnf install erlang elixir and you are good to go.

Anyway, if you intend to work with several versions of erlang or elixir at the same time, or you are tied to a specific version, you will need to compile it yourself. Then asdf is your best friend.

@Terkwood
Terkwood / Lambda.scala
Created March 8, 2021 19:33 — forked from RaasAhsan/Lambda.scala
Type-level, untyped lambda calculus in Scala 3
object Lambda extends App {
sealed trait Term
sealed trait Var[I <: Index] extends Term
sealed trait App[T1 <: Term, T2 <: Term] extends Term
sealed trait Abs[T1 <: Term] extends Term
sealed trait If[T1 <: Term, T2 <: Term, T3 <: Term] extends Term
sealed trait Bool[T1 <: Boolean] extends Term
sealed trait Index
@Terkwood
Terkwood / global-gitignore.md
Created March 6, 2021 15:57 — forked from subfuzion/global-gitignore.md
Global gitignore

There are certain files created by particular editors, IDEs, operating systems, etc., that do not belong in a repository. But adding system-specific files to the repo's .gitignore is considered a poor practice. This file should only exclude files and directories that are a part of the package that should not be versioned (such as the node_modules directory) as well as files that are generated (and regenerated) as artifacts of a build process.

All other files should be in your own global gitignore file. Create a file called .gitignore in your home directory and add anything you want to ignore. You then need to tell git where your global gitignore file is.

Mac

git config --global core.excludesfile ~/.gitignore

Windows

git config --global core.excludesfile %USERPROFILE%\.gitignore

#Inject javascript into HTML pages from console

An easy way to inject Javascripts into the current loaded dom using the developer console in chrome.

jQuery

var script = document.createElement('script');
script.src = 'http://code.jquery.com/jquery-1.7.2.min.js';
@Terkwood
Terkwood / gist:89348347bb11ed58d7b38c1d5217de67
Created January 17, 2021 14:02 — forked from danking/gist:1068185
A very simple example showing how to use Racket's lexing and parsing utilities
#lang racket
(require parser-tools/lex
(prefix-in re- parser-tools/lex-sre)
parser-tools/yacc)
(provide (all-defined-out))
(define-tokens a (NUM VAR))
(define-empty-tokens b (+ - EOF LET IN))
(define-lex-trans number
(syntax-rules ()
@Terkwood
Terkwood / writeup.md
Created November 30, 2020 17:14 — forked from edmundsmith/writeup.md
Method for Emulating Higher-Kinded Types in Rust

Method for Emulating Higher-Kinded Types in Rust

Intro

I've been fiddling about with an idea lately, looking at how higher-kinded types can be represented in such a way that we can reason with them in Rust here and now, without having to wait a couple years for what would be a significant change to the language and compiler.

There have been multiple discussions on introducing higher-ranked polymorphism into Rust, using Haskell-style Higher-Kinded Types (HKTs) or Scala-looking Generalised Associated Types (GATs). The benefit of higher-ranked polymorphism is to allow higher-level, richer abstractions and pattern expression than just the rank-1 polymorphism we have today.

As an example, currently we can express this type: