Skip to content

Instantly share code, notes, and snippets.

@harperreed
harperreed / create_custom_origin.py
Created January 14, 2011 21:46
creates a custom origin for cloudfront. EASY CDN!
import boto
# requires cf_customorigin branch
# https://github.com/boto/boto/tree/cf_customorigin
origin_domain = 'www.example.org'
cdn_cname = ['media.example.org']
caller_reference = 'exmaple Distribution'
c = boto.connect_cloudfront()
d = c.create_custom_distribution(
@zerolab
zerolab / gist:1633661
Created January 18, 2012 15:52
Convert smart quotes with regular ones (and vice-versa)
<?php
//Quotes: Replace smart double quotes with straight double quotes.
//ANSI version for use with 8-bit regex engines and the Windows code page 1252.
preg_replace('[\x84\x93\x94]', '"', $text);
//Quotes: Replace smart double quotes with straight double quotes.
//Unicode version for use with Unicode regex engines.
preg_replace('[\u201C\u201D\u201E\u201F\u2033\u2036]', '"', $text);
@chappy84
chappy84 / cloudflare_dyn_dns.sh
Last active October 29, 2023 11:10
CloudFlare Dynamic DNS Shell Script
#!/bin/sh
#
# CloudFlare Dynamic DNS
#
# Updates CloudFlare records with the current public IP address
#
# Takes the same basic arguments as A/CNAME updates in the CloudFlare v4 API
# https://www.cloudflare.com/docs/client-api.html#s5.2
#
# Use with cron jobs etc.
@grant-roy
grant-roy / update-jekyll
Last active March 28, 2024 10:45
Bash script to poll Github and rebuild and restart a jekyll site
#!/bin/sh
#This is a simple bash script that will poll github for changes to your repo,
#if found pull them down, and then rebuild and restart a Jekyll site running
#in Nginx. Note, we cannot use cron to schedule a job every 5 seconds, so we create
#a script that executes an infinite loop that sleeps every 5 seconds
#We run the script with nohup so it executes as a background process: $nohup ./update-jekyll
while true
do
@iMerica
iMerica / viscosity-to-ios-connect.rb
Last active May 17, 2024 17:39 — forked from chrisboulton/viscosity-to-ios-connect.rb
Quickly convert all of your Viscosity connections into OVPN configuration files for OpenVPN for iOS (bundles certificates and keys in the files too)
Dir.glob("#{ENV['HOME']}/Library/Application Support/Viscosity/OpenVPN/*/config.conf").each do |file|
certificate_files = ['ca', 'cert', 'key', 'tls-auth']
config_dir = File.dirname(file)
connection_name = nil
new_config = []
File.read(file).lines.each do |line|
line.strip!
if line.start_with?('#viscosity name')
@trapexit
trapexit / split-ovpn
Created August 22, 2016 17:58
Extract certs and keys from OpenVPN ovpn file
#!/bin/bash
OVPN_FILE="${1}"
OUTPUT_PREFIX="${2}"
if [ ! -e "${OVPN_FILE}" ]; then
echo "File not found: ${OVPN_FILE}"
exit 1
fi
@sheldonhull
sheldonhull / RClone-Fixing-Duplicates-GoogleDrive.ps1
Created August 20, 2018 04:50
Fixing Duplicates in Google Drive using Rclone to Dedupe
<#
RCLONE HELP
https://rclone.org/commands/rclone_dedupe/
Useful options I choose
--max-depth int
--dry-run
--log-file=PATH
--tpslimit 1 # can help prevent rate limiting errors you might see if you run verbose x2, ie `-vv`
--checkers 1
@marcwjj
marcwjj / mosh-setup-guide.md
Last active November 12, 2023 12:17
Step by step guide to setup mosh ssh client to Google Cloud VM instance

A beginner's guide to setup Mosh roaming terminal on Mac to access Google Cloud Compute Engine instance

Being new to training ML models using Google Cloud VM instances, I faced issues where my ssh connection to the cloud instance (using either the clound web-based ssh client or using cloud shell) would disconnect from time to time (for example when I power off my laptop or the network gets disconnected) which would terminate the model training process. Therefore I searched for a ssh client that can handle disconnection and can resume connection without disrupting the process running on the server and came across with Mosh mobile shell, a remote terminal app that supports roaming.

It took me a while to figure out how to set up a third party ssh terminal using the google cloud OAuth. Here's a step-by-step guide:

Update: a simpler alternative for persisting remote sessions

Since this writing, another Mosh user kindly advised me that using terminal multiplexer co

@romain9292
romain9292 / mysql_to_bq.py
Last active June 22, 2023 14:31
[Mysql to BigQuery using Pandas] Load Mysql tables to BigQuery using pandas to auto-generate schema #python #pandas #bigquery
import os
import pandas as pd
import pandas_gbq as pd_gbq
import modin.pandas as pd_mod
from sqlalchemy import create_engine
from google.oauth2 import service_account
# Service account file for GCP connection
credentials = service_account.Credentials.from_service_account_file('key.json')
@gmolveau
gmolveau / usb-automount.sh
Last active January 7, 2024 17:56
ubuntu server automount usb hard drive exfat
sudo fdisk -l
sudo blkid
# note the UUID
# create the folder where you want the USB drive to be mounted
sudo mkdir -p /media/usb
# if your USB drive is in exfat
sudo apt install exfat-fuse exfat-utils