Skip to content

Instantly share code, notes, and snippets.

@andrasbacsai
andrasbacsai / firewall.sh
Last active November 10, 2024 12:02
Update a Hetzner Firewall rule with your IP address
#!/bin/bash
# Script to update a firewall rule in a Hetzner Firewall with your current IP address.
# Good if you would like to restrict SSH access only for your current IP address (secure).
#################
# WARNING: This script will overwrite all rules in the firewall rules, so make sure you
# added all the required rules.
# I use a separate firewall rule just for SSH access.
#################
@VariableVic
VariableVic / google-analytics.ts
Last active November 11, 2024 19:47
Medusa -> Google Analytics 4 server side tracking example
import { TransactionBaseService } from "@medusajs/medusa";
import {
ConsentSettings,
EventItem,
JSONPostBody,
} from "../types/google-analytics";
const { subtle } = require("crypto").webcrypto;
// Modified from @mutsuda's https://medium.com/@mutsuda/create-an-ios-widget-showing-google-spreadsheets-data-856767a9447e
// by @levelsio
// HOW TO
// 1) Make a Google Sheet, we'll pull the first cell e.g. A1
// 2) Publish your Google Sheet, File -> Publish To Web
// 3) Copy the SHEET_ID in the URL, put it in here below:
const endpoint = "https://spreadsheets.google.com/feeds/cells/SHEET_ID/1/public/full?alt=json"
// 4) Install Scriptable @ https://apps.apple.com/us/app/scriptable/id1405459188
// 5) Copy this entire script in to Scriptable (tip: you can send it to your iPhone via Whatsapp/Messenger/Telegram etc)
@rsky
rsky / manifest.json
Last active November 9, 2020 21:47
Tiny Proxy Configurator
{
"name": "Tiny Proxy Configurator",
"version": "1.0",
"description": "A tiny and simple proxy configurator.",
"permissions": [
"proxy"
],
"background": {
"scripts": [
"pac.js"
@anjia0532
anjia0532 / nginx.conf
Created December 14, 2017 04:08
nginx proxy_pass add a static parameter
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
@ali-master
ali-master / router.js
Last active September 28, 2020 14:32
HTML5 PushState Routing
const Router = (function () {
"use strict";
/**
* @routes
* get or set routes
*/
var routes = [];
/**
@bergerx
bergerx / aws-spot-price-2017-05-20.out
Last active January 9, 2021 20:56
aws spot instance cheapest core price finder
ap-southeast-1a d2.8xlarge ecpu:116 vcpu:36 monthly:85.3193883495 max:1090.728 price_count:824 --> 0.73551196853$/month/ecpu
us-east-2b c4.xlarge ecpu:16 vcpu:4 monthly:17.229996 max:19.008 price_count:1000 --> 1.07687475$/month/ecpu
us-east-2c c4.xlarge ecpu:16 vcpu:4 monthly:17.247312 max:18.72 price_count:1000 --> 1.077957$/month/ecpu
us-east-2c c4.large ecpu:8 vcpu:2 monthly:8.981424 max:10.656 price_count:1000 --> 1.122678$/month/ecpu
us-east-2a c4.xlarge ecpu:16 vcpu:4 monthly:18.167256 max:18.864 price_count:1000 --> 1.1354535$/month/ecpu
us-east-2b c4.2xlarge ecpu:31 vcpu:8 monthly:35.26795008 max:39.59136 price_count:1000 --> 1.13767580903$/month/ecpu
eu-west-2b c4.xlarge ecpu:16 vcpu:4 monthly:18.251064 max:27.864 price_count:1000 --> 1.1406915$/month/ecpu
us-east-2b c4.large ecpu:8 vcpu:2 monthly:9.128448 max:10.656 price_count:1000 --> 1.141056$/month/ecpu
us-east-2c c4.2xlarge ecpu:31 vcpu:8 monthly:35.5776192 max:40.176 price_count:1000 --> 1.14766513548$/month/ecpu
us-east-2a c4.large ecpu:8 vc
@micw
micw / install_jenkins_plugin.sh
Last active August 11, 2023 06:14
Script to install one or more jenkins plugins including dependencies while jenkins is offline
#!/bin/bash
set -e
if [ $# -eq 0 ]; then
echo "USAGE: $0 plugin1 plugin2 ..."
exit 1
fi
plugin_dir=/var/lib/jenkins/plugins
@DanHerbert
DanHerbert / fix-homebrew-npm.md
Last active September 15, 2024 20:33
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

OBSOLETE

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

@yig
yig / JavaScript reference.md
Last active April 21, 2024 23:36
An overview of JavaScript best practices. Geared towards someone with a C/C++/Java/Python background.

JavaScript reference for non-JavaScript programmers

Author: Yotam Gingold
License: Public Domain (CC0)

This document is intended as a reference or introduction to JavaScript for someone familiar with a language like C/C++/Java or Python. It follows best practices and gathers the scattered wisdom from matny stackoverflow questions and in-depth JavaScript essays. It relies on no external libraries.