Skip to content

Instantly share code, notes, and snippets.

@terrancesnyder
terrancesnyder / regex-japanese.txt
Created November 7, 2011 14:05
Regex for Japanese
Regex for matching ALL Japanese common & uncommon Kanji (4e00 – 9fcf) ~ The Big Kahuna!
([一-龯])
Regex for matching Hirgana or Katakana
([ぁ-んァ-ン])
Regex for matching Non-Hirgana or Non-Katakana
([^ぁ-んァ-ン])
Regex for matching Hirgana or Katakana or basic punctuation (、。’)
@terrancesnyder
terrancesnyder / setenv.sh
Created May 23, 2011 00:07
./setenv.sh - example setenv.sh with defaults set for minimal time spent in garbage collection
#! /bin/sh
# ==================================================================
# ______ __ _____
# /_ __/___ ____ ___ _________ _/ /_ /__ /
# / / / __ \/ __ `__ \/ ___/ __ `/ __/ / /
# / / / /_/ / / / / / / /__/ /_/ / /_ / /
#/_/ \____/_/ /_/ /_/\___/\__,_/\__/ /_/
# Multi-instance Apache Tomcat installation with a focus
# on best-practices as defined by Apache, SpringSource, and MuleSoft
@terrancesnyder
terrancesnyder / app.js
Last active August 28, 2024 01:55
Google Form Script to Update Dropdown from Sheet
/**
* Main function to run to update our forms.
*/
function main(formID) {
var dropdown = findDropdown_(formID || '1l3Txklywu6AF6jfkzMRPccdzpsOkhHLoOhNol9OwVV4', 'Agreement Group')
dropdown.setChoiceValues(getAgreementGroups_());
}
/**
* Get the latest agreement groups available to select from.
@terrancesnyder
terrancesnyder / envoy_workload_id.yaml
Created August 8, 2024 15:20
Enable envoyfilter to inject a common workload id sourced from env, jwt and mtls with a priority of (1) jwt, (2) mtls and (3) env.
kubectl apply -n gateways -f - <<EOF
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: lua-filter-example
spec:
configPatches:
- applyTo: HTTP_FILTER
match:
context: ANY # Adjust if needed for your use case
@terrancesnyder
terrancesnyder / lua.yaml
Created August 8, 2024 15:21
JSON encode LUA configmap for istio
apiVersion: v1
kind: ConfigMap
metadata:
annotations:
name: lua-libs
namespace: gateways
data:
JSON.lua: "-- -*- coding: utf-8 -*-\n--\n-- Simple JSON encoding and decoding in
pure Lua.\n--\n-- Copyright 2010-2017 Jeffrey Friedl\n-- http://regex.info/blog/\n--
Latest version: http://regex.info/blog/lua/json\n--\n-- This code is released
@terrancesnyder
terrancesnyder / send_email_row.js
Created June 5, 2024 06:30
send_email_on_row_change (Click on Extensions > Apps Script.)
function onEdit(e) {
// Get the range that was edited
var range = e.range;
var sheet = range.getSheet();
// Specify the column that triggers the email (e.g., column 3 is column C)
var triggerColumn = 3;
// Check if the edited column is the one we are interested in
if (range.getColumn() == triggerColumn) {
// Get the row of the edited cell
var row = range.getRow();
@terrancesnyder
terrancesnyder / node-0mq-ctrl-c.js
Created September 7, 2012 21:14
Handling Ctrl-C cleanly in Node.js
// Show how to handle Ctrl+C in Node.js
var zmq = require('zmq')
, socket = zmq.createSocket('rep');
socket.on('message', function(buf) {
// echo request back
socket.send(buf);
});
@terrancesnyder
terrancesnyder / logging.properties
Created May 24, 2011 21:56
logging.properties - default logging.properties for shared use in tomcat
# ==================================================================
# ______ __ _____
# /_ __/___ ____ ___ _________ _/ /_ /__ /
# / / / __ \/ __ `__ \/ ___/ __ `/ __/ / /
# / / / /_/ / / / / / / /__/ /_/ / /_ / /
#/_/ \____/_/ /_/ /_/\___/\__,_/\__/ /_/
# Multi-instance Apache Tomcat installation with a focus
# on best-practices as defined by Apache, SpringSource, and MuleSoft
# and enterprise use with large-scale deployments.
@terrancesnyder
terrancesnyder / example_rule.json
Created September 14, 2023 02:59
Example of protecting with Ory Oathkeeper Access to API (GET)
{
"id": "Protect a People API with Consent Check",
"match": {
"url": "http://api.woven-city.io/api/people/contacts",
"methods": [ "GET" ]
},
"upstream": {
"url": "https://my_container_or_dns:8080/api/people/contacts"
},
"authenticators": [{
@terrancesnyder
terrancesnyder / gzip-hdfs
Created October 29, 2013 18:34
Hadoop GZIP command line
hadoop fs -cat /Work/lon_text/lon_order_data_t/cdw320_lon_order_data_t.1.txt | head -100 | gzip > test.csv.gz
cat cdw320_lon_order_data_t.1.txt | head -100 | gzip > ../../tsnyder/cdw320_lon_order_data_t.1.txt.gz
hadoop fs -cat /Work/tsnyder/cdw320_lon_order_data_t.1.txt.gz | gunzip