Skip to content

Instantly share code, notes, and snippets.

@CodeBrauer
CodeBrauer / gist:b938983729c024ad6ab81b1ee7e2f1ed
Last active November 16, 2016 15:32 — forked from mikejolley/gist:1604009
WooCommerce - Add a special field to the checkout, order emails and user/order meta
<?php
/**
* Add the field to the checkout
**/
add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');
function my_custom_checkout_field( $checkout ) {
echo '<div id="my_custom_checkout_field"><h3>'.__('My Field').'</h3>';
@CodeBrauer
CodeBrauer / composer.json
Last active August 15, 2018 13:34
Get all snapshots from archive.org as list
{
"require": {
"fabpot/goutte": "^3.2",
"digitalnature/php-ref": "^1.2"
}
}
@CodeBrauer
CodeBrauer / mount-image-qcow2-from-kvm-on-macos.md
Last active April 13, 2026 05:50
Mount image (qcow2) from KVM on macOS - fastest way? / Convert qcow2 to access files (EXT4 partition)

If you haven't installed any FUSE yet:

brew tap homebrew/fuse
brew install Caskroom/cask/osxfuse
  1. brew install qemu ext4fuse
  2. qemu-img convert -p -O vmdk snapshot.qcow2 system.vmdk This will take some time...
  3. Download and register for a free licence of VMDK Mounter for Mac® OS X and install it.
  4. Reboot your macOS device.
{
// If plugin has trouble finding Node.js, replace this string with path
// to your `node` bin
"node-path" : ":/usr/local/bin",
// Full list of supported options and acceptable values can be found here:
// https://github.com/csscomb/csscomb.js/blob/master/doc/options.md
"config": {
// Whether to add a semicolon after the last value/mixin.
@CodeBrauer
CodeBrauer / Default (OSX).sublime-keymap
Created June 21, 2017 07:41 — forked from mjleino/Default (OSX).sublime-keymap
Banish non-breaking spaces from Sublime Text
// Preferencs -> Key Bindings – User
[
{
"keys": ["alt+space"],
"command": "insert",
"args": { "characters": " "}
}
]
// Place your settings in the file "Packages/User/Preferences.sublime-settings",
// which overrides the settings in here.
//
// Settings may also be placed in syntax-specific setting files, for
// example, in Packages/User/Python.sublime-settings for python files.
{
// Sets the colors used within the text area
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
// Note that the font_face and font_size are overridden in the platform
@CodeBrauer
CodeBrauer / composer-stats.sh
Last active February 17, 2022 13:51
prints how ofter you required which package (tested on mac with zsh)
history | grep "composer require" | cut -d " " -f 7- | grep -v "grep" | sort | uniq -c | sort -r
<?php
// or just use json_last_error_msg...
public function get_json_human_error($err_code)
{
$constants = get_defined_constants(true);
$json_error_constants = array_filter(array_keys($constants['json']), function($row) {
return strpos($row, 'JSON_ERROR_') !== false;
});
foreach ($json_error_constants as $index => $error_name) {
$json_error_constants[constant($error_name)] = $error_name;
@CodeBrauer
CodeBrauer / mask_ip.php
Last active January 18, 2022 12:00
PHP function that anonymizes IP addresses like Google Analytics does (https://support.google.com/analytics/answer/2763052)
<?php
function mask_ip($ip) {
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
$parts = explode('.', $ip);
$parts[count($parts)-1] = '0';
return implode('.', $parts);
} else if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
$parts = explode(':', $ip);
$parts[count($parts)-1] = '0';
@CodeBrauer
CodeBrauer / twf.german.js
Last active November 24, 2020 14:31
com.twf
this.windAll = [
//Highest
["Ein verdammter Tornado.", "Kinder werden weggeblasen.", "Binde dein Haus fest.", "Ein verfickter Hurrikan.", "Stürmisch wie Scheiße.", "Tornadoig.", "Irgendeine Scheiße auf Monsun-Niveau."],
//High
["Ziemlich scheißwindig.", "Scheißböig.", "Geh heute nicht zum Frisör.", "Du wist einen bad-hair-day haben.", "Trag bloß keinen Rock", "Ein verdammter Sturm.", "Gründlich beschissen.", "Der Wind hat es heute verdammt eilig."],
//Medium
["Ziemlich windig.", "Ziemlich böig, verdammt.", "Genug Wind, um Scheiße zu sein.", "Vielleicht mit dem Segeln anfangen.", "Ziemlich verfickt zugig.", "Beschissen windig.", "Rather windy.", "Fairly fucking windy.", "Good time to buy a kite."],
//LOW
["Not a lot.", "Some.", "Some shitty breeze.", "Like someone breathing in your face.", "A bit of a draft.", "A bit drafty.", "Dull little breeze.", "Rather breezy.", "The air is in a bit of a hurry."],
//Lowest