Skip to content

Instantly share code, notes, and snippets.

View halaei's full-sized avatar
🎵
Code for music

Hamid Alaei Varnosfaderani halaei

🎵
Code for music
View GitHub Profile
@halaei
halaei / Install-php7.md
Created January 6, 2016 13:44 — forked from hollodotme/Install-php7.md
Installing php7-fpm with phpredis extension on Ubuntu 14.04

Install php7.0-fpm

# remove php5 modules
apt-get autoremove --purge php5-*
# add php-7.0 source list by [Ondřej Surý](https://github.com/oerdnj)
add-apt-repository ppa:ondrej/php-7.0
# Update index
apt-get update
# Install php7.0-fpm with needed extensions
<?php
declare(ticks = 1);
class TimeoutException extends Exception {};
function signal_handler($signal) {
throw new TimeoutException();
}
@halaei
halaei / find-pattern.c
Last active March 3, 2018 07:23
find pattern in string
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
/**
* Hamming Weight
* Code from stackoverflow:
* @see https://stackoverflow.com/questions/109023/how-to-count-the-number-of-set-bits-in-a-32-bit-integer
*/
uint8_t numberOfSetBits(uint32_t i)
@halaei
halaei / nullable.php
Created July 22, 2019 10:22
Nullable helper
<?php
class Nullable implements ArrayAccess, JsonSerializable
{
protected $value;
public function __construct($instance)
{
$this->value = $instance;
}
@halaei
halaei / EncryptCookies.php
Created August 2, 2020 09:54
AllowMissingPrefixForEncryptCookies
<?php
/**
* The name of the cookies that are safe not to be protected by value prefix.
*
* @see https://blog.laravel.com/laravel-cookie-security-releases
*
* @var string[]
*/
protected $allowMissingPrefix = [
'put name of remember me cookie here',