Skip to content

Instantly share code, notes, and snippets.

@jrunning
jrunning / base58.rb
Last active Nov 17, 2020
UUID to Base 58 in Ruby
View base58.rb
# 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 Aug 29, 2015
Send OpsWorks log files to Papertrail using the remote_syslog gem
View 1-OpsWorksPapertrail.md
  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 Jun 22, 2013
Adding Geos and Proj4 support to Heroku using buildpacks
View .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 Dec 6, 2020
Android Google Maps V2 - MapView in XML
View SomeFragment.java
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 Nov 28, 2012
RSpec basic authentication helper module for request and controller specs
View gist:4158961
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 May 15, 2021
Latency Numbers Every Programmer Should Know
View latency.txt
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