Skip to content

Instantly share code, notes, and snippets.

@josephruscio
josephruscio / keybase.md
Created September 12, 2017 22:14
keybase.md

Keybase proof

I hereby claim:

  • I am josephruscio on github.
  • I am josephruscio (https://keybase.io/josephruscio) on keybase.
  • I have a public key ASCUSG2qjcAZVGf0I3h4pYcGT9DYeTpoD-SxRngCBKlwkwo

To claim this, I am signing this object:

@josephruscio
josephruscio / gist:9297594
Created March 1, 2014 21:22
Problems reaching 37Signals Campfire Service
# Failed traceroute to 37S Campfire
13:17 $ traceroute librato.campfirenow.com
traceroute to librato.campfirenow.com (204.62.114.183), 64 hops max, 52 byte packets
1 router.asus.com (192.168.2.1) 4.576 ms 1.705 ms 3.346 ms
2 192.168.1.254 (192.168.1.254) 2.147 ms 1.251 ms 1.825 ms
3 70-36-139-1.dsl.dynamic.sonic.net (70.36.139.1) 30.174 ms 10.125 ms 9.260 ms
4 gig1-26.cr1.colaca01.sonic.net (70.36.228.61) 9.805 ms 9.042 ms 6.739 ms
5 po3.cr1.lsatca11.sonic.net (75.101.33.166) 10.631 ms 9.692 ms 26.293 ms
6 0.xe-5-1-0.gw.pao1.sonic.net (69.12.211.1) 33.997 ms 39.120 ms 11.086 ms
#!/bin/sh
#set -x
PROG=$0
# Install an updated rsync using homebrew with the instructions here:
# http://blog.jm3.net/2012/07/30/os-x-rsync
RSYNC="/usr/local/bin/rsync"
SRC="/"
@josephruscio
josephruscio / gist:1260593
Created October 4, 2011 00:09
Something just went alpha ...
1.9.2@librato laserbeak:heroku-addon-test master $ heroku addons:add librato-metrics
-----> Adding librato-metrics to <APP>... done, v5 (free)
class MetricsController < ApplicationController
before_filter :find_metric
respond_to :html, :json
def edit
if admin_signed_in?
@user = metric.user
end
@josephruscio
josephruscio / ruby_symbol_fail
Created February 22, 2011 18:12
Symbols are not always interchangeable with strings
ree-1.8.7-2010.02 :014 > k = "1"
=> "1"
ree-1.8.7-2010.02 :015 > k.to_i
=> 1
ree-1.8.7-2010.02 :016 > k = "1".to_sym
=> :"1"
ree-1.8.7-2010.02 :017 > k.to_i
=> 16943
@josephruscio
josephruscio / rb_const_macro.c
Created October 6, 2009 16:36
Macro-fu to export C constants into Ruby
/*
* Macro-fu to simplify the exporting C constants from a Ruby extension.
*/
#define EXPORT_RB_CONST(val, x) \
do{ rb_define_const(val, #x, INT2NUM(x)); } while(0)
#define BAR 42
void
Init_foo(void)
#Forcing mkmf to include a library when the simplistic test used by
#have_library fails
require 'mkmf'
dir_config('foo')
if have_header('foo.h') and
$libs = append_library($libs, 'foo')
then
create_makefile('wrapfoo')
@josephruscio
josephruscio / stats.rb
Created September 15, 2009 21:41 — forked from mojombo/stats.rb
Refactor with aggregate gem
# Using the aggregate gem (http://www.gemcutter.org/gems/aggregate),
# run the given block +num+ times and then print out the mean, min,
# max, std_dev, and histogram of the run duration. For example:
#
# irb> stats(100, 0, 10, 1) { sleep(rand / 100) }
# mean: 5.99ms
# min: 1.49ms
# max: 9.28ms
# stddev: 2.54ms
# value |------------------------------------------------------------------| count
@@ -283,7 +283,10 @@ inet_connect(int s, const char *hname, uint16_t port)
{
struct addrinfo *lookup_result=NULL;
struct addrinfo hints;
- struct sockaddr_storage dest_addr;
+ union {
+ struct sockaddr_storage sa_stor;
+ struct sockaddr_in sa_in;
+ } dest_addr;
struct sockaddr_in *dest_in;