Skip to content

Instantly share code, notes, and snippets.

View azizshamim's full-sized avatar
:octocat:
talkin' bout GitHub

Aziz Shamim azizshamim

:octocat:
talkin' bout GitHub
View GitHub Profile
@namlet
namlet / Box Coordinates
Created February 9, 2011 23:37
Maintain selection coordinates using a closure. This example using jQuery.
var boxCoord = function(endCoord) {
var coord = endCoord;
return function(anotherCoord) {
return [anotherCoord, coord];
}
}
$('body').mousedown(function(e){
var thate = e;
$(this).mouseup(function(e){
@ordinaryzelig
ordinaryzelig / minitest_spec_expectations.md
Last active December 10, 2022 13:34
How to write MiniTest::Spec expectations

I'm a fan of MiniTest::Spec. It strikes a nice balance between the simplicity of TestUnit and the readable syntax of RSpec. When I first switched from RSpec to MiniTest::Spec, one thing I was worried I would miss was the ability to add matchers. (A note in terminology: "matchers" in MiniTest::Spec refer to something completely different than "matchers" in RSpec. I won't get into it, but from now on, let's use the proper term: "expectations").

Understanding MiniTest::Expectations

Let's take a look in the code (I'm specifically referring to the gem, not the standard library that's built into Ruby 1.9):

# minitest/spec.rb

module MiniTest::Expectations
@jboner
jboner / latency.txt
Last active May 2, 2024 09:45
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@evanmiller67
evanmiller67 / chili_con_carne.md
Created December 14, 2012 17:18
Frakin' good chili.

Chili Con Carne

=============== This shit is awesome. It's hot, so nut up pansy.
Don't like it that way? Leave out some peppers and spices.
Green bell pepper is for color, substitute another red or yellow for a sweeter taste.
Like different beans? Add them shits too, get wild with Emeril.
Want this to be even better? Cook/mix everything the night before, put in the fridge. Then cook it all day.

Ingredients

@kesor
kesor / Gemfile
Created March 19, 2013 00:32
Vagrant configuration to install two Ubuntu 12.04 servers, first server has a Chef Server installed, second server has a Chef Client installed, and the folder where these files are places is configured to be a Chef Workstation using admin.pem.
source "https://rubygems.org"
gem 'chef', '>= 11.0'
gem 'librarian'
gem 'vagrant', '= 1.0.6'
gem 'vagrant-hostmaster'
gem 'foodcritic'
GitHub is pretty awesome. Pass it on!
require "thread"
Thread.abort_on_exception = true
class ReadWriteLock
def initialize
@lock_request_queue = SizedQueue.new(1)
@thread = Thread.new { thread_main }
@readers = 0
@writer_queue = []
@jfryman
jfryman / gist:4744a01fd68b6336377a
Last active May 22, 2020 17:48
DO Post Mortem - Mark Imbriaco
Hi, I would like to take a moment to apologize for the problems you may have experienced accessing your droplets in the NYC2 region July 21st, starting around 6PM Eastern time. Providing a stable infrastructure for all customers is our number one priority, and whenever we fall short we work to understand the problem and take steps to reduce the chance of it happening again.
In this case, we’ve determined what were a few related events which contributed to the outage:
First, we had a problematic optical module in one of our switches that was sending malformed packets to one of the core switches in our network. Under normal circumstances, losing connectivity to a single core switch should not be problematic since each cabinet in our datacenter is connected to multiple upstream switches. In this case, however, the invalid data caused problems with the upstream core switch.
When the core switch received the invalid packet, it triggered a bug in the software on the core switch which caused some internal process
@stephenyeargin
stephenyeargin / remote-control-dashing.md
Last active April 27, 2017 11:41
Using Dashing with Hubot to control which dashboard is being shown.

Remotely control your Dashing Dashboard

The problem

We have a dashboard at the office that displays some internal company metrics so everyone can be up to speed on them. However, when we have guests, we have to either SSH into the Raspberry Pi or simply turn off the television. This seems clumsy, and we can do better than that.

The solution

Dashing works by adding event listeners in Javascript and updating the associated widgets. We're going to hijack this process to build a simple redirect that can accept a posted value and send the dashboard to another screen.

How to become a decent photographer in five years

You're not gonna become a master in your spare time, but you can get decently good at photography in five years of dedicated but non-full-time practice. It's taken me about twice that to get decent, but I fucked around a lot along the way.

You don't need a ton of fancy equipment, but photography does require some gear. I'll limit the gear-buying here to once a year (not counting books).