Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
"You have a heart and I love you for being ashamed to show it". ― Nietzsche

Junaid Atari blacksmoke26

🏠
"You have a heart and I love you for being ashamed to show it". ― Nietzsche
View GitHub Profile
@blacksmoke26
blacksmoke26 / columns-partition.php
Created Mar 29, 2016
Divide an array into a desired number of split lists
View columns-partition.php
<?php
/**
* Divide an array into a desired number of split lists
* @author Azspot
* @link http://www.php.net/manual/en/function.array-chunk.php#75022
* @param array $list The Array
* @param integer $size Partition Size
* @return array Output array
*/
@blacksmoke26
blacksmoke26 / spl-autoload.php
Last active Mar 29, 2016
Autoload Register PHP Files
View spl-autoload.php
<?php
/**
* Autoload Register the Directory's PHP Classes
*
* @author Junaid Atari <mj.atari@gmail.com>
*
* @param string Path to direcetory
* @param string Files extension
* @return bool TRUE on registered | FALSE
@blacksmoke26
blacksmoke26 / timezone-list.php
Created Mar 29, 2016
List of timezones (PHP)
View timezone-list.php
<?php
$listOfTimeZones = [
'Africa'=> [
'Africa/Algiers'=>'Algeria (+01:00)',
'Africa/Gaborone'=>'Botswana (+02:00)',
'Africa/Douala'=>'Cameroon (+01:00)',
'Africa/Bangui'=>'Central African Republic (+01:00)',
'Africa/Ndjamena'=>'Chad (+01:00)',
'Africa/Kinshasa'=>'Democratic Republic of the Congo (+01:00)',
@blacksmoke26
blacksmoke26 / raw-url-encode.php
Last active Jun 15, 2017
Multibyte URL-encode according to UTF-8
View raw-url-encode.php
<?php
function rawUrlEncode ( $str )
{
$encoded = '';
$length = mb_strlen ($str);
for ( $i = 0; $i < $length; $i++ )
{
$encoded .= '%'.wordwrap ( bin2hex( mb_substr($str,$i,1) ), 2, '%', true );
View yii2-random-model-activerecord.php
<?php
// Todo: Place this snippet into your Model class.
/**
* Get random model(s) from table
* @see \yii\db\ActiveQuey
* @param array|string|null (optional) $columns Columns to be fetched (default: all columns)
* @param array $options Additional options pass to function<br>
* <code>
@blacksmoke26
blacksmoke26 / use-breakpoint.js
Last active Jun 15, 2021
React-bootstrap 'use-breakpoint' hook (flow)
View use-breakpoint.js
// @flow
/**
* @author Junaid Atari
* @link https://github.com/blacksmoke26
* @since 2020-09-20
*/
// npm i -S debounce
@blacksmoke26
blacksmoke26 / use-localforge.js
Created Sep 20, 2020
React hook for Localforage (flow)
View use-localforge.js
// @flow
// LocalForage: https://github.com/localForage/localForage
// npm i -S localForage
/**
* @author Junaid Atari <mj.atari@gmail.com>
* @link https://github.com/blacksmoke26
* @since 2020-08-05
*/