Skip to content

Instantly share code, notes, and snippets.

View E1101's full-sized avatar
🏠
Working from home

Payam Naderi E1101

🏠
Working from home
View GitHub Profile
@E1101
E1101 / PHP7-extensions.md
Created April 25, 2016 09:15
PHP 7 Extensions

Extensions Catalog

This page holds everything we know about every extension we know about. Instructions for working with this page can be found on our main website.

If this page is annoyingly narrow to read, try this: https://github.com/xthexder/wide-github

Core Extensions

Name Homepage/location Has maintainers Has tests Has docs Works on PHP5 Works on PHP7 Is good on PHP 7 Details
@E1101
E1101 / php7.php
Last active April 28, 2021 06:45
PHP New Features
<?php
## --------------------------------------------------
## PHP ^7.4
## --------------------------------------------------
##
# Typed properties
#
class User {
@E1101
E1101 / inheritance-type-declarations.php
Created September 19, 2015 12:49
php inheritance interface type declarations
<?php
interface iInvokable {
function __invoke($arg = null);
}
interface iResponder extends iInvokable {
/** Bind next responder */
function then(iInvokable $responder);
}
@E1101
E1101 / ci_array_intersect.php
Created May 25, 2015 09:18
array_intersect case-insensitive and ignoring tildes
<?php
function to_lower_and_without_tildes($str,$encoding="UTF-8") {
$str = preg_replace('/&([^;])[^;]*;/',"$1",htmlentities(mb_strtolower($str,$encoding),null,$encoding));
return $str;
}
function compare_function($a,$b) {
return to_lower_and_without_tildes($a)===to_lower_and_without_tildes($b)?0:1;
}
@E1101
E1101 / featured-mobile-detection.js
Last active August 29, 2015 14:07
Mobile Detection
@E1101
E1101 / encryption.php
Last active April 19, 2016 06:15
Encryption
<?php
class Crypto {
/**
* Encrypt using 3DES
*
* @param string $clear clear text input
* @param string $key encryption key to retrieve from the configuration, defaults to 'des_key'
* @param boolean $base64 whether or not to base64_encode() the result before returning
*
* @return string encrypted text
@E1101
E1101 / sekeleton-appmodule.js
Last active August 29, 2015 14:06
js module skeleton
// initially you create your main application module that will
// load all his child modules
myapp = (function ($) {
'use strict';
var pub = {
initModule: function (module) {
if (module.isActive === undefined || module.isActive) {
if ($.isFunction(module.init)) {
module.init();
@E1101
E1101 / unique-string.php
Last active August 29, 2015 14:05
Get unique string in length
<?php
function($length) {
$char = "abcdefghijklmnopqrstuvwxyz0123456789";
$char = str_shuffle($char);
for($i = 0, $rand = '', $l = strlen($char) - 1; $i < $length; $i ++) {
$rand .= $char{mt_rand(0, $l)};
}
return $rand;
};
@E1101
E1101 / MetaTrait.php
Created May 24, 2014 10:28
Add methods on the fly to an object.
<?php
trait MetaTrait
{
private $methods = array();
public function addMethod($methodName, $methodCallable)
{
if (!is_callable($methodCallable)) {
throw new InvalidArgumentException('Second param must be callable');
@E1101
E1101 / .gitignore
Last active August 29, 2015 14:01
gitignore
/.vagrant
.buildpath
.DS_Store
.idea
.project
.settings/
.*.sw*
.*.un~
build/
composer.lock