Skip to content

Instantly share code, notes, and snippets.

@iancoleman
iancoleman / bruteforce_table.py
Created January 12, 2018 02:35
number of tries to generate a specific key with a specific probability
# Prints out a table of the number of tries to generate a specific key with a
# specific probability
#
# More info at https://forum.safedev.org/t/secure-random-relocation/1321/41
#
# It's messy but the maths is correct.
import math
def tidyNum(n):
@iancoleman
iancoleman / convert_surround_to_stereo.py
Last active October 2, 2017 09:42
Convert surround sound to stereo for all files in a directory
#!/usr/bin/python3
# Convert files with surround sound to use stereo
# CAUTION: will overwrite original file!
# Some additional bash helpers
# convert all videos in directory to smaller size, output in /tmp
# for f in `ls | grep mp4`; do ffmpeg -i $f -vf scale=720:-2 -c:a copy /tmp/$f; done
@iancoleman
iancoleman / en.json
Created November 21, 2016 02:22
Phrases from safe_launcher v0.9.2
{
"Account": "Account",
"Account Info": "Account Info",
"Account not found": "Account not found",
"Account Password": "Account Password",
"Account password needs to be stronger.": "Account password needs to be stronger.",
"Account Secret": "Account Secret",
"Account secret needs to be stronger.": "Account secret needs to be stronger.",
"Account Storage": "Account Storage",
"Accounts are made of two parts, an 'account secret' and an 'account password'.": "Accounts are made of two parts, an 'account secret' and an 'account password'.",
@iancoleman
iancoleman / chunk_store_ram.rs
Created August 26, 2016 04:52
SAFE network vault chunk_store using RAM instead of disk IO
// Copyright 2016 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License,
// version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which
// licence you accepted on initial access to the Software (the "Licences").
//
// By contributing code to the SAFE Network Software, or to this project generally, you agree to be
// bound by the terms of the MaidSafe Contributor Agreement, version 1.0. This, along with the
// Licenses can be found in the root directory of this project at LICENSE, COPYING and CONTRIBUTOR.
//
@iancoleman
iancoleman / harken_error.json
Created March 17, 2013 09:51
This is an example error message when an invalid method is called with harken.
{
"Ext": "http",
"Method": "Call",
"Error": "Invalid ext.Method: chat.Shout"
}
@iancoleman
iancoleman / to_harken.json
Last active December 15, 2015 01:29
This is an example of the type of message that should be sent over the websocket using harken.
{
"Ext": "chat",
"Method": "Send",
"Data": "This is a chat message"
}
@iancoleman
iancoleman / txjson.py
Last active November 17, 2020 19:55
Decimal numbers in python json dump
# In response to https://bitcointalk.org/index.php?topic=56424.msg1454348#msg1454348
# Highlights that json encoding of floats is no good
# and that decimals can be used for encoding.
import json
from decimal import Decimal as D
d1 = D(11) / D(10) # 1.1
d2 = D(22) / D(10) # 2.2
@iancoleman
iancoleman / httpd.conf
Created October 21, 2012 23:00 — forked from santouras/httpd.conf
httpd conf for wildcard dev virtualhosts
<Virtualhost *:80>
VirtualDocumentRoot "/var/www/%1/public"
ServerName vhosts.dev
ServerAlias *.dev
UseCanonicalName Off
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
ErrorLog ${APACHE_LOG_DIR}/vhosts-error_log
SetEnv APPLICATION_ENV "development"
<Directory "/var/www/*">
Options Indexes FollowSymLinks MultiViews