Skip to content

Instantly share code, notes, and snippets.

@valpackett
valpackett / 1_WTF.md
Created February 3, 2012 18:32
Kindle dictionary template

Kindle dictionary template

Use it with KindleGen

kindlegen dic.opf

@lamberta
lamberta / vbox.sh
Created August 6, 2012 04:31
Convenience wrapper around VBoxManage for controlling VirtualBox virtual machines.
#!/usr/bin/env bash
# Convenience wrapper around VBoxManage for controlling VirtualBox virtual machines.
#
# Headless Ubuntu server gets stuck at boot menu on unsuccessful boots:
# http://serverfault.com/questions/243343/headless-ubuntu-server-machine-sometimes-stuck-at-grub-menu
function print_help {
echo "Usage: $(basename $0) [options] name"
echo "Easy control of VirtualBox virtual machines."
echo " -h Show this usage guide."
@wch
wch / mynamespace.js
Last active March 28, 2021 14:07
Namespace example in Javascript. This also demonstrates the module pattern.
// mynamespace is an object to use as a namespace
mynamespace = (function() {
// Variables in the namespace
var mynamespace = {
foo: "Yes, this is foo."
};
// "Public" methods for the namespace
mynamespace.fooTwo = function() {
@gitaarik
gitaarik / git_submodules.md
Last active May 1, 2024 12:25
Git Submodules basic explanation

Git Submodules basic explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of usecases of submodules:

  • Separate big codebases into multiple repositories.
@lars-tiede
lars-tiede / asyncio_loops.py
Last active April 3, 2024 15:28
asyncio + multithreading: one asyncio event loop per thread
import asyncio
import threading
import random
def thr(i):
# we need to create a new loop for the thread, and set it as the 'default'
# loop that will be returned by calls to asyncio.get_event_loop() from this
# thread.
loop = asyncio.new_event_loop()
@nepsilon
nepsilon / git-change-commit-messages.md
Last active April 24, 2024 06:30
How to change your commit messages in Git? — First published in fullweb.io issue #55

How to change your commit messages in Git?

At some point you’ll find yourself in a situation where you need edit a commit message. That commit might already be pushed or not, be the most recent or burried below 10 other commits, but fear not, git has your back 🙂.

Not pushed + most recent commit:

git commit --amend

This will open your $EDITOR and let you change the message. Continue with your usual git push origin master.

@NikolaiRuhe
NikolaiRuhe / NRLabel.swift
Last active April 9, 2020 05:01
A UILabel subclass that adds padding around the text and handles layout properly.
import UIKit
class NRLabel : UILabel {
var textInsets = UIEdgeInsets.zero {
didSet { invalidateIntrinsicContentSize() }
}
override func textRect(forBounds bounds: CGRect, limitedToNumberOfLines numberOfLines: Int) -> CGRect {
let insetRect = UIEdgeInsetsInsetRect(bounds, textInsets)
@zmwangx
zmwangx / # macOS release checksums
Last active February 8, 2020 02:33
macOS / OS X installer checksums. When I don't have a particular image, I filled as many fields as possible with data from https://github.com/notpeter/apple-installer-checksums and/or https://github.com/drduh/macOS-Security-and-Privacy-Guide/blob/master/InstallESD_Hashes.csv. A list of build numbers can be found in the Apple Support article http…
We couldn’t find that file to show.
@matthewdowney
matthewdowney / gen.py
Created October 13, 2017 09:42
P2WPKH-P2SH (SegWit) Wallet Address Generation
"""
Implementation of "Pay to Witness Public Key Hash nested in BIP16 Pay to Script Hash" (P2WPKH-P2SH) address generation.
Described in BIP 141 (SegWit) https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#P2WPKH_nested_in_BIP16_P2SH
I.e.: Public key -> SegWit address
"""
import hashlib
from hashlib import sha256
@robocoder
robocoder / decode.php
Last active December 2, 2023 04:25
PHP Decoding MySQL's .mylogin.cnf
<?php // tested with PHP 8.0.11
$start = microtime(true);
const LOGIN_KEY_LEN = 20;
const MY_LOGIN_HEADER_LEN = 24;
const MAX_CIPHER_STORE_LEN = 4;
$raw = file_get_contents(__DIR__ . '/mylogin.cnf');
$fp = 4; // skip null bytes