Skip to content

Instantly share code, notes, and snippets.

@rbarazi
rbarazi / kafka_setup_mac.md
Last active March 3, 2023 14:45 — forked from siliconsenthil/kafka_setup_mac.md
Install Kafka in Mac

Installation

Install kafka

brew install kafka

The above will install kafka and it's dependency zookeeper

You can start in the background by

@rbarazi
rbarazi / postgres_queries_and_commands.sql
Created June 12, 2020 14:44 — forked from rgreenjr/postgres_queries_and_commands.sql
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%'
function getHeight(elementStyle) {
return parseInt(elementStyle.height) + parseInt(elementStyle["margin-top"]) + parseInt(elementStyle["margin-bottom"]);
}
function trimText(element, elementHeight, maxHeight) {
var tmpText = element.innerHTML;
var words = tmpText.split(" ");
var min = 0;
var max = words.length;
@rbarazi
rbarazi / nginx-passenger-ssl.conf
Created November 10, 2016 22:23 — forked from rkjha/nginx-passenger-ssl.conf
Nginx/Passenger config when using SSL with a Ruby/Rails Application.
# for redirecting hhtp traffic to https version of the site
server {
listen 80;
server_name example.com;
return 301 https://$server_name$request_uri;
}
# for redirecting to non-www version of the site
server {
listen 80;

Keybase proof

I hereby claim:

  • I am rbarazi on github.
  • I am rida (https://keybase.io/rida) on keybase.
  • I have a public key whose fingerprint is 7226 ECAA 9246 A00B 169E 4E9B B460 6F17 E71F AD15

To claim this, I am signing this object:

@rbarazi
rbarazi / how-to-set-up-stress-free-ssl-on-os-x.md
Created January 5, 2016 17:10 — forked from jed/how-to-set-up-stress-free-ssl-on-os-x.md
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

@rbarazi
rbarazi / routes.rb
Created March 2, 2010 20:54
[Beginning Rails 3] Listing 2-4. The config/routes.rb file
Hello::Application.routes.draw do |map|
match ':controller(/:action(/:id(.:format)))'
end
@rbarazi
rbarazi / resume_svn_to_git_conversion.sh
Created June 23, 2016 02:47
Continue Converting SVN to GIT repo
head -4 REPO_NAME.dump > REPO_NAME-partial.dump && tail -n +$(grep -n "Revision-number: $(($(svn info file:///REPO_PATH/REPO_NAME | grep Revision | awk -F": " '{print $2}') + 1))" REPO_NAME.dump | awk -F":" '{print $1}') REPO_NAME.dump >> REPO_NAME-partial.dump && svnadmin load /REPO_PATH/REPO_NAME < REPO_NAME-partial.dump
@rbarazi
rbarazi / gist:337f470bf957cd16daf9b6b33bebef17
Created June 15, 2016 14:26 — forked from gkop/gist:1371962
Capture javascript errors in Cucumber+Capybara+Webdriver tests
# in features/support/env.rb
require 'selenium/webdriver'
# we need a firefox extension to start intercepting javascript errors before the page
# scripts load
Capybara.register_driver :selenium do |app|
profile = Selenium::WebDriver::Firefox::Profile.new
# see https://github.com/mguillem/JSErrorCollector
profile.add_extension File.join(Rails.root, "features/support/extensions/JSErrorCollector.xpi")
Capybara::Selenium::Driver.new app, :profile => profile
@rbarazi
rbarazi / ssl_hack.rb
Created June 15, 2016 13:42 — forked from Papierkorb/ssl_hack.rb
SSL with Capybara and Selenium
# Hack for Capybara to use SSL connections using selenium.
#
### Usage:
# Require this from rails_helper.rb
#
### Steps to generate a SSL certificate on a Linux box:
# 0. Starting from 'Rails.root'
# 1. Generate private key. Type in some password.
# $ openssl genrsa -des3 -out private.key 4096
# 2. Generate certificate sign request