Skip to content

Instantly share code, notes, and snippets.

@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.

@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 :).

@rastandy
rastandy / docx2md.md
Created March 13, 2019 12:03 — forked from aembleton/docx2md.md
Convert a Word Document into MD

Converting a Word Document to Markdown in One Move

The Problem

A lot of important government documents are created and saved in Microsoft Word (*.docx). But Microsoft Word is a proprietary format, and it's not really useful for presenting documents on the web. So, I wanted to find a way to convert a .docx file into markdown.

Installing Pandoc

On a mac you can use homebrew by running the command brew install pandoc.

The Solution

@rastandy
rastandy / mkfavicon.sh
Created October 23, 2018 13:10 — forked from pfig/mkfavicon.sh
Make a multi-resolution favicon.ico from a source image, using ImageMagick
#!/bin/bash
# from
# http://bergamini.org/computers/creating-favicon.ico-icon-files-with-imagemagick-convert.html
convert source-WxW.png -resize 256x256 -transparent white favicon-256.png
convert favicon-256.png -resize 16x16 favicon-16.png
convert favicon-256.png -resize 32x32 favicon-32.png
convert favicon-256.png -resize 64x64 favicon-64.png
convert favicon-256.png -resize 128x128 favicon-128.png
@rastandy
rastandy / cljs-main.md
Created July 11, 2018 22:53 — forked from mfikes/cljs-main.md
Command to get a preview of cljs.main

Usage

Start up the new cljs.main with Node:

clj -Sdeps '{:deps {org.clojurescript {:git/url "https://github.com/clojure/clojurescript" :sha "3f4084efcb5cd92cceb8ca30765144691d8cfd7e"}}}' -m cljs.main -re node

The above works by specifying ClojureScript as a "git dep" and you can ensure that you are running the very latest by replacing the :sha value with the latest commit SHA at https://github.com/clojure/clojurescript.