Skip to content

Instantly share code, notes, and snippets.

View johnsyweb's full-sized avatar

Pete Johns johnsyweb

View GitHub Profile
def binary_search(elements, required):
if 1 == len(elements):
if required == elements[0]:
return required
else:
return None
else:
midpoint = int(len(elements) / 2)
if elements[midpoint] > required:
return binary_search(elements[:midpoint], required)
#include <iostream>
#include <fstream>
class scoped_cout_redirector
{
public:
scoped_cout_redirector(const std::string& filename)
:backup_(std::cout.rdbuf())
,filestr_(filename.c_str())
,sbuf_(filestr_.rdbuf())
#include <iostream>
#if WINDOWS
#include <conio.h>
#else
#include <fcntl.h>
#include <termios.h>
@johnsyweb
johnsyweb / lie.cpp
Created February 5, 2013 08:41
Comments are lies!
// --------------------------------------------------------------------------
// Method Name: CProtocolField::setValue
// Definition: This method sets the value attribute of the CProtocolField.
// Qualification: none
// Export: public
//
// Return: void
// Parameters: double value
//
// Preconditions: none
@johnsyweb
johnsyweb / noise.cpp
Created February 5, 2013 08:47
Comments are noise!
//////////////////////////////////////////////////////////////////////////////
//
// Function Name: ExcCxlCached::~ExcCxlCached()
//
// Definition: Destructor for the ExcCxlCached class
//
// Qualification: virtual
//
// Export: public
//
@johnsyweb
johnsyweb / mtr --report github.com.md
Last active December 16, 2015 08:48
10% packet loss in rackspace.

From Work [115.146.71.1]

[Fri 13/05/10 08:14 EST][s009][x86_64/darwin12.2.0/12.3.0][5.0.2]
<paj@pajimac:~>
zsh 3013 % mtr --report github.com
HOST: pajimac.local               Loss%   Snt   Last   Avg  Best  Wrst StDev
  1.|-- 192.168.0.1                0.0%    10    5.2   4.2   3.3   5.2   0.7
  2.|-- lo-1-pe1-mel-dc2.firenet.  0.0%    10    2.5   3.0   2.3   5.2   0.9
  3.|-- ge-0-0-0-bdr1-mel-dc2.fir  0.0%    10    5.2  10.8   4.4  60.5  17.5

It seems AAPL are now using MSFT mail services to deliver "Important" messages.

Received: from CO9EHSNDR001.bigfish.com (mail14-co9on0067.outbound.messaging.microsoft.com [157.56.211.67])
  (using TLSv1 with cipher AES128-SHA (128/128 bits))
	(No client certificate requested)
	by beaujolais.extremis.net (Postfix) with ESMTPS id 3b4rGJ5GXPzXCl8
	for <pete@xxxxxx.org>; Tue,  7 May 2013 20:19:04 +0100 (BST)
Received: from co9outboundpool.messaging.microsoft.com (10.236.132.244) by
 CO9EHSNDR001.bigfish.com (10.236.130.55) with Microsoft SMTP Server (TLS) id
#!/usr/bin/ruby
#-*-ruby-*-
# A script to run ctags on all .rb files in a project. Can be run on
# the current dir, called from a git callback, or install itself as a
# git post-merge and post-commit callback.
CTAGS = '/opt/local/bin/ctags'
HOOKS = %w{ post-merge post-commit post-checkout }
HOOKS_DIR = '.git/hooks'
@johnsyweb
johnsyweb / robomo.conf
Created July 11, 2013 06:47
Start robomo from upstart
# vim: ft=upstart
description "Robomo"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec su - ci -c 'cd /home/ci/robomo/lib && ruby robomo.rb > /var/log/robomo.log 2>&1'
Default:Solarized Dark xterm-256color
# Development
ci-public:Ocean
ci:Ocean
skynet:Ocean
skynet-public:Ocean
# Test
gateqa-p11:Grass