Skip to content

Instantly share code, notes, and snippets.

View Siilwyn's full-sized avatar
🦀

Selwyn Siilwyn

🦀
View GitHub Profile
@Siilwyn
Siilwyn / 16:9-resolutions.txt
Last active January 18, 2016 18:37
16:9 Resolutions
640 x 360
1280 x 720
1920 x 1080
2560 x 1440
2880 x 1620
3200 x 1800
3840 x 2160
4000 x 2250
@Siilwyn
Siilwyn / scrape-stargazer-names.js
Created January 18, 2016 18:33
Scrape stargazer names from GitHub repository stargazers page
var stargazers = document.querySelectorAll('.follow-list-name');
var stargazerNames = [];
for (let node of stargazers) {
let stargazerName = node.querySelector('a').pathname;
stargazerName = stargazerName.split('/')[1];
stargazerNames.push(stargazerName);
}
@Siilwyn
Siilwyn / statement.md
Last active February 16, 2018 17:15
#Node.js:matrix.org mission statement

This is the mission statement I seek to uphold when I provide support on the #Node.js:matrix.org channel.

To support users of Node.js and their related projects to create a collaborative, creative, diverse, interested, and inter-generational sustainable culture of programmers of all skill levels, with room and encouragement to grow.

One of the great criticisms of open messaging channels for software support is that they’re often the blind leading the blind. Experts have little direct incentive to jump in with half-formed questions, and it takes some real skill to elicit good questions that can be answered accurately. There’s some incentive for some members to use questions to opine their favorite tools, and to show off clever answers not necessarily in the best interests of the person asking.

The other problem is times of day – American nights and weekends have a lull, and questions asked then are often left to the void. Hard to answer questions – vague and incomplete ones especially – are the easiest to

@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') {
@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 / 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 / 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 / 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 / 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 / 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