Skip to content

Instantly share code, notes, and snippets.

View wesamly's full-sized avatar

Wesam Alalem wesamly

View GitHub Profile
@wesamly
wesamly / readme.md
Last active February 13, 2022 14:21
Homebrew php version per vhost
@wesamly
wesamly / code.php
Last active June 28, 2022 06:32
Lumen generate app key code
<?php
// Use command line in generate.sh
// Generation code line by line
include __DIR__ . "/vendor/autoload.php";
include __DIR__ . "/bootstrap/app.php";
// Check https://github.com/laravel/framework/blob/8.x/src/Illuminate/Foundation/Console/KeyGenerateCommand.php
$key = "base64:" . base64_encode(Illuminate\Encryption\Encrypter::generateKey(config("app.cipher")));
@wesamly
wesamly / .env
Last active July 25, 2023 10:17
Laravel Array Environment Variable
MY_KEY=key1|value1,key2|value2
@wesamly
wesamly / reset_same_top_elms_height.js
Created March 17, 2020 11:06
Make adjacent divs same height with Javascript
function resetSameTopElmsHeight(container, childSelector) {
var cols, ph, pt, tempElms, i, ch, co, j;
cols = container.find(childSelector);
ph = -1;
pt = -1;
tempElms = [];
for (i in cols) {
ch = $(cols[i]).outerHeight();
@wesamly
wesamly / pagination_limit.php
Created August 6, 2017 08:27
Limit Long Pagination List
<?php
$pages = 22;
$current = 1;
if (isset($_GET['p'])) {
$current = filter_var($_GET['p'], FILTER_SANITIZE_NUMBER_INT);
}
$maxShow = 10;
$start = 1;
@wesamly
wesamly / .bashrc
Created February 28, 2017 10:52
composer on cpanel shared hosting with ssh access
#Add at the top after # .bashrc
[ -z "$PS1" ] && return
#Add at the bottom
alias mycomposer="/usr/bin/php-cli -d suhosin.executor.include.whitelist=phar /home/userdir/bin/composer.phar"
@wesamly
wesamly / nid_regex.php
Last active February 23, 2021 13:53
Libyan National Number Regex
<?php
/**
* Total Length: 12 digits
* [1][2002][0012345]
* | | |
* | | -> Random: 7 digits
* | -> Birth Year: 4 digits
* -> Gender 1 male / 2 female: 1 digit
*/
@wesamly
wesamly / admin_tabs.php
Last active October 13, 2016 20:53
WordPress Admin Page with simple Javascript tabs
<div class="wrap">
<h1>My Plugin Admin Page</h1>
<h2 class="nav-tab-wrapper">
<a class="nav-tab nav-tab-active" href="#tab1">Tab 1</a>
<a class="nav-tab" href="#tab2">Tab 2</a>
</h2>
<div id="tab1">
<h3>Tab 1 Content</h3>
@wesamly
wesamly / mycron.php
Last active August 29, 2015 14:21
Execute code within given time range
<?php
$y = date('Y');
$m = date('m');
$d = date('d');
$restrictStart = mktime(0, 30, 0, $m, $d, $y);
$restrictEnd = mktime(1, 30, 0, $m, $d, $y);
$time = time();
if ($time < $restrictStart || $time > $restrictEnd) {
die('not yet!');
@wesamly
wesamly / pre-commit
Created April 14, 2015 10:17
Git mysql schema on project commits
#!/bin/sh
#path to script: /path_to_git_repo/.git/hooks/pre-commit
#DB Details
DBHOST=localhost
DBUSER=myuser
DBPASS=mypass
DBNAME=test_dbname