Skip to content

Instantly share code, notes, and snippets.

View abarrak's full-sized avatar

Abdullah Barrak abarrak

View GitHub Profile

Keybase proof

I hereby claim:

  • I am abarrak on github.
  • I am abarrak (https://keybase.io/abarrak) on keybase.
  • I have a public key ASBtnTV27fy-xMPVgidTEnyGB5ZqemRmk2LIVyebNIk7DQo

To claim this, I am signing this object:

@abarrak
abarrak / imagemagick-on-aws.md
Last active August 13, 2016 01:07
imagemagick on AWS

Installing ImageMagick on AWS EC2

yum install ImageMagick ImageMagick-devel
@abarrak
abarrak / add_flash_types_snippet.md
Last active August 13, 2016 16:14
Register flash types in Rails

application_controller.rb

class ApplicationController
  add_flash_types :primary, :success, :warning, :danger, :info
end

layout.html.erb

@abarrak
abarrak / nginx_file_upload_size.md
Created August 14, 2016 20:02
Configure NGINX File Upload Size on AWS EB
@abarrak
abarrak / responsive-table-styling.md
Last active August 16, 2016 22:48
Contained Table Scrolling

One strategy to make tables look nice on smaller devices is to contain them in an element with the follwoing style:

.table-container {
  width: 100%;
  overflow-x: auto;
}

In my_page.html:

@abarrak
abarrak / locks_rails.md
Last active August 17, 2016 20:39
DB Locking in Rails

Two approaches for database locking supported natively in Rails

[1] Optimistic Locking.

Deals with conflicts when they occur by implementing a locking table attribute. It happens in application logic and does not involve database specific mechanism.

Add locking cloumn.

Class AddLockVersionToTimesheets < ActiveRecord::Migration
@abarrak
abarrak / dummy_files.md
Last active August 18, 2016 17:23
Generate Dummy Large Files

You can generate large files using the bash dd command as follows:

  dd of=large.png bs=1024 count=0 seek=$[1024*10]

This will generate 10 MB.

Notice that it's not an actual png image despite the .png extenstion.

@abarrak
abarrak / rtl_from_wikipedia.md
Last active September 29, 2016 23:38
Scripting Wikipedia to get RTL languages list

This shows how to obtain a list of the known languages that are written from right to lift.

Scripting is done on ISO 15924 Page on Wikipedia

Get Data Container:

var t = document.querySelector('table.wikitable');
var tb = t.getElementsByTagName('tbody');
var ch = tb[0].children;
@abarrak
abarrak / locale_dates_jekyll.rb
Created October 6, 2016 21:13
A simple jekyll pluging for simple locale dates
##
# A simple jekyll pluging to distinguish date for :ar and :en languages
# inside the post page.
#
# Usage:
# {% render_date %}
#
# Author: Abdullah Barrak (abarrak)
# License: Unlicensed.
##
@abarrak
abarrak / jekyll_ar_date.rb
Created October 6, 2016 22:20
arabic date filter for jekyll
##
# A simple jekyll filter for :ar language dates.
#
# Usage:
# {% post.date | arabic_date %}
#
# Author: Abdullah Barrak (abarrak)
# License: Unlicensed.
##
require 'date'