Skip to content

Instantly share code, notes, and snippets.

import datetime
import re
import os
badTimeStamp = datetime.datetime.strptime("2010-03-08 15:02:59 -0500", "%Y-%m-%d %H:%M:%S %z")
desiredTimeStamp = datetime.datetime.strptime("2017-08-28 11:15:59 -0400", "%Y-%m-%d %H:%M:%S %z")
delta = desiredTimeStamp - badTimeStamp
for line in open("../backup.log", "r"):
m = re.match("r(\\d+) \\| jeff \\| (.*) \(", line)
@preshing
preshing / main.cpp
Created January 3, 2018 21:54
Use SFINAE to call member function if present
#include <iostream>
class Foo {
public:
void bar() {
std::cout << "Foo::bar() called" << std::endl;
}
};
class Foo2 {
@preshing
preshing / gist:561dca75964f284b376b1610b11735fd
Created April 27, 2019 03:56
Testing range-based for loop over explicitly created std::initializer_list
Results of a few quick tests performed in response to:
https://twitter.com/Steven_Pigeon/status/1121900020746338305
// This is the original version that HAS the bug (garbage value encountered during iteration):
for (const AxisRay& faceRelVedge : std::initializer_list<AxisRay>{
{{0, 0, -1}, Axis3::YNeg},
{{0, 1, 0}, Axis3::ZPos},
{{-2, -1, 0}, Axis3::ZPos},
{{-1, -1, -1}, Axis3::XPos}}) {
@preshing
preshing / ManifoldGarden.asl
Last active March 2, 2020 18:46
Manifold Garden AutoSplit script
// AutoSplit script for Manifold Garden 1.0.30.13294
//
// Automatically starts the timer ~2.4 seconds after starting a new game, and splits the timer
// when transitioning between game levels. You must still reset the timer manually between runs.
// If you accidentally backtrack through a portal, causing an unwanted split, you'll have
// to undo it manually (default NumPad8 in LiveSplit).
//
// To compensate for the late start, you should delay your start timer by 2.4 seconds in LiveSplit.
// (Right-click -> Edit Splits -> Start timer at:)
//