Skip to content

Instantly share code, notes, and snippets.

@micho
micho / gist:1733598
Created February 3, 2012 23:17
Prevent stupid Mac scroll
/**
* Show a notice when Mac's stupid scroll happens
* http://micho.biz/mac-osx-lion-horizontal-scroll-event/
*/
Global.preventStupidMacScroll = function () {
var self = this,
broken_browser = navigator.userAgent.match(/Macintosh/),
hide = Teambox.models.user.get('settings').hide_scroll_notice;
if (!broken_browser || hide) {
@micho
micho / gist:728639
Created December 5, 2010 00:40
Throttle and debounce examples
// Run the function as soon as it's called, but prevent further calls during `delay` ms
// Example: function.throttle(200) will only run function() once every 200 ms.
// Useful, for example, to avoid constant processing while typing in a live search box.
Function.prototype.throttle = function(delay) {
var fn = this
return function() {
var now = (new Date).getTime()
if (!fn.lastExecuted || fn.lastExecuted + delay < now) {
fn.lastExecuted = now
fn.apply(fn, arguments)
@micho
micho / nginx.conf
Last active September 29, 2023 16:38 — forked from unixcharles/nginx.conf
nginx config for http/https proxy to localhost:3000
First, install nginx for mac with "brew install nginx".
Then follow homebrew's instructions to know where the config file is.
1. To use https you will need a self-signed certificate: https://devcenter.heroku.com/articles/ssl-certificate-self
2. Copy it somewhere (use full path in the example below for server.* files)
3. sudo nginx -s reload
4. Access https://localhost/
Edit /usr/local/etc/nginx/nginx.conf: