Skip to content

Instantly share code, notes, and snippets.

View blurredbits's full-sized avatar

Mark Morris blurredbits

View GitHub Profile
@blurredbits
blurredbits / index.html
Last active December 18, 2015 11:18 — forked from dbc-challenges/index.html
DBC Phase 2 Practice Assessment Part 3
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css">
</head>
@blurredbits
blurredbits / stakeout_solution.md
Last active December 20, 2015 00:29
Stakeout Solution

#Stakeout

Congratulations! You are the new elite hacker in a group of villainous ne'er-do-wells.

Luckily this group is more saavy than your last band of ruffians, and they are looking to software (and you) to improve their take. The con man for the team, has gone door-to-door down each street posing as a termite inspector so he could covertly total the valuable goods in each house. Normally the gang would just rob all the valuable homes, but there's a catch! Whenever a house is robbed in this wealthy neighborhood, the police watch it and the neighboring houses for months.

# This is a simple refactoring exercise.
#
# What to do?
#
# 1. Look at the code of the class CorrectAnswerBehavior
# 2. Try to see what it does by running `ruby refactoring_example.rb`
# 3. Record characterisation tests by running `ruby refactoring_example.rb --record`
# 4. Make the code beautiful;)
# 5. You are allowed to modify only the code between markers (REFACTORING START/REFACTORING END).
# 6. Test must pass! You can run them with command `ruby refactoring_example.rb --test`
#!/usr/bin/env ruby
require 'excon'
require 'statsd-ruby'
require 'json'
module ExconConnection
class << self
@blurredbits
blurredbits / craftingcode.md
Last active March 14, 2016 15:02
Crafting Code

Crafting Code

Here's the thing. Computers are nothing more than really fast light switches. On & off millions of times per second. All it cares about is ones & zeroes.

So when it comes to code, and more specifically crafting code, who are we really writing code for?

We're writing it for ourselves, our teammates or our customers - basically other humans. We're using code to express ideas, human ideas in terms of a computer language. As developers, we're tasked with creating sets of instructions to be carried out by our dumb servants to execute these ideas.

If the computer doesn't particularly care about code (other than a clean compile) - what are some of the tools we can use to craft our code for human consumption?

@blurredbits
blurredbits / pg_consumer.rb
Last active May 17, 2018 16:50
Kafka PostgreSQL Consumer
#!/usr/bin/env ruby
require 'poseidon'
require 'pg'
conn = PG.connect(host: 'localhost', port: 5432, dbname: 'postgres', user: 'postgres')
begin
conn.exec("CREATE DATABASE metrics")
rescue PG::DuplicateDatabase
Type Start End # Pages Attributes
Available 0000000000000000-000000000009EFFF 000000000000009F 000000000000000F
Reserved 000000000009F000-000000000009FFFF 0000000000000001 000000000000000F
Available 0000000000100000-000000001DF0DFFF 000000000001DE0E 000000000000000F
BS_Data 000000001DF0E000-000000001DF4DFFF 0000000000000040 000000000000000F
Available 000000001DF4E000-0000000033FAFFFF 0000000000016062 000000000000000F
LoaderCode 0000000033FB0000-00000000340D4FFF 0000000000000125 000000000000000F
BS_Data 00000000340D5000-0000000035DEFFFF 0000000000001D1B 000000000000000F
ACPI_NVS 0000000035DF0000-0000000035DF0FFF 0000000000000001 000000000000000F
RT_Data 0000000035DF1000-0000000035DF1FFF 0000000000000001 800000000000000F
@blurredbits
blurredbits / heroku_export.md
Last active January 3, 2021 21:16
Import/exporting database info from Heroku

Importing/Exporting a Postgres DB from Heroku

In the following scenario, we have the following apps on the Heroku server:

  • Staging Server: staging-stackoverfluff
  • Production Server: stackoverfluff

In addition, each developer has a local development environment.

The goal is to move production data over to the staging server, and also provide production data to each of the developers. Here's what we will do.