Skip to content

Instantly share code, notes, and snippets.

@antimatter15
antimatter15 / dynamic.js
Last active December 2, 2018 23:43
Dynamic Scoped Javascript
// Part I: The Magic
// The crux of this are two methods: pushStackTokens and readStackTokens
// They form the primitives for manipulating the Javascript VM's call stack
// pushStackTokens allows us to inject information (tokens) into the call stack
// readStackTokens allows us to retrieve all the stack tokens in the
// current call stack.
function pushStackTokens(tokens, fn, ...args){
tokens.forEach(tok => console.assert(/^\w+$/.test(tok),
;; In response to blog post:
;; https://medium.com/@kasperpeulen/10-features-from-various-modern-languages-that-i-would-like-to-see-in-any-programming-language-f2a4a8ee6727
;; Run with lumo
;; https://github.com/anmonteiro/lumo
;;
;; # npm install -g lumo-cljs
;; lumo clojurescript-feature-examples.cljs
@voidfiles
voidfiles / index.json
Created May 19, 2017 22:08
Hugo JSON Feed Template add to layouts/index.json
{
"version": "https://jsonfeed.org/version/1",
"title": {{ .Site.Title | jsonify }},
"home_page_url": {{ .Permalink | jsonify }},
{{ with .OutputFormats.Get "json" -}}
"feed_url": {{ .Permalink | jsonify }},
{{- end }}
{{ if (.Site.Params.author) or (.Site.Params.author_url) -}}
"author": {
{{ if .Site.Params.author -}}
@purukaushik
purukaushik / Competitive.java
Created December 7, 2016 07:35
Competitive Programming template
package io.purush.hadoop.giscup.script;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
public class Main {
private static int totalchars = 0, offset = 0;
private static InputStream stream;
@chiragtoor
chiragtoor / text_example.ex
Last active January 9, 2020 21:37
Example Elixir code for sending a text message through ExTwilio
def send_text_message(phone_number, message) do
ExTwilio.Api.create(ExTwilio.Message,
[to: phone_number,
from: Application.get_env(:ex_twilio, :send_number),
body: message])
end
@cobalamin
cobalamin / HaskellVsElm.md
Last active April 2, 2022 09:19
Elm (0.17) syntax and functionality differences for Haskell programmers
  • Types are declared with : and not ::, and the consing operator conversely is :: instead of :
  • No where clauses, only let/in
  • The standard style is different, check http://elm-lang.org/docs/style-guide for reference
  • Multiline strings are a thing with """
  • Haskell's data corresponds to type in Elm, and also, Haskell's type corresponds to Elm's type alias
  • ($) is (<|), but you don't use it all that much – Elm people like the flipped operator (|>) which lets you build something that reads like a pipeline
  • Related: Backticks will likely die soon in favour of functions that have an argument order that lends itself to pipelining with (|>)
  • Also, (.) is (<<), and a flipped version (>>) exists, but I don't see it used that much either
  • (&gt;&gt;=) is not an available operator and would not be polymorphic (no typeclasses, see below), and is instead commonly named SomeType.andThen – e.g. Maybe.andThen : Maybe a -&gt; (a -&gt; Maybe b) -&gt; Maybe b
/**
* Called if a parameter is missing and
* the default value is evaluated.
*/
function mandatory() {
throw new Error('Missing parameter');
}
function foo(mustBeProvided = mandatory()) {
return mustBeProvided;
}
@emyarod
emyarod / color-map.scss
Created April 8, 2016 09:35
Google Material Design colors in a Sass map
// $primary: get-color('cyan', '500');
@function get-color($color-hue, $color-shade: '500') {
$color: map-get(map-get($colors, $color-hue), $color-shade);
@if $color {
@return $color;
} @else { @error '=> ERROR'; }
}
$colors: (
@masahirompp
masahirompp / User.ts
Last active May 5, 2021 20:04
mongoose + typescript
/// <reference path="../tsd/tsd.d.ts" />
import mongoose = require('mongoose');
import passport = require('passport');
interface IUser extends mongoose.Document {
provider: string;
id: string;
authorId: string;
displayName: string;
@johnpolacek
johnpolacek / .gitconfig
Last active May 8, 2024 04:05
My current .gitconfig aliases
[alias]
co = checkout
cob = checkout -b
coo = !git fetch && git checkout
br = branch
brd = branch -d
brD = branch -D
merged = branch --merged
st = status
aa = add -A .