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 HAS_EXPANDING_BOX_BUG = (function(){ | |
var el = document.createElement('div'), | |
isBuggy = false; | |
el.style.width = '1px'; | |
el.innerHTML = 'xxxxxxxxxx'; | |
document.body.appendChild(el); | |
isBuggy = (el.offsetWidth > 1); | |
document.body.removeChild(el); | |
el = null; | |
return isBuggy; |
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 fs = require('fs'); | |
const { exec } = require('child_process'); | |
const moment = require('moment'); | |
const _ = require('lodash'); | |
const chalk = require('chalk'); | |
fs.readFile('package.json', (err, data) => { | |
const { dependencies } = JSON.parse(data.toString()); | |
let totalDays = 0; |
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
quicksort :: (Ord a) => [a] -> [a] | |
quicksort [] = [] | |
quicksort (x:xs) = | |
let smallerSorted = quicksort (filter (<=x) xs) | |
biggerSorted = quicksort (filter (>x) xs) | |
in smallerSorted ++ [x] ++ biggerSorted |
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 Ember from 'ember'; | |
const { | |
Component, set, get | |
} = Ember; | |
export default Component.extend({ | |
imageSource:'', | |
didInsertElement() { | |
get(this, 'setChildReference')(this); |
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 '@glimmer/component'; | |
const defaultProps = { | |
firstName: 'Kenneth', | |
lastName: 'Larsen', | |
}; | |
export default class PersonComponent extends Component { | |
args = { defaultProps, ...this.args } |
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
console.highlight = function(text, sample) { | |
var escapedSample = sample.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); | |
var reSample = new RegExp(escapedSample, 'g'); | |
var args = ['']; | |
var highlightedText = text.replace(reSample, function(match) { | |
args.push('background-color: #ffc', 'background-color: none'); | |
return '%c' + match + '%c'; | |
}); | |
args[0] = highlightedText; | |
console.log.apply(console, args); |
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 type { GlobalState } from 'redux/modules'; | |
export type ExtractReturn<Fn> = $Call<<T>((...Iterable<any>) => T) => T, Fn>; | |
// ... | |
export type BaseAction = $ReadOnly<{ type: string, error?: boolean }>; | |
// ... |
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
/* | |
A collection of tests where Flow and TypeScript might have different behavior | |
Some tests are borrowed from https://github.com/vkurchatkin/typescript-vs-flow | |
Some tests now have the same behavior as the new versions of Flow/TS have fixed the bugs and improved type safety | |
*/ | |
/* 1. Accessing unknown properties on objects */ |
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
/** | |
* Example: | |
* 'hello {{username}}'.between('{{','}}') === 'username' | |
*/ | |
String.prototype.between_regexp = function between(begin, end) { | |
var regexp = new RegExp(begin + '(.+)' + end); | |
return this.match(regexp)[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
// https://www.reuters.com/article/us-usa-tax-provisions-factbox/whats-in-the-final-republican-tax-bill-idUSKBN1ED27K | |
// 10 percent up to $9,525, versus 10 percent up to $9,325 under existing law; | |
// 12 percent from $9,526 to $38,700, versus 15 percent on $9,326 to $37,950; | |
// 22 percent on $38,701 to $82,500, versus 25 percent on $37,951 to $91,900; | |
// 24 percent on $82,501 to $157,500, versus 28 percent on $91,901 to $191,650; | |
// 32 percent on $157,501 to $200,000, versus 33 percent on $191,651 to $416,700; | |
// 35 percent on $200,001 to $500,000, versus 35 percent on $416,701 to $418,400; | |
function calcTax(income) { |
NewerOlder