Skip to content

Instantly share code, notes, and snippets.

View khelll's full-sized avatar

Khaled alHabache khelll

View GitHub Profile
words = %w[الفاتحة البقرة آل\ عمران النساء المائدة الأنعام الأعراف الأنفال التوبة يونس هود يوسف الرعد إبراهيم الحجر النحل الإسراء الكهف مريم طه الأنبياء الحج المؤمنون النور الفرقان الشعراء النمل القصص العنكبوت الروم لقمان السجدة الأحزاب سبأ فاطر يس الصافات ص الزمر غافر فصلت الشورى الزخرف الدخان الجاثية الأحقاف محمد الفتح
الحجرات ق الذاريات الطور النجم القمر الرحمن الواقعة الحديد المجادلة الحشر الممتحنة الصف الجمعة المنافقون التغابن الطلاق التحريم الملك القلم الحاقة المعارج نوح الجن المزمل المدثر القيامة الإنسان المرسلات النبأ النازعات عبس التكوير الانفطار المطففين الانشقاق البروج الطارق الأعلى الغاشية الفجر البلد الشمس الليل الضحى الشرح التين العلق القدر
البينة الزلزلة العاديات القارعة التكاثر العصر الهمزة الفيل قريش الماعون الكوثر الكافرون النصر المسد الإخلاص الفلق الناس]
accepted_letters = %w[ن ل ج ش ر د م ح ع ق ا أ آ إ \ ]
words.select {|word| word.each_char.all? { |char| accepted_letters.include?(char) } }
# => ["آل عمران", "الأنعام", "الرعد", "الحجر", "النحل", "الحج", "النمل", "لقمان", "محمد", "ق", "
@khelll
khelll / flatten.rb
Last active September 10, 2019 13:25
Ruby Implementation for `Array#flatten`, that flattens a map.
# rspec flatten.rb
def flatten(array)
return array if array == []
head, *tail = array
current = head.class == Array ? flatten(head) : [head]
current + flatten(tail)
end
@khelll
khelll / puma_notes.md
Last active June 19, 2018 17:30
Puma notes

Some notes about Puma that I collected while moving Shipit to work with Puma.

Shipit notes

  • Shipit is using a gem called pubsubstub to handle sockets. That gem will force the app server connection to be alive as long as the socket is open.
  • On the other side, Rails 5 introduced ActionCable that acts as a seperate process that uses EventMachine to handle sockets, thus after initiating the socket connection, the app server gets out of the picture. Unfortunatly, Shipit doesn't use ActionCable.

Puma notes

  • Has no worker request timeout. There is a setting called worker_timeout, but that's not for request timeout. Suggested workaround is to set Rack timeout, or have Nginx infront of it.
class Kops < Formula
desc "Production Grade K8s Installation, Upgrades, and Management"
homepage "https://github.com/kubernetes/kops"
url "https://github.com/kubernetes/kops/archive/1.8.0.tar.gz"
sha256 "16d75793d138204c56c43c28e356102a11901919ae9c7ce2eea16843f340abe6"
head "https://github.com/kubernetes/kops.git"
bottle do
cellar :any_skip_relocation
rebuild 1
@khelll
khelll / install-ffmpeg-amazon-linux.sh
Last active March 3, 2016 14:40 — forked from gboudreau/install-ffmpeg-amazon-linux.sh
How to compile ffmpeg on Amazon Linux (EC2)
#!/bin/sh
# Based on instructions found here: http://wiki.razuna.com/display/ecp/FFMpeg+Installation+on+CentOS+and+RedHat#FFMpegInstallationonCentOSandRedHat-InstallX264
# usage \curl -sSL https://gist.githubusercontent.com/khelll/6eee332fcbc8667b326c/raw/4efeb70acad6e41fea129c472d6bf7f2236fa37d/install-ffmpeg-amazon-linux.sh | bash
if [ "`/usr/bin/whoami`" != "root" ]; then
echo "You need to execute this script as root."
exit 1
fi
rm -rf ~/ffmpeg_build ~/bin/{ffmpeg,ffprobe,ffserver,lame,vsyasm,x264,x265,yasm,ytasm}
#!/bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: nginx initscript
# Description: nginx
### END INIT INF
@khelll
khelll / nginx
Created January 10, 2015 05:12
A start / stop script for Nginx on Amazon Linux
#!/bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: nginx initscript
# Description: nginx
### END INIT INF
@khelll
khelll / install-redis.sh
Last active March 12, 2024 08:33
Installing Redis on Amazon Linux
#!/bin/bash
###############################################
# To use:
# chmod +x install-redis.sh
# ./install-redis.sh
###############################################
version=3.2.0
echo "*****************************************"
echo " 1. Prerequisites: Install updates, set time zones, install GCC and make"
@khelll
khelll / praytimes.py
Created January 14, 2014 21:51
Fix for the python code version 2 of the Pray Times algorithm http://praytimes.org/code/
#!/usr/bin/env python
# compatible with python 2.x and 3.x
import math
import re
'''
--------------------- Copyright Block ----------------------
praytimes.py: Prayer Times Calculator (ver 2.3)
# Default ruby is 1.9.3, but opening a new shell results in having 1.9.2 instead!
~|⇒ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.2.0]
~|⇒ rvm list default
Default Ruby (for new shells)
ruby-1.9.3-p125 [ x86_64 ]