Skip to content

Instantly share code, notes, and snippets.

@mattdesl
mattdesl / cli.js
Created September 13, 2022 10:37
colour palette from text prompt using Stable Diffusion https://twitter.com/mattdesl/status/1569457645182152705
/**
* General-purpose NodeJS CLI/API wrapping the Stable-Diffusion python scripts.
*
* Note that this uses an older fork of stable-diffusion
* with the 'txt2img.py' script, and that script was modified to
* support the --outfile command.
*/
var { spawn, exec } = require("child_process");
var path = require("path");
@sammaxwellxyz
sammaxwellxyz / jrnl.sh
Created February 20, 2020 11:18
A bash script for a journaling alias
function jrnl(){
mkdir -p "$HOME/.journal/"
if [ -z "$1" ]; then
local esc=$(printf '\033')
local prev=$([[ `date +"%u"` == "1" ]] && echo `date -v-3d +%F` || echo `date -v-1d +%F`)
if [ -f "$HOME/.journal/`date +"%F"`.txt" ]; then
echo "${esc}[36mToday"
/bin/cat "$HOME/.journal/`date +"%F"`.txt" 2>/dev/null | sed "s/\([0-9:]*\)\(\.*\)/${esc}[35m\1${esc}[39m \2/"
fi
if [ -f "$HOME/.journal/$prev.txt" ]; then
@getify
getify / 1.js
Last active September 29, 2021 11:58
experiment: mimicking React's new "useState()" hook for stand-alone functions, including "custom hooks"
"use strict";
[foo,bar] = TNG(foo,bar);
// NOTE: intentionally not TNG(..) wrapping useBaz(), so that it's
// basically like a "custom hook" that can be called only from other
// TNG-wrapped functions
function foo(origX,origY) {
var [x,setX] = useState(origX);
var [y,setY] = useState(origY);
@staltz
staltz / streamio.js
Created October 3, 2016 13:22
Playful Haskell Stream I/O with ES6 Generators
function *main() {
const confirmRequest = {
type: 'confirm',
value: 'Are you sure?',
};
const confirmResponse = yield confirmRequest;
if (confirmResponse === true) {
const consoleRequest = {
type: 'console',
@eloypnd
eloypnd / dnsmasq_setup_osx.md
Last active April 28, 2024 14:32
wildcard DNS record on OS X in localhost development with dnsmasq

wildcard DNS in localhost development

$ brew install dnsmasq
   ...
$ cp /usr/local/opt/dnsmasq/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf
  • edit /usr/local/etc/dnsmasq.conf
address=/local/127.0.0.1
@evilsoft
evilsoft / Writer.js
Last active November 16, 2019 09:14
Valid Writer in javascript?
// Based on http://adit.io/posts/2013-06-10-three-useful-monads.html
import map from 'ramda/src/map'
import compose from 'ramda/src/compose'
import curry from 'ramda/src/curry'
import multiply from 'ramda/src/multiply'
const chain = curry((fn, m) => m.chain(fn))
const read = m => m.read()
@deebloo
deebloo / rxjs-worker-map.example.js
Last active August 19, 2016 17:24
A RxJs operator that runs in a new thread. https://github.com/deebloo/rxjs-worker
// https://github.com/deebloo/rxjs-worker
var observable = Observable.of([0, 1, 2, 3, 4]);
observable
.map(function (data) {
return data.concat([5, 6, 7, 8, 9]);
})
.workerMap(function (data) {
return data.concat([10,11,12,13,14]);;
})
@gusty
gusty / polyvariadic.fsx
Last active July 20, 2023 15:19
Polyvariadic functions in F#
// Unfortunatelly it stopped working in F# 4.1 after this PR https://github.com/Microsoft/visualfsharp/pull/1650
// Will ask to revert it
type FoldArgs<'t> = FoldArgs of ('t -> 't -> 't)
let inline foldArgs f (x:'t) (y:'t) :'rest = (FoldArgs f $ Unchecked.defaultof<'rest>) x y
type FoldArgs<'t> with
static member inline ($) (FoldArgs f, _:'t-> 'rest) = fun (a:'t) -> f a >> foldArgs f
static member ($) (FoldArgs f, _:'t ) = f
@zackferrofields
zackferrofields / gulpfile.js
Last active September 19, 2015 19:33
Inline JavaScript (ES6) unit-tests with node, gulp, speckjs, babel & tape
require('babel-core/register');
var babel = require('babel-core');
var gulp = require('gulp');
var speckjs = require('speckjs');
var tape = require('tape');
var through = require('through2');
function requireFromBuffer(buffer) {
var m = new module.constructor();
m.paths = module.paths;
dependencies:
pre:
- source /etc/lsb-release && echo "deb http://download.rethinkdb.com/apt $DISTRIB_CODENAME main" | sudo tee /etc/apt/sources.list.d/rethinkdb.list
- wget -qO- http://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add -
- sudo apt-get update
- sudo apt-get install rethinkdb=1.16.3~0precise
- sudo cp /etc/rethinkdb/default.conf.sample /etc/rethinkdb/instances.d/instance1.conf
- sudo /etc/init.d/rethinkdb restart