Skip to content

Instantly share code, notes, and snippets.

View Tam's full-sized avatar
🐢
I may be slow to respond.

Tam Tam

🐢
I may be slow to respond.
View GitHub Profile
@Tam
Tam / smooth_camera_zoom_and_pan.gd
Last active May 9, 2024 17:48
A smoothly panning and zooming camera for Godot 4 (now with mouse edge panning)
extends Camera2D
# Note: Limit smoothing and position smoothing must be disabled
const V2_2: Vector2 = Vector2.ONE * 2
const PAN_SPEED: int = 2000
const PAN_SMOOTHING: int = 8
# How far from the edge of the screen panning starts (% of screen size)
const EDGE_PAN_THRESHOLD_MIN: Vector2 = Vector2(0.06, 0.12)
@Tam
Tam / merge_repos.sh
Last active October 25, 2023 15:16 — forked from icholy/merge_repos.sh
Automatically get correct main branch name
#!/bin/bash
# This script takes a remote repository and merges it into
# the current one as a subdirectory
set -e
if [ -z "$1" ]
then
echo "Usage:"
@Tam
Tam / no-pg-guff
Created July 5, 2021 11:58
Will follow the logs of your PGSQL container while filtering out the guff
$ docker logs -fn 10 my_container_name 2>&1 | grep -v -e "] LOG:" -e "] DETAIL:" -e "] STATEMENT:"
@Tam
Tam / regex.txt
Created January 28, 2021 10:01
Regex to remove comments from graphql.schema file
/\s+"""[\s\S]*?"""/sg
@Tam
Tam / Plugin.php
Last active September 23, 2022 04:07
Add subscription pause support to Commerce Stripe
<?php
namespace modules;
use Craft;
use craft\commerce\elements\Subscription;
use DateTime;
use Twig\Error\LoaderError;
use Twig\Error\SyntaxError;
use yii\base\Module;
@Tam
Tam / preact-router-match-hook.js
Last active December 10, 2020 15:47
Preact Router match hook (useMatch)
import { getCurrentUrl, exec, subscribers } from 'preact-router';
import { useEffect, useState } from 'preact/hooks';
/**
* Hook to check if the given path matches the current URL
*
* const [matches, { path }] = useMatch('/my/:path?');
*
* @param {string} path - The path to check against
* @return {[boolean, Object]}
@Tam
Tam / currency-to-country.csv
Last active October 15, 2020 10:49
Mapping country code to currency code with currency name and symbol
country country_code currency unit_text symbol
New Zealand NZ NZD New Zealand Dollar $
Cook Islands CK NZD New Zealand Dollar $
Niue NU NZD New Zealand Dollar $
Pitcairn PN NZD New Zealand Dollar $
Tokelau TK NZD New Zealand Dollar $
Australian AU AUD Australian Dollar $
Christmas Island CX AUD Australian Dollar $
Cocos (Keeling) Islands CC AUD Australian Dollar $
Heard and Mc Donald Islands HM AUD Australian Dollar $
@Tam
Tam / cmd.sh
Last active June 25, 2019 10:30
Using ngrok with Craft CMS 3
ngrok http -region=eu -host-header=my-dev-domain.local 443
@Tam
Tam / command.sh
Last active May 16, 2019 10:17
Craft CMS Ngrok w/ Docker
ngrok http dev.example.com:443 -host-header=dev.example.com -region=eu
@Tam
Tam / crontab
Last active February 23, 2019 10:45
Digital Ocean IP A record updater
*/15 * * * * python /path/to/ddns.py