Skip to content

Instantly share code, notes, and snippets.

View JonGretar's full-sized avatar

Jon Gretar Borgthorsson JonGretar

View GitHub Profile
@JonGretar
JonGretar / ssh_install_key
Created January 27, 2009 11:41
Uploads your ssh key to a host
#!/bin/sh
# USE: ssh_install_key username@some.host.com
KEY="$HOME/.ssh/id_rsa.pub"
if [ ! -f ~/.ssh/id_rsa.pub ];then
echo "private key not found at $KEY"
echo "* please create it with "ssh-keygen -t dsa" *"
echo "* to login to the remote host without a password, don't give the key you create with ssh-keygen a password! *"
exit
@implementation CalendarView: CPView
{
}
-(id)init {
self = [super initWithFrame:CGRectMake(0, 0, 200, 200)];
if (self) {
[self loadData];
}
/*
* Copyright 2009 agile42 GmbH - All rights reserved
*
* Authors:
* - Martin Häcker <martin.haecker@agile42.com>
*/
// TODO: minimize this so only the actual dependencies are included
@import <AppKit/AppKit.j>

Instrument Anything in Rails 3

With Rails 3.0 released a few weeks ago I've migrated a few apps and I'm constantly finding useful new improvements. One such improvement is the ability to log anything in the same way that Rails internally logs ActiveRecord and ActionView. By default Rails 3 logs look slightly spiffier than those produced by Rails 2.3: (notice the second line has been cleaned up)

Started GET "/" for 127.0.0.1 at Mon Sep 06 01:07:11 -0400 2010
  Processing by HomeController#index as HTML
  User Load (0.2ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1

Rendered layouts/_nav.html.erb (363.4ms)

@JonGretar
JonGretar / ipcalc.erl
Created March 14, 2012 16:35
Module for calculating network address.
-module(ipcalc).
-author('Jon Gretar Borgthorsson <jongretar@medizza.com>').
-export([
get_network/2
]).
%% When Netmask is not Integer
get_network(_NetworkAddress, Netmask) when is_list(Netmask) ->
throw(netmask_not_integer);
@JonGretar
JonGretar / output
Created August 27, 2013 14:59
Log node.js http server response times and output it's distribution on exit.
[root@market1 ~]# ./request_time.d
Request took 275 ms to complete /users/ubf4a1949-bb12-484a-80c5-ef7d079933e8/entitlement/edf627d85-f6bc-485c-a387-65b32bf4d231/token
Request took 278 ms to complete /users/ubf4a1949-bb12-484a-80c5-ef7d079933e8/entitlement/edf627d85-f6bc-485c-a387-65b32bf4d231/token
Request took 286 ms to complete /users/u07edf558-8f50-4963-992a-728f56e49590/entitlement/e3afec1f9-ed01-4444-b7b9-6e90cf573e17/token
Request took 163 ms to complete /users/u7716cbc1-e0b9-4fab-b705-43d74aad9541/entitlement/ed89cf626-28c3-48ee-84d0-964726a9caef/token
Request took 1 ms to complete /organization/oz/catchup/content/26cf243fda948f68430942993257746b
Request took 3 ms to complete /organization/oz/catchup/content/26cf243fda948f68430942993257746b
Request took 0 ms to complete /organization/oz/catchup/content/a61d78c15d3aecf8982e097ff8f74d2f
Request took 2 ms to complete /organization/oz/catchup/content/a61d78c15d3aecf8982e097ff8f74d2f
Request took 3 ms to complete /organization/oz/catchup/content/a
@JonGretar
JonGretar / salt-pam.log
Created March 2, 2014 21:01
Salt PAM not loading
[root@salt-master ~]# salt "salt*" test.ping -l all -a pam
[DEBUG ] Reading configuration from /etc/salt/master
[DEBUG ] Missing configuration file: /root/.salt
[TRACE ] loading log_handlers in ['/var/cache/salt/master/extmods/log_handlers', '/opt/local/lib/python2.7/site-packages/salt/log/handlers']
[TRACE ] Skipping /var/cache/salt/master/extmods/log_handlers, it is not a directory
[DEBUG ] Loaded logstash_mod as virtual logstash
[TRACE ] Added logstash.DatagramLogstashHandler to log_handlers
[TRACE ] Added logstash.LogstashFormatter to log_handlers
[TRACE ] Added logstash.NewStyleClassMixIn to log_handlers
[TRACE ] Added logstash.ZMQLogstashHander to log_handlers
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
@JonGretar
JonGretar / Vagrantfile
Last active August 29, 2015 14:01
SmartOS Saltstack Vagrant
Vagrant.configure("2") do |config|
config.vm.box = "smartos-base1310-64-virtualbox-20130806.box"
config.vm.box_url = "http://dlc-int.openindiana.org/aszeszo/vagrant/smartos-base1310-64-virtualbox-20130806.box"
config.vm.provision "shell", path: "salt_install.sh"
end
@JonGretar
JonGretar / keybase.md
Created August 15, 2014 00:07
keybase.md

Keybase proof

I hereby claim:

  • I am JonGretar on github.
  • I am jongretar (https://keybase.io/jongretar) on keybase.
  • I have a public key whose fingerprint is A25C E494 708E 603A 7A8E 0F34 32FC 10A9 E2D4 4D0F

To claim this, I am signing this object: