Skip to content

Instantly share code, notes, and snippets.

View philcrissman's full-sized avatar

Phil Crissman philcrissman

View GitHub Profile
@philcrissman
philcrissman / dock
Created June 14, 2019 20:54
Attach to a docker container with less typing
#!/usr/bin/env ruby
class DockerAttacher
attr_reader :docker_container
def initialize(docker_container)
if docker_container.nil?
puts "Usage: dock [container_id]\nGet container id with `docker ps`"
else
@docker_container = docker_container
@data = File.read("./input.txt").split("\n").map{|n| n.split(": ").map(&:to_i)}.to_h
@firewall = Array.new(99)
@firewall = @firewall.each_with_index.map{|n,i| next if @data[i].nil?; ((0..@data[i]-1).to_a + (1..@data[i]-2).to_a.reverse).cycle}
@results = (0..98).map{|n| n if @firewall.map{|e| next if e.nil?; e.next}[n] == 0}.select{|n| n if !n.nil?}
@severity = @results.map{|i| i * @data[i]}.inject(&:+)
require 'minitest/autorun'
require 'minitest/emoji'
class Version
def self.next_version version
next_version_3 version
end
def self.next_version_1 version
number_as_string = version.split(".").join('')
require 'minitest/autorun'
class Bloom
attr_accessor :array
def initialize(array_size=10_000_000, hashes_per_word=4, words_file="/usr/share/dict/words")
@array_size = array_size
@hashes_per_word = hashes_per_word
@words_file = words_file
/*
Objects can have the following parameters:
color: '#fff' by default
impassable: true if it blocks the player from movement (false by default)
onCollision: function (player, game) called when player moves over the object
onPickUp: function (player, game) called when player picks up the item
symbol: Unicode character representing the object
type: 'item' or null
*/
/*****************
* bossFight.js *
*****************
*
* NO FARTHER, DR. EVAL!!!!
* YOU WILL NOT GET OUT OF HERE ALIVE!!!!
* IT'S TIME YOU SEE MY TRUE FORM!!!!
* FACE MY ROBOT WRATH!!!!!
*/
/****************************
* documentObjectMadness.js *
****************************
*
* I can't believe it! I can't believe you made it onto
* Department of Theoretical Computation's web server!
* YOU SHOULD HAVE BEEN DELETED! This shouldn't even be
* possible! What the hell were the IT folks thinking?
*
* No matter. I still have the Algorithm. That's the
/**********************
* superDrEvalBros.js *
**********************
*
* You're still here?! Well, Dr. Eval, let's see
* how well you can operate with one less dimension.
*
* Give up now. Unless you have a magic mushroom
* up your sleeve, it's all over.
*/
/***************
* pointers.js *
***************
*
* You! How are you still alive?
*
* Well, no matter. Good luck getting through this
* maze of rooms - you'll never see me or the Algorithm again!
*/
/*************
* lasers.js *
*************
*
* Time to unleash the killer lasers! Each laser will kill you
* unless you have the appropriate color. Too bad you can't
* see which color corresponds to which laser!
*/
function getRandomInt(min, max) {