Skip to content

Instantly share code, notes, and snippets.

@crhg
crhg / count.php
Last active August 8, 2018 04:35
php7.2のcount
<?php
class Foo implements Countable {
protected $count;
public function __construct($n)
{
$this->count = $n;
}
@crhg
crhg / fuzzydirfilter
Last active January 15, 2018 07:03
fuzzydirfilter
#!/usr/local/bin/python3
import argparse
import sys
from fuzzywuzzy import fuzz
DEFAULT_THRESHOLD = 70
parser = argparse.ArgumentParser()
@crhg
crhg / ide-helper-generate
Created December 1, 2017 00:36
run ide-helper:generate and fix
#!/bin/bash
php artisan ide-helper:generate
perl -a -p -i.orig -e '
$in_eloquent = $F[1] eq "Eloquent" if $F[0] eq "class";
$in_eloquent and /\@return/ and s/\\Illuminate\\Database\\Eloquent\\Model\b/static/g
' _ide_helper.php
<?php
$d = range(1, 20000);
$t0 = microtime(true);
$r = array_reduce(
$d,
function (&$carry, $item) {
$carry []= $item;
return $carry;