Skip to content

Instantly share code, notes, and snippets.

davecoutts /
Last active May 20, 2024 04:59
Install Ubiquiti Unifi Controller on Ubuntu 20.04
# Install Ubiquiti Unifi Controller on Ubuntu 20.04.
# As tested on a fresh install of ubuntu-20.04.1-live-server, August 22nd 2020.
# Thanks to for posting the updated install steps.
sudo apt update
sudo apt install --yes apt-transport-https
echo 'deb stable ubiquiti' | sudo tee /etc/apt/sources.list.d/100-ubnt-unifi.list
sudo wget -O /etc/apt/trusted.gpg.d/unifi-repo.gpg
Koff / bitcoin_core_26.1.bash
Last active April 7, 2024 16:11
Bitcoin core 26.1 on Ubuntu 23.10
# Assuming a fresh install of Ubuntu 23.10, 400+Gbytes of free HDD, and that you are logged in as root.
# More detailed instructions available in
# Update packages
apt update
apt upgrade -y
# Add bitcoin_user user non-interactively
adduser --gecos "" bitcoin_user
paul-english / rs_levenshtein.sql
Last active July 8, 2021 17:53
Redshift Levenshtein UDF
CREATE FUNCTION levenshtein(s1 varchar, s2 varchar) RETURNS integer IMMUTABLE AS $$
import numpy as np
def levenshtein(source, target):
source = source or ""
target = target or ""
if len(source) < len(target):
return levenshtein(target, source)
oinopion / read-access.sql
Created October 5, 2016 13:00
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
-- Grant access to future tables
nmalkin /
Last active May 20, 2022 00:18
SHA-256 hash of a string in Python 3
#!/usr/bin/env python3
import hashlib
def hash_string(string):
Return a SHA-256 hash of the given string
return hashlib.sha256(string.encode('utf-8')).hexdigest()
jfcarr /
Created March 28, 2016 18:25
"Feels Like" (temperature) Calculation in Python
# I use a Python script to pull current weather conditions from the NOAA web service API. The NOAA web
# service does not return a windchill value for all locations, but given temperature, relative humidity,
# and wind speed you can calculate a “feels like” temperature as follows.
# This code assumes units of Fahrenheit, MPH, and Relative Humidity by percentage. In this example, a
# temperature of 35F, wind speed of 10mph, and relative humidity of 72% yields a "feels like" value of 27.4F
import math
vTemperature = float(35)
eerwitt /
Created January 31, 2016 05:52
Example loading multiple JPEG files with TensorFlow and make them available as Tensors with the shape [[R, G, B], ... ].
# Typical setup to include TensorFlow.
import tensorflow as tf
# Make a queue of file names including all the JPEG images files in the relative
# image directory.
filename_queue = tf.train.string_input_producer(
# Read an entire image file which is required since they're JPEGs, if the images
# are too large they could be split in advance to smaller files or use the Fixed
georgiana-gligor / osx-pdf-from-markdown.markdown
Last active March 5, 2024 21:09
Markdown source for the "Create PDF files from Markdown sources in OSX" article

Create PDF files from Markdown sources in OSX

When [Markdown][markdown] appeared more than 10 years ago, it aimed to make it easier to express ideas in an easy-to-write plain text format. It offers a simple syntax that takes the writer focus away from the formatting, thus giving her time to focus on the actual content.

The market abunds of editors to be used for help with markdown. After a few attempts, I settled to Sublime and its browser preview plugin, which work great for me and have a small memory footprint to accomplish that. To pass the results around to other people, less technical, a markdown file and a bunch of images is not the best approach, so converting it to a more robust format like PDF seems like a much better choice.

[Pandoc][pandoc] is the swiss-army knife of converting documents between various formats. While being able to deal with heavy-weight formats like docx and epub, we will need it for the more lightweight markdown. To be able to generate PDF files, we need LaTeX. On OSX, the s

baxeico /
Last active August 28, 2021 19:39
A custom UpdateView to set initial data and save the user profile with a custom group field
from django.contrib.auth.models import User
from django.views.generic import UpdateView
from .forms import UserProfileForm
class UserProfileUpdateView(UpdateView):
model = User
def get_initial(self):
initial = super(UserProfileUpdateView, self).get_initial()
pixline / squid.conf
Last active June 29, 2020 11:38
pfsense 2.1 squid3 proxy + adblock setup
http_port intercept
icp_port 7
dns_v4_first off
pid_filename /var/run/
cache_effective_user proxy