Skip to content

Instantly share code, notes, and snippets.

View weirdwater's full-sized avatar
🌮

Arjo Bruijnes weirdwater

🌮
View GitHub Profile
@weirdwater
weirdwater / dayOnDate
Created May 4, 2015 15:43
JavaScript function that returns a given date's weekday
/**
* Returns a string with the weekday of the given date
* Example: 1, 1, 1970 returns 'Thursday'
* @param {number} day The date's day
* @param {number} month The date's month
* @param {number} year The date's year
* @return {string} The weekday
*/
function dayOnDate(day, month, year) {
// Days of the week, starting at Saturday = 0;
@weirdwater
weirdwater / target
Created June 14, 2015 18:54
Returns the next position towards the target.
/// <summary>
/// Plots a path towards the specified target.
/// Only returns a position within the given speed.
/// </summary>
/// <param name="target">Target.</param>
public Vector2 Target(Vector2 position, Vector2 target, float speed)
{
// Determines current triangle.
var diffX = target.X - position.X;
var diffY = target.Y - position.Y;

Keybase proof

I hereby claim:

  • I am weirdwater on github.
  • I am weirdwater (https://keybase.io/weirdwater) on keybase.
  • I have a public key whose fingerprint is D7B5 7020 C3B6 52B0 A956 AC11 796D 3EF7 146C 895A

To claim this, I am signing this object:

@weirdwater
weirdwater / scanDirForExtension.php
Created August 7, 2015 15:45
Returns a list of files in a directory that match the given
/**
* Scans the given directory for files that end with the given file extension.
* @param string $directory Directory to be scanned.
* @param string $extension The desired file extension.
* @return array List of files with given extension.
*/
function scanDirForExtension($directory, $extension)
{
$list = scandir($directory);
$filelist = [];
@weirdwater
weirdwater / pluralToSimple.php
Last active January 19, 2016 13:06
Convert a plural noun to a singular one.
<?php
function pluralToSimple($str)
{
$newStr = $str;
$irregulars = [
'women' => 'woman',
'men' => 'man',
'teeth' => 'tooth',
'children' => 'child',
@weirdwater
weirdwater / getProp.sh
Last active December 9, 2016 20:40
Get the value of a key from a .properties file
#!/bin/bash
E_BADARGS=85
E_NOTFOUND=86
# Check if key parameter was provided.
if [ -z "$1" ]; then
echo "Please provide a key to match."
exit $E_BADARGS
fi
Verifying my Blockstack ID is secured with the address 1BN5V6tey6J59sPSaEivcxHcNrP1fn7Pta https://explorer.blockstack.org/address/1BN5V6tey6J59sPSaEivcxHcNrP1fn7Pta
@weirdwater
weirdwater / DatepickerTest.tsx
Last active December 19, 2019 20:48
UTC Datepicker
import React, { useState } from 'react';
import ReactDatePicker from 'react-datepicker';
export const DatepickerTest = () => {
const [date, setDate] = useState(new Date())
return (
<div>
<p>Actual value: {date.toString()}</p>
@weirdwater
weirdwater / trello-to-csv.ts
Created June 20, 2020 13:47
Card Sorting Transformation Script
// Run with Deno
import * as log from 'https://deno.land/x/std/log/mod.ts'
interface ListLike {
id: string
name: string
}
interface CardLike {
id: string
@weirdwater
weirdwater / cron-container.yml
Last active December 31, 2020 13:35
Cron Sidecar
version: '3'
services:
cron:
image: alpine:3.5
environment:
CRON_RULES: |
0-58/2 * * * * /bin/echo 'tick'
1-59/2 * * * * /bin/echo 'tock'
command: /bin/sh -c "echo \"$$CRON_RULES\" | crontab - ; /usr/sbin/crond -f"