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 / db.sh
Created June 25, 2018 09:34
Postgres DB remote to local puller
#!/bin/bash
ssh devski "pg_dump -U postgres -h 127.0.0.1 -w [DB_NAME] | gzip" >> "/Users/[USER_FOLDER]/Downloads/db.sql.gz";
"/Applications/Postgres.app/Contents/Versions/10/bin/dropdb" [DB_NAME];
"/Applications/Postgres.app/Contents/Versions/10/bin/createdb" [DB_NAME];
gunzip -c "/Users/[USER_FOLDER]/Downloads/db.sql.gz" | "/Applications/Postgres.app/Contents/Versions/10/bin/psql" [DB_NAME] -U postgres;
rm "/Users/[USER_FOLDER]/Downloads/db.sql.gz";
<?php
// Stripped down for brevity
class BPlugin {
public function init () {
// Trigger Google Shopping updates
// =====================================================================
if (!craft()->config->get('devMode')) {
@Tam
Tam / Usage.md
Last active October 30, 2021 20:02
Convert .m4a files that don't work with Spotify to ones that do

How to use (macOS)

  1. $ brew install ffmpeg --with-fdk-aac --with-tools --with-freetype --with-libass --with-libvorbis --with-libvpx --with-x265
    a. You probably will only need the --with-fdk-aac flag, but I'm not sure.
  2. $ cd into the directory with the files you want to fix.
  3. Place the fix_m4a file into that directory (remove the .sh file extension)
  4. $ chmod 700 fix_m4a to allow you to run it
  5. $ ./fix_m4a This will fix all the .m4a files, creating fixed versions prefixed with s-.
@Tam
Tam / craft-ngrok.php
Created June 27, 2017 12:34
How to get ngrok working with Craft CMS during development
<?php
// When using:
// `ngrok http -host-header=example.dev 80`
$isNgrok = array_key_exists("HTTP_X_ORIGINAL_HOST", $_SERVER) && strpos($_SERVER["HTTP_X_ORIGINAL_HOST"], "ngrok");
$host = 'http://' . $_SERVER[$isNgrok ? 'HTTP_X_ORIGINAL_HOST' : 'SERVER_NAME'] . '/';
return array(
function get(url, success, error) {
var request = new XMLHttpRequest();
request.open('GET', window.baseUrl + url, true);
request.setRequestHeader("X-Requested-With", "XMLHttpRequest");
request.onload = function() {
var data = request.responseText;
if (request.status >= 200 && request.status < 400) {
success(data);
} else {
@Tam
Tam / Swipe-Example.js
Created June 2, 2016 09:38
Vanilla JavaScript Swipe Detection
new Swipe(document.getElementById("gallery"), function(event, direction) {
event.preventDefault();
switch (direction) {
case "up":
// Handle Swipe Up
break;
case "down":
// Handle Swipe Down
break;
@Tam
Tam / jetbrains-atom-keymap.cson
Last active February 25, 2016 07:56
A basic JetBrains IDE (IntelliJ,WebStorm,PHPStorm) to Atom Keymap
'atom-text-editor':
'ctrl-g': 'find-and-replace:select-next'
'atom-workspace atom-text-editor:not([mini])':
'cmd-d': 'editor:duplicate-lines'
'alt-shift-up': 'editor:move-line-up'
'alt-shift-down': 'editor:move-line-down'
@Tam
Tam / TextAdventureControls
Last active January 16, 2016 16:22
How to play classic text adventures!
From the first few pages of the manual to
Lost Treasures of Infocom I (also Frotz):
============================================
|| Communicating with Interactive Fiction ||
============================================
With Interactive Fiction, you type your commands in plain English each
time you see the prompt which looks like this:
@Tam
Tam / node_nginx.md
Last active October 19, 2015 12:40
nginx on DigitalOceans NodeJS image

Node / NPM

Use DigitalOceans Ubuntu Node image.

nginx

Install

sudo apt-get update
sudo apt-get install nginx