Skip to content

Instantly share code, notes, and snippets.

@miracle2k
miracle2k / truncate_url.py
Created October 26, 2013 23:22
Aborted insane attempt to shorten a url by removing the least interesting parts first.
def pairwise(iterable):
"s -> (s0,s1), (s1,s2), (s2, s3), ..."
a, b = itertools.tee(iterable)
next(b, None)
return zip(a, b)
def shorten_url(url, maxlength):
"""Will shorten a url to the given maximum length by removing the
(hopefully) least interesting parts - the ones in the middle.
@miracle2k
miracle2k / ripple.html
Last active June 27, 2020 19:15
Validate a Ripple address in Python/JavaScript.
<!-- JavaScript is def. not batteries included. -->
<!-- From http://pastebin.com/B5r3P5Ny -->
<script src="http://crypto-js.googlecode.com/files/2.5.3-crypto-sha256.js"></script>
<script src="http://www-cs-students.stanford.edu/~tjw/jsbn/jsbn.js"></script>
<script src="http://www-cs-students.stanford.edu/~tjw/jsbn/jsbn2.js"></script>
<!-- taken from bitcoinjs almost verbatim -->
<script>
BigInteger.valueOf = nbv;
BigInteger.prototype.toByteArrayUnsigned = function () {
var ba = this.toByteArray();
@miracle2k
miracle2k / ledger.json
Last active January 2, 2016 16:08
Examples for Ripple transaction and ledger data structures
{
"hash": "427621A220C2DA6A5791C7EC160C1BE1DF1AECBF78883F8BF3513DAC3B21DAE9",
"accepted": true,
"closed": true,
"parent_hash": "E3804285F2284708A8F3F25BEB3D5DC9710F73BCD9D3ED7B2E4D5235DCD29C6B",
"transactions": 3,
"totalCoins": "99999998168574101",
"ledger_hash": "427621A220C2DA6A5791C7EC160C1BE1DF1AECBF78883F8BF3513DAC3B21DAE9",
"transaction_hash": "AA6C38477BB136C87BE0363391509404A435F27DD52107268EDB4BFFBDE2F013",
"account_hash": "271103032FA414BE2E662FBCC8B2AACC08E518EAEB7ACB4FDF773001A7154E9A",
@miracle2k
miracle2k / dabblet.css
Last active January 2, 2016 17:59
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
UInt160 = require('../src/js/ripple/uint160').UInt160;
sjcl = require('../src/js/ripple/utils').sjcl;
u = UInt160.from_bits(sjcl.codec.hex.toBits('F4FD179DF34F1C2483618F44CD61F8E0E46BC8F3'))
u._version_byte = 0
u.to_json()
#!/bin/sh
# Installs tarsnap client on Debian and Ubuntu
#
# You'll need to setup an account at
# http://www.tarsnap.com
# and load it with some funds
#
# Make sure you run this as root
#
@miracle2k
miracle2k / .bashrc
Created July 6, 2014 12:19
Convert an existing docker container into a "docker run" command line
# Convert an existing docker container into a "docker run" command line.
#
# This is useful when trying to debug containers that have been created
# by orchestration tools.
#
# Install jq: stedolan.github.io/jq/
function format_run() {
cid=$1
root@1ab2badf98de:/hibiscus-server/cfg# /hibiscus-server/jameicaserver.sh -p 234234234234234234 -f /srv/hibiscus2
[Mon Jul 07 05:55:37 UTC 2014][INFO][de.willuhn.jameica.system.StartupParams.<init>] starting in SERVER mode
[Mon Jul 07 05:55:37 UTC 2014][INFO][de.willuhn.jameica.system.StartupParams.<init>] workdir: /srv/hibiscus2
[Mon Jul 07 05:55:37 UTC 2014][INFO][de.willuhn.jameica.system.StartupParams.<init>] master password given via commandline
[Mon Jul 07 05:55:37 UTC 2014][INFO][de.willuhn.jameica.system.Application.init] starting jameica...
[Mon Jul 07 05:55:37 UTC 2014][INFO][de.willuhn.jameica.system.Platform.getWorkdir] using workdir: /srv/hibiscus2
[Mon Jul 07 05:55:37 UTC 2014][INFO][de.willuhn.jameica.services.SecurityManagerService.init] applying jameica security manager
[Mon Jul 07 05:55:37 UTC 2014][INFO][de.willuhn.jameica.security.JameicaSecurityManager.<init>] protecting program dir /hibiscus-server/
[Mon Jul 07 05:55:37 UTC 2014][INFO][de.willuhn.jameica.services.LockService.init] creati
@miracle2k
miracle2k / ass_parser.js
Created July 18, 2014 08:33
Old code, trying to parse ASS files.
// https://github.com/Arnavion/libjass
// https://github.com/spiegeleixxl/html5-ass-subtitles/blob/master/assparser.js
Subtitles = {};
Subtitles.ASS = function(content) {
var linesOfDialog = [];