Skip to content

Instantly share code, notes, and snippets.

View finagin's full-sized avatar
🖖

Igor Finagin finagin

🖖
View GitHub Profile
<?php
namespace Finagin;
use Finagin\Traits\Readable;
use Finagin\Traits\TraitBootstrapper;
class Example
{
use Readable, TraitBootstrapper;
<?php declare(strict_types=1);
if (!function_exists('dump')) {
function dump(...$args)
{
ob_start();
var_dump($args);
file_put_contents('/tmp/igor.manual.log', ob_get_clean());
}
}
@finagin
finagin / integer_uses_bits.php
Created March 13, 2018 09:14
Integer uses bits
<?php
function dits(int $int, $min = 1): int
{
for($i = $min; $int > 1 << $i; $i++);
return ++$i; /* "minus" bit */
}
echo dits(9999999999999).'bits'; /* 45bits*/
server {
listen 80;
server_name ~^(.+)\.dev$;
set $path $1;
if ($host ~ "([^\.]+)\.[^\.]+$") {
set $path $1;
}
root /var/www/$path;
#!/usr/bin/env php
<?php
function check(string $password): int
{
$hash = strtoupper(hash('sha1', $password));
$start = substr($hash, 0, 5);
$content = file_get_contents('https://api.pwnedpasswords.com/range/'.$start);
<?php
namespace App;
use Finagin\Support\Singleton;
class Instance extends Singleton
{
protected function __construct()
{
for (var i = 0, l; ; = log[i]; ++i) {
#!/usr/bin/env php
<?php
function crow($dir = __DIR__)
{
$items = scandir($dir);
foreach ($items as $item) {
if (! preg_match('/^\.{1,2}$/', $item)) {
$path = $dir.DIRECTORY_SEPARATOR.$item;
#!/bin/bash
echo "Testing sudo..."
sudo true
if [ $? -ne 0 ]
then
echo "ERROR: You must be able to sudo to run this script.";
exit 1;
fi;
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;