Skip to content

Instantly share code, notes, and snippets.

View Siilwyn's full-sized avatar
🦀

Selwyn Siilwyn

🦀
View GitHub Profile
@Siilwyn
Siilwyn / configuration.nix
Created November 16, 2020 08:00
Nix is too hard to use, config dump
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
];
boot.loader.grub.enable = true;
boot.loader.grub.version = 2;
@Siilwyn
Siilwyn / npm-netlify.toml
Last active March 6, 2023 12:41
Netlify TOML configuration for static websites
[build]
command = "npm run build"
publish = "dist"
[build.environment]
NODE_ENV = "production"
NPM_CONFIG_AUDIT = "false"
NPM_CONFIG_FUND = "false"
NPM_FLAGS = "--ignore-scripts"
@Siilwyn
Siilwyn / if-else.js
Last active December 11, 2018 13:36
Get status with multiple conditions: if-else chain vs reducing
const resultState = state => {
if (!inputMatchesResult(state)) {
return 'unsynced';
} else if (state.isCalculating) {
return 'loading';
} else if (!state.result.success) {
return 'error';
} else if (state.result.success) {
return 'success';
}
@Siilwyn
Siilwyn / userscript.js
Last active November 20, 2020 09:04
Violentmonkey, mark watched YouTube videos
// ==UserScript==
// @name Mark watched YouTube videos
// @version 5
// @match https://www.youtube.com/feed/subscriptions
// @description Mark watched YouTube videos more prominently.
// @namespace https://gist.github.com/Siilwyn/
// @homepageURL https://gist.github.com/Siilwyn/669bb2b69cf039a02b6f209415a312f9/
// @downloadURL https://gist.githubusercontent.com/Siilwyn/669bb2b69cf039a02b6f209415a312f9/raw/userscript.js
// @updateURL https://gist.githubusercontent.com/Siilwyn/669bb2b69cf039a02b6f209415a312f9/raw/userscript.js
// @grant GM_addStyle
@Siilwyn
Siilwyn / gitter.js
Last active June 7, 2018 21:59 — forked from evilsoft/bigTest.txt
Fun for Selwyn
const {
Async, constant, curry,
mapReduce, maybeToAsync,
safe
} = require('crocks')
// FileAsync :: Async Error String
// access :: (String, Number) -> Async Error ()
const access =
@Siilwyn
Siilwyn / server.rs
Last active September 5, 2017 19:30
Rust simple HTTP server with no external crates
use std::io::{Read, Write, BufReader, BufRead};
use std::net::{TcpListener, TcpStream};
fn main() {
loop {
let listener = TcpListener::bind("localhost:5432").unwrap();
let stream = listener.accept().unwrap().0;
handle_request(stream);
}
}
@Siilwyn
Siilwyn / ava.js
Last active February 11, 2020 16:10
Comparison of testing promises with Jest & Ava
test('expect a reject', (t) =>
rejectSomething()
.then(t.fail)
.catch(error => t.is(error, 'bla'))
)
test('expect a resolve', (t) =>
resolveSomething()
.then(result => t.is(result, 'hey'))
)
@Siilwyn
Siilwyn / semi-code.js
Last active February 17, 2017 13:04 — forked from joepie91/.js
Transforming object comparison
/* Assuming: */
{
user: 1,
paymentMethod: 3
item: 51,
date: 1481892890, /* epoch timestamp */
payments: [{
payment: 44,
amountCents: 400,
@Siilwyn
Siilwyn / await-unnest.js
Last active September 19, 2016 20:55
Comparison of function style, Ramda & flattening
async function displaySteamApps() {
const paths = await getSteamAppsPaths();
const appIdLibraries = await Promise.all(paths.map(getSteamAppIds));
const appIds = Array.prototype.concat.apply([], appIdLibraries);
const appsData = appIds.map(getSteamAppInfo);
appsData.forEach(function (appData) {
Promise.resolve(appData).then(renderSteamApp);
});
};
@Siilwyn
Siilwyn / if.js
Last active April 26, 2024 08:05
Multiple ways to handle the platform: switch vs. if...else vs. object
var getConfigDirectory = function () {
var platform = process.platform;
if (platform === 'linux') {
return process.env.XDG_CONFIG_HOME || path.join(home(), '.config')
}
else if (platform === 'darwin') {
return path.join(home(), 'Library', 'Preferences');
}
else if (platform === 'win32') {