Skip to content

Instantly share code, notes, and snippets.

View brushbox's full-sized avatar

Peter Sumskas brushbox

View GitHub Profile
@brushbox
brushbox / hack.sh
Created March 31, 2012 11:53 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@brushbox
brushbox / Plea.markdown
Created July 16, 2012 04:31 — forked from justinko/Plea.markdown
Am I doing it wrong?

Dear Rubyists,

I just lost a contract because of my code in a Rails project.

The specific code in question is related to a "posting a comment" feature. Here are the details:

In this project, "posting a comment" does not simply entail inserting a row into the database. It involves a procedure to yes, insert a row, but also detect its language, check for spam, send emails, and "share" it to Twitter and Facebook. I believe this algorithm should be encapsulated. I do not believe it belongs in a controller or a model. I do not believe Active Record callbacks should be used.

The "senior developer", whom is the stake holder's right hand man, said this:

@brushbox
brushbox / chef_solo_bootstrap.sh
Created July 23, 2012 05:09 — forked from ryanb/chef_solo_bootstrap.sh
Bootstrap Chef Solo
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.gz
tar -xvzf ruby-1.9.3-p194.tar.gz
cd ruby-1.9.3-p194/
./configure --prefix=/usr/local
make
make install
@brushbox
brushbox / channels.rs
Created April 30, 2014 02:13
Having trouble with match and enums in rust.
use std::comm::channel;
use std::io::timer::sleep;
use std::sync::deque::BufferPool;
use std::sync::deque::Stolen;
fn main() {
let (tx, rx) = channel();
let mut pool = BufferPool::new();
let (worker, stealer) = pool.deque();
@brushbox
brushbox / breaking_suppress.rb
Last active May 14, 2016 01:40
Is suppress broken?
# This code shows how the implementation of ActiveRecord::Suppressor#suppress is broken if nested.
Notification.suppress do
#... suppressed code calling down into other things.
complex_logic
# NOT supressed! Surprise!
end
# this method should be considered as passing control down through enough levels of logic that
# it is reasonable to believe that the person calling the inner suppress is unaware that
# Notification is already suppressed.
@brushbox
brushbox / example_pipeline.ex
Last active August 5, 2017 06:06
reducer pipeline snippets
user_token
|> find_user_by_token
|> fetch("/messages/unread")
|> parse_json_to_message_list
|> Enum.each(&save_message(&1))
Enum.each(
parse_json_to_message_list(
fetch(find_user_by_token(user_token), "/messages/unread")
### Keybase proof
I hereby claim:
* I am brushbox on github.
* I am brushbox (https://keybase.io/brushbox) on keybase.
* I have a public key ASCpHBOKT6nx4WjnME42Y9Z_xRlkw6KqX8k955otlLNSXwo
To claim this, I am signing this object: