Skip to content

Instantly share code, notes, and snippets.

View julienma's full-sized avatar

Julien Ma julienma

View GitHub Profile
@julienma
julienma / README.md
Last active August 15, 2023 10:40
GitHub Actions: using SSH keys to auto-deploy with dokku-push

The dokku-push action requires an SSH key with push access to the Dokku instance. Here's how to do that.

Replace APPNAME with the name of the app (e.g. this is a good idea to use the same name used on Dokku's).

Generate a new SSH keypair

We want each repo to have its own SSH key, so it's easier to rotate/invalidate them if required, without affecting all the repos. Let's generate a new key on your computer (see GitHub help):

@dhh
dhh / Gemfile
Created June 24, 2020 22:23
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers

How to setup a practically free CDN using Backblaze B2 and Cloudflare

⚠️ Note 2023-01-21
Some things have changed since I originally wrote this in 2016. I have updated a few minor details, and the advice is still broadly the same, but there are some new Cloudflare features you can (and should) take advantage of. In particular, pay attention to Trevor Stevens' comment here from 22 January 2022, and Matt Stenson's useful caching advice. In addition, Backblaze, with whom Cloudflare are a Bandwidth Alliance partner, have published their own guide detailing how to use Cloudflare's Web Workers to cache content from B2 private buckets. That is worth reading,

@julienma
julienma / DT3 - Add OCR to PDF.scpt
Last active April 2, 2024 08:43
OCR PDFs in DEVONthink 3 with jbarlow83/OCRmyPDF
-- Script for DEVONthink 3
-- Run OCRmyPDF on PDFs without OCR
-- Requires https://github.com/jbarlow83/OCRmyPDF to be installed e.g. with brew
on performSmartRule(theRecords)
tell application id "DNtp"
set strExportPath to "PATH=/opt/homebrew/bin:$PATH "
set intRecordsCount to count of theRecords
show progress indicator "Adding OCR to PDF..." steps intRecordsCount
repeat with theRecord in theRecords
@systemed
systemed / gist:be2d6bb242d2fa497b5d93dcafe85f0c
Last active April 10, 2024 03:49
Routing algorithm implementations
(Dijkstra and plain A* are generally not included here as there are thousands of
implementations, though I've made an exception for rare Ruby and Crystal versions,
and for Thor, Mapzen's enhanced A*. )
A* Ruby https://github.com/georgian-se/shortest-path
A* Crystal https://github.com/petoem/a-star.cr
A* (bidirectional with shortcuts) C++ https://github.com/valhalla/valhalla
NBA* JS https://github.com/anvaka/ngraph.path
NBA* Java https://github.com/coderodde/GraphSearchPal
NBA* Java https://github.com/coderodde/FunkyPathfinding

Fix Ubuntu package cache

Had problem with Ubuntu package cache.

➜  sources.list.d sudo apt-get update                   
Hit:1 http://fi.archive.ubuntu.com/ubuntu xenial InRelease
Hit:2 http://fi.archive.ubuntu.com/ubuntu xenial-updates InRelease                                                                   
Hit:3 http://fi.archive.ubuntu.com/ubuntu xenial-backports InRelease                                                                 
Hit:4 http://security.ubuntu.com/ubuntu xenial-security InRelease

Let’s Encrypt + Heroku

Step 1: Setup certificate

$ sudo letsencrypt certonly --manual -d <domain>

You'll need to deploy a verification file to your current website.

@fiftin
fiftin / Convert PostgreSQL to SQLite
Created October 5, 2015 07:04
Convert PostgreSQL to SQLite
1. Dump the data only sql to file
$ pg_dump --data-only --inserts YOUR_DB_NAME > dump.sql
2. scp to local
3. Remove the SET statements at the top
such as:
SET statement_timeout = 0;
SET client_encoding = 'SQL_ASCII';
4. Remove the setval sequence queries