Skip to content

Instantly share code, notes, and snippets.

@bmfurtado
bmfurtado / cssh.applescript
Last active January 5, 2025 03:00
Create multiple SSH sessions in split panes on iTerm2 and enable key broadcasting.
Moved to: https://github.com/bmfurtado/iterm2-cssh
private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
private static final MethodHandles.Lookup PUBLOOKUP = MethodHandles.publicLookup();
@Test
public void basics() throws Throwable {
// method invocation
String value1 = System.getProperty("java.home");
System.out.println("Hello, world");
@mxriverlynn
mxriverlynn / createObject.js
Created October 26, 2012 14:30
An Object.create wrapper / shim for MarionetteJS
// Helpers
// -------
// For slicing `arguments` in functions
var slice = Array.prototype.slice;
// Borrow the Backbone `extend` method so we can use it as needed
Marionette.extend = Backbone.Model.extend;
// A wrapper / shim for `Object.create`. Uses native `Object.create`
@mbostock
mbostock / .block
Last active June 16, 2019 03:59
Creating Thumbnails with GraphicsMagick
license: gpl-3.0
@mxriverlynn
mxriverlynn / compute.js
Created September 23, 2012 01:38
Computed Fields For Backbone.Model
// EXPERIMENTAL
// ------------
//
// an idea for computed fields with Backbone.Model.
// total hack implementation, but basic idea works.
// use at your own risk.
// Entity With Computed Field
// --------------------------
anonymous
anonymous / gist:3753571
Created September 20, 2012 02:10
@ChristinGorman gave this talk at JavaZone: https://vimeo.com/49484333 It's quite good, short, energetic, enthusiastic,
intelligent, and completely misses the point.
While it's true that the code she produces is much better than the original, and is quite easy to understand; it fails one
critical test. It's not polite.
Polite code is like a well written newspaper article. It allows you to bail out early. A well written article has a
headline, a synopsis, and a set of paragraphs that begin with the high level concepts and get more and more detailed as you
read through the article. At any point you can decide: "I get it! I don't need to read further." Indeed, this is how most
people read newspapers or magazines. The articles are polite, because they allow you to get out quickly.
@AtmosphereHandlerService(path="/chat",
interceptors = {AtmosphereResourceLifecycleInterceptor.class, BroadcastOnPostAtmosphereInterceptor.class})
public class ChatAtmosphereHandler extends OnMessage<Data> {
private final ObjectMapper mapper = new ObjectMapper();
@Override
public void onMessage(AtmosphereResponse response, Data message) throws IOException {
response.getWriter().write(mapper.writeValueAsString(data));
}
@pda
pda / www.rb
Created August 9, 2012 02:23
www: Serve the current directory via HTTP.
#!/usr/bin/env ruby
# Serve the current directory via HTTP.
# Like Python's SimpleHTTPServer, but with no-cache headers.
# Default port 8000, specify alternate port as first parameter:
# www 3000
# sudo www 80 # (probably a bad idea)
# Inspired by http://chrismdp.github.com/2011/12/cache-busting-ruby-http-server/
@andsens
andsens / bootstrap_homeshick.sh
Last active December 13, 2024 17:55
Script that can set up an entire user account with homeshick automatically
#!/bin/bash -ex
# Paste this into ssh
# curl -sL https://gist.github.com/andsens/2913223/raw/bootstrap_homeshick.sh | tar -xzO | /bin/bash -ex
# When forking, you can get the URL from the raw (<>) button.
### Set some command variables depending on whether we are root or not ###
# This assumes you use a debian derivate, replace with yum, pacman etc.
aptget='sudo apt-get'
chsh='sudo chsh'
@jboner
jboner / latency.txt
Last active August 2, 2025 22:26
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