Skip to content

Instantly share code, notes, and snippets.

View mmorearty's full-sized avatar

Mike Morearty mmorearty

View GitHub Profile

To create a cron expression that runs at 3 AM every other Tuesday, we need to carefully calculate the days. Cron doesn't natively support "every other Tuesday" directly in a simple expression, so we typically work around this limitation by specifying the exact days of the month this would occur or by using additional scripts or conditions to check weeks. Here, I'll give you an example using a basic cron expression set to trigger every Tuesday, and then explain how you might manually calculate specific Tuesdays if you want to strictly limit it to "every other Tuesday."

Basic Cron Expression for Every Tuesday at 3 AM

The basic cron format is:

MIN HOUR DAY_OF_MONTH MONTH DAY_OF_WEEK COMMAND
const myset = new Set();
const myarray = [];
for (let i=0; i<1000 * 1000; i++) {
myset.add(i);
myarray.push(i);
}
function reportTime(label, callback) {
const start = process.hrtime();
@mmorearty
mmorearty / BUILD
Created March 23, 2018 15:47
Bazel stamp for a custom rule
load(":myrules.bzl", "mybundle")
mybundle(
name = "main",
srcs = ["in.txt"],
)
@mmorearty
mmorearty / malloc-bytes.c
Created October 26, 2015 17:08
Memory-consumption test to accompany http://superuser.com/a/767491/94393
// Compile this with "cc malloc-bytes.c -o malloc-bytes"
// Run with e.g. "./malloc-bytes 1000000" (mallocs 1MB)
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[]) {
if (argc < 2) {
fprintf(stderr, "Usage: %s <bytes-to-allocate>\n", argv[0]);
exit(1);
@mmorearty
mmorearty / inittest.go
Created March 14, 2013 17:11
Cute: in #golang, any function called init() is automatically executed, AND you can have more than one per source file.
package main
func init() {
println("first")
}
func init() {
println("second")
}
@mmorearty
mmorearty / TestImplicitValue.scala
Created January 8, 2013 20:56
I can't get the new Scala 2.10 implicit value classes to compile. Trying to compile this with "scalac TestImplicitValue.scala" fails with the errors shown below in the Comments section. If you reply, please let me know on Twitter: @mmorearty
implicit class MyRichInt(val self: Int) extends AnyVal {
def plusOne: Int = self + 1
}
object TestImplicitValue {
def main(args: Array[String]) =
println(30.plusOne)
}
@mmorearty
mmorearty / gitpullall.rb
Created September 27, 2012 18:57
Finds all git repos under the current directory, and does "git pull" on each
#!/usr/bin/env ruby
#
# Finds all git repos under the current directory, and does "git pull" on each.
#
# To use this, you must first "gem install colored"
require 'colored'
def gitpull(dir)
dir = File.absolute_path(dir)
@mmorearty
mmorearty / 0001-Fix-comment-on-TTPhoto.size-property.patch
Created January 9, 2011 15:49
Fix comment on TTPhoto.size property
From 07c36b4b85f0ca93cfda9a480fd76b204f472296 Mon Sep 17 00:00:00 2001
From: Mike Morearty <mike@morearty.com>
Date: Mon, 10 Jan 2011 22:32:56 -0800
Subject: [PATCH] Fix comment on TTPhoto.size property
---
src/Three20UI/Headers/TTPhoto.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/Three20UI/Headers/TTPhoto.h b/src/Three20UI/Headers/TTPhoto.h