Skip to content

Instantly share code, notes, and snippets.

Avatar

Steven styfle

View GitHub Profile
@styfle
styfle / InputNumber.tsx
Last active Apr 17, 2018
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
styfle / simpsons-characters.md
Created Apr 10, 2018
An alphabetical list of characters from The Simpsons
View simpsons-characters.md

Simpsons Characters

An alphabetical list of characters from The Simpsons

  • Apu Nahasapeemapetilon
  • Bart Simpson
  • Carl Carlson
  • Duffman
  • Edna Krabappel
  • Fat Tony
@styfle
styfle / 49156502.ts
Created Mar 7, 2018
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
styfle / 41705559.ts
Created Nov 17, 2017
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
styfle / keybase.md
Created Oct 5, 2017
Proof that I am the real styfle!
View keybase.md

Keybase proof

I hereby claim:

  • I am styfle on github.
  • I am styfle (https://keybase.io/styfle) on keybase.
  • I have a public key ASBNLU4Ir9YfbXm5mKOxx4PCrpCIUJ75lbl40R4oyZNkUwo

To claim this, I am signing this object:

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": "https://www.nytimes.com/2017/08/23/business/media/wall-street-journal-editor-admonishes-reporters-over-trump-coverage.html",
"urlToImage": "https://static01.nyt.com/images/2017/08/24/business/24wsj1/24wsj1-facebookJumbo.jpg",
@styfle
styfle / web.config.xml
Created Jul 13, 2017
Security and Caching settings for web.config in ASP.NET
View web.config.xml
<system.web>
<httpCookies requireSSL="true" />
</system.web>
<system.webServer>
<httpProtocol>
<customHeaders>
<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
styfle / .htaccess
Last active Nov 12, 2018
Apache config for a https enabled, secure headers, cache headers, etc
View .htaccess
## Set security headers per https://observatory.mozilla.org
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 https://stackoverflow.com/a/13997498/266535
RewriteEngine On
@styfle
styfle / requirePromise.js
Created May 10, 2017
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
styfle / after-promisify.js
Created May 10, 2017
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;
You can’t perform that action at this time.