Skip to content

Instantly share code, notes, and snippets.

View milesj's full-sized avatar
🙃

Miles Johnson milesj

🙃
View GitHub Profile
'use strict';
function nativeModule() {
const data = _interopRequireWildcard(require('module'));
nativeModule = function () {
return data;
};
return data;
/// <reference types="debug" />
declare module "color" {
export interface ColorFormatter {
(message: string | {
toString: () => string;
}): string;
}
const _default: {
fail: ColorFormatter;
mute: ColorFormatter;
@milesj
milesj / styles.ts
Created February 10, 2020 18:15
Styles
import CSS from 'csstype';
type SheetType = 'global' | 'low-pri' | 'high-pri';
type Properties = CSS.Properties;
type Property = string;
type Value = string | number;
type Cache = {
className: string;
rank: number;
@milesj
milesj / fn.ts
Created April 30, 2018 17:19
TS function interface inferrence
import React from 'react';
interface ComponentProps {}
// Inferred, don't need to do anything (preferred)
function Component(props: ComponentProps) {}
// Using "this" special argument, but this does not support static properties or methods
function Component(this: React.SFC<ComponentProps>, props: ComponentProps) {}
@milesj
milesj / webpack.config.js
Created August 18, 2017 19:48
Webpack config
/* eslint-disable strict, comma-dangle, prettier/prettier */
'use strict';
const path = require('path');
const webpack = require('webpack');
const WebpackGitHash = require('webpack-git-hash');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const ServiceWorkerWebpackPlugin = require('serviceworker-webpack-plugin');
const ParallelUglifyPlugin = require('webpack-parallel-uglify-plugin');
@milesj
milesj / rust-json.md
Last active June 30, 2016 01:20
Rust JSON formats

Be able to parse the following JSON format:

{
  "token": "ASDSD",
  "action": "Foo",
  "payload": {},
}
@milesj
milesj / gist:1097f6f8a4f7801710e1
Last active April 20, 2020 03:27
HHI Definition Generator
<?php
/**
* This file can be used to generate HHVM/Hack HHI definitions.
* It requires a specific extension to be passed as an argument on the command line.
* It will then loop through all constants, functions, and classes and print accordingly.
*
* For example, to generate HHI definitions for the SPL extension.
*
* php generate.php spl
*