Skip to content

Instantly share code, notes, and snippets.

View jasonleow's full-sized avatar

Jason Leow jasonleow

View GitHub Profile
@lhermann
lhermann / AdvancedSelect.vue
Created January 29, 2024 09:43
Vue Timezone Picker
<template>
<!-- Select Button -->
<button
ref="referenceRef"
class="flex items-center gap-3 rounded h-10 px-4"
:class="{
'border text-black' : !props.dark,
'border bg-neutral-800 border-neutral-600 text-white' : props.dark,
'opacity-40': disabled,
}"
@realvjy
realvjy / ChoasLinesShader.metal
Last active June 1, 2024 06:19
Choas Lines - Metal Shader
// Lines
float hash( float n ) {
return fract(sin(n)*753.5453123);
}
// Slight modification of iq's noise function.
float noise(vector_float2 x )
{
vector_float2 p = floor(x);
vector_float2 f = fract(x);
@levelsio
levelsio / gist:5bc87fd1b1ffbf4a705047bebd9b4790
Last active May 28, 2024 17:40
Secret of Monkey Island: Amsterdam (by @levelsio) or how to create your own ChatGPT image+text-based adventure game
# 2023-11-27 MIT LICENSE
Here's the open source version of my ChatGPT game MonkeyIslandAmsterdam.com.
It's an unofficial image+text-based adventure game edition of Monkey Island in Amsterdam, my home town.
Please use it however you want. It'd be nice to see more ChatGPT-based games appear from this. If you get inspired by it, please link back to my X https://x.com/levelsio or this Gist so more people can do the same!
Send me your ChatGPT text adventure game on X, I'd love to try it!
@levelsio
levelsio / upgradeSubPrice.php
Created October 8, 2023 17:28
This script upgrades the price on active subscriptions on Stripe
<?
// set price
$newPricePlanId='price_1NsRt5Inbsdfsfddsf';
$newPriceMonthly=39;
$i=1;
foreach($users as $user) {
if(!$user['stripe_customer_id']) {
echo "No Stripe customer id, maybe update in db?";
@sandeep1995
sandeep1995 / worker.js
Created September 29, 2022 08:33
DocsWrite Complete Blogging Platform on top of Google Docs. This small code shows how to have the blog running at `/blog` using Cloudflare worker.
addEventListener("fetch", (event) => {
event.respondWith(
handleRequest(event.request).catch(
(err) => new Response(err.stack, { status: 500 })
)
);
});
async function handleRequest(request) {
let url = new URL(request.url);
<meta property="og:image" content="https://imgen.jitbit.com/?txt={{ title }}&logo={{ url }}" />
<meta name="twitter:image" content="https://imgen.jitbit.com/?txt={{ title }}&logo={{ url }}" />
@tharna
tharna / streak.js
Last active January 12, 2021 09:03
Check streak
if(user.lastPost) {
let lastDate = new Date(JSON.parse(user.lastPost))
lastDate.setHours(0, 0, 0)
lastDate.setMilliseconds(0)
lastDate.setMinutes(-(data.offset))
let currentDate = new Date()
currentDate.setDate(postDate.getDate() - 1)
currentDate.setHours(0, 0, 0)
currentDate.setMilliseconds(0)
currentDate.setMinutes(-(data.offset))
<?
# MIT license, do whatever you want with it
#
# This is my invoice.php page which I use to make invoices that customers want,
# with their address on it and which are easily printable. I love Stripe but
# their invoices and receipts were too wild for my customers on Remote OK
#
require_once(__DIR__.'/../vendor/autoload.php');
@phawk
phawk / payhere_embed_sdk.html
Last active December 29, 2020 08:00
Payhere embed SDK example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Embed Test Site</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
.container {
margin: 4rem auto;
@shanelonergan
shanelonergan / streak-tracker.rb
Last active February 9, 2022 01:01
Example code for tracker number of consecutive days a User performs a Session
class User < ApplicationRecord
has_many :sessions, -> {order "created_at DESC"}
def streak
streak_count = 0
today = Time.now.to_date
dates_array = self.sessions.map do | session |
session.created_at.to_date