Skip to content

Instantly share code, notes, and snippets.

@lawrenceching
lawrenceching / install-frp-as-systemd-service.sh
Last active April 24, 2024 10:57
Install frp as systemd service
# Update on 2024/04/13
# 1. Improved OS compatibility: try wget and then curl for downloading files.
#
# Update on 2024/01/26
# 1. Thanks to GitHub user @aka-Ani, this script now will install latest version of frp:
# https://gist.github.com/lawrenceching/41244a182307940cc15b45e3c4997346?permalink_comment_id=4851742#gistcomment-4851742
# 2. Use .toml conf file as .ini became lagacy
#
# Update on 2023/06/19
# 1. frp no longer provide systemctl service file. This script creates frpc/fprs systemctl service file by itself
@kktse
kktse / README.md
Created October 19, 2023 20:28
Installing brlaser CUPS drivers for printing on Apple Silicon Macs and Brother printers

Installing brlaser CUPS drivers for printing on Apple Silicon Macs and Brother printers

Problem

You own a Mac running MacOS and want to print a document using a Brother printer. You also prefer not to use MacPorts because you have another package maanger installed.

Environment

  • I used a 2021 Macbook Pro 14" running Sonoma 14.0
  • I am using Homebrew as a package manager
@wpweb101
wpweb101 / woo-vou-unlimited-code-params.php
Last active April 24, 2024 10:53
Woocommerce PDF Vouchers - Modify Unlimited voucher codes pattern logic
<?php
// You can modify / remove following fields using the filter
// buyername, code_prefix, order_id, data_id, $item_id
// $voucher_codes = array( 'buyername' => $buyername, 'code_prefix' => $code_prefix, 'order_id' => $order_id, 'data_id' => $data_id, 'item_id' => $item_id, 'separator' => '-' );
function woo_vou_unlimited_code_pattern_modification( $voucodes_args = array() ) {
if( $voucodes_args['buyername'] ) {// if you want to remove buyername from pattern
unset( $voucodes_args['buyername'] );
}
@dhh
dhh / pagination_controller.js
Last active April 24, 2024 10:53
HEY's Stimulus Pagination Controller
/*
ERB template chunk from The Feed's display of emails:
<section class="postings postings--feed-style" id="postings"
data-controller="pagination" data-pagination-root-margin-value="40px">
<%= render partial: "postings/snippet", collection: @page.records, as: :posting, cached: true %>
<%= link_to(spinner_tag, url_for(page: @page.next_param),
class: "pagination-link", data: { pagination_target: "nextPageLink", preload: @page.first? }) unless @page.last? %>
</section>
@mendhak
mendhak / apigateway.tf
Last active April 24, 2024 10:52
Terraform - API Gateway with greedy path (proxy+) calling httpbin. Also includes deployment
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.0"
}
}
}
provider "aws" {
@gene1wood
gene1wood / all_aws_lambda_modules_python.md
Last active April 24, 2024 10:52
AWS Lambda function to list all available Python modules for Python 2.7 3.6 and 3.7
@lepikhinb
lepikhinb / .aliases
Created October 1, 2022 23:23
Bash aliases for common commands
# Git
alias wip="git add .; git commit -m 'wip'"
alias push="git push"
# PHP
alias c="composer"
alias pest='./vendor/bin/pest'
alias pint='./vendor/bin/pint'
alias stan='./vendor/bin/phpstan'
@wholtz
wholtz / rclone_copy.py
Last active April 24, 2024 10:49
Rclone copy in Jupyter notebook with progress bar widget
from subprocess import Popen, PIPE
from tqdm.notebook import tqdm
RCLONE_PATH = "/usr/local/bin/rclone"
cmd = [RCLONE_PATH, "copy", "source_directory", "my_remote:destination_directory/", "--progress"]
with tqdm(total=100, desc="Percentage of total number of files", unit="%") as pbar:
with Popen(cmd, stdout=PIPE, bufsize=1, universal_newlines=True) as proc:
for line in proc.stdout:
line = line.strip()
# ██████╗ ███████╗███╗ ███╗ ██████╗ ██╗ ██╗███████╗ ██╗ ██╗██████╗
# ██╔══██╗██╔════╝████╗ ████║██╔═══██╗██║ ██║██╔════╝ ██║ ██║██╔══██╗
# ██████╔╝█████╗ ██╔████╔██║██║ ██║██║ ██║█████╗ ███████║██████╔╝
# ██╔══██╗██╔══╝ ██║╚██╔╝██║██║ ██║╚██╗ ██╔╝██╔══╝ ██╔══██║██╔═══╝
# ██║ ██║███████╗██║ ╚═╝ ██║╚██████╔╝ ╚████╔╝ ███████╗ ██║ ██║██║
# ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═══╝ ╚══════╝ ╚═╝ ╚═╝╚═╝
#
# ██████╗ ██╗ ██████╗ █████╗ ████████╗██╗ ██╗ █████╗ ██████╗ ███████╗
# ██╔══██╗██║ ██╔═══██╗██╔══██╗╚══██╔══╝██║ ██║██╔══██╗██╔══██╗██╔════╝
# ██████╔╝██║ ██║ ██║███████║ ██║ ██║ █╗ ██║███████║██████╔╝█████╗