Skip to content

Instantly share code, notes, and snippets.

View gyopiazza's full-sized avatar

Giordano Piazza gyopiazza

View GitHub Profile
@gyopiazza
gyopiazza / schema.ts
Last active November 10, 2024 10:52
Multi-tenant with Drizzle ORM (multiple sqlite databases) - PoC
import { integer, sqliteTableCreator, text } from 'drizzle-orm/sqlite-core'
const sqliteTable = (tenant?: string) =>
sqliteTableCreator(name => (tenant ? `${tenant}_${name}` : name))
export const users = sqliteTable()('users', {
id: integer('id', { mode: 'number' }).primaryKey({ autoIncrement: true }),
name: text('name'),
})
@gyopiazza
gyopiazza / util-elastic-collision.js
Last active November 8, 2019 20:48 — forked from christopher4lis/util-elastic-collision.js
A set of utility functions used to reproduce the effect of elastic collision within HTML5 canvas. Used in the Chris Courses tutorial video on collision detection: https://www.youtube.com/watch?v=789weryntzM
/**
* Check if 2 circles collide
*
* Takes velocities and alters them as if the coordinate system they're on was rotated
*
* @param Number | p1x | x coordinate of the first particle
* @param Number | p1y | y coordinate of the first particle
* @param Number | r1 | radius of the first particle
* @param Number | p2x | x coordinate of the second particle
* @param Number | p2y | y coordinate of the second particle
import { app, h } from "hyperapp";
import { Stateful } from './helpers'
/* Working example, https://codepen.io/sergey-shpak/pen/maMopd */
// --- STATEFUL COMPONENT ---
// Don't use arrow functions for stateful components/actions
// Since context is linked to it's definition context
@gyopiazza
gyopiazza / auto_install_activate_plugins.php
Created May 26, 2015 10:51
Auto install/activate plugins in TGMPA
<?php
// Usage:
//
// Copy the 2 functions below into your theme.
//
// Add the 'auto_install' attribute when registering the plugins:
//
// array(
// 'name' => 'Some Plugin',
<?php
/*
*------------------------------------------------------------------------------------------------
* Determine if string is serialized
*------------------------------------------------------------------------------------------------
*
*/
function string_is_serialized($str)
{