Skip to content

Instantly share code, notes, and snippets.

View benlovell's full-sized avatar
🕺
Dancing

Ben Lovell benlovell

🕺
Dancing
  • Ben Lovell Ltd
  • London, United Kingdom
View GitHub Profile
@vilusa
vilusa / environment.rb
Created September 3, 2021 18:56
Rails Redis Cache Configuration
# For TLS Connections
config.cache_store = :redis_cache_store, {
url: ENV.fetch('CACHE_STORE_REDIS_TLS_URL') { ENV['CACHE_STORE_REDIS_URL'] || 'redis://127.0.0.1:6379' },
db: 0,
connect_timeout: 20, # Defaults to 20 seconds
read_timeout: 1, # Defaults to 1 second
write_timeout: 1, # Defaults to 1 second
reconnect_delay: 1.5 ,
reconnect_delay_max: 10.0,
reconnect_attempts: 10, # Defaults to 0
@tam7t
tam7t / gist:86eb4793e8ecf3f55037
Last active April 14, 2022 10:57
Securing Ruby's OpenSSL

Are your Ruby HTTPS API calls secure?

Let's check:

2.0.0-p481 :001 > OpenSSL::SSL::SSLContext::DEFAULT_PARAMS
 => {:ssl_version=>"SSLv23", :verify_mode=>1, :ciphers=>"ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW", :options=>-2147482625}
2.0.0-p481 :002 > rating = JSON.parse(RestClient::Resource.new("https://www.howsmyssl.com/a/check" ).get)['rating']
 => "Bad"
@wjessop
wjessop / gist:14c51363acb189b17963
Last active August 29, 2015 14:03
90's house and dance
Please make suggestions to @will_j on twitter
- Additions
- Removals
- Ordering
- etc.
Rules:
- 90's Dance or house in the style of what's already on the list
@benlovell
benlovell / benlovell.md
Last active August 29, 2015 13:57 — forked from matiaskorhonen/speaker.md
Frozen Rails 2014 proposal
@darkhelmet
darkhelmet / balance.go
Created June 16, 2013 05:05
Simple TCP load balancer in Go.
package main
import (
"flag"
"io"
"log"
"net"
"strings"
)
require 'spec_helper'
require 'redis'
describe "a fucked situation" do
class SimpleQueue
QUEUE_NAME = 'simple_queue'
@straydogstudio
straydogstudio / circle_path
Last active September 11, 2018 21:18
Convert latitude/longitude pair with radius in meters to 16 sided polygon useful in GIS. Useful for converting a Google maps drawing manager circle into a polygon for storage in a GIS system. Implemented as a class method.
def self.circle_path(center, radius, complete_path = false)
# For increased accuracy, if your data is in a localized area, add the elevation in meters to r_e below:
r_e = 6378137.0
@@d2r ||= Math::PI/180
@@multipliers ||= begin
segments = 16
dRad = 2*Math::PI/segments
(segments + (complete_path ? 1 : 0)).times.map do |i|
rads = dRad*i
y = Math.sin(rads)
@bf4
bf4 / ruby_learning.md
Last active July 17, 2021 08:06
Some Ruby Learning Resources
@mislav
mislav / procs-vs-lambda.md
Last active March 26, 2021 18:34
Jim Weirich on the differences between procs and lambdas in Ruby

Jim Weirich:

This is how I explain it… Ruby has Procs and Lambdas. Procs are created with Proc.new { }, lambdas are created with lambda {} and ->() {}.

In Ruby 1.8, proc {} creates lambda, and Ruby 1.9 it creates procs (don't ask).

Lambdas use method semantics when handling parameters, procs use assignment semantics when handling parameters.

This means lambdas, like methods, will raise an ArgumentError when called with fewer arguments than they were defined with. Procs will simply assign nil to variables for arguments that were not passed in.