Skip to content

Instantly share code, notes, and snippets.

@igstan
igstan / fp.md
Created June 14, 2011 14:41
Patterns and idioms in functional languages

I'll throw my opinion in here, but take it with a pretty large grain of salt as I've done no professional development in a functional language yet. Just tinkering with (quite a few of) them in my spare time. Some of the patterns I spotted are irrespective of type systems (static, dynamic).

  • lists, sequences or similar primitives are ubiquitous
  • abstract away duplicate code using higher-order functions
  • no iteration constructs, recursion is the only way to traverse lists
  • watch out your recursion, be sure it's tail-recursive
  • abstract over this tail-recursive pattern with a higher-order function: foldLeft or foldRight. So, know your language's equivalent of foldLeft/foldRight and prefer these over explicit recursion.
  • abstract over folds in an even more general way and provide folding functions for arbitrary data structures, not just list, e.g., trees.
  • provide a few convenience higher-order functions (implementable using fold) like: map, filter, any/some, all/every, zip, `zipWith
@osfameron
osfameron / gist:1545468
Created December 31, 2011 21:59
Finnish Christmas treats from Dec 2011
Perunalaatikko
--------------
This came out like a rather posh, creamy, and caramelised potato mash. It does take rather a long
time with the fermenting and slow cooking, but I think was worth it. I remember the versions
we ate as kids being more fermented (this one was perhaps more to my taste, perhaps because not
so warm in Edinburgh kitchen to really ferment it)
1 kg potatoes (old mashing potatoes)
1 dl flour
@evancz
evancz / Architecture.md
Last active December 21, 2022 14:28
Ideas and guidelines for architecting larger applications in Elm to be modular and extensible

Architecture in Elm

This document is a collection of concepts and strategies to make large Elm projects modular and extensible.

We will start by thinking about the structure of signals in our program. Broadly speaking, your application state should live in one big foldp. You will probably merge a bunch of input signals into a single stream of updates. This sounds a bit crazy at first, but it is in the same ballpark as Om or Facebook's Flux. There are a couple major benefits to having a centralized home for your application state:

  1. There is a single source of truth. Traditional approaches force you to write a decent amount of custom and error prone code to synchronize state between many different stateful components. (The state of this widget needs to be synced with the application state, which needs to be synced with some other widget, etc.) By placing all of your state in one location, you eliminate an entire class of bugs in which two components get into inconsistent states. We also think yo
@timmc
timmc / ramdisk-target.sh
Last active October 12, 2017 19:39
Mount a ramdisk over target
#!/bin/bash
# Overwrite ./target with a tmpfs ramdisk. Prompts for sudo.
function usage() {
echo 'Usage: `ramdisk-target.sh recreate|restore`'
}
if [ ! -f "project.clj" ]; then
echo "Not in Clojure project."
exit 2
@noisesmith
noisesmith / repl
Last active January 11, 2017 20:39
use all non-macros from target ns in local scope
phoenix.core=> (user/with-use user (+ 1 1))
2
phoenix.core=> (macroexpand-1 '(user/with-use user (+ 1 1)))
(clojure.core/let [help user/help find-name user/find-name non-macros user/non-macros src-dir user/src-dir exercise-coverage user/exercise-coverage apropos-better user/apropos-better] (+ 1 1))
@vmandic
vmandic / dotnet core .gitignore
Last active July 18, 2024 09:03
A default .NET Core project .gitignore file - or just type `dotnet new gitignore`
# From .NET Core 3.0 you can use the command: `dotnet new gitignore` to generate a customizable .gitignore file
*.swp
*.*~
project.lock.json
.DS_Store
*.pyc
# Visual Studio Code
.vscode
"use strict"
var diff2html = require("diff2html").Diff2Html;
var unidiff = require('unidiff');
var stringify = require('json-stable-stringify');
exports.stableStringify = function(x) {
return stringify(x);
}
exports.isJsonEqual = function(a) {

Here's some commentary and a list of links that people find helpful as they explore and evaluate GitHub Actions.

GitHub Actions 101

Actions is a CI/CD automation platform built natively within GitHub SCM. Check out the official introduction to GitHub Actions docs article to learn more. Here's the high-level gist of what Actions is:

  • Automate everything. GitHub Actions uses script automation to automate core CI/CD activities (code scan, code compilation, e2e testing, packaging, deployment), a vast variety of SCM activities within GitHub, and a another vast variety of activities that take place outside of GitHub. Learn about events that trigger GitHub Actions automation here.
  • Automate with workflows. Automation scripts or pipelines are called "workflows" and are written and stored in YAML as a workflow file in the .github/w