Skip to content

Instantly share code, notes, and snippets.

@eloypnd
eloypnd / dnsmasq_setup_osx.md
Last active June 16, 2024 04:23
wildcard DNS record on OS X in localhost development with dnsmasq

wildcard DNS in localhost development

$ brew install dnsmasq
   ...
$ cp /usr/local/opt/dnsmasq/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf
  • edit /usr/local/etc/dnsmasq.conf
address=/local/127.0.0.1
@matsadler
matsadler / ruby_preload
Last active October 3, 2018 08:33
Simple Ruby app preloader.
#!/usr/bin/env ruby
require "socket"
# This is a simple preloader for Ruby apps.
# Usage:
# Put this file somewhere in your PATH, named 'ruby_preloader' and make sure
# it's executable.
# Add whatever you need to load your app environment to a .preload.rb in the
# base directory of your project.
# Add #!/usr/bin/env ruby_preload as the first line of any script you want to
@fabrizioc1
fabrizioc1 / election_candidate.rb
Created July 10, 2013 05:48
Zookeeper leader election using Ruby
# http://zookeeper.apache.org/doc/r3.3.4/recipes.html#sc_leaderElection
require 'rubygems'
require 'bundler/setup'
require 'zookeeper'
require 'hashie'
class ElectionCandidate
ROOT_PATH = "/election"
NODE_PATH = "candidate_"
@mislav
mislav / OpenSSL fix.md
Last active June 8, 2023 07:48
Fix OpenSSL certificate errors on Ruby 2.0

The reason why you might get certificate errors in Ruby 2.0 when talking HTTPS is because there isn't a default certificate bundle that OpenSSL (which was used when building Ruby) trusts.

Update: this problem is solved in edge versions of rbenv and RVM.

$ ruby -rnet/https -e "Net::HTTP.get URI('https://github.com')"
net/http.rb:917:in `connect': SSL_connect returned=1 errno=0 state=SSLv3
  read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)

You can work around the issue by installing a certificate bundle that you trust. I trust Mozilla and curl.

@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active September 19, 2024 05:47
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@them0nk
them0nk / rspec_rails_cheetsheet.rb
Created March 23, 2012 03:39
Rspec Rails cheatsheet (include capybara matchers)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
@yumike
yumike / blocks.py
Created December 8, 2011 06:45
Thoughts about RSpec for Python
# codec: blocks
describe('articles.views.ArticleView'):
context('when user has permissions'):
it('should add new article'):
# some code
it('should delete existing article'):