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
require 'base64' | |
# tools.ietf.org/html/rfc2397 | |
# developer.mozilla.org/en/data_URIs | |
# "data:" + MIME type + ";base64," + base64-encoded content | |
def to_data_url(content, content_type) | |
outuri = 'data:' + content_type + ';base64' | |
content = Base64.encode64(content).gsub("\n", '') | |
outuri += ",#{content}" |
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
#!/usr/bin/env python3 | |
# The below code is an attemt to understand Elliptic Curve Cryptography | |
# by implementing Elliptic Curve Diffie-Hellman key exchange from scratch. | |
# DON'T USE THIS CODE IN YOUR APP!! | |
# It is not safe and is intended only as a learning tool. | |
import secrets |
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
curl -0 -v -X POST http://wemo:49153/upnp/control/basicevent1 -H 'SOAPACTION: "urn:Belkin:service:basicevent:1#GetBinaryState"' -H 'Content-Type: text/xml; charset=utf-8' -d @- << EOF | |
<?xml version="1.0" encoding="utf-8"?> | |
<s:Envelope | |
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" | |
s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> | |
<s:Body> | |
<u:GetBinaryState xmlns:u="urn:Belkin:service:basicevent:1" /> | |
</s:Body> | |
</s:Envelope> | |
EOF |
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(file_utils). | |
-export([recursively_list_dir/1, | |
recursively_list_dir/2]). | |
% @type name() = string() | atom() | binary(). | |
-type name() :: string() | atom() | binary(). | |
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
#!/usr/bin/env python | |
import argparse | |
import json | |
import re | |
import subprocess | |
import sys | |
def ssh_config_lookup(key, config_text): | |
return re.search("(({})\s+(.*))".format(key), config_text).group(3) |
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
def utc_iso8601_milli(time) | |
time.utc.strftime '%FT%T.%LZ' | |
end | |
utc_iso8601_milli Time.now | |
# => "2016-09-02T07:06:18.134Z" | |
utc_iso8601_milli Time.new(2002, 10, 31, 2, 2, 2, "+05:00") | |
# => "2002-10-30T21:02:02.000Z" |
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
#!/usr/bin/env bash | |
## | |
## Usage: ip | |
## Display external IP using OpenDNS. | |
## | |
dig +short myip.opendns.com @resolver1.opendns.com | |
# REFERENCES | |
# http://www.commandlinefu.com/commands/view/5253/get-your-outgoing-ip-address |
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
#!/usr/bin/env bash | |
## | |
## Usage: usage [command|path] | |
## Assuming that a command script file starts with a block of usage info | |
## where each line in the block starts with two '##' characters. This script | |
## extracts and displays that block of usage info. | |
## | |
## Example: | |
## Given a file a_command with the following contents: | |
## |
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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Ampersand</title> | |
<style> | |
@font-face { | |
font-family:"Goudy Bookletter 1911"; | |
src:url('http://themes.googleusercontent.com/static/fonts/goudybookletter1911/v3/l5lwlGTN3pEY5Bf-rQEuIHkY3soKkPv_thL__S829Cw.eot#iefix') format('embedded-opentype'), |
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
#!/usr/bin/env bash | |
# redsymbol.net/articles/unofficial-bash-strict-mode/ | |
set -euo pipefail | |
IFS=$'\n\t' | |
# `set` is safer than relying on a hashbang like `#!/bin/bash -e` | |
# because that is neutralized when someone runs the script as `bash script.sh` | |
# Exit on error. Append `|| true` if we expect an error. | |
# set -o errexit |
NewerOlder