Skip to content

Instantly share code, notes, and snippets.

View ryanwild's full-sized avatar
🏴‍☠️

Ryan Wild ryanwild

🏴‍☠️
View GitHub Profile
@ryanwild
ryanwild / emoji.txt
Created January 31, 2024 09:52
emoji
:bowtie:
😄 :smile:
😆 :laughing:
😊 :blush:
😃 :smiley:
☺️ :relaxed:
😏 :smirk:
😍 :heart_eyes:
😘 :kissing_heart:
😚 :kissing_closed_eyes:
@ryanwild
ryanwild / random.md
Created May 17, 2022 03:43 — forked from joepie91/random.md
Secure random values (in Node.js)

Not all random values are created equal - for security-related code, you need a specific kind of random value.

A summary of this article, if you don't want to read the entire thing:

  • Don't use Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.
  • Don't use crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.
  • If you want to generate random tokens or API keys: Use uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.
  • If you want to generate random numbers in a range: Use random-number-csprng.

You should seriously consider reading the entire article, though - it's

@ryanwild
ryanwild / ssr-example.js
Created July 9, 2021 06:56
React Streaming SSR
const render = async (response: ServerResponse, requestProps: RequestProps) => {
const { page, parameters } = findPage(requestProps.url);
const serverProps = {
request: {
parameters,
...requestProps
}
}
const pageProps = await getPageProps(page, serverProps, {});
@ryanwild
ryanwild / tutorial.md
Created July 17, 2018 12:46 — forked from swalkinshaw/tutorial.md
Designing a GraphQL API

Tutorial: Designing a GraphQL API

This tutorial was created by Shopify for internal purposes. We've created a public version of it since we think it's useful to anyone creating a GraphQL API.

It's based on lessons learned from creating and evolving production schemas at Shopify over almost 3 years. The tutorial has evolved and will continue to change in the future so nothing is set in stone.

@ryanwild
ryanwild / combinators.js
Created August 11, 2017 14:46 — forked from Avaq/combinators.js
Common combinators in JavaScript
const I = x => x;
const K = x => y => x;
const A = f => x => f(x);
const T = x => f => f(x);
const W = f => x => f(x)(x);
const C = f => y => x => f(x)(y);
const B = f => g => x => f(g(x));
const S = f => g => x => f(x)(g(x));
const P = f => g => x => y => f(g(x))(g(y));
const Y = f => (g => g(g))(g => f(x => g(g)(x)));
@ryanwild
ryanwild / excelSheetsToJsonRows.js
Created May 10, 2017 10:37 — forked from SneakyPeet/excelSheetsToJsonRows.js
Get all rows from all sheets in a excel doc as json array
// Get all rows from all sheets in a excel doc as json array
// Assumes sheets have header rows
const XLSX = require('xlsx');
const jsonfile = require('jsonfile');
const R = require('ramda');
const getWorkbook = () => XLSX.readFile('./data/test.xlsx');
const pickSheetsByName = (workbook) => R.pick(workbook.SheetNames, workbook.Sheets);
@ryanwild
ryanwild / css_regression_testing.md
Created May 5, 2017 22:16 — forked from cvrebert/css_regression_testing.md
Survey of screenshot-based CSS testing tools

Currently considering https://github.com/webdriverio/webdrivercss


Core Goals:

  • Can test in up-to-date versions of all major browsers
  • Can test on up-to-date versions of all major OSes
  • Can test in IE9 (because Bootstrap v4 will support IE9+)
  • Don't want to have to setup/maintain our own cluster of VMs running all the necessary OSes (and all the versions of Windows)
  • Workflow for management of reference/baseline/norm screenshots
@ryanwild
ryanwild / getVideoImage.js
Created May 5, 2017 11:29 — forked from westc/getVideoImage.js
A function to grab the frame at a specific point within a video.
function getVideoImage(path, secs, callback) {
var me = this, video = document.createElement('video');
video.onloadedmetadata = function() {
if ('function' === typeof secs) {
secs = secs(this.duration);
}
this.currentTime = Math.min(Math.max(0, (secs < 0 ? this.duration : 0) + secs), this.duration);
};
video.onseeked = function(e) {
var canvas = document.createElement('canvas');
@ryanwild
ryanwild / transcode
Created May 5, 2017 08:41 — forked from datashaman/transcode
Convert anything to x264 .mp4
#!/usr/bin/env bash
#
# Usage:
# transcode filename [filename...]
#
# Video: anything -> x264
# Audio: copy
# Output: .mp4 alongside the source file(s)
#
# I live here: https://gist.github.com/datashaman/6866879e4ad07b0483e6efd9ea49d8a2
@ryanwild
ryanwild / iconv.docker
Created April 18, 2017 10:24 — forked from tristanlins/iconv.docker
Docker PHP extension recipes
FROM php:5.6-cli
RUN apt-get update \
&& apt-get install -y \
libfreetype6-dev \
&& rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-install iconv \
&& apt-get remove -y \
libfreetype6-dev \
&& apt-get install -y \