Skip to content

Instantly share code, notes, and snippets.

xcode-select --install
# homebrew / cask / util
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
brew doctor
brew tap phinze/homebrew-cask
brew install brew-cask
brew cask install alfred
brew cask install iterm2
@marksim
marksim / README.md
Last active September 28, 2018 15:56
Pair Sessions Script Adding more security (automatically timeout sudo, append the command to each ssh key

My script for pair sessions on my box.

What it does

  • downloads the appropriate ssh keys from github
  • copies the appropriate 'ssh pair@your-external-ip' command to your clipboard (see Note #1)
  • sets up the tmux session
  • cleans up the session, and the keys after it's done

How to use

@marksim
marksim / README.md
Created July 10, 2012 16:18
How to isolate mail dependency without integrating into data model?

I'm not sure how to remove the dependency on VerificationMailer without pushing it into the profile model and making the model suddenly care about how to mail verifications.

I WANT to remove it so I don't have any need to load up rails when running the tests, but also want to keep my models sensible and without a lot of knowledge of business logic.

Example usage:

profile = Profile.find(1)
profile.extend Verifier

profile.verify(email: 'myemail@example.com')

The Erlang VM only allows a limited set of expressions as guards:

  • comparison operators (==, !=, ===, !==, >, <, <=, >=);
  • boolean operators (and, or) and negation operators (not, !);
  • arithmetic operators (+, -, *, /);
  • <> and ++ as long as the left side is a literal;
  • the in operator;
  • all the following type check functions:
    • is_atom/1
  • is_binary/1
@marksim
marksim / keybase.md
Created March 3, 2016 17:06
Keybase

Keybase proof

I hereby claim:

  • I am marksim on github.
  • I am marksim (https://keybase.io/marksim) on keybase.
  • I have a public key whose fingerprint is 351B AEFF 19E6 F01A 283F E0E6 FB4A 9F3A 2F2C B718

To claim this, I am signing this object:

require 'rspec'
require 'date'
class EmploymentEvent < Struct.new(:date, :status)
def <=> (b)
date <=> b.date
end
def as_start
date + 1

Github Questions

Q1:

Knowing what you know about GitHub, how would you design the high level infrastructure for github.com? What sequence of steps would happen when loading http://www.github.com in a browser? Don't worry about describing the specific libraries and services that handle each step.

A1:

Assumptions

Well, let's start with a few assumptions so we're on the same page:

require 'rspec'
def next_server_number(server_numbers)
server_numbers.sort.each.with_index do |s, i|
return i+1 if s > i+1
end
return server_numbers.count + 1
end
describe 'next_server_number' do
@marksim
marksim / .powenv
Last active January 4, 2016 17:39
Pow Config
# Automatically exports all variables in .env files
export $(cat .env)
require 'rspec'
class GameOfLife
def initialize(generation)
@generation = generation
end
attr_reader :generation
def is_alive?(x, y)