Skip to content

Instantly share code, notes, and snippets.

@ralphilius
ralphilius / route.ts
Created June 7, 2024 09:00 — forked from amosbastian/route.ts
Lemon Squeezy webhook using the new route handler in Next.js 13
import crypto from "crypto";
import { listAllSubscriptions } from "lemonsqueezy.ts";
import { NextRequest } from "next/server";
// Put this in your billing lib and just import the type instead
type LemonsqueezySubscription = Awaited<ReturnType<typeof listAllSubscriptions>>["data"][number];
const isError = (error: unknown): error is Error => {
return error instanceof Error;
};
{
"meta": {
"theme": "elegant"
},
"basics": {
"name": "Ralph Ngo",
"label": "Product Manager",
"image": "https://avatars0.githubusercontent.com/u/416209?s=460&u=38f220a2c9c658141804f881c334c594eb1642ac&v=4",
"summary": "I’m a full stack web developer who can build apps from the ground up. I've worked mostly at startups so I am use to wearing many hats. I am a very product focussed developer who priotizes user feedback first and foremost. I'm generally very flexible when investigating new roles. ",
"website": "https://ralphilius.com",
@ralphilius
ralphilius / regex
Created March 4, 2022 06:02
This regular expression will match app versions following the Semantic Versioning scheme greater than or equal to 3.5.0 - https://regex101.com/r/LZBxhe/1
/([3]\.[5]\.([0-9]$|[1-9]\d{1,}))|([3]\.([6-9]|[1-9]\d{1,})\.\d*)|(([4-9]|[1-9]\d{1,})\.\d*\.\d*)/gm
@ralphilius
ralphilius / generate.sql
Created December 8, 2021 02:08
MySQL: Generate millions of rows
CREATE TABLE customers
(
id int not null
);
INSERT INTO customers (id)
SELECT n
FROM
(
select a.N + b.N * 10 + c.N * 100 + d.N * 1000 + e.N * 10000 + f.N * 100000 + 1 N
@ralphilius
ralphilius / [email protected]
Created April 22, 2021 09:43
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.4+commit.c7e474f2.js&optimize=true&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
@ralphilius
ralphilius / [email protected]
Created April 22, 2021 09:43
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.4+commit.c7e474f2.js&optimize=true&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*

Keybase proof

I hereby claim:

  • I am ralphilius on github.
  • I am ralphilius (https://keybase.io/ralphilius) on keybase.
  • I have a public key ASB5H-GWMRRmh6Tv5BRdrOcB9l0hv7Sz4FmriN0CES6ODQo

To claim this, I am signing this object:

@ralphilius
ralphilius / submit.md
Created August 5, 2019 16:09 — forked from tanaikech/submit.md
Enhanced onEdit(e) using Google Apps Script

Enhanced onEdit(e) using Google Apps Script

onEdit(e) which is used for the Edit event on Spreadsheet has the old value as e.oldValue. The specifications for this are as follows.

  1. When an user edited a single "A1" cell, e of onEdit(e) shows hoge for e.oldValue and fuga for e.value.
  2. When an user edited the "A1:A2" multiple cells, e.oldValue and e.value of onEdit(e) are not shown anything.
  3. When an user copied and pasted from other cell, e.oldValue and e.value of onEdit(e) are not shown anything.

This sample script was created to retrieve both the edited values and the old values for the range of edited cells. This is the modified e.oldValue.

{
"messages": [
{
"attachment":{
"type":"template",
"payload":{
"template_type":"list",
"top_element_style":"large",
"elements":[
{
{
"messages": [
{
"attachment": {
"type": "template",
"payload": {
"template_type": "receipt",
"sharable": true,
"recipient_name": "Mark Zuckerberg",
"merchant_name": "Gomi Beauty Shop",