Skip to content

Instantly share code, notes, and snippets.

@boscomonkey
boscomonkey / 4-hardest-cs-problems.md
Created June 5, 2023 16:55
Four Hardest Problems in Computer Science
  1. Naming
  2. Cache consistency
  3. Off-by-One error
@boscomonkey
boscomonkey / xkcd_password_bookmarklet.js
Last active November 12, 2021 22:28
Bookmarklet to take XKCD password - https://preshing.com/20110811/xkcd-password-generator/ - and turn it into caps, special chars (periods), and numbers.
(
function() {
function massage_xkcd(txt) {
const arry = txt.split(' ');
const randNum = String(Math.random()).slice(2, 5);
const caps = arry.map(word => word.charAt(0).toUpperCase() + word.substring(1));
caps.push(randNum);
return caps.join('.');
}
@boscomonkey
boscomonkey / url-to-qr-code-bookmarklet.js
Created January 28, 2021 03:12
Bookmarklet to display the current URL as a QR-code in a separate popup window (so as to not replace your current window)
javascript:void(
(
function() {
var orig=location.href;
var url='http://chart.apis.google.com/chart?cht=qr&chs=300x250&chl='+encodeURIComponent(orig);
window.open(url,"_blank","width=320,height=270,resizable=yes,status=yes")
}
)()
)
@boscomonkey
boscomonkey / pre-commit.sh
Last active April 17, 2019 02:09
Git pre-commit hook to warn about CSV, TSV, or TXT files with 50 lines or more
#!/bin/bash
# Git pre-commit hook to warn about CSV, TSV, or TXT files with 50
# lines or more. Original example at:
#
# https://codeinthehole.com/tips/tips-for-using-a-git-pre-commit-hook/
# Make sure this script is executable. Installation is simply:
# ln -s pre-commit.sh .git/hooks/pre-commit

Cam settings

Before you do anything, perform a factory reset.

Exposure

Shutter: Auto

Brightness: 44 (factory default)

javascript:$('#branding img').css('width', '40%');jQuery('#ctaMessage').css('display', 'none');
function getString(str, offset) {
return str.split('')
.map(function(ch) {
return String.fromCharCode(ch.charCodeAt(0) + offset);
})
.join('');
}
@boscomonkey
boscomonkey / devise-1.5.3-install.txt
Created March 6, 2012 20:39
Devise 1.5.3 gem installation message
===============================================================================
Some setup you must do manually if you haven't yet:
1. Setup default url options for your specific environment. Here is an
example of development environment:
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
This is a required Rails configuration. In production it must be the
@boscomonkey
boscomonkey / bind_this.js
Created January 21, 2012 21:26
In JavaScript, binds an object to a callback function to use as "this".
// In JavaScript, binds an object to a callback function to use as "this".
//
// When a function is passed as an event callback, "this" is bound to
// the DOM element triggering the event; in other scenarios when a
// function is used as a callback, "this" is bound to the window
// object.
//
// To override the default binding of "this", call bindThis on your
// function. For example:
//
@boscomonkey
boscomonkey / brew-install-mysql.txt
Created December 8, 2011 19:17
"brew install mysql" output on Mac OSX Lion
Set up databases to run AS YOUR USER ACCOUNT with:
unset TMPDIR
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
To set up base tables in another folder, or use a different user to run
mysqld, view the help for mysqld_install_db:
mysql_install_db --help
and view the MySQL documentation:
* http://dev.mysql.com/doc/refman/5.5/en/mysql-install-db.html