From Bas van Dijk:
To understand these things I would recommend using nix-repl:
$ nix-repl Welcome to Nix version 1.11.2. Type :? for help.
# Automatic nginx virtual subdomains with sub-folders or sub-directories | |
# | |
# Since the original source where I found this code is now offline, I have decided to mirror it here. | |
# All credit goes to: http://web.archive.org/web/20150307193208/http://www.messaliberty.com/2010/10/automatic-nginx-virtual-subdomains-with-sub-folders-or-sub-directories | |
# | |
# Description: In my web root directory I wanted create a folder called photos, and another called | |
# music using a sftp program. Without manually going back to the config file or to the shell I like to | |
# be able to access them at photos.nginxdomain.com and music.nginxdomain.com. That is what this config does. | |
# Redirect visitors from http://nginxdomain.com/ to http://www.nginxdomain.com/ |
# Automatic nginx virtual subdomains with sub-folders or sub-directories | |
# | |
# Since the original source where I found this code is now offline, I have decided to mirror it here. | |
# All credit goes to: http://web.archive.org/web/20150307193208/http://www.messaliberty.com/2010/10/automatic-nginx-virtual-subdomains-with-sub-folders-or-sub-directories | |
# | |
# Description: In my web root directory I wanted create a folder called photos, and another called | |
# music using a sftp program. Without manually going back to the config file or to the shell I like to | |
# be able to access them at photos.nginxdomain.com and music.nginxdomain.com. That is what this config does. | |
# Redirect visitors from http://nginxdomain.com/ to http://www.nginxdomain.com/ |
CREATE EXTENSION pgcrypto; | |
CREATE OR REPLACE FUNCTION totp(key BYTEA, clock_offset INT DEFAULT 0) RETURNS INT AS $$ | |
DECLARE | |
c BYTEA := '\x000000000' || TO_HEX(FLOOR(EXTRACT(EPOCH FROM NOW()) / 30)::INT + clock_offset); | |
mac BYTEA := HMAC(c, key, 'sha1'); | |
trunc_offset INT := GET_BYTE(mac, 19) % 16; | |
result INT := SUBSTRING(SET_BIT(SUBSTRING(mac FROM 1 + trunc_offset FOR 4), 7, 0)::TEXT, 2)::BIT(32)::INT % 1000000; | |
BEGIN | |
RETURN result; | |
END; |
<?xml version="1.0" encoding="utf-8"?> | |
<rss version="2.0"> | |
<channel> | |
<title>Example Feed</title> | |
<description>Insert witty or insightful remark here</description> | |
<link>http://example.org/</link> | |
<lastBuildDate>Sat, 13 Dec 2003 18:30:02 GMT</lastBuildDate> | |
<managingEditor>johndoe@example.com (John Doe)</managingEditor> |
set imap_user="mail.vpal@gmail.com" | |
set imap_pass=`/usr/bin/security find-generic-password -w -a 'mail.vpal@gmail.com' -s 'Gmail'` | |
set folder=imaps://imap.gmail.com/ | |
set spoolfile=+INBOX | |
set record="+[Gmail]/Sent Mail" | |
set postponed="+[Gmail]/Drafts" | |
# https://www.neomutt.org/guide/reference search sleep_time for additional info | |
set sleep_time=0 # be faster |
-- Functions to create and draw histograms with PostgreSQL. | |
-- | |
-- psql# WITH email_lengths AS ( | |
-- -# SELECT length(email) AS length | |
-- -# FROM auth_user | |
-- -# LIMIT 100 | |
-- -# ) | |
-- -# SELECT * FROM show_histogram((SELECT histogram(length, 0, 32, 6) FROM email_lengths)) | |
-- bucket | range | count | bar | cumbar | cumsum | cumpct | |
-- --------+-------------------------------------+-------+--------------------------------+--------------------------------+--------+------------------------ |
begin; | |
-- Load in uuid-ossp extension for uuid_generate_v1mc | |
create schema "uuid-ossp"; | |
create extension "uuid-ossp" with schema "uuid-ossp"; | |
-- Create roles | |
create role alice; | |
create role bob; |
-- from https://gist.github.com/ruslantalpa/b2f10eb1b5f6dd0fc1c154e071a1c91b | |
\set API_SCHEMA_NAME test | |
with tables as ( | |
-- Return a list of entities in the database (tables/views/materialized views) | |
select | |
n.nspname as table_schema, | |
relname as table_name, | |
case |
-- http GET "localhost:3000/items?select=id,name,c1,c2,c3,c4,subitems{id,name}&id=lte.100" | |
\set rid random(1, 999900) | |
BEGIN ISOLATION LEVEL READ COMMITTED READ ONLY; | |
WITH pg_source AS ( | |
SELECT | |
"new_m2m_child_queries"."items"."id", | |
"new_m2m_child_queries"."items"."name", |