Skip to content

Instantly share code, notes, and snippets.

View tom2strobl's full-sized avatar
:shipit:
busy building some rad shizzle

Thomas Strobl tom2strobl

:shipit:
busy building some rad shizzle
View GitHub Profile
@tom2strobl
tom2strobl / index.js
Created May 20, 2016 09:03
Quick script that reads all files on given paths and writes the occurences of arguments to a __() function to a JSON and CSV file. Useful for localization and internationalization.
'use strict';
const Promise = require("bluebird");
const _ = require("lodash");
const glob = require("glob");
const async = require("async");
const fs = require("fs");
const jsonfile = require("jsonfile");
const json2csv = require("json2csv");
Promise.promisifyAll(fs);
@tom2strobl
tom2strobl / draw.js
Last active September 13, 2017 14:47
draw an arc of a circle with plain math and a react render
function polarToCartesian(centerX, centerY, radius, angleInDegrees) {
var angleInRadians = (angleInDegrees-90) * Math.PI / 180.0;
return {
x: centerX + (radius * Math.cos(angleInRadians)),
y: centerY + (radius * Math.sin(angleInRadians))
};
}
function describeArc(x, y, radius, startAngle, endAngle){
var start = polarToCartesian(x, y, radius, endAngle);
@tom2strobl
tom2strobl / ssl.sh
Created November 2, 2017 10:02
https://localhost
cd; mkdir .ssl
openssl req -newkey rsa:2048 -x509 -nodes -keyout .ssl/localhost.key -new -out .ssl/localhost.crt -subj /CN=localhost -reqexts SAN -extensions SAN -config <(cat /System/Library/OpenSSL/openssl.cnf <(printf '[SAN]\nsubjectAltName=DNS:localhost')) -sha256 -days 3650
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain .ssl/localhost.crt
import ReactPlayer from 'react-player'
import { useSize } from 'react-use'
const videoConfig = {
vimeo: {
playerOptions: {
background: true
}
}
}
import { useState, setState, useRef } from "react";
import Observer from "@researchgate/react-intersection-observer";
import anime from "animejs";
import { ANIMATIONS } from "constants";
function handleIntersection(event, ref, delay, callback) {
if (event.isIntersecting) {
callback();
anime.set(ref, { opacity: 0 });
@tom2strobl
tom2strobl / datum.js
Last active July 23, 2019 16:52
datumgist
parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({
@tom2strobl
tom2strobl / 01_add_cors.config.yaml
Created February 11, 2016 10:32 — forked from vsviridov/01_add_cors.config.yaml
Add CORS to Nginx on AWS Elastic Beanstalk
container_commands:
01_fix_static_cors:
command: "/tmp/fix_static_cors.sh"
files:
"/tmp/fix_static_cors.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
@tom2strobl
tom2strobl / urqlHasura.ts
Created March 16, 2021 10:42
Helper factory to create update functions for gql-generated hasura queries (WIP)
/* eslint-disable no-else-return */
// disabling no-else-return for readability
import { Cache, Data, Variables } from '@urql/exchange-graphcache'
import {
ArgumentNode,
DocumentNode,
EnumValueNode,
FieldNode,
ObjectValueNode,
@tom2strobl
tom2strobl / pirschFetchClient.ts
Last active November 4, 2021 11:38
basically the pirsch-sdk client, without getters and fetch instead of axios to make it run on an edge / service worker environment
import { IncomingMessage } from 'http'
import { NextRequest } from 'next/server'
import { ClientConfig, AuthenticationResponse, APIError, Hit } from 'pirsch-sdk/types'
const referrerQueryParams = ['ref', 'referer', 'referrer', 'source', 'utm_source']
const defaultBaseURL = 'https://api.pirsch.io'
const defaultTimeout = 5000
const defaultProtocol = 'http'
const authenticationEndpoint = '/api/v1/token'
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.