This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.remove = function(str) { return this.replace(str, ''); }; | |
String.prototype.surround = function(char, char2=char) { return char + this + char2; }; | |
// String.prototype.print = function() { console.log(this); return this; }; | |
foo = location.search | |
.remove('?') | |
.split('&') | |
.map(exp => exp.split('=').map(str => str.surround('"')).join(':').surround('{', '}')) | |
// .print() | |
.join(',') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from "React"; | |
export var Enhance = ComposedComponent => class extends Component { | |
constructor() { | |
this.state = { data: null }; | |
} | |
componentDidMount() { | |
this.setState({ data: 'Hello' }); | |
} | |
render() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run with administrator rights, | |
# you can simply copy and paste into a powershell session | |
$PATH = [Environment]::GetEnvironmentVariable("PATH"); | |
$subl = "C:\Program Files\Sublime Text 3"; | |
[Environment]::SetEnvironmentVariable("PATH", "$PATH;$subl", "Machine"); | |
refreshenv; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare module '*.icss' { | |
const styles: { | |
[className: string]: string | |
}; | |
export default styles; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add a require function that works just like in node, but can require any npm package, with it's version too. | |
// example 1 : require('lodash'); instanceof window.lodash === 'object' | |
function require(npmModule) { | |
console.info(`Attempting to load ${npmModule}...`); | |
var version = npmModule.indexOf('@') !== -1 ? '' : '@latest'; | |
var body = document.getElementsByTagName('body')[0]; | |
var script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.src = `https://wzrd.in/standalone/${npmModule}${version}`; | |
script.onload = () => console.log(`Loaded ${npmModule}!`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The Typescript language spec, https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md, is the definitive guide for | |
// how to annotate a react class, or anything else. But, sometimes, examples with a lot of SEO compatible words is better. | |
// Annotate a decorator that takes a react class, and wraps it. It'll have the same props as it's child. | |
export const decorateWithX = <T extends {}>(Comp: ComponentClass<T>): ComponentClass<T> => class extends PureComponent<T, State> { | |
} | |
// https://github.com/Microsoft/TypeScript/issues/4922 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type User | |
= Activated | |
| Deleted | |
update state = | |
case state of | |
Activated -> | |
-- do something | |
Deleted -> | |
-- do again |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sadf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Functions are curried, that means when a function is called with not enough arguments, we don't get an "argument error exception", but a NEW function, that expects the remaining amount of arguments. | |
-- This can lead to some cryptic-for-beginners compiler type errors. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// const getPortfoliosSync = createActionWithoutAlsoTyingDispatch(() => ({})); | |
const createActionWithoutAlsoTyingDispatchAsync = <T>(getMeAPromise: () => Promise<T>) => { | |
const retValue: any = () => { | |
return; | |
}; | |
return retValue as Promise<T>; | |
}; | |
const getPortfoliosAsync = createActionWithoutAlsoTyingDispatchAsync(() => Promise.resolve(1)); |