Skip to content

Instantly share code, notes, and snippets.

View jesboat's full-sized avatar

Jade Sailor jesboat

  • Boston, MA
View GitHub Profile
@jesboat
jesboat / delete-old-branches
Created January 16, 2015 03:09
deletes branches in a git repo not accessed in the last month
#!/usr/bin/perl
use strict;
use warnings;
use autodie;
use Time::Piece;
use Time::Seconds;
use Getopt::Long;
@jesboat
jesboat / pass-by-ref.cpp
Created April 7, 2015 04:20
demo of pass-by-value vs pass-by-reference in C++
#include <iostream>
#include <string>
using std::string;
void passByVal(string passBy) {
passBy = "reference";
}
void passByRef(string &passBy) {
@jesboat
jesboat / confirm-lock.c
Created December 26, 2015 21:14
Check whether there are outstanding POSIX fcntl or flock locks on files. Written after a stray lock broke my mbox, to see if there were any others hiding around. Does not check for dotlocks (just use ls).
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
/* Compile with any c99 compiler:
#!/usr/bin/env python
months = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")
days_normal = map(int, "31 28 31 30 31 30 31 31 30 31 30 31".split(" "))
days_leap = map(int, "31 29 31 30 31 30 31 31 30 31 30 31".split(" "))
assert len(months) == 12
assert len(days_normal) == 12
assert len(days_normal) == 12
assert sum(days_normal) == 365
Jan 1 of a year with $y mod 400 = 0$,
Jan 2 of a year with $y mod 400 = 0$,
...
Feb 28 of a year with $y mod 400 = 0$,
Feb 29 of a year with $y mod 400 = 0$,
Mar 1 of a year with $y mod 400 = 0$,
...
Dec 31 of a year with $y mod 400 = 0$,
Jan 1 of a year with $y mod 400 = 1$,
This file has been truncated, but you can view the full file.
Jan 1 in a year $y mod 400 = 0$
Jan 2 in a year $y mod 400 = 0$
Jan 3 in a year $y mod 400 = 0$
Jan 4 in a year $y mod 400 = 0$
Jan 5 in a year $y mod 400 = 0$
Jan 6 in a year $y mod 400 = 0$
Jan 7 in a year $y mod 400 = 0$
Jan 8 in a year $y mod 400 = 0$
Jan 9 in a year $y mod 400 = 0$
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@jesboat
jesboat / resign-chrome-secure-prefs.py
Created August 14, 2019 02:12
python script to fix signatures in a chrome profile after moving it to a new computer (macOS)
#!/usr/bin/env python3
import argparse
import functools
import hmac
import json
import plistlib
import subprocess
pub fn voidfn() -> () {}
bash -c '
if [ "$(whoami)" = root ]; then
echo "No, you are supposed to run this bit as non-root"
exit 1
fi
sudo -v
pass=$(openssl rand -hex 16 | sed -e "s/\\(....\\)/\\1-/g; s/-\$//")
echo "Chosen random password: $pass"
{
echo "root:$pass"