Skip to content

Instantly share code, notes, and snippets.

View hkp22's full-sized avatar

Harish Kumar hkp22

View GitHub Profile
@hkp22
hkp22 / error_blade_directive.php
Created March 29, 2019 07:32 — forked from calebporzio/error_blade_directive.php
A little Blade directive to make working with validation errors a bit nicer.
<?php
// Usage:
// Before
@if ($errors->has('email'))
<span>{{ $errors->first('email') }}</span>
@endif
// After:
@hkp22
hkp22 / regexCheatsheet.js
Created January 15, 2019 06:10 — forked from sarthology/regexCheatsheet.js
A regex cheatsheet 👩🏻‍💻 (by Catherine)
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"
## How to install mcrypt in php7.2
##
## https://lukasmestan.com/install-mcrypt-extension-in-php7-2/
##
#
# Check version php and pecl
#
php -v # if default php is not 7.2 then use /usr/bin/php7.2 instead php
@hkp22
hkp22 / hash.js
Created August 22, 2018 19:24
Js Hashing and Un-Hasing a given string.
/**
* Un-hash the provided hashed string.
*
* @param {string} hash
*/
function unhash(hash) {
var parts = [];
var letters = 'acdfgilmnoprstuw'; // Letter Index
while (hash !== 7) {
@hkp22
hkp22 / Math.php
Created July 21, 2018 16:14 — forked from jgrossi/Math.php
Math class from Taylor Otwell. Thanks to @brad (captain_jim1@yahoo.com) for the class content.
<?php
class Math {
/**
* The base.
*
* @var string
*/
private static $base = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';