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
var deromanize = function(str) { | |
var str = str.toUpperCase(), | |
validator = /^M*(?:D?C{0,3}|C[MD])(?:L?X{0,3}|X[CL])(?:V?I{0,3}|I[XV])$/, | |
token = /[MDLV]|C[MD]?|X[CL]?|I[XV]?/g, | |
key = { | |
M: 1000, | |
CM: 900, | |
D: 500, | |
CD: 400, | |
C: 100, |
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
var romanize = function(num) { | |
var rom = { | |
M: 1000, | |
CM: 900, | |
D: 500, | |
CD: 400, | |
C: 100, | |
XC: 90, | |
L: 50, | |
XL: 40, |
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 pigLatin = str => { | |
let pigStr = ""; | |
const key = ["a", "e", "i", "o", "u"]; | |
if (key.some(val => val === str.charAt(0))) { | |
pigStr = str + "way"; | |
return pigStr; | |
} else { | |
pigStr = str.slice(1) + str.charAt(0) + "ay"; | |
return pigStr; | |
} |
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
'JSX comment': | |
'prefix': 'reJSXComment' | |
'body': '{/* ${1:Comments...} */}' | |
'ReactDOM.render': | |
'prefix': 'reDOMRender' | |
'body': 'ReactDOM.render(${1:<App />}, document.getElementById(\'${2:root}\'));' | |
'class component w/ extras': | |
'prefix': 'reCompFull' | |
'body': """ | |
class ${1:Component} extends React.Component { |
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
'configure store': | |
'prefix': 'rdStore' | |
'body': """ | |
export default function configureStore(preloadedState) { | |
return createStore( | |
rootReducer, | |
preloadedState, | |
applyMiddleware( | |
$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
'snippet block': | |
'prefix': 'snippet' | |
'body': """ | |
\'${1:Snippet Name}\': | |
\'prefix\': \'${2:Snippet Shortcut}\' | |
\'body\': \'${3:Snippet}\' | |
""" |
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
'default import': | |
'prefix': 'impDefault' | |
'body': 'import ${1:defaultMember} from \'${2:module-name}\'' | |
'named import': | |
'prefix': 'impNamed' | |
'body': 'import { ${1:namedMember} } from \'${2:module-name}\'' | |
'export default': | |
'prefix': 'expDefault' | |
'body': 'export default ${1:name}' | |
'export': |
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
/** | |
* Module dependencies. | |
*/ | |
var express = require('express'); | |
var rpcMethods = require('./methods.js'); | |
var app = module.exports = express.createServer(); | |
// Configuration |
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 pMap = require('p-map') | |
const Chance = require('chance') | |
const chance = new Chance() | |
const userIds = [ 52, 84, 71, 66, 12, 39, 18, 99, 7, 48 ] | |
// Simulate a network call | |
const getUser = async (id) => { | |
await new Promise(resolve => setTimeout(resolve, 1000)) |
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
// Sometimes we do cool stuff like this... | |
let tacoType = hasQueso ? 'supreme' : 'normal' | |
// Or this in our markup... | |
`ng-class="isActive && 'md-primary'"` | |
// Or this to set default values... | |
this.color = config.color || 'blue' | |
// Sometimes though we'd like to have more |
OlderNewer