Skip to content

Instantly share code, notes, and snippets.

@supairish
supairish / gist:2951524
Created June 18, 2012 23:58
Nginx - how to limit requests by User Agent
http {
map $http_user_agent $limit_bots {
default '';
~*(google|bing|yandex|msnbot) $binary_remote_addr;
}
limit_req_zone $limit_bots zone=bots:10m rate=1r/m;
server {
@suprememoocow
suprememoocow / intercept.js
Created May 29, 2012 09:53
AJAX timing interceptor: this class intercepts all AJAX calls and records the time taken for the HTTP request to complete. These timings are posted back to the server in batches, if there are any to send, about every two seconds. Tested in Firefox, Chrome
(function(XHR) {
"use strict";
var stats = [];
var timeoutId = null;
var open = XHR.prototype.open;
var send = XHR.prototype.send;
@s0what
s0what / nginx.conf
Created May 9, 2012 07:10
nginx config
user www www;
worker_processes 2;
pid /var/run/nginx.pid;
error_log /var/log/nginx/err.info.log info;
worker_rlimit_nofile 20046;
@michaelhelmick
michaelhelmick / check_ssl.py
Created April 16, 2012 19:21
Update SSL certs
import os.path
import ssl
import sys
import urlparse
import urllib
def check_ssl(hostname, port=443):
'''Check that an SSL certificate is valid
@agarzon
agarzon / random_color.php
Last active August 15, 2024 13:29
PHP Random Color Generator Hex
<?php $color = dechex(rand(0x000000, 0xFFFFFF)); ?>
<body style="background-color: <?php echo $color; ?>;">
<h1><?php echo $color ?></h1>
</body>
@stonehippo
stonehippo / adding-HA-hack-to-all-children.css
Created March 8, 2012 01:52
Adding Webkit native scrolling to an element
.scrolling-element-class * {
-webkit-transform: translate3d(0,0,0);
}
@davidkaneda
davidkaneda / _user-select.scss
Created March 3, 2012 21:05
User select mixin
@mixin user-select($select) {
$select: unquote($select);
@include experimental(user-select, $select,
-moz, -webkit, not -o, not -ms, -khtml, official
);
}
@kuleszaj
kuleszaj / gist:1911050
Created February 25, 2012 21:53
Nginx with X-Forwarded-Proto set for SSL
server {
listen 1.2.3.4:443;
server_name railsapp.example.com;
ssl on;
ssl_certificate cert.pem;
ssl_certificate_key cert.key;
location / {
proxy_set_header X-Forwarded-Proto https;
# Sets the HTTP headers appropiately;
proxy_pass http://rails_application;
@jxson
jxson / README.md
Created February 10, 2012 00:18
README.md template

Synopsis

At the top of the file there should be a short introduction and/ or overview that explains what the project is. This description should match descriptions added for package managers (Gemspec, package.json, etc.)

Code Example

Show what the library does as concisely as possible, developers should be able to figure out how your project solves their problem by looking at the code example. Make sure the API you are showing off is obvious, and that your code is short and concise.

Motivation

@alotaiba
alotaiba / google_speech2text.md
Created February 3, 2012 13:20
Google Speech To Text API

Google Speech To Text API

Base URL: https://www.google.com/speech-api/v1/recognize
It accepts POST requests with voice file encoded in FLAC format, and query parameters for control.

Query Parameters

client
The client's name you're connecting from. For spoofing purposes, let's use chromium

lang
Speech language, for example, ar-QA for Qatari Arabic, or en-US for U.S. English