Skip to content

Instantly share code, notes, and snippets.

@joemccann
joemccann / nginx + node setup.md
Created October 25, 2010 02:06
Set up nginx as a reverse proxy to node.js.

The idea is to have nginx installed and node installed. I will extend this gist to include how to install those as well, but at the moment, the following assumes you have nginx 0.7.62 and node 0.2.3 installed on a Linux distro (I used Ubuntu).

In a nutshell,

  1. nginx is used to serve static files (css, js, images, etc.)
  2. node serves all the "dynamic" stuff.

So for example, www.foo.com request comes and your css, js, and images get served thru nginx while everything else (the request for say index.html or "/") gets served through node.

  1. nginx listens on port 80.
@grantslatton
grantslatton / hngen.py
Last active September 27, 2021 11:07
A program that uses Markov chains to generate probabilistic Hacker News titles.
import urllib2
import re
import sys
from collections import defaultdict
from random import random
"""
PLEASE DO NOT RUN THIS QUOTED CODE FOR THE SAKE OF daemonology's SERVER, IT IS
NOT MY SERVER AND I FEEL BAD FOR ABUSING IT. JUST GET THE RESULTS OF THE
CRAWL HERE: http://pastebin.com/raw.php?i=nqpsnTtW AND SAVE THEM TO "archive.txt"
@andir
andir / debian.nix
Last active May 2, 2020 14:19
debian stretch
{ pkgs ? import <nixpkgs> {}}:
let
lib = pkgs.lib;
makeImageFromDebDist =
{ name, fullName, size ? 4096, urlPrefix
, packagesList ? "", packagesLists ? [packagesList]
, packages, extraPackages ? [], postInstall ? ""
, extraDebs ? []
, QEMU_OPTS ? "", memSize ? 512
, createRootFS }:
@wirew0rm
wirew0rm / xtensa-esp-32-elf.nix
Created October 31, 2018 15:26
ESP32 Toolchain for nixos
{ stdenv, fetchgit, fetchurl, writeText, automake, autoconf, aria, coreutils, curl, cvs, gcc, git, python, which, bison, flex, gperf, help2man, libtool, ncurses, texinfo, wget, file }:
stdenv.mkDerivation {
name = "xtensa-esp32-elf";
version = "1.22.x";
src = fetchgit {
url = "https://github.com/espressif/crosstool-NG.git";
# branch = "xtensa-${version}";
rev = "6c4433a51e4f2f2f9d9d4a13e75cd951acdfa80c";
sha256 = "03qg9vb0mf10nfslggmb7lc426l0gxqhfyvbadh86x41n2j6ddg6";
@joelonsql
joelonsql / decode_cbor.sql
Last active January 13, 2024 04:36
Decode WebAuthn CBOR Using PostgreSQL Recursive CTE
CREATE OR REPLACE FUNCTION decode_cbor(cbor bytea)
RETURNS TABLE (
item integer,
map_item_count integer,
text_string text,
bytes bytea
)
LANGUAGE sql
AS $$
/*