Skip to content

Instantly share code, notes, and snippets.

@brainlid
brainlid / confirm_discard.js
Created June 4, 2011 03:50
Handle "Your changes will be lost" prompt when navigating away from a changed page.
// To activate this, add the class "confirm_discard" to your form. If
// you change any value on the form, it will set the onbeforeunload.
// When you send the submit event (AJAX or normal GET / POST), it
// clears it. Since it uses delegate, there's no need to run
// additional setup code after an ajax call has loaded a form on the
// page.
// This won't interfere with any other custom beforeunload event
// handlers you may have.
// This works with multiple forms on a page as well.
@brainlid
brainlid / net_http_debug.rb
Created May 17, 2012 20:43 — forked from kaiwren/net_http_debug.rb
Enable debug for all Ruby HTTP requests
require 'net/http'
module Net
class HTTP
def self.enable_debug!
raise "You don't want to do this in anything but development mode!" unless Rails.env == 'development'
class << self
alias_method :__new__, :new
def new(*args, &blk)
instance = __new__(*args, &blk)
instance.set_debug_output($stderr)
@brainlid
brainlid / application_helper.rb
Created May 18, 2012 04:06 — forked from purcell/application_helper.rb
Make will_paginate generate HTML that bootstrap.less will render nicely
# Based on https://gist.github.com/1182136
# config/initializers/will_paginate.rb
class BootstrapLinkRenderer < ::WillPaginate::ActionView::LinkRenderer
protected
def html_container(html)
tag :div, tag(:ul, html), container_attributes
end
@brainlid
brainlid / instructurezendesk.js
Last active October 13, 2015 00:48 — forked from ryankshaw/instructurezendesk.js
Instructure Zendesk Agent-only mods
previousjQuery = jQuery;
jQuery(function($){
// only run in browsers that can do localStorage (not IE) and only on the tickets page
if ('localStorage' in window && $('body').hasClass('tickets-show') || $('body').hasClass('tickets-new')) {
// I want to make sure that this always runs with my version of jquery, not zendesk's
$.getScript('http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js', function(){
jQuery(function($){
//var username = 'testuser';
//var password = 'testpass';
init: function() {
var view = this;
var resizeHandler = function() {
view.rerender();
};
this.set('resizeHandler', resizeHandler);
$(window).bind('resize', this.get('resizeHandler'));
},
init: ->
@_super()
view = this
resizeHandler = ->
view.rerender()
@.set('resizeHandler', resizeHandler);
$(window).bind('resize', @get('resizeHandler'))

Docker Cheat Sheet

Why

Why Should I Care (For Developers)

"Docker interests me because it allows simple environment isolation and repeatability. I can create a run-time environment once, package it up, then run it again on any other machine. Furthermore, everything that runs in that environment is isolated from the underlying host (much like a virtual machine). And best of all, everything is fast and simple."

TL;DR, I just want a dev environment

@brainlid
brainlid / nginx.conf
Last active August 29, 2015 14:09 — forked from plentz/nginx.conf
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@brainlid
brainlid / poolboy_demo.ex
Last active March 8, 2016 13:30 — forked from henrik/poolboy_demo.ex
Example of using Poolboy in Elixir to limit concurrency (e.g. of HTTP requests).
defmodule HttpRequester do
use GenServer
def start_link(_) do
GenServer.start_link(__MODULE__, nil, [])
end
def fetch(server, url) do
# Don't use cast: http://blog.elixirsips.com/2014/07/16/errata-dont-use-cast-in-a-poolboy-transaction/
timeout_ms = 10_000
@brainlid
brainlid / index.html
Created August 4, 2016 13:22 — forked from anonymous/index.html
JS Bin [Queue for rendering 1 at a time] // source http://jsbin.com/basuzi
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="[Queue for rendering 1 at a time]">
<script src="https://cdnjs.cloudflare.com/ajax/libs/q.js/1.0.1/q.js"></script>
<script src="https://npmcdn.com/@reactivex/rxjs@5.0.0-beta.6/dist/global/Rx.umd.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style>