This code is companion to my blog post here: https://blog.sandipb.net/2015/05/20/serializing-structured-data-into-avro-using-python/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import sys | |
import requests | |
def expand_url(match): | |
short_url = match.group(0) | |
response = requests.head(short_url, allow_redirects=False) | |
if response.status_code in (301, 302): | |
return response.headers["location"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
code_remote () | |
{ | |
local remote_node_path=$VSCODE_GIT_ASKPASS_NODE; | |
if [ -z "$remote_node_path" ]; then | |
echo "VSCODE_GIT_ASKPASS_NODE is not set. Cannot determine path to remote-cli"; | |
return 1; | |
fi; | |
local remote_cli_path=$(dirname $remote_node_path)/bin/remote-cli/code; | |
if [ ! -f "$remote_cli_path" ]; then | |
echo "Remote CLI not found at $remote_cli_path"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export GCLOUD_TUNNEL_PID=/tmp/gcloud-tunnel-pid | |
function proxy_bastion() { | |
local BASTION_HOST="bastion-instance" | |
local GCP_ZONE="us-east4-a" | |
[[ -f $GCLOUD_TUNNEL_PID ]] && echo "File $GCLOUD_TUNNEL_PID exists. A previous tunnel might be active. Aborting." && return | |
set -x | |
gcloud compute ssh $BASTION_HOST --zone=$GCP_ZONE --verbosity=warning --tunnel-through-iap --ssh-flag='-D1080 -N' & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
EXTENSIONS=( | |
# General | |
ms-vscode-remote.vscode-remote-extensionpack | |
ms-vscode-remote.remote-ssh | |
stkb.rewrap | |
tomsaunders-code.workspace-explorer | |
# Golang | |
golang.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e -o pipefail | |
usage() { | |
cat <<HELP | |
USAGE: $0 PDF_FILE [OUTPUT_DIR|OUTPUT_FILE] | |
Decrypts given pdf file usingh qpdf by prompting for a password. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# $PRIVATE_IF is private lan, $PUBLIC_IF is public lan | |
# the interface which is connected to the interface. | |
# The default route of this host is already set via this interface | |
PUBLIC_IF=enp1s0 | |
# The interface connecting to the internal lan, which needs this host to be a router to the Internet | |
PRIVATE_IF=enp2s0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mkdir dtemp | |
$ cd dtemp | |
$ poetry init | |
This command will guide you through creating your pyproject.toml config. | |
Package name [dtemp]: Django Test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$data = [ | |
{'name'=> 'emily', 'age'=> 6}, | |
{'name'=> 'john', 'age'=> 5}, | |
{'name'=> 'jade', 'age'=> 4}, | |
{'name'=> 'grant', 'age'=> 2}, | |
] | |
function age_sorted_names($ar) >> Array { | |
$ar.map |$idx, $entry| { | |
[$entry['age'], $entry['name']] |
Specifically, even if the file has no printing restrictions, like many government forms do (my specific itch), Ghostscript refuses to print the file and generates a blank pdf.
- Put contents of
unblockprint.sh
in an executable file named/usr/lib/cups/filter/unblockprint
. Make sure that the permissions of this file matches others in the same directory. - Put
local.convs
in/etc/cups
NewerOlder