Skip to content

Instantly share code, notes, and snippets.

@esycat
esycat / WEEKDAYOFMONTH.vba
Created July 14, 2019 12:41
A custom function for Excel to find Nth weekday of the month
Function WEEKDAYOFMONTH(month As Date, dow As Integer, offset As Integer)
FirstDayOfMonth = month - Day(month) + 1
LastDayOfMonth = WorksheetFunction.EoMonth(month, 0)
If offset > 0 Then
StartDate = FirstDayOfMonth + offset * 7
adjustment = weekday(FirstDayOfMonth + 7 - dow)
ElseIf offset < 0 Then
StartDate = LastDayOfMonth + (offset + 1) * 7
adjustment = weekday(LastDayOfMonth - dow)
@esycat
esycat / git-find-unique-commits-nr.sh
Last active June 16, 2017 14:23
Find the number of unique commits since the given date on all remote heads
# N.B. The uniquenes is determined based on `git-patch-id` that is simply a hash of the diff
since="2016-07-01"
for c in $(git log --since="${since}" --remotes --format="%H") ; do git show $c | git patch-id ; done | sort -u | wc -l
@esycat
esycat / yay-time.sql
Last active August 29, 2015 14:05
For Tim & Marley with Love :-)
SELECT
DATABASE(), table_name, column_name, data_type,
CONCAT(
"UPDATE ", table_name,
" SET ", column_name, " = CONVERT_TZ(", column_name, ", 'UTC', 'Australia/Sydney')",
" WHERE ", column_name, " > '2014-08-05 22:00:00';"
) AS query
FROM information_schema.columns
WHERE
table_schema = DATABASE()
<?php //exit;
ini_set('display_errors', true);
require_once('config.php');
require_once($folders['lib_prefix'].'/common.php');
echo 'I am relatively healthy.', '<br />';
$filename = './t_second_rna_a14.log';
@esycat
esycat / .gitignore
Last active January 1, 2016 09:08
MinifyJsTask doesn't work from an included file https://github.com/eriwen/gradle-js-plugin/issues/61
.gradle
build
main.min.js
@esycat
esycat / .gitignore
Last active January 17, 2018 00:17
/.gradle/
/build/
/buildSrc/
generated.conf
@esycat
esycat / indent.sh
Created September 27, 2013 06:16
indent params
TAB_SIZE=4
LINE_LENGTH=120
indent \
--no-tabs \
--tab-size${TAB_SIZE} \
--line-length${LINE_LENGTH} \
--space-after-cast \
--braces-on-if-line \
--braces-on-func-def-line \
@esycat
esycat / PrettyPrinter.groovy
Last active December 19, 2023 16:20
A simple way to pretty print nested lists and maps in Groovy.
import static groovy.json.JsonOutput.*
def config = ['test': 'lalala']
println prettyPrint(toJson(config))
@esycat
esycat / build.gradle
Last active June 6, 2018 21:48
An example Gradle build configuration that shows that `ext` does not always point to the same object as `project.ext`. The assertion on line 10 fails.
assert(project.ext == ext)
// assigning some values just for testing
project.ext.set('a', 'a-val')
ext.set('b', 'b-val')
assert(project.ext == ext)
task test() {
assert(project.ext == ext)