Skip to content

Instantly share code, notes, and snippets.


Steven styfle

View GitHub Profile
styfle / InputNumber.tsx
Last active April 17, 2018 17:01
InputNumber.tsx example for componentWillReceiveProps
View InputNumber.tsx
interface Props {
value: number;
onChange: (value: number) => void;
widthPx?: number;
inline?: boolean;
disabled?: boolean;
interface State {
valueAsString: string;
styfle /
Created April 10, 2018 15:49
An alphabetical list of characters from The Simpsons

Simpsons Characters

An alphabetical list of characters from The Simpsons

  • Apu Nahasapeemapetilon
  • Bart Simpson
  • Carl Carlson
  • Duffman
  • Edna Krabappel
  • Fat Tony
styfle / 49156502.ts
Created March 7, 2018 17:55
Answer to stackoverflow question 49156502
View 49156502.ts
function isDate(obj: any): obj is Date {
return typeof obj === 'object' && 'toISOString' in obj;
function isString(obj: any): obj is string {
return typeof obj === 'string';
interface JWT {
id: string;
styfle / 41705559.ts
Created November 17, 2017 15:04
TypeScript SO question 41705559
View 41705559.ts
type Opt = { id: string, name: string }
interface MultiProps {
isMultiple: true;
options: Opt[];
id: string[];
onChange: (id: string[]) => void;
interface SingleProps {
styfle /
Created October 5, 2017 16:01
Proof that I am the real styfle!

Keybase proof

I hereby claim:

  • I am styfle on github.
  • I am styfle ( on keybase.
  • I have a public key ASBNLU4Ir9YfbXm5mKOxx4PCrpCIUJ75lbl40R4oyZNkUwo

To claim this, I am signing this object:

styfle / newsapi.json
Created August 25, 2017 18:03
View newsapi.json
"status": "ok",
"source": "the-new-york-times",
"sortBy": "top",
"articles": [{
"author": "Michael M. Grynbaum",
"title": "Wall Street Journal Editor Admonishes Reporters Over Trump Coverage",
"description": "In internal emails, Gerard Baker described the draft of an article about the president’s rally in Phoenix as “commentary dressed up as news reporting.”",
"url": "",
"urlToImage": "",
styfle / web.config.xml
Created July 13, 2017 15:14
Security and Caching settings for web.config in ASP.NET
View web.config.xml
<httpCookies requireSSL="true" />
<add name="Strict-Transport-Security" value="max-age=31536000"/>
<add name="X-XSS-Protection" value="1; mode=block"/>
<add name="X-Content-Type-Options" value="nosniff"/>
styfle / .htaccess
Last active November 12, 2018 17:04
Apache config for a https enabled, secure headers, cache headers, etc
View .htaccess
## Set security headers per
Header set Strict-Transport-Security "max-age=15768000" env=HTTPS
Header set Content-Security-Policy "frame-ancestors 'self'"
Header set X-Frame-Options "SAMEORIGIN"
Header set X-XSS-Protection "1; mode=block"
Header set X-Content-Type-Options "nosniff"
## Add some rewrite rules per
RewriteEngine On
styfle / requirePromise.js
Created May 10, 2017 01:40
Promises in Node.js 8.x Core
View requirePromise.js
function requirePromise(modName, fnName) {
return require('util').promisify(require(modName)[fnName]);
const stat = requirePromise('fs', 'stat');
const writeFile = requirePromise('fs', 'writeFile');
const appendFile = requirePromise('fs', 'appendFile');
styfle / after-promisify.js
Created May 10, 2017 01:37
Promises in Node.js 8.x Core
View after-promisify.js
const promisify = require('util').promisify;
const fs = require('fs');
const stat = promisify(fs.stat);
const writeFile = promisify(fs.writeFile);
const appendFile = promisify(fs.appendFile);
async function exists(f) {
try {
const stats = await stat(f);
return true;