Skip to content

Instantly share code, notes, and snippets.

View obahareth's full-sized avatar
🧉
In the Zone

Omar Bahareth obahareth

🧉
In the Zone
View GitHub Profile
@obahareth
obahareth / speed_up_terminal_launch.sh
Last active March 17, 2024 00:30
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:
# https://ariejan.net/2011/11/08/fixing-a-slow-starting-terminal-or-iterm2-on-mac-os-x/
sudo rm /private/var/log/asl/*.asl
$("a#bookmark").click(function(e)
{
e.preventDefault(); // this will prevent the anchor tag from going the user off to the link
var bookmarkUrl = this.href;
var bookmarkTitle = this.title;
if ($.browser.mozilla) // For Mozilla Firefox Bookmark
{
window.sidebar.addPanel(bookmarkTitle, bookmarkUrl,"");
@obahareth
obahareth / README.md
Created June 11, 2017 10:29
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
obahareth / hyperpayPayments.js
Created December 19, 2019 16:39 — forked from saikatharryc/hyperpayPayments.js
Hyperpay integration
const saveCardToHyperPay = data => {
var path = "/v1/registrations";
let cardBrand = Payment.fns.cardType(data.number);
if (cardBrand == "visa" || cardBrand == "master" || cardBrand == "mada") {
var cardData = querystring.stringify({
"authentication.userId": config.HYPERPAY.UserId,
"authentication.password": config.HYPERPAY.Password,
"authentication.entityId": config.HYPERPAY.EntityId,
paymentBrand: cardBrand.toUpperCase(),
"card.number": data.number || "",
@obahareth
obahareth / setup_os_x.sh
Last active October 22, 2023 12:57
A script to setup OS X with the apps and formulas I use.
# Install Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor
# Tap sources we need
brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
brew tap caskroom/versions
@obahareth
obahareth / #ChatGPT Streaming.md
Created May 13, 2023 22:43 — forked from alexrudall/#ChatGPT Streaming.md
ChatGPT streaming with ruby-openai, Rails 7, Hotwire, Turbostream, Sidekiq and Tailwind!

How to add ChatGPT streaming to your Ruby on Rails 7 app!

This guide will walk you through adding a ChatGPT-like messaging stream to your Ruby on Rails 7 app using ruby-openai, Rails 7, Hotwire, Turbostream, Sidekiq and Tailwind. All code included below!

Alt Text

First, add the ruby-openai gem! Needs to be at least version 4. Add Sidekiq too.

@obahareth
obahareth / Gemfile
Created August 28, 2022 09:06 — forked from czj/Gemfile
Outputting Rails app logs to Logz.io via logstash
gem "lograge"
gem "logstash-event"
gem "logstash-logger"
@obahareth
obahareth / main.yaml
Created August 24, 2022 13:00 — 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 https://docs.knapsackpro.com/2019/how-to-run-rspec-on-github-actions-for-ruby-on-rails-app-using-parallel-jobs or sign up at https://knapsackpro.com/?utm_source=github&utm_medium=…
# .github/workflows/main.yaml
name: Main
on: [push]
jobs:
test:
runs-on: ubuntu-latest
# If you need DB like PostgreSQL, Redis then define service below.
@obahareth
obahareth / squid_proxy_tutorial.md
Created August 15, 2022 10:37 — forked from jackblk/squid_proxy_tutorial.md
Tutorial on how to setup a squid proxy with authentication.

Note

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
obahareth / README-container-as-systemd-service.md
Created August 15, 2022 06:31 — forked from drmalex07/README-container-as-systemd-service.md
Wrap a docker container in a systemd service. #docker #systemd.service #systemd #cgroups

README

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: