TypeScript
const things: string[] = ['foo', 'bar'];
vs
JavaScript
const things: string[] = ['foo', 'bar'];
echo "hello" |
{ | |
"compilerOptions": { | |
"allowJs": false, | |
"allowSyntheticDefaultImports": true, | |
"baseUrl": ".", | |
"esModuleInterop": true, | |
"experimentalDecorators": true, | |
"jsx": "react", | |
"lib": ["es6"], | |
"module": "commonjs", |
interface Foo { | |
handleSelect(field: string): (newSelected: string) => void; | |
} | |
// vs | |
interface Bar { | |
handleSelect: (field: string) => (newSelected: string) => void; | |
} |
/* | |
* Returns array of items de-duped based on primary key field | |
* ie: id | |
* */ | |
function removeDuplications<T>(primaryKey: string, items: T[]): T[] { | |
if (items && items.length === 0) { | |
return []; | |
} | |
if (!items[0].hasOwnProperty(primaryKey)) { |
TypeScript
const things: string[] = ['foo', 'bar'];
vs
JavaScript
const things: string[] = ['foo', 'bar'];
You can use as many APIs and concepts as you would like in your app, but it must contain at least one of each of the following:
#!/bin/bash | |
adb shell screencap -p /sdcard/screenshot.png | |
adb pull /sdcard/screenshot.png | |
now=$(date +%d:%m-%H.%M.%S) | |
mv screenshot.png screenshot-${now}.png |
// props to @rosszurowski for this: | |
// https://gist.github.com/rosszurowski/67f04465c424a9bc0dae | |
function lerpColor(a, b, amount) { | |
let ah = parseInt(a.replace(/#/g, ''), 16), | |
ar = ah >> 16, ag = ah >> 8 & 0xff, ab = ah & 0xff, | |
bh = parseInt(b.replace(/#/g, ''), 16), | |
br = bh >> 16, bg = bh >> 8 & 0xff, bb = bh & 0xff, | |
rr = ar + amount * (br - ar), | |
rg = ag + amount * (bg - ag), |
const spaceBetweenDataPoints = (this.chartDimensions.width - data.length * DATA_POINT_SIZE) / (data.length + 1); | |
const leftMargin = spaceBetweenDataPoints * (index + 1) + (index > 0 ? (index) * DATA_POINT_SIZE : 0); |
#!/usr/bin/python | |
from selenium import webdriver | |
from datetime import datetime | |
import time | |
import urllib | |
url = "http://stackoverflow.com" | |
everyXHours = 6 | |
refreshrate = 60 * 60 * everyXHours # Refresh every hour | |
browser = webdriver.Firefox() |