Skip to content

Instantly share code, notes, and snippets.

View bruno-'s full-sized avatar
♦️
Async Ruby enthusiast

Bruno Sutic bruno-

♦️
Async Ruby enthusiast
View GitHub Profile
@yossorion
yossorion / what-i-wish-id-known-about-equity-before-joining-a-unicorn.md
Last active April 7, 2024 22:55
What I Wish I'd Known About Equity Before Joining A Unicorn

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@janko
janko / keyword_arguments.rb
Last active July 24, 2018 08:34
Ruby keyword arguments advantages and use cases
####
# 1. Simple assertion of required arguments
####
# - You can forget #fetch
# - You get a better error, and always on the line where method is defined
def search(options = {})
query = options.fetch(:query)
end
search() # => KeyError: key not found :query
@zmajstor
zmajstor / smart_card_adapter.rb
Created August 23, 2014 12:21
SmartCard adapter using smartcard gem with demo
# http://www.rdoc.info/github/costan/smartcard/master/Smartcard
require 'smartcard'
class SmartCardAdapter
# scope of the smart-card connection; valid values are :system, :user, and :terminal
# (see the SCARD_SCOPE_ constants in the PC/SC API)
def connect(scope = :system)
@context = Smartcard::PCSC::Context.new(scope)
end
@janko
janko / application.rb
Created June 7, 2014 16:57
Custom error pages in Rails
module MyApp
class Application < Rails::Application
# ...
config.exceptions_app = self.routes
config.action_dispatch.rescue_responses.merge!(
"RDS::ResourceNotFound" => :not_found,
)
# ...
end
@subfuzion
subfuzion / redis-autostart-osx.md
Last active April 26, 2024 21:40
redis auto start OS X

Install with Homebrew

brew install redis

Set up launchctl to auto start redis

$ ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents

/usr/local/opt/redis/ is a symlink to /usr/local/Cellar/redis/x.y.z (e.g., 2.8.7)

@zmajstor
zmajstor / _form.html.haml
Last active December 23, 2015 05:38
Rails nested form (Add/Remove nested resource without Controller for nested resource) inspired by http://davidlesches.com/blog/rails-nested-forms-using-jquery-and-simpleform and http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html * to destroy the associated model: add the _destroy key to the attributes hash, with a…
= simple_form_for @portfolio do |f|
= f.input :title, label: 'Portfolio Title'
= f.simple_fields_for :assets do |assets_form|
.duplicatable_nested_form
= assets_form.association :stock
= assets_form.input :amount, :input_html => { min: 0 }
= link_to 'Remove', '', :class => 'destroy_duplicate_nested_form'
= assets_form.input :id, as: :hidden
@dergachev
dergachev / backup-services.md
Last active October 12, 2023 06:14
Results of my backup services research

backup services research

I googled around, especially with site:news.ycombinator.com for backup recommendations. Here are notes on the top hits.

tarsnap

http://www.tarsnap.com/

  • by prolific HN member; focus on encryption and deduplication
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@josephwecker
josephwecker / new_bashrc.sh
Created August 11, 2012 04:36
Replace .bashrc, .bash_profile, .profile, etc. with something much more clean, consistent, and meaningful. Now a repo: https://github.com/josephwecker/bashrc_dispatch
#!/bin/bash
# License: Public Domain.
# Author: Joseph Wecker, 2012
#
# -- DEPRICATED --
# This gist is slow and is missing .bashrc_once
# Use the one in the repo instead! https://github.com/josephwecker/bashrc_dispatch
# (Thanks gioele)
#
# Are you tired of trying to remember what .bashrc does vs .bash_profile vs .profile?
@jboner
jboner / latency.txt
Last active May 21, 2024 07:18
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD