Skip to content

Instantly share code, notes, and snippets.

Building @ejaro, We are hiring!

Omar Bahareth obahareth

Building @ejaro, We are hiring!
View GitHub Profile
obahareth / Gemfile
Created Aug 28, 2022 — forked from czj/Gemfile
Outputting Rails app logs to via logstash
View Gemfile
gem "lograge"
gem "logstash-event"
gem "logstash-logger"
obahareth / main.yaml
Created Aug 24, 2022 — forked from ArturT/main.yaml
GitHub Actions - how to run parallel tests in RSpec for Ruby on Rails project. See article how to run RSpec on GitHub Actions for Ruby on Rails app using parallel jobs or sign up at…
View main.yaml
# .github/workflows/main.yaml
name: Main
on: [push]
runs-on: ubuntu-latest
# If you need DB like PostgreSQL, Redis then define service below.
obahareth /
Created Jun 11, 2017
GitHub GraphQL API Starred Repositories With Pagination

GitHub GraphQL API Starred Repositories Examples With Pagination

You can play with the GraphQL API live here. It's pretty nice and has autocompletion based on the GraphQL schema.

The first example gets your first 3 starred repos, the cursor values can be used for pagination.

Here's an example response from the first query:

obahareth /
Created Aug 15, 2022 — forked from jackblk/
Tutorial on how to setup a squid proxy with authentication.


This tutorial is for Ubuntu & Squid3. Use AWS, Google cloud, Digital Ocean or any services with Ubuntu to follow this tutorial.

Install squid & update

sudo apt-get update
sudo apt-get install squid3
sudo apt-get install apache2-utils
obahareth /
Created Aug 15, 2022 — forked from drmalex07/
Wrap a docker container in a systemd service. #docker #systemd.service #systemd #cgroups


Suppose we want to wrap a container running a Redis instance as a service.

Override unit file for docker daemon

We must override the service unit file that ships with docker (under /lib/systemd/system) in order to pass some cgroup-related options to the docker daemon. So, following the usual method to override parts of a unit file, we create the file /etc/systemd/system/docker.service.d/10-service.conf with contents:

obahareth / faraday_ssl_example.rb
Created Jul 19, 2022
An example on how to configure Faraday for SSL using client certificates, a private key, and a certificate authority file. This can help if you're getting errors like: TypeError (wrong argument type String (expected OpenSSL/X509))
View faraday_ssl_example.rb
# Taken from
connection = 'https://host:443/ping', ssl: {
ca_file: 'config/credentials/ROOT_CA.cer',
obahareth /
Last active May 25, 2022
Speed up launch of Terminal or iTerm 2
# Apparently Apple keeps system logs in this folder as .asl files. They're
# loaded into terminal sessions and can slow things down when there's a lot of
# them.
# Taken from:
sudo rm /private/var/log/asl/*.asl
obahareth /
Last active Jan 28, 2022
A script to setup OS X with the apps and formulas I use.
# Install Homebrew
ruby -e "$(curl -fsSL"
brew doctor
# Tap sources we need
brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
brew tap caskroom/versions
obahareth /
Last active Nov 30, 2021
Extract Ruby on Rails enum values into a dictionary (represented by markdown tables).


Sometimes you have members from your data team who are looking at the database and have no idea what the enum integer values mean. This snippet of code helps to extract the readable names for those integers into markdown tables to help out your data team.

There are alternative approaches by using string enums via gems, or database enums, but this was made for an environment where those weren't an option (legacy enums, and no database enums available).

You could also put this into a Rake task and publish it into a wiki.


View redis_hash_store.rb
module RedisHashStore
extend self
class Entry
attr_reader :value
def initialize(value, expires_in:)
@value = value
@created_at =
@expires_in = expires_in