This file contains hidden or 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 express = require('express'); | |
| var request = require('request'); | |
| var app = express(); | |
| var port = Number(process.env.PORT || 3000); | |
| var apiServerHost = (process.env.ELASTIC_URL || 'http://127.0.0.1:9200') | |
| // Listen for requests on all endpoints | |
| app.use('/', function(req, res, body) { | |
| // short-circuit favicon requests for easier debugging |
This file contains hidden or 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
| async function makePizza(sauceType = 'red') { | |
| let dough = await makeDough(); | |
| let sauce = await makeSauce(sauceType); | |
| let cheese = await grateCheese(sauce.determineCheese()); | |
| dough.add(sauce); | |
| dough.add(cheese); | |
| return dough; |
This file contains hidden or 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 DateTime = luxon.DateTime; | |
| var then = DateTime.fromISO('2017-07-04T15:16:14.000Z'); | |
| var now = DateTime.local(); | |
| var diff = then.diff(now, 'days'); | |
| diff.toObject(); // => {days: 150.30536171296296} || diff.as('days') => 150 |
This file contains hidden or 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 | |
| FILES=*.wav | |
| for f in $FILES | |
| do | |
| # echo "Processing ${f/.wav/.mp3} file..." | |
| echo "Processing $f file..." | |
| ffmpeg -i "$f" -codec:a libmp3lame -qscale:a 0 "${f/.wav/.mp3}" | |
| # take action on each file. $f store current file name | |
| # cat $f | |
| done |
This file contains hidden or 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
| [ | |
| { | |
| "name": "Afghanistan", | |
| "iso_code": "AF", | |
| "provinces": [ | |
| { | |
| "name": "Badakhshan", | |
| "code": "BDS" | |
| }, | |
| { |
This file has been truncated, but you can view the full file.
This file contains hidden or 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
| ZIP,LAT,LNG | |
| 00601,18.180555, -66.749961 | |
| 00602,18.361945, -67.175597 | |
| 00603,18.455183, -67.119887 | |
| 00606,18.158345, -66.932911 | |
| 00610,18.295366, -67.125135 | |
| 00612,18.402253, -66.711397 | |
| 00616,18.420412, -66.671979 | |
| 00617,18.445147, -66.559696 |
This file contains hidden or 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
| function seconds_since_epoch() { | |
| return Math.floor( Date.now() / 1000 ) | |
| } | |
| epoch_time = seconds_since_epoch(); |
This file contains hidden or 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 = [1,2,3] | |
| b = [1,2,3,4,5] | |
| x = list(set(b) - set(a)) | |
| y = list(set(b) - set(b).intersection((set(a)))) | |
| print x == y |
This file contains hidden or 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
| try { | |
| doSomething(); | |
| } catch(e) { | |
| window.open('http://stackoverflow.com/search?q=[js] +' + e.message); | |
| } | |
| // or... | |
| window.onError = function(e) { | |
| window.open('http://stackoverflow.com/search?q=[js] +' + e.message); | |
| }); |
This file contains hidden or 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, { PropTypes } from "react"; | |
| const Icon = props => { | |
| const styles = { | |
| img: { | |
| width: `${props.size}`, | |
| height: `${props.size}` | |
| } | |
| }; | |
| return <img style={styles.img} src={props.icon} />; |