Skip to content

Instantly share code, notes, and snippets.

require 'io/console'
require 'game-client'
def readKey
c = ''
result = ''
$stdin.raw do |stdin|
c = stdin.getc
result << c
if c == "\e"
require 'game-client'
class Position < Struct.new(:x, :y)
GameClient.configure do |config|
# Configure Bearer authorization: token
config.host = 'http://td-capture-the-flag.herokuapp.com' # https://example.com
config.access_token = 'adam@testdouble.com' # alice@example.com
end
class Errorable
attr_accessor :state, :errors
def initialize(state)
@state = state
@errors = []
end
def method_missing(symbol, *args)
raise NoMethodError, "undefined method `#{symbol}' for #{self}" unless self.respond_to?(symbol, true)
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails", github: "rails/rails"
@McPolemic
McPolemic / multiprint.c
Created January 25, 2015 05:13
A nimrod example
#include <stdio.h>
void multiprint(int times, char *message) {
for (int i = 0; i < times; i++) {
printf(message);
}
printf("\n");
}
@McPolemic
McPolemic / gist:25c6a74fb658bb7a3fc9
Last active August 29, 2015 14:12
Home Automation with Redis Pub/Sub

I've been thinking a lot about home automation lately. Turning lights on when you enter rooms, turning the television on and off from your smart phone, making sure the doors are locked when you're not home - there's a lot of use cases I'm interested in.

I've read a number of articles where people will do one of the above. The order is usually the same:

  1. Get an Arduino/Raspberry Pi.
  2. Wire it up to power.
  3. Turn it on and off with a simple switch.

That didn't excite me very much. Some people went through the trouble of giving it a web front-end, so you could open http://192.168.12.34/ to view or change the device. That's getting closer, but it's a little... user hostile. I don't want to remember random IP addresses, especially if I'll have more than one device in the house ("Was that the garage door I just turned on, or the coffee pot?").

FROM ubuntu:14.04
MAINTAINER Adam Lukens "spawn968@gmail.com"
RUN echo "deb http://us.archive.ubuntu.com/ubuntu/ trusty universe" >> /etc/apt/sources.list
RUN apt-get -y update
# Install node.js
RUN apt-get install -y python-software-properties software-properties-common python python-setuptools git build-essential build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev curl ruby2.0-dev
RUN add-apt-repository ppa:chris-lea/node.js
RUN apt-get -y update
class NautilusUploadService
def initialize options
required = [:username,
:password,
:hostname,
:share,
:domain]
@username = options.fetch(:username)
@password = options.fetch(:password)
class NautilusUploadService
def initialize options
required = [:username,
:password,
:hostname,
:share,
:domain]
@username = options.fetch(:username)
@password = options.fetch(:password)
package leap
func IsLeap(year int) bool {
if isEveryFourYears(year) {
if isCentury(year) && !isCenturyLeapYear(year) {
return false
} else {
return true
}
} else {