Skip to content

Instantly share code, notes, and snippets.

% ruby -rbcrypt -e '(1..100).each { |len| abort "max len is #{len}" if BCrypt::Password.create("a" * len) == "a" * (len+1) }'
max len is 72
zsh: exit 1 ruby -rbcrypt -e
ruby -rbcrypt -e 9.12s user 0.06s system 99% cpu 9.192 total
% ruby -rbcrypt -rpp -e 'pp (1..100).map { |len| goodpass = "a" * len; badpass = "a" * (len+1); pass = BCrypt::Password.create(goodpass); [len, pass == goodpass, pass == badpass] }'
[[1, true, false],
[2, true, false],
[3, true, false],
[4, true, false],

MGSV's online system

Why does online suck?

  • Whenever you connect online, it redistributes your resources between offline and online.
    • Generally, a small amount will remain offline and all the rest will go online.
  • If you spend stuff for online stuff, it comes out of your online resources.
  • If you spend stuff for regular (offline) stuff, it typically comes out of your offline resources.
    • This can leave you deeply in the negative if you're ever offline.
  • Being negative is very bad and can lead to staff leaving.
// ==UserScript==
// @name RPS mixed-content defuckifier
// @namespace rps-img-https
// @include https://www.rockpapershotgun.com/*
// @version 1
// @grant none
// ==/UserScript==
var images = document.getElementsByTagName('img');
var length = images.length;
#!/usr/bin/env ruby
require 'tempfile'
KNOWN_HOSTS = ENV['HOME'] + '/.ssh/known_hosts'
read_fh, write_fh = IO.pipe
command = ['ssh', '-oStrictHostKeyChecking=yes'] + ARGV + ['echo', 'Successful connection.']
@wisq
wisq / gist:521731c3395810cb23db
Created November 17, 2015 00:56
Multifox .vimperatorrc snippet
command! home js set_multifox_profile("3");
command! work js set_multifox_profile("2");
" Get the multifox version hash by looking inside the multifox XPI file.
" (Look at the hash it uses in its own imports.)
:js << EOF
Components.utils.import("resource://multifox-88f97b0/commands.js");
function set_multifox_profile(id) {
event = {
target: {
#!/usr/bin/env ruby
require 'digest/md5'
def random_hex(length)
bytes_needed = (length + 1) / 2
bytes = $urandom.read(bytes_needed)
hex = ("%02x" * bytes_needed) % bytes.bytes
return hex[0,length]
@wisq
wisq / slowlog
Created June 3, 2015 02:08
Tool to determine 50 slowest & 50 most rows-examined queries in MySQL slowlog
#!/usr/bin/env ruby
Entry = Struct.new(:duration, :rows, :data)
def trim(array, limit, &block)
too_many = array.count - limit
if too_many > 0
array.sort_by!(&block)
array.shift(too_many)
end
@wisq
wisq / notes.md
Created June 1, 2015 21:58
Rakefile task for a git pre-commit hook
  • Unlike a lot of pre-commit scripts, it uses only the changes you've staged for commit, and doesn't touch your working tree (stash etc.).
  • I use skip 'slow' if ENV['FAST_TESTS'] == '1' in tests that needlessly slow down everyday rake testing, but this runs them all before commit.
  • Written in 10 minutes. Barely tested. YMMV.
  • See https://github.com/wisq/autocrew/blob/master/Rakefile for the latest version (e.g. if I find any bugs in this).
@wisq
wisq / no-env-functions.diff
Created September 25, 2014 23:05
My solution to the bash exploit
diff -ruN a/bash/shell.c b/bash/shell.c
--- a/bash/shell.c 2011-01-02 21:04:51.000000000 +0000
+++ b/bash/shell.c 2014-09-25 21:20:24.656725026 +0000
@@ -1703,13 +1703,8 @@
tilde_initialize ();
/* Initialize internal and environment variables. Don't import shell
- functions from the environment if we are running in privileged or
- restricted mode or if the shell is running setuid. */
-#if defined (RESTRICTED_SHELL)
@wisq
wisq / gist:0fa021df52a3bd2485ac
Last active April 25, 2024 10:22
Protip: Bisecting a single commit

Situation: Some commit (on master, but not necessarily head of master) has broken things, but it's a big commit and it's not clear what part broke things.

% git checkout master
% git checkout -b bisect-branch
% git revert <offending commit>

(test here to make sure reverting fixed your problem)

% git bisect start