Skip to content

Instantly share code, notes, and snippets.

@soveran
soveran / elements.md
Created November 18, 2011 17:38
Excerpts from The Elements of Programming Style. The source of this compilation is unknown.

The Elements of Programming Style

The following rules of programming style are excerpted from the book "The Elements of Programming Style" by Kernighan and Plauger, published by McGraw Hill. Here is quote from the book: "To paraphrase an observation in The Elements of Style by Strunk and White, the rules of programming style, like those of English, are sometimes broken, even by the best writers. When a rule is broken, however, you will usually find in the program some compensating merit, attained at the cost of the violation. Unless you are certain of doing as well, you will probably do best to follow the rules."

@jed
jed / how-to-set-up-stress-free-ssl-on-os-x.md
Last active July 10, 2024 14:35
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

@sergeylukin
sergeylukin / make.conf
Created November 19, 2013 15:08
Optimized system-wide makefile for FreeBSD. Saved in /etc/make.conf
# default to -j6 for make
FORCE_MAKE_JOBS=yes
MAKE_JOBS_NUMBER=6
# specific options/etc for ports
.if ${.CURDIR:M*/databases/mysql*-server}
BUILD_OPTIMIZED=yes
.endif
# static zsh build for root
@hgfischer
hgfischer / benchmark+go+nginx.md
Last active April 11, 2024 22:09
Benchmarking Nginx with Go

Benchmarking Nginx with Go

There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.

So, these are the different settings we are going to compare:

  • Go HTTP standalone (as the control group)
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI
anonymous
anonymous / gist:fdcbcc27278c287ce5e0
Created June 14, 2014 17:52
clone & resize Ubuntu Cloud image from 2GB to 40GB in 2 seconds
# time ./do-all.sh
+ lvcreate -kn -s -n ubunt2 /dev/k2/ubunt
Logical volume "ubunt2" created
+ lvresize -L 40G /dev/k2/ubunt2
Extending logical volume ubunt2 to 40.00 GiB
Logical volume ubunt2 successfully resized
+ echo -en 'd\nn\np\n\n\n\n\n\nw\nq\n'
+ fdisk /dev/k2/ubunt2
Command (m for help): Selected partition 1
@staltz
staltz / introrx.md
Last active July 22, 2024 09:31
The introduction to Reactive Programming you've been missing
package main
import (
"net/http"
"database/sql"
"fmt"
"log"
"os"
)
└──╼ cat device_chip.ads
--
-- Copyright (C) 2014 Edward O'Callaghan <eocallaghan@alterapraxis.com>
--
--
-- Each Driver implements a concrete realisation of the Chip interface.
-- This constitutes a "Class" of Chips that are enumerated from the devicetree.
--
@EGreg
EGreg / Q.Promises.js
Created November 11, 2014 22:36
A clear and tested Promises implementation
/**
* Q Promises implementation
* @module Q
*/
(function (Q) {
/**
* Q.Promise constructor.
* Call the .fulfill(...) or .reject(...) method to
* signal that the promise is fulfilled or rejected.
@31
31 / gist:3781b066e16bf538f170
Last active November 10, 2023 02:05
OpenGL functions by object