Skip to content

Instantly share code, notes, and snippets.

Avatar

Dale Hamel dalehamel

View GitHub Profile
@dalehamel
dalehamel / gmailstats.gs
Last active Nov 16, 2020
Basic Gmail statistics
View gmailstats.gs
// To load this script, open a Google Sheet (yeah, weird I know), then select "Tools->Script Editor"
// From there, past this content into a script. You can set up triggers to run this script every day at a certain time
// by selecting Resources -> Triggers.
// I recommend you set the trigger to every 5-10 minutes. This will let the batches complete. If the trigger is too infrequent, it wont have time to finish.
// https://developers.google.com/apps-script/reference/gmail/
// For large inboxes (the ones you want to analyze) gmail will rate limit you.
// They recommend adding a sleep to call less, but then your exec time will be too long.
// To solve this, we run in batches. This is the batch size. Decrease this if exec time is too long.
View 0001-Pull-patch-onto-1.17.8-drop-systemtap-specifics.patch
From d75537062f1f72b8dc6115f1960d6f56a47c3793 Mon Sep 17 00:00:00 2001
From: Dale Hamel <dale.hamel@shopify.com>
Date: Tue, 10 Mar 2020 18:46:03 -0400
Subject: [PATCH] Pull patch onto 1.17.8, drop systemtap specifics
---
README | 17 +++++++-
auto/make | 43 ++++++++++++++++++
auto/modules | 3 +-
auto/options | 11 ++++-
@dalehamel
dalehamel / gist:782cbbb9f343c48a112f
Last active Mar 10, 2020
Convert /etc/fstab to use UUID's for any matching /dev/sd* device.
View gist:782cbbb9f343c48a112f
#!/bin/bash
cp /etc/fstab /etc/fstab.bak
while read line; do
drive=$(echo $line | awk '{print $1}')
if [[ $drive =~ /dev/sd.* ]];then
uuid=$(blkid | grep $drive | sed 's/.*\sUUID="\([a-zA-Z0-9-]*\)".*/\1/g')
sed -i "s:$drive:UUID=$uuid:g" /etc/fstab
fi
done < /etc/fstab
@dalehamel
dalehamel / mcsnopp.bt
Created Mar 10, 2020
bpftrace script to attach to memcached and probe connections and commands
View mcsnopp.bt
usdt::memcached:command__get,
usdt::memcached:command__set,
usdt::memcached:command__add,
usdt::memcached:command__replace,
usdt::memcached:command__prepend,
usdt::memcached:command__append,
usdt::memcached:command__cas
{
@calls[str(arg1, arg2)]++;
@bytes[str(arg1, arg2)]+= arg3;
@dalehamel
dalehamel / simple_epoll_inotify_test.c
Created Feb 7, 2020
Test inotify on memfd with epoll api
View simple_epoll_inotify_test.c
#include <stdio.h>
#include <sys/inotify.h>
#include <sys/time.h>
#include <sys/epoll.h>
#include <errno.h>
#include <linux/memfd.h>
#include <sys/mman.h>
#include <sys/syscall.h>
@dalehamel
dalehamel / simple_epoll_inotify_test.c
Created Feb 7, 2020
Test inotify on memfd with epoll api
View simple_epoll_inotify_test.c
#include <stdio.h>
#include <sys/inotify.h>
#include <sys/time.h>
#include <sys/epoll.h>
#include <errno.h>
#include <linux/memfd.h>
#include <sys/mman.h>
#include <sys/syscall.h>
@dalehamel
dalehamel / docker-desktop-headers.sh
Last active Feb 6, 2020
install kernel headers for docker desktop, for BCC
View docker-desktop-headers.sh
#!/bin/bash
set -x
set -e
KERNEL_VERSION="${KERNEL_VERSION:-$(uname -r)}"
kernel_version="$(echo "${KERNEL_VERSION}" | awk -vFS=- '{ print $1 }')"
major_version="$(echo "${KERNEL_VERSION}" | awk -vFS=. '{ print $1 }')"
apt-get install -y build-essential bc curl flex bison libelf-dev
@dalehamel
dalehamel / dmi.rb
Last active Feb 5, 2020
Ruby dmidecode
View dmi.rb
require 'json'
def standardize_key(k)
k.downcase.gsub(/\s+/,'_')
end
def read_dmi
data=`dmidecode`
dict={}
@dalehamel
dalehamel / android-bionic-poll-t.patch
Last active Jan 9, 2020
BCC patches to build embedded for android
View android-bionic-poll-t.patch
--- embedded_bcc.orig/src/cc/libbpf/include/linux/types.h 2020-01-08 16:33:31.384052137 +0000
+++ embedded_bcc/src/cc/libbpf/include/linux/types.h 2020-01-08 02:22:36.269082225 +0000
@@ -23,7 +23,7 @@
#ifndef __aligned_u64
# define __aligned_u64 __u64 __attribute__((aligned(8)))
#endif
-
+typedef unsigned __bitwise __poll_t;
struct list_head {
struct list_head *next, *prev;
@dalehamel
dalehamel / lib-makefile-warning-clang.patch
Last active Jan 9, 2020
Patches to build libelf with clang toolchain
View lib-makefile-warning-clang.patch
Index: src/embedded_libelf/lib/Makefile.in
===================================================================
--- src.orig/embedded_libelf/lib/Makefile.in
+++ src/embedded_libelf/lib/Makefile.in
@@ -330,9 +330,9 @@ ARFLAGS = cr
# Use strict fallthrough. Only __attribute__((fallthrough)) will prevent the
# warning
-@HAVE_IMPLICIT_FALLTHROUGH_WARNING_TRUE@IMPLICIT_FALLTHROUGH_WARNING = -Wimplicit-fallthrough=5
+@HAVE_IMPLICIT_FALLTHROUGH_WARNING_TRUE@IMPLICIT_FALLTHROUGH_WARNING = -Wimplicit-fallthrough
You can’t perform that action at this time.