Skip to content

Instantly share code, notes, and snippets.

@AmrMekkawy
AmrMekkawy / codeigniter-active-record.php
Created December 30, 2013 09:09
Codeigniter Active Record
### Selecting Data ###
######################
// Runs the selection query and returns the result. Can be used by itself to retrieve all records from a table:
$query = $this->db->get("table_name"); // Produces: SELECT * FROM table_name
$result = $query->result(); // result(): returns the query result as an array of objects, or an empty array on failure
$query = $this->db->get("table_name", $limit, $offset);
$query = $this->db->get("table_name", 10, 20); // Produces: SELECT * FROM table_name LIMIT 20, 10
@AmrMekkawy
AmrMekkawy / .gitignore
Last active August 29, 2015 14:03
A useful .gitignore template (more info: https://github.com/github/gitignore)
# Compiled source (source: http://goo.gl/hVcp7b) #
##################################################
*.com
*.class
*.dll
*.exe
*.o
*.so
@AmrMekkawy
AmrMekkawy / html-simple-template
Last active August 29, 2015 14:11
Simple HTML Template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Simple HTML Template</title>
</head>
<body>
<div>Content here..</div>
</body>
</html>
@AmrMekkawy
AmrMekkawy / make-slug
Last active August 29, 2015 14:13
How to make a slug or a friendly URL that contains Arabic characters?
/**
* make_slug
* @author @AmrMekkawy
*
* based on http://goo.gl/7WULfc & http://goo.gl/P6j345
* and modified by @AmrMekkawy to be used with Arabic language
*/
if (!function_exists("make_slug")) {
function make_slug($string = null, $separator = "-") {
if (is_null($string)) {
@AmrMekkawy
AmrMekkawy / bootstrap-template.html
Last active August 29, 2015 14:14
Bootstrap Template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<!-- Bootstrap core CSS -->
@AmrMekkawy
AmrMekkawy / currency-dropdown-list.html
Last active April 8, 2023 15:03
Currency HTML "select" element (dropdown list)
<select name="">
<option value="USD" selected="selected">United States Dollars</option>
<option value="EUR">Euro</option>
<option value="GBP">United Kingdom Pounds</option>
<option value="DZD">Algeria Dinars</option>
<option value="ARP">Argentina Pesos</option>
<option value="AUD">Australia Dollars</option>
<option value="ATS">Austria Schillings</option>
<option value="BSD">Bahamas Dollars</option>
<option value="BBD">Barbados Dollars</option>
@AmrMekkawy
AmrMekkawy / arabic-timezone-dropdown-list.html
Created March 7, 2015 04:16
Arabic timezone HTML "select" element (dropdown list)
<select name="">
<option value='UTC' selected='selected'>توقيت جرينيتش</option>
<optgroup label='آسيا'>
<option value='Asia/Hebron'>Hebron</option>
<option value='Asia/Kathmandu'>Kathmandu</option>
<option value='Asia/Khandyga'>Khandyga</option>
<option value='Asia/Novokuznetsk'>Novokuznetsk</option>
<option value='Asia/Ust-Nera'>Ust-Nera</option>
<option value='Asia/Ashgabat'>أشكبات</option>
<option value='Asia/Aqtau'>أكتو</option>
@AmrMekkawy
AmrMekkawy / brief-text
Created March 22, 2015 16:51
Get specific number of words from a string.
/**
* returns a specific number of words
*
* @param string $string the whole string
* @param integer $num_words number of words to return from the whole string
* @return string returned string
*/
if (!function_exists("brief_text")) {
function brief_text($string, $num_words = 50) {
$string = trim(preg_replace('/\s+/', ' ', $string));
@AmrMekkawy
AmrMekkawy / arabic-country-dropdown-list.html
Created May 17, 2015 10:24
Arabic countries HTML "select" element (dropdown list)
<!-- Country List in Arabic | source: https://github.com/umpirsky/country-list -- >
<select name="country">
<option value="AW">آروبا</option>
<option value="AZ">أذربيجان</option>
<option value="AM">أرمينيا</option>
<option value="ES">أسبانيا</option>
<option value="AU">أستراليا</option>
<option value="AF">أفغانستان</option>
<option value="AL">ألبانيا</option>
<option value="DE">ألمانيا</option>
@AmrMekkawy
AmrMekkawy / arabic-date-format.php
Last active August 29, 2016 01:02
A PHP function to format Arabic date to be user friendly and more readable (Twitter Like)
<?php
function arabic_date_format($timestamp)
{
$periods = array(
"second" => "ثانية",
"seconds" => "ثواني",
"minute" => "دقيقة",
"minutes" => "دقائق",
"hour" => "ساعة",