Skip to content

Instantly share code, notes, and snippets.

View garyharan's full-sized avatar
🎯
Focusing

Gary Haran garyharan

🎯
Focusing
View GitHub Profile
@spilth
spilth / albums-index.html.erb
Created February 25, 2022 02:46
Tabbed Navigation with Turbo Frames
<p style="color: green"><%= notice %></p>
<h1>Albums</h1>
<%= turbo_frame_tag :items do %>
<% @albums.each do |album| %>
<%= render album %>
<p>
<%= link_to "Show this album", album %>
</p>
@macournoyer
macournoyer / game.litcoffee
Last active April 14, 2017 23:44
JavaScript Game Basics in (Literate) CoffeeScript http://macournoyer.com/game/

The game we're building is a simple side-scrolling racing game. The player's car is static on the screen, only the background is moving. The enemies are planes whom the player must dodge using the up and down arrow keys. If the player hits a plane, he dies. One point is given each time a plane goes off screen without touching the player.

Sprites

Our game is composed of sprites. Each sprite has a position (x, y), velocity (speed) and one image, or more if animated.

Images are loaded from the DOM using their CSS selector (imagesSelector). We use ID selectors (#name) for single images and class selectors (.name) for animated sprites composed of several images.

See the images used in the game.

@jboner
jboner / latency.txt
Last active April 19, 2024 23:08
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
@cykod
cykod / goat.rb
Created November 29, 2011 14:30
RCov + `git blame` = Find out who the non-testing Goat on your Rails project is
#!/usr/bin/env ruby1.8
require 'rubygems'
require 'nokogiri'
# Copyright @2011 Pascal Rettig - Released under the MIT License,
# No Warranty whatsoever. This will probably destroy your project
#
# Find out who the goat is on your Rails the project - i.e the person responsible for
# writing or modifying the most untested code. Drop goat.rb into your script/
# directory, make it executable then run: