Skip to content

Instantly share code, notes, and snippets.

@mjac
mjac / master.sh
Created July 13, 2022 10:53 — forked from tomkins/master.sh
Python IPv6 Neighbor Advertisements
#!/bin/bash
# all-routers ff02::2
# server1 fe80::f03c:91ff:1122:3344
# server2 fe80::f03c:91ff:5566:7788
exec /usr/local/sbin/pyv6na.py \
2001:db8::1 \
2001:db8::2 \
--interface enp0s3 \
@mjac
mjac / flac2mp3.sh
Created March 30, 2020 21:51
Convert all FLAC to MP3
for f in **/*.flac; do ffmpeg -i "$f" -aq 3 "${f%flac}mp3";
@mjac
mjac / stash-cherry-pick.sh
Created January 10, 2019 14:59
Cherry pick from Git stash
git cherry-pick "stash@{0}" -m 1
@mjac
mjac / brew-cleanup-deps.sh
Created January 5, 2019 14:50
Remove dependencies of brew packages
brew rm FORMULA
brew rm $(join <(brew leaves) <(brew deps FORMULA))
@mjac
mjac / restore-mysql-backup.sh
Created January 5, 2019 14:36
Restore backup as root
gunzip -c backup.sql.gz | mysql -u root targetdatabasename
@mjac
mjac / storyworth-remove-empty.js
Created October 28, 2018 09:01
StoryWorth - Remove empty questions (without answers/stories)
$('#stories .remove').each(function (idx, remove) {
$.post('https://www.storyworth.com' + $(remove).attr('href'), {action: 'remove'});
});
@mjac
mjac / NormalDistributionCDF_MySQL
Created June 23, 2015 08:03
MySQL Normal Distribution CDF
DROP FUNCTION IF EXISTS gauss_cdf;
DELIMITER //
CREATE FUNCTION gauss_cdf(mean float, stdev float, x float) RETURNS float
BEGIN
set @z = (x - mean) / stdev;
set @b1 = 0.319381530;
set @b2 = -0.356563782;
set @b3 = 1.781477937;
@mjac
mjac / CheckAll.js
Created February 19, 2014 12:05
Check all the checkboxes in a page
var allCheckboxNodes = document.querySelectorAll('input[type=checkbox]');
var allCheckboxes = Array.prototype.slice.call(allCheckboxNodes, 0);
allCheckboxes.forEach(function (node)
{
node.setAttribute('checked', 'checked');
});
@mjac
mjac / ConvertGuidStringToCppStructure.js
Created February 19, 2014 11:56
Creates a C++ GUID structure from a source string
// Creates a C++ GUID structure from a source string
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa373931(v=vs.85).aspx
/*
typedef struct _GUID {
DWORD Data1;
WORD Data2;
WORD Data3;
BYTE Data4[8];
@mjac
mjac / GroupCharacters.js
Created February 19, 2014 11:51
Create character groups from a source string
// GroupCharacters('abc', 2)
// ["ab", "c"]
function GroupCharacters(sourceString, groupLength)
{
return sourceString.split('').reduce(function(groupedStrings, currentCharacter) {
var lastGrouping = groupedStrings.pop();
if(lastGrouping.length < groupLength)
{
lastGrouping += currentCharacter;