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 / nord.css
Created November 12, 2019 17:50
Nord highlight.js CSS theme
/*
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
title Nord highlight.js +
project nord-highlightjs +
version 0.1.0 +
repository https://github.com/arcticicestudio/nord-highlightjs +
author Arctic Ice Studio +
email development@arcticicestudio.com +
copyright Copyright (C) 2017 +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@obahareth
obahareth / markdown-here.css
Created November 12, 2019 17:51
Markdown Here Primary CSS Styling (I only changed it to use the PragmataPro Font)
/*
* NOTE:
* - The use of browser-specific styles (-moz-, -webkit-) should be avoided.
* If used, they may not render correctly for people reading the email in
* a different browser than the one from which the email was sent.
* - The use of state-dependent styles (like a:hover) don't work because they
* don't match at the time the styles are made explicit. (In email, styles
* must be explicitly applied to all elements -- stylesheets get stripped.)
*/
@obahareth
obahareth / night.css
Last active November 12, 2019 17:53
Typora Night Theme with Pragmata Pro and Pragmata Pro Mono
@import "night/mermaid.dark.css";
@import "night/codeblock.dark.css";
@import "night/sourcemode.dark.css";
:root {
--bg-color: #363B40;
--side-bar-bg-color: #2E3033;
--text-color: #b8bfc6;
--select-text-bg-color:#4a89dc;
@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 / install_notion_rtl.go
Created January 7, 2020 19:39
A Go script to install Notion RTL (on macOS only for now) for the desktop app. Sadly Notion recreates the HTML file this script modifies on whenever the app is relaunched, so the changes need to keep being reapplied.
package main
import (
"errors"
"fmt"
"io/ioutil"
"os"
"os/user"
"path/filepath"
"runtime"
@obahareth
obahareth / Gemfile
Created July 5, 2020 10:58 — forked from dhh/Gemfile
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
module RedisHashStore
extend self
class Entry
attr_reader :value
def initialize(value, expires_in:)
@value = value
@created_at = Time.now.to_f
@expires_in = expires_in
@obahareth
obahareth / extract_enum_mappings.md
Last active November 30, 2021 11:59
Extract Ruby on Rails enum values into a dictionary (represented by markdown tables).

README

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.

Usage

@obahareth
obahareth / faraday_ssl_example.rb
Created July 19, 2022 09:24
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))
# Taken from https://gist.github.com/mdeiters/975231?permalink_comment_id=3015720#gistcomment-3015720
def self.ping
connection = Faraday::Connection.new 'https://host:443/ping', ssl: {
ca_file: 'config/credentials/ROOT_CA.cer',
client_key: OpenSSL::PKey::RSA.new(File.read('config/credentials/client.key')),
client_cert: OpenSSL::X509::Certificate.new(File.read('config/credentials/agent.cer'))
}
connection.get.body
end
@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: