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 expect from 'expect' | |
let items = [{price: 19.9}, {price: 59}, {price: 120}, {price: 29.9}] | |
// the reducer | |
const add = function add(sum, item) { | |
return sum + item.price | |
} | |
expect(items.reduce(add, 0)).toEqual(228.8) |
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
module Module1 | |
def self.method1 | |
puts "method1 called" | |
end | |
end | |
class Test | |
def self.method_missing(name, *args) | |
if Module1.respond_to?(name) | |
return Module1.__send__(name, *args) |
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/sh | |
# move this file to /etc/init.d/monit | |
### BEGIN INIT INFO | |
# Provides: monit | |
# Required-Start: $remote_fs | |
# Required-Stop: $remote_fs | |
# Should-Start: $all | |
# Should-Stop: $all |
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 request = require("request") | |
var replaceStream = require('replacestream') | |
var fs = require('fs') | |
var path = require('path') | |
var originCurrency = "EUR" | |
var originFile = "eu-prices.xml" | |
var targetCurrency = "NOK" | |
var rate = 1 |
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 http = require('http'); | |
http.createServer(function (request, response) { | |
response.setHeader('Content-Type', 'text/html; charset=UTF-8'); | |
//response.setHeader('Transfer-Encoding', 'chunked'); | |
var html = | |
'<!DOCTYPE html>' + | |
'<html lang="en">' + | |
'<head>' + |
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
#!/usr/bin/env bash | |
for folder in $(find * -maxdepth 0 -type d) | |
do | |
cat <<EOF > $folder/.project | |
<?xml version="1.0" encoding="UTF-8"?> | |
<projectDescription> | |
<name>$folder</name> | |
<comment></comment> | |
<projects> |
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 | |
set -e | |
# source: http://jezenthomas.com/using-git-to-manage-todos/ | |
main() { | |
while IFS= read -r todo; do | |
printf "%s\n" "$(file_path):$(line_number) $(line_author) $(message)" | |
done < <(todo_list) | |
} |
- https://github.com/public-apis/public-apis (A collective list of free APIs)
- https://github.com/n0shake/Public-APIs
- https://github.com/toddmotto/public-apis (huge list of public APIs)
- http://openweathermap.org
- https://market.mashape.com
- http://numbersapi.com (An API for interesting facts about numbers)
- http://fixer.io (JSON API for foreign exchange rates and currency conversion)
- http://restcountries.eu (Get information about countries)
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
* { | |
font-size: 12pt; | |
font-family: monospace; | |
font-weight: normal; | |
font-style: normal; | |
text-decoration: none; | |
color: black; | |
cursor: default; | |
} |