Skip to content

Instantly share code, notes, and snippets.

View mrageh's full-sized avatar
💪
Waaat

Adam Magan mrageh

💪
Waaat
View GitHub Profile

FWIW: I didn't produce the content presented here (the outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

@mrageh
mrageh / custom_flatten.rb
Last active May 8, 2018 08:39
A custom implementation of Array#flatten
RSpec.describe "Custom implementation of Array Flatten" do
it 'flattens array containing empty array' do
list = [[]]
expect(custom_flatten(list)).to eq([])
end
it 'flattens array containing array with one element' do
list = [[1]]
expect(custom_flatten(list)).to eq([1])
end
@mrageh
mrageh / unfavorite.js
Created September 25, 2017 23:26 — forked from ashander/unfavorite.js
Delete all your favorites (unfavorite or unlike every tweet) on twitter.com (thx to @JamieMason and @b44rd for inspiring this)
// 1. Go to https://twitter.com/i/likes
// 2. Keep scrolling to the bottom repeatedly until all your favs are loaded.
// 3. Run this in your console (open in chrome by View > Developer > JavaScript Console)
// Notes: this may take a while if you have a lot of favs/likes
// you can only access your most recent ~2000 likes.
// inspired by https://gist.github.com/JamieMason/7580315
$('.ProfileTweet-actionButtonUndo').click()

There are three easy to make mistakes in go. I present them here in the way they are often found in the wild, not in the way that is easiest to understand.

All three of these mistakes have been made in Kubernetes code, getting past code review at least once each that I know of.

  1. Loop variables are scoped outside the loop.

What do these lines do? Make predictions and then scroll down.

func print(pi *int) { fmt.Println(*pi) }
@mrageh
mrageh / bosh-init-failure.log
Last active July 15, 2016 11:23
Bosh init failure log from following this CF tutorial https://docs.cloudfoundry.org/deploying/aws/setup_bosh_aws.html
[File System] 2016/07/14 21:41:44 DEBUG - Copying dir '/Users/Adam/.bosh_init/installations/924920ae-200f-404a-7704-9ac3c6cf284e/tmp/rendered-jobs553169157' to '/Users/Adam/.bosh_init/installations/924920ae-200f-404a-7704-9ac3c6cf284e/tmp/rendered-job-list-archive177362242/nats'
[File System] 2016/07/14 21:41:44 DEBUG - Copying dir '/Users/Adam/.bosh_init/installations/924920ae-200f-404a-7704-9ac3c6cf284e/tmp/rendered-jobs553169157/bin' to '/Users/Adam/.bosh_init/installations/924920ae-200f-404a-7704-9ac3c6cf284e/tmp/rendered-job-list-archive177362242/nats/bin'
[File System] 2016/07/14 21:41:44 DEBUG - Copying file '/Users/Adam/.bosh_init/installations/924920ae-200f-404a-7704-9ac3c6cf284e/tmp/rendered-jobs553169157/bin/nats_ctl' to '/Users/Adam/.bosh_init/installations/924920ae-200f-404a-7704-9ac3c6cf284e/tmp/rendered-job-list-archive177362242/nats/bin/nats_ctl'
[File System] 2016/07/14 21:41:44 DEBUG - Copying dir '/Users/Adam/.bosh_init/installations/924920ae-200f-404a-7704-9ac3c6cf284e/tmp/rendered-jobs553
@mrageh
mrageh / user.rb
Created June 25, 2016 15:26 — forked from harlow/user.rb
Extract a validator in Rails. Zip code validation.
# app/models/user.rb
class User < ActiveRecord::Base
validates :zip_code, presence: true, zip_code: true
end
@mrageh
mrageh / sieve.rs
Created January 30, 2016 16:12
Basic implementation of Sieve of Eratosthenes
/// Find all prime numbers less than `n`.
/// For example, `sieve(7)` should return `[2, 3, 5]`
pub fn sieve(n: usize) -> Vec<usize> {
let mut p:usize = 2;
let range = p..n;
let mut list:Vec<usize> = vec![];
//build list
for x in range {
list.push(x);
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', path: '~/programming/projects/rails', branch: '4-2-stable'
@mrageh
mrageh / about.md
Last active August 29, 2015 14:11 — forked from jasonrudolph/about.md