Skip to content

Instantly share code, notes, and snippets.

View AlvinTheDeveloper's full-sized avatar

Alvin Lau AlvinTheDeveloper

View GitHub Profile
@AlvinTheDeveloper
AlvinTheDeveloper / stripe-one-time-payment-backend.js
Last active February 18, 2022 08:00
Another alternative solution for Stripe one time payment. This code can be used on Serverless products and Express.js.
require('dotenv').config()
const stripe = require("stripe")(process.env.STRIPE_API_SECRET_KEY);
async function getOrCreateCustomer(req){
let customer=await stripe.customers.list({email:req.body.email})
if(customer.data.length<=0){
customer = await stripe.customers.create({
name:req.body.name,
email:req.body.email,
@AlvinTheDeveloper
AlvinTheDeveloper / bitcoin.conf
Last active September 12, 2025 12:03
Config for Bitcoin Core
# Generated by https://jlopp.github.io/bitcoin-core-config-generator/
# This config should be placed in following path:
# $HOME/Library/Application Support/Bitcoin/bitcoin.conf
# [core]
# Specify a non-default location to store blockchain data.
blocksdir=/Users/alvinlau/Library/Application Support/Bitcoin/blocks
# Run in the background as a daemon and accept commands.
daemon=1
@AlvinTheDeveloper
AlvinTheDeveloper / shake_html_element.js
Created March 21, 2018 06:36
Using jQuery to make a HTML element shakes.
$("div").animate({
left: '1%'
},50).animate({
left: '0%'
},50);$("div").animate({
left: '1%'
},50).animate({
left: '0%'
},50);$("div").animate({
left: '1%'
@AlvinTheDeveloper
AlvinTheDeveloper / tryProxyApi.js
Last active February 5, 2021 07:23
This is a little learning note for myself actually. This can be a little hint for someone who started to use proxy API without knowledge on making HTTP request with proxy. Not all the proxies given by the provider work. Please retry if you got connection failed. I used GimmeProxy for this note but it does not mean I suggest to use it.
const request=require('request-promise');
async function main(){
//By making a GET request to the API, the API returns the information about the proxy.
//The code below also parse JSON into JavaScript object.
let proxyInfo=JSON.parse(await request('https://gimmeproxy.com/api/getProxy?protocol=http'));
console.log(proxyInfo);
/* Sample JSON result
{
"supportsHttps": true,