- #000000
- #7F7F7F
- #880015
- #ED1C24
- #FF7F27
- #FFF200
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Text; | |
namespace Temp | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The MIT License (MIT) | |
// | |
// Copyright (c) 2013, Nathan Reed | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is | |
// furnished to do so, subject to the following conditions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WorkerThread | |
def initialize | |
end | |
def start(options = nil) | |
raise 'background_task needs a block' unless block_given? | |
options ||= {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def benchmark(count = 1, &block) | |
start = Time.now | |
count.times do |i| | |
yield | |
end | |
duration = Time.now - start | |
per_sec = count / duration | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# create a gem templete | |
bundle gem gem_name_goes_here | |
# run the unit tests | |
bundle exec rake test | |
# upload the gem to rubygems | |
bundle exec rake release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Object | |
def is_a!(t, name = nil) | |
if !is_a? t | |
if name.nil? | |
raise "expected #{t} but got #{self.class}" | |
else | |
raise "#{name} requires #{t} but got #{self.class}" | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# screens.rb | |
# @reednj, 2016-12-06 | |
# | |
# This script will take a screenshot of the desktop on up to two monitors, and save it in the | |
# given location (usually Dropbox). It will only take a screenshot if the user is active. | |
# | |
# If there is already a screenshot that exists for that day, it will _sometimes_ overwrite it | |
# and make a new one. This is an attempt to get a screenshot at a random time each day. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aback | |
abase | |
abate | |
abbey | |
abbot | |
abhor | |
abide | |
abled | |
abode | |
abort |
Imagine you need to implement (integer) mulitplication in code. Maybe you are on a system which doesn't have it or something. How to do this, and what is the minimal set of operators that are required?
The most obvious way to do multiplition is through repeated addition. To get the answer to 56 x 67 you add 56 to itself 67 times (or 67, 56 times - the order doesn't matter).
This is simple to implement if we assume for the moment that both a
and b
are positive (we will deal with negative integers later)