Skip to content

Instantly share code, notes, and snippets.

View oisin's full-sized avatar
💭
Thing.

Oisín Hurley oisin

💭
Thing.
View GitHub Profile
@oisin
oisin / throw.rb
Created February 27, 2016 14:37
Compute odds of receiving N instances of symbol Y in a throw of M dice with SYMBOLS faces
# Compute odds of occurrence of N symbol Y in M dice
#
symbols = ARGV[0].split(",") # ["s", "ss", "sss", "h", "b", "f"]
m = ARGV[1].to_i
n = ARGV[2].to_i
y = ARGV[3]
def to_radix(int, radix)
@oisin
oisin / Log Requests
Last active August 29, 2015 14:09
HTTP Server that will print the JSON arriving from a client.
Simple server which just formats and prints JSON requests.
@oisin
oisin / Dockerfile
Last active January 29, 2019 20:13
Dockerfile snippet for Ruby API Server setup experiment
FROM ubuntu:14.04
MAINTAINER Oisin Hurley <oisin@nis.io>
RUN apt-get update && apt-get install -y curl wget git
RUN adduser --home /home/api_server --disabled-password --gecos '' api_server
RUN adduser api_server sudo
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER api_server
RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
RUN curl -sSL https://get.rvm.io | bash -s stable
RUN /bin/bash -l -c "source /home/api_server/.rvm/scripts/rvm"
@oisin
oisin / pool.rb
Created October 30, 2014 08:58
Simple Ruby thread pool as per http://burgestrand.se/code/ruby-thread-pool/
require 'thread'
module Alert
def self.yikes(msg)
# Use this to log/trigger monitor
puts msg
end
end
# See http://burgestrand.se/code/ruby-thread-pool/
@oisin
oisin / codereview.md
Created August 29, 2014 08:08
code-review

This is a summary of an original prose piece

Author

  • Patches to be kept as small as practicable
  • Patches to be explained clearly

Reviewer

  • What is the intent of the patch?
@oisin
oisin / crushem.sh
Last active August 29, 2015 14:02
Convert all TIFF files in the current directory to PNG
# Crush all the Pings!
for i in *.png
pngcrush "$i" `basename -s .png "$i"`-crushed.png
@oisin
oisin / pr.md
Created May 27, 2014 12:30 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@oisin
oisin / gist:10116472
Created April 8, 2014 12:22
From https://coderwall.com/p/dz6ttq - code snippet to switch on/off logging moped commands when in the Rails console.
# This initializer adds a method, show_mongo, when running a rails console. When active, all
# moped commands (moped is mongoid's mongodb driver) will be logged inline in the console output.
# If called again, logging will be restored to normal (written to log files, not shown inline).
# Usage:
# > show_mongo
if defined?(Rails::Console)
def show_mongo
if Moped.logger == Rails.logger
Moped.logger = Logger.new($stdout)

Keybase proof

I hereby claim:

  • I am oisin on github.
  • I am oisin (https://keybase.io/oisin) on keybase.
  • I have a public key whose fingerprint is 5A6B 3BEF B837 764F EAC4 FD6E 0D97 5065 C08C F6CF

To claim this, I am signing this object:

@oisin
oisin / feedback.m
Created February 9, 2014 15:56
Changing the background colour of the Converser SDK generated feedback form.
# Simple tester for Converser SDK feedback form manipulation. No network connections
# made.
#import "CIOSecondViewController.h"
@interface CIOSecondViewController ()
@property (strong,nonatomic) VGConversationEngine *converser;
@end
@implementation CIOSecondViewController