Skip to content

Instantly share code, notes, and snippets.

@nikoheikkila
nikoheikkila / README.md
Last active November 14, 2024 07:16
Fish Shell function for sourcing standard .env files

envsource

⚠️ NOTE (20.5.2023): I don't really use this function at all anymore since there are now tools such as Taskfile, which reads the .env file for me sparing me the need to pollute my session with environment variables.


I've been using Fish shell for years which is great and all, but one thing that has got me frustrated is using it with .env files.

When attempting to run source .env in a project, I usually encounter this problem:

@naddeoa
naddeoa / Makefile
Created November 5, 2018 20:49
Using a Makefile to build TypeScript and React Native
workspace.dir := $(PWD)
workspace.node_modules := $(workspace.dir)/node_modules
typescript.src.dir := $(workspace.dir)/src
typescript.src.ts := $(shell find $(typescript.src.dir) -name '*.ts' -type f)
typescript.src.tsx := $(shell find $(typescript.src.dir) -name '*.tsx' -type f)
typescript.src.files := $(typescript.src.ts) $(typescript.src.tsx)
typescript.build.dir := $(workspace.dir)/artifacts
typescript.build.ts := $(patsubst $(typescript.src.dir)%.ts,$(typescript.build.dir)%.js, $(filter %.ts,$(typescript.src.files)))
@VictorTaelin
VictorTaelin / promise_monad.md
Last active October 24, 2024 01:25
async/await is just the do-notation of the Promise monad

async/await is just the do-notation of the Promise monad

CertSimple just wrote a blog post arguing ES2017's async/await was the best thing to happen with JavaScript. I wholeheartedly agree.

In short, one of the (few?) good things about JavaScript used to be how well it handled asynchronous requests. This was mostly thanks to its Scheme-inherited implementation of functions and closures. That, though, was also one of its worst faults, because it led to the "callback hell", an seemingly unavoidable pattern that made highly asynchronous JS code almost unreadable. Many solutions attempted to solve that, but most failed. Promises almost did it, but failed too. Finally, async/await is here and, combined with Promises, it solves the problem for good. On this post, I'll explain why that is the case and trace a link between promises, async/await, the do-notation and monads.

First, let's illustrate the 3 styles by implementing

@aengelberg
aengelberg / core.clj
Created February 3, 2017 16:53
Manifold examples
(ns hello-manifold.core
(:require
[aleph.http :as http]
[byte-streams :as bs]
[cheshire.core :as json]
[clojure.string :as str]
[manifold.deferred :as d]
[manifold.executor :as e]
[manifold.stream :as s]))
@naddeoa
naddeoa / xps-touchscreen-workaround.service
Last active February 14, 2024 22:03
I just got an XPS and I ran into the issue where the touch screen stops working after resume. After doing a little digging, I was able to find out that this is fixed in the Linux kernel by a developer named Mika Westerberg. I got in touch with him and he was able to set me off on the right track for developing a proper work around that I could u…
[Unit]
Description=Potentially dangerous fix touchscreen after resume on the XPS 13 9350
After=suspend.target
[Service]
Type=simple
ExecStart=/home/anthony/path/to/xps-touchscreen-workaround.sh
[Install]
WantedBy=suspend.target
@j-hannes
j-hannes / Main.elm
Last active October 4, 2016 13:13
Hello world example from elm-lang.org
module Main exposing (..)
import Html exposing (Html, span, text)
import Html.Attributes exposing (class)
main : Html a
main =
span [ class "welcome-message" ] [ text "Hello, World!" ]
@yang-wei
yang-wei / destructuring.md
Last active November 3, 2024 16:23
Elm Destructuring (or Pattern Matching) cheatsheet

Should be work with 0.18

Destructuring(or pattern matching) is a way used to extract data from a data structure(tuple, list, record) that mirros the construction. Compare to other languages, Elm support much less destructuring but let's see what it got !

Tuple

myTuple = ("A", "B", "C")
myNestedTuple = ("A", "B", "C", ("X", "Y", "Z"))
@gchiam
gchiam / tmux-theme-gruvbox.conf
Created October 7, 2015 00:34
gruvbox color scheme for tmux
# This tmux statusbar config was created based on gruvbox colorscheme
set -g status "on"
set -g status-justify "left"
set -g status-left-length "100"
set -g status-right-length "100"
set -g status-right-attr "none"
set -g status-attr "none"
set -g status-utf8 "on"
set -g status-left-attr "none"
@ylegall
ylegall / select.d
Created November 8, 2013 04:17
Use order statistics to select the median of an array in linear time without sorting.
import std.stdio;
auto swap(T)(ref T a, ref T b) {
T tmp = a;
a = b;
b = tmp;
}
auto part(T)(T[] array, int low, int high) {
auto size = low-1;
@ylegall
ylegall / randset.d
Last active December 21, 2015 15:19
A data structure with: O(1) random access, O(1) insertion, and O(1) deletion.
/**
* data structure with:
* O(1) random access
* O(1) insertion
* O(1) deletion
* O(1) containment
*/
class RandomAccessSet(T)
{
private {