Skip to content

Instantly share code, notes, and snippets.

@thomasstep
thomasstep / stripeWebhookLambdaHandler.js
Created July 2, 2021 15:38
Stripe webhook handler code for AWS API Gateway and Lambda proxy integration
const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);
const {
updateUserSubscription,
deleteUserSubscription,
} = require('./database');
exports.handler = async function (event, context, callback) {
const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET;
try {
const requestId = event?.requestContext?.requestId;
@BenSampo
BenSampo / deploy.sh
Last active July 16, 2024 07:53
Laravel deploy script
# Change to the project directory
cd $FORGE_SITE_PATH
# Turn on maintenance mode
php artisan down || true
# Pull the latest changes from the git repository
# git reset --hard
# git clean -df
git pull origin $FORGE_SITE_BRANCH
@gruber
gruber / Battery Test — Chrome.scpt
Last active April 22, 2024 08:33
A simple test to load a series of web pages in Chrome on MacOS repeatedly until the battery runs out.
on run
set imessage_id to "" -- leave blank to skip sending periodic iMessage progress updates, put your iMessage ID here to get updates as the script runs
set delay_seconds to 5 -- Don't set to 0, it runs too fast. 0.75 is a good setting for "go fast".
set computer_name to do shell script "scutil --get ComputerName"
set os_version to do shell script "sw_vers -productVersion"
set os_build to do shell script "sw_vers -buildVersion"
set _uptime to do shell script "uptime"
set url_list to {"http://techmeme.com", "http://www.consumerreports.org/laptops/macbook-pros-fail-to-earn-consumer-reports-recommendation/", "https://twitter.com/panzer/status/812367550734401536", "http://www.politico.com/story/2016/12/foreign-travelers-social-media-232930", "http://www.macworld.com/article/3153384/gaming/nintendo-plans-to-release-2-or-3-mobile-games-a-year-after-super-mario-runs-success.html", "http://www.wsj.com/articles/cyber-experts-cite-link-between-dnc-hacks-and-aggression-against-uk
@eresende
eresende / nif-pt.js
Last active April 11, 2024 15:49
Validação de NIF Portugal com Javascript
/*
Source: http://www.portugal-a-programar.pt/topic/58852-algoritmo-de-validacao-de-nif-pt/
*/
function validaContribuinte(contribuinte){
// algoritmo de validação do NIF de acordo com
// http://pt.wikipedia.org/wiki/N%C3%BAmero_de_identifica%C3%A7%C3%A3o_fiscal
var temErro=0;
@staltz
staltz / introrx.md
Last active July 15, 2024 15:43
The introduction to Reactive Programming you've been missing
@jayj
jayj / flexbox.less
Last active June 23, 2024 01:14
CSS3 Flexbox - LESS Mixins
// --------------------------------------------------
// Flexbox LESS mixins
// The spec: http://www.w3.org/TR/css3-flexbox
// --------------------------------------------------
// Flexbox display
// flex or inline-flex
.flex-display(@display: flex) {
display: ~"-webkit-@{display}";
display: ~"-ms-@{display}box"; // IE10 uses -ms-flexbox
@lavoiesl
lavoiesl / apache-template
Created May 7, 2012 19:24
Apache VirtualHost Template with variable replacement
<VirtualHost *:80>
ServerAdmin {USER}@cslavoie.com
ServerName {DOMAIN}
ServerAlias www.{DOMAIN}
ServerAlias {USER}.localhost
ServerAlias {USER}.static.cslavoie.com
DocumentRoot {DOC_ROOT}
<Directory {DOC_ROOT}>
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//