Skip to content

Instantly share code, notes, and snippets.

View dhassanali's full-sized avatar
Working

Hassan Ali dhassanali

Working
View GitHub Profile
@dhassanali
dhassanali / ImageTools.es6
Created January 25, 2019 17:34 — forked from dcollien/ImageTools.es6
Resize Images in the Browser
let hasBlobConstructor = typeof(Blob) !== 'undefined' && (function () {
try {
return Boolean(new Blob());
} catch (e) {
return false;
}
}());
let hasArrayBufferViewSupport = hasBlobConstructor && typeof(Uint8Array) !== 'undefined' && (function () {
try {
@dhassanali
dhassanali / Builder.php
Created January 25, 2019 17:32 — forked from VinceG/Builder.php
Laravel support for replace into / insert ignore / insert on duplicate key update
<?php
namespace App\Library\Database\Query;
use Illuminate\Database\Query\Builder as QueryBuilder;
class Builder extends QueryBuilder
{
/**
* Insert a new record into the database.
@dhassanali
dhassanali / BinarySearch.js
Last active December 22, 2018 19:47
Simple Binary Search in JS
function binarySearch(elm, set) {
let i = 0
let j = set.length - 1
while (i < j) {
const m = Math.floor((j + i) / 2);
if (elm > set[m])
i = m + 1
else
CREATE TABLE `cars` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(32) NOT NULL,
`brand_id` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8;
INSERT INTO `cars` (`id`, `name`, `brand_id`)
VALUES
(1, 'تويوتا', 0),
@dhassanali
dhassanali / Emoji.php
Created February 4, 2018 08:32
Clean Emoji from String
function cleanEmoji($str) {
$clean_text = "";
// Match Emoticons
$regexEmoticons = '/[\x{1F600}-\x{1F64F}]/u';
$clean_text = preg_replace($regexEmoticons, '', $str);
// Match Miscellaneous Symbols and Pictographs
$regexSymbols = '/[\x{1F300}-\x{1F5FF}]/u';
@dhassanali
dhassanali / Digit.php
Created February 4, 2018 08:29
Convert to arabic digits
<?php
/**
* Created by PhpStorm.
* User: dhassanali
* Date: 12/4/17
* Time: 8:56 PM
*/
class Digit
{
@dhassanali
dhassanali / SaudiMobileNumber.php
Last active February 11, 2019 11:36
Saudi Mobile Number
<?php
/**
* Created by PhpStorm.
* User: Dev_Hassan
* Date: 12/4/17
* Time: 8:37 PM
*/
class SaudiMobileNumber
{