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
// Don't use characters that look similar in certain fonts, I/L/1, 0/O, B/8 etc. | |
const charSet = "ACDEFGHJKMNPQRSTUVWXYZ2345679"; | |
const delimiter = '-' | |
interface GeneratePromoCodeParams { | |
len: number; | |
} | |
export const generatePromoCode = (params: GeneratePromoCodeParams) => { | |
let result = ""; |
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
#!/bin/bash | |
# This script does a hard clean of caches and dependencies. It can be | |
# particularly useful when switching between branches with different | |
# native module packages or react native versions. It may take awhile to run. | |
printf "Cleaning cache\n" | |
rm -rf $TMPDIR/react-native-packager-cache-*; | |
rm -rf $TMPDIR/metro-bundler-cache-*; |
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
package main | |
import "fmt" | |
import "math" | |
import "math/big" | |
func bigFactorial(n int64) *big.Int { | |
if (n > 0) { | |
x := bigFactorial(n - 1) | |
m := big.NewInt(n) |
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 { AnyAction, Reducer } from 'redux' | |
type UserState = Readonly<{ | |
id: number | |
}> | |
export const initialState: UserState = { | |
id: -1 | |
} |
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 React from 'react'; | |
const visible = isVisible => Component => { | |
class VisibleComponent extends React.Component { | |
componentDidMount() { | |
this.unsubscribe = this.context.store.subscribe(this.handleChange.bind(this)); | |
} | |
componentWillUnmount() { | |
this.unsubscribe(); |
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
// Usage: | |
// const records = [['James', '[email protected]'], ['Steve', '[email protected]']]; | |
// const titles = ['name', 'email']; | |
// generateCsv(records, titles); | |
// RFC 4180 | |
// Fields containing line breaks (CRLF), double quotes, and commas should be enclosed in double-quotes. | |
const formatValue = value => { | |
const chars = [',', '"', '\n']; | |
const mustBeEnclosed = chars.some(c => value.includes(c)); |
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 attempts = [ | |
[ 1.613, 4.2010000000000005, 13.652000000000001, 7.035, 5.371, 9.951, 8.934000000000001, 5.534, 4.251, 7.636, 15.402000000000001, 6.384 ], | |
[ 1.401, 5.051, 11.852, 5.534, 3.384, 4.95, 6.501, 7.1850000000000005, 5.702, 5.401, 10.685, 5.867 ], | |
[ 1.349, 3.984, 9.401, 2.983, 4.0840000000000005, 5.05, 6.939, 5.7170000000000005, 3.517, 3.384, 9.185, 6.417 ], | |
]; | |
const levels = []; | |
for (let i = 0; i < attempts[0].length; i++) { |
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 lngRadius = 0.25; | |
const point = { | |
lat: 51.507351, | |
lng: -0.127758, | |
}; | |
const latmin = point.lat - lngRadius; | |
const latmax = point.lat + lngRadius; | |
const lngmin = point.lng - (lngRadius / 85 * 180); // Number of units different from lng so need to calculate |
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 countHoriz = 24; | |
// 16, 24 | |
const width = 960; | |
const height = 600; | |
const squareSize = width / countHoriz; | |
const countVert = height / squareSize |
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
<snippet> | |
<content><![CDATA[ | |
{/* ${1:JSX Comment} */} | |
]]></content> | |
<!-- Hit `jc` in any JS document to get a JSX comment --> | |
<tabTrigger>jc</tabTrigger> | |
<scope>source.js</scope> | |
</snippet> |
NewerOlder