Skip to content

Instantly share code, notes, and snippets.

@jrunning
jrunning / base58.rb
Last active November 17, 2020 03:55
UUID to Base 58 in Ruby
# base58_to_int and int_to_base58 loosely based on base58 gem by Douglas F. Shearer
# https://github.com/dougal/base58
ALPHABET = "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ".chars
BASE = ALPHABET.size
def base58_to_int(base58_val)
base58_val.chars
.reverse_each.with_index
.reduce(0) do |int_val, (char, index)|
@swrobel
swrobel / 1-OpsWorksPapertrail.md
Last active August 5, 2021 20:41
Send OpsWorks log files to Papertrail using the remote_syslog gem
  1. Add remote_syslog to your Gemfile
  2. Add papertrail.rake to lib/tasks
  3. Add remote_syslog.yml to config/
  4. Add before_restart.rb to deploy/
  5. Set the PAPERTRAIL_PORT ENV var to the one provided by Papertrail for your system

Inspiration from Scott W. Bradley

@mrdanadams
mrdanadams / .buildpacks
Created June 22, 2013 01:34
Adding Geos and Proj4 support to Heroku using buildpacks
https://github.com/peterkeen/heroku-buildpack-vendorbinaries.git
https://github.com/aaronrenner/heroku-buildpack-rgeo-prep.git
https://github.com/kr/heroku-buildpack-inline.git
https://github.com/heroku/heroku-buildpack-ruby.git
@joshdholtz
joshdholtz / SomeFragment.java
Last active December 22, 2022 09:41
Android Google Maps V2 - MapView in XML
public class SomeFragment extends Fragment {
MapView mapView;
GoogleMap map;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.some_layout, container, false);
@mattconnolly
mattconnolly / gist:4158961
Created November 28, 2012 04:04
RSpec basic authentication helper module for request and controller specs
module AuthHelper
def http_login
user = 'username'
pw = 'password'
request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(user,pw)
end
end
module AuthRequestHelper
#
@jboner
jboner / latency.txt
Last active April 26, 2024 03:40
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