Skip to content

Instantly share code, notes, and snippets.

@noname77
noname77 / build_nginx.sh
Last active April 25, 2017 19:35 — forked from Belphemur/build_nginx.sh
Compiling Nginx with LibreSSL (and http2) and neverbleed
#!/usr/bin/env bash
# adopted from https://gist.github.com/Belphemur/3c022598919e6a1788fc
# includes neverbleed patch
# names of latest versions of each package
export NGINX_VERSION=1.11.1
export VERSION_PCRE=pcre-8.38
export VERSION_LIBRESSL=libressl-2.4.1
export VERSION_NGINX=nginx-$NGINX_VERSION
@lachesis
lachesis / letsencrypt_notes.sh
Last active December 13, 2023 11:02
Set up LetsEncrypt using acme.sh without root
# How to use "acme.sh" to set up Lets Encrypt without root permissions
# See https://github.com/Neilpang/acme.sh for more
# This assumes that your website has a webroot at "/var/www/<domain>"
# I'll use the domain "EXAMPLE.com" as an example
# When this is done, there will be an "acme" user that handles issuing,
# updating, and installing certificates. This account will have the following
# (fairly minimal) permissions:
# - Host files at http://EXAMPLE.com/.well-known/acme-challenge
@nottrobin
nottrobin / setup-lxc-shared-directory.sh
Last active January 20, 2017 16:03
How to set up a *writeable* shared directory in an LXC/LXD container
[robin@xps ~ ]$ lxc launch ubuntu:16.04 my-xenial # Create & start a new container
[robin@xps ~ ]$ getfacl ./share/ # Check extended permissions on "share" directory
# file: share
# owner: robin
# group: robin
user::rwx
group::rwx
other::r-x
[robin@xps ~ ]$ sudo ls -ld /var/lib/lxd/containers/my-xenial # Find the user ID for my container (165536)
[sudo] password for robin:
@CalebEverett
CalebEverett / events-websock.js
Last active March 29, 2023 15:04
Lxd api example: lxc exec and operations websocket via nodejs
const fs = require('fs')
const WebSocket = require('ws');
const wsoptions = {
cert: fs.readFileSync('../../.config/lxc/client.crt'),
key: fs.readFileSync('../../.config/lxc/client.key'),
rejectUnauthorized: false
}
var ws = new WebSocket('wss://127.0.0.1:8443/1.0/events?type=operation', wsoptions);
@zachrose
zachrose / reserved-words.txt
Created November 28, 2015 05:46
URL paths to reserve in a web app
about
admin
blog
calendar
contact
copyright
dashboard
email
errors
events
@primoz-k
primoz-k / merge_model_objects.py
Last active March 13, 2016 22:17 — forked from nick-merrill/merge_model_objects.py
A variation on a snippet that handles one-to-one relationships by recursively migrating those relationships' field data to the `primary_object`'s related object.
# -*- coding: utf-8 -*-
from django.db.models import Model
from django.contrib.contenttypes.fields import GenericForeignKey
from django.db.utils import IntegrityError
from django.db import transaction
from urllib import parse
try:
from django.apps import apps
@ipmb
ipmb / Dockerfile
Created May 24, 2015 21:23
Example wheel upload to simple PyPI on S3
FROM ubuntu:14.04
ENV BUCKET your-s3-bucket
RUN apt-get update && apt-get install -y wget \
build-essential python-dev \
libssl-dev libffi-dev \
libpcre3-dev \
libmemcached-dev \
libpq-dev \
@tkadlec
tkadlec / perf.js
Created April 23, 2015 11:54
Super simple example of adding perf timing to the page display during dev work
(function () {
var perfBar = function(budget) {
window.onload = function() {
window.performance = window.performance || window.mozPerformance || window.msPerformance || window.webkitPerformance || {};
var timing = window.performance.timing,
now = new Date().getTime(),
output, loadTime;
@jhargis
jhargis / django_bulk_export.py
Last active June 13, 2018 17:43
django and psycopg2 with server side cursors for memory efficient large bulk data exports
import uuid
import psycopg2
from psycopg2.extras import DictCursor
from django.conf import settings
from django.db import models
from django.contrib.auth.models import User
class classproperty(object):
@nick-merrill
nick-merrill / merge_model_objects.py
Created December 5, 2014 01:07
A variation on a snippet that handles one-to-one relationships by recursively migrating those relationships' field data to the `primary_object`'s related object.
# Based on https://djangosnippets.org/snippets/2283/
from django.db import transaction
from django.db.models import get_models, Model
from django.contrib.contenttypes.generic import GenericForeignKey
@transaction.atomic
def merge_model_objects(primary_object, alias_objects=None, keep_old=False):
"""
Use this function to merge model objects (i.e. Users, Organizations, Polls,