Skip to content

Instantly share code, notes, and snippets.

@rastandy
rastandy / aws-rds-global-bundler-extractor.sh
Last active July 11, 2024 11:08 — forked from alencar/aws-rds-global-bundler-extractor.sh
Extract AWS RDS Global Bundle certificates into a PKCS#12 keystore compatible with Java
#!/bin/bash
# Based on https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL-certificate-rotation.html
#
# Improvements
# - Removed Perl dependency
mydir=tmp/certs
if [ ! -e "${mydir}" ]
then
@rastandy
rastandy / building-sync-systems.md
Created February 13, 2024 15:55 — forked from pesterhazy/building-sync-systems.md
Building an offline realtime sync engine

So you want to write a sync system for a web app with offline and realtime support? Good luck. You might find the following resources useful.

Overview articles

Quick Start

sudo curl https://gist.githubusercontent.com/pankaj28843/3ad78df6290b5ba931c1/raw/soffice.sh > /usr/local/bin/soffice && sudo chmod +x /usr/local/bin/soffice

Create an bash script at /usr/local/bin/soffice with following content

#!/bin/bash

# Need to do this because symlink won't work
@rastandy
rastandy / ffmpeg GIF to MP4.MD
Created October 26, 2022 17:09 — forked from gvoze32/ffmpeg GIF to MP4.MD
Convert animated GIF to MP4 using ffmpeg in terminal.

To convert animation GIF to MP4 by ffmpeg, use the following command

ffmpeg -i animated.gif -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" video.mp4

Description

movflags – This option optimizes the structure of the MP4 file so the browser can load it as quickly as possible.

pix_fmt – MP4 videos store pixels in different formats. We include this option to specify a specific format which has maximum compatibility across all browsers.

#!/bin/bash
user=$1
repo=$2
permissions=$3
echo "Adding ${user} to repo ${repo} with permissions ${permissions}..."
gh api -XPUT repos/${repo}/collaborators/${user} -f permission=${permissions}
echo "done."
@rastandy
rastandy / solutions-json.php
Last active October 1, 2024 13:31
A Wordpress page template for obtaining a GeoJSON file from a list of posts with custom fields
<?php
/*
Template Name: Solutions JSON
*/
header( 'Content-Type: application/geo+json' . '; charset=' . get_option( 'blog_charset' ), true );
$more = 1;
echo '{"type": "FeatureCollection", "features": [';
@rastandy
rastandy / HOWTO.md
Created March 17, 2021 13:50 — forked from cvan/HOWTO.md
get all URLs of all network requests made on a web page from the Chrome Dev Tools (from an exported HAR)

Setup

Using Homebrew on Mac OS X:

brew install jq

Add these aliases to your profile (e.g., ~/.zshrc, ~/.bashrc, ~/.profile, etc.):

alias hurlp='pbpaste | jq ".log.entries" | tee >(jq --raw-output "[.[] | .request.url] | sort | unique | .[]")'

alias hurld='pbpaste | jq ".log.entries" | jq --raw-output "[.[] | .request.url] | sort | unique | .[]" | harurls | tee >(xargs -n 1 curl -O $1)'

@rastandy
rastandy / README.md
Created November 26, 2019 11:16 — forked from zulhfreelancer/README.md
S3 Website + CloudFront - how to show index.html content when at /sub-directory/ path?

Problem

We have index.html file in S3 bucket under a folder called /about-us/. When checking in browser using CloudFront distribution link, custom-domain.com/about-us/ shows AccessDenied error.

But, custom-domain.com/about-us/index.html works fine and show content.

What we want

We want custom-domain.com/about-us/ to show the index.html content.

@rastandy
rastandy / readme.md
Created April 28, 2019 00:22 — forked from eddiewebb/readme.md
Hugo JS Searching with Fuse.js
@rastandy
rastandy / 00-README.md
Created April 20, 2019 17:08 — forked from guumaster/00-README.md
How to upload a file with $.ajax to AWS S3 with a pre-signed url

Upload a file with $.ajax to AWS S3 with a pre-signed url

When you read about how to create and consume a pre-signed url on this guide, everything is really easy. You get your Postman and it works like a charm in the first run.

Then you open your browser, try your usual $.ajax() and send your PUT operation, and you hit the cold iced wall of AWS error message, a simple <Code>SignatureDoesNotMatch</Code> that will steal hours from your productivity.

So here I come to save you and give you a free working example of how to upload a file directly to AWS S3 from your browser. You are wellcome :).