Skip to content

Instantly share code, notes, and snippets.

View pestilence669's full-sized avatar

Paul Chandler pestilence669

View GitHub Profile
@pestilence669
pestilence669 / factorial.scala
Last active July 12, 2016 06:57
Various ways to implement factorial in Scala
#!/bin/sh
exec scala "$0" "$@"
!#
// vim: set ts=2 sw=2 et fileencoding=utf-8:
import java.lang.reflect.Method
import scala.annotation.tailrec
import scala.language.postfixOps
/**
@pestilence669
pestilence669 / obliterateFileFromGit.sh
Created September 16, 2016 22:37
p4 obliterate (for Git)
#!/bin/bash
#
# run from the project's root with the full relative path to the file
# to destroy from history.
#
git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch $1" \
--prune-empty --tag-name-filter cat -- --all
@pestilence669
pestilence669 / CMakeLists.txt
Last active December 23, 2016 01:22
Run CPU utilization very high
# vim: set ts=4 sw=4 noet fileencoding=utf-8:
#
# cmake -DCMAKE_BUILD_TYPE=Debug ..
# cmake -DCMAKE_BUILD_TYPE=Release ..
cmake_minimum_required(VERSION 2.8)
set(PACKAGE_NAME "evil")
set(PACKAGE_VERSION "0.0.1-dev")
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
@pestilence669
pestilence669 / donteverdothis.c++
Last active February 13, 2017 22:38
Planting seeds for evil things to do to someone reading your code
// vim: set ts=4 sw=4 noet fileencoding=utf-8:
#include <iostream>
using namespace std;
#define _______ 0b0
#define ________ 0b1
#define _________ =
#define __________ <=
#define ___________ <<
#define ____________ int
@pestilence669
pestilence669 / basic_benchmark_rig.py
Created March 8, 2017 10:53
Simple Python benchmark rig
#!/usr/bin/env python
# vim: set ts=4 sw=4 et fileencoding=utf-8:
#
# Simple benchmark & testing rig to play with finding the fastest methods when
# searching for the first value in a sequence, determined by a predicate. This
# file uses: lambda x: x / 2 == target
#
from __future__ import print_function
@pestilence669
pestilence669 / github-to-bitbucket
Created March 9, 2017 02:28 — forked from sangeeths/github-to-bitbucket
Forking a Github repo to Bitbucket
Go to Bitbucket and create a new repository (its better to have an empty repo)
git clone [email protected]:abc/myforkedrepo.git
cd myforkedrepo
Now add Github repo as a new remote in Bitbucket called "sync"
git remote add sync [email protected]:def/originalrepo.git
Verify what are the remotes currently being setup for "myforkedrepo". This following command should show "fetch" and "push" for two remotes i.e. "origin" and "sync"
git remote -v
@pestilence669
pestilence669 / CoreBrightness.xdelta3
Last active October 30, 2017 06:33
Enable Night Shift on macOS 10.13 for MacBook Air 4,1+
@pestilence669
pestilence669 / spectre.c
Created January 4, 2018 05:25 — forked from ErikAugust/spectre.c
Spectre example code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif
@pestilence669
pestilence669 / aws_elb_log_parser.py
Last active September 21, 2018 18:44
Naïve Python AWS ELB log file regex parser
# vim: set ts=4 sw=4 et fileencoding=utf-8:
# The named tuple and JSON output are just examples / place holders.
from collections import namedtuple
from typing import Optional
import json
import re
import sys
@pestilence669
pestilence669 / cleanupOldAppEngineVersions.sh
Created February 4, 2019 23:27
Delete old deployed versions on Google App Engine
#!/bin/bash
# vim: set ts=4 sw=4 noet fileencoding=utf-8:
readonly SERVICE=${1-api}
readonly versions=$(gcloud app versions list --service=$SERVICE \
--sort-by=~version.createTime \
--format='table[no-heading](id)')
declare -i KEEP_LAST=${KEEP_LAST-5}
declare -i c=0