Skip to content

Instantly share code, notes, and snippets.

@renchap
renchap / README.md
Last active October 12, 2022 17:14
One-line certificate generation/renews with Letsencrypt and nginx

Prerequisites : the letsencrypt CLI tool

This method allows your to generate and renew your Lets Encrypt certificates with 1 command. This is easily automatable to renew each 60 days, as advised.

You need nginx to answer on port 80 on all the domains you want a certificate for. Then you need to serve the challenge used by letsencrypt on /.well-known/acme-challenge. Then we invoke the letsencrypt command, telling the tool to write the challenge files in the directory we used as a root in the nginx configuration.

I redirect all HTTP requests on HTTPS, so my nginx config looks like :

server {
@chrismdp
chrismdp / s3.sh
Last active March 5, 2024 12:57
Uploading to S3 in 18 lines of Shell (used to upload builds for http://soltrader.net)
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
RATE_LIMIT_SCRIPT = r'''
local now = tonumber(ARGV[1])
local required = tonumber(ARGV[2])
local rate = tonumber(ARGV[3])
local per_secs = tonumber(ARGV[4])
local do_subtract = tonumber(ARGV[5]) == 1
local full_at = tonumber(redis.call('GET', KEYS[1])) or 0
local score, result
if full_at < now then
score = rate
@ewalk153
ewalk153 / upgrade_postgres.bash
Created January 3, 2014 03:32
upgrade heroku postgres from crane to yanari
# this can be done anytime
heroku addons:add heroku-postgresql:standard-yanari --app nav-chronos; heroku pg:wait
# about 3m30s
heroku maintenance:on
heroku ps:scale worker=0
heroku pgbackups:capture --expire
# less than 20 min
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active April 19, 2024 11:00
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@josegonzalez
josegonzalez / access.lua
Created December 3, 2012 18:26
Simple lua file enabling oauth support for nginx via nginx-lua and access_by_lua.
- certain endpoints are always blocked
if nginx_uri == "/_access_token" or nginx_uri == "/_me" then
ngx.exit(403)
end
-- import requirements
local cjson = require "cjson"
-- setup some app-level vars
local app_id = "APP_ID"
require 'rubygems'
require 'railsless-deploy'
# Your application name
set :application, "someapp"
# We're not deploying from a repo, since this is scala and we
# need to compile. Set SCM to none
set :scm, :none
# Our deploy is to copy the contents of…
@n0ts
n0ts / gist:3810200
Created October 1, 2012 08:01
keepalived supervisor.conf
[program:keepalived-check]
command=/usr/sbin/keepalived
--use-file /etc/keepalived/keepalived.conf
--dont-fork
--dump-conf
--log-detail
--log-facility 0
--check
--pid /var/run/keepalived_check.pid
redirect_stderr=true
@leandrosilva
leandrosilva / klogd.py
Created September 6, 2012 20:12
My dumb Python script to stream Syslog messages to a Kafka server
# ==========================
# Getting Started with klogd
# ==========================
#
# Klogd is a dumb script to stream Syslog messages to a Kafka server.
#
# 1) Make sure you have all dependencies installed properly
#
# - Twisted
# - PyParsing
@coryalder
coryalder / fb_open_source_ios
Created August 23, 2012 20:10
Open source libraries used in the new Facebook app.
Appirater
AQGridView
AutoHyperlinks
Boost
Chromium
CocoaLumberjack
CoreTextHyperlinkView
EGODatabase
EGOTableViewPullRefresh
HPGrowingTextView