Skip to content

Instantly share code, notes, and snippets.

View blacksmoke26's full-sized 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 / use-localforge.js
Created September 20, 2020 12:54
React hook for Localforage (flow)
// @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
*/
@blacksmoke26
blacksmoke26 / use-breakpoint.js
Last active April 14, 2023 22:28
React-bootstrap 'use-breakpoint' hook (flow)
// @flow
/**
* @author Junaid Atari
* @link https://github.com/blacksmoke26
* @since 2020-09-20
*/
// npm i -S debounce
@blacksmoke26
blacksmoke26 / yii2-random-model-activerecord.php
Created August 15, 2016 20:37
Yii2 Random Model (ActiveRecord)
<?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 / timezone-list.php
Created March 29, 2016 11:10
List of timezones (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 / columns-partition.php
Created March 29, 2016 11:03
Divide an array into a desired number of split lists
<?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 / raw-url-encode.php
Last active June 15, 2017 13:17
Multibyte URL-encode according to UTF-8
<?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 );
@blacksmoke26
blacksmoke26 / spl-autoload.php
Last active March 29, 2016 11:04
Autoload Register PHP Files
<?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