Skip to content

Instantly share code, notes, and snippets.

View m3m0r7's full-sized avatar
🐱
$ cat /usr/bin/php

memory m3m0r7

🐱
$ cat /usr/bin/php
View GitHub Profile
@m3m0r7
m3m0r7 / SSLSEGV_valgrind.log
Created August 3, 2019 15:06
Swoole: /bin/sh: line 1: 29 Segmentation fault valgrind --log-file=/var/src/valgrind.log php /var/src/bootstrap.php
==29== Memcheck, a memory error detector
==29== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==29== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==29== Command: php /var/src/bootstrap.php
==29== Parent PID: 1
==29==
==29== Conditional jump or move depends on uninitialised value(s)
==29== at 0x420402: zend_string_equal_val (in /usr/bin/php)
==29== by 0x4091FF: zend_hash_find (in /usr/bin/php)
==29== by 0x3E62B9: ??? (in /usr/bin/php)
@m3m0r7
m3m0r7 / SSLError_valgrind.log
Created August 3, 2019 14:53
Swoole: WARNING swSSL_connect: SSL_connect(fd=16) failed. Error: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol[1|252]
==28== Memcheck, a memory error detector
==28== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==28== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==28== Command: php /var/src/bootstrap.php
==28== Parent PID: 1
==28==
==28== Conditional jump or move depends on uninitialised value(s)
==28== at 0x420402: zend_string_equal_val (in /usr/bin/php)
==28== by 0x4091FF: zend_hash_find (in /usr/bin/php)
==28== by 0x3E62B9: ??? (in /usr/bin/php)
@m3m0r7
m3m0r7 / PHP-Conference-Fukuoka-2019-Answer.php
Last active June 30, 2019 11:55
Code Golf Answer at PHP Conference Fukuoka 2019
<?php array_multisort($v=$_GET,$a=SORT_DESC,$b=SORT_STRING,array_keys($v),$a,$b,$v)?><!DOCTYPE html><style>body,html{height:100vh;margin:0;background-color:#fff;color:#465560;font-family:Arial,Verdana,Meiryo,sans-serif;font-feature-settings:"pkna";letter-spacing:.04em;font-size:1rem;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased}body{font-size:1rem}*{box-sizing:border-box;background-repeat:no-repeat;padding:0;margin:0}table{width:100%;height:100%}html{box-sizing:border-box;-webkit-text-size-adjust:100%}td{text-align:center;height:50%;width:5%}h1{font-weight:400;margin:0}</style><table border="0" cellspacing="0"><tr><td bgcolor="#147ecc">&nbsp;<td>&nbsp;<td style="width:80%"><table><tr><td style="height:10%;">&nbsp;<tr><td style="height:80%"><img src="https://raw.githubusercontent.com/pepabo/lolipop-mc-codegolf-challenge/master/mc.png" width="100%"/><br><h1><?=strrev(array_values($v)[2]??'')?></h1><tr><td style="height:10%">&nbsp;</table><td>&nbsp;<td bgcolor="#147ecc">&nbsp;
@m3m0r7
m3m0r7 / an-introduction-to-run-jvm-on-php.php
Last active March 28, 2019 11:21
A sample code for PHPerKaigi 2019 which is an introduction to run JVM on PHP.
<?php
//
// [Test.java]
// class Test
// {
// public static void main(String[] args)
// {
// System.out.println("Hello World!");
// }
<?php function z($_,$p){return array_filter($_,function($v)use($p){return$v%$p==0;});}function x(&$_,$p){array_walk($_,function(&$v)use($p){$v=$p;});}$y=@array_keys;$a=array_combine($a=$y(array_fill(1,100,0)),$a);$b=z($a,3);$c=z($a,5);$d=array_intersect($b,$c);x($b,@Fizz);x($c,@Buzz);x($d,@FizzBuzz);$f=$d+$c+$b+$a;ksort($f);echo join("\n",$f);
@m3m0r7
m3m0r7 / cleaner.php
Created October 7, 2017 12:54
Delete all your tweets
<?php
// Before step, `composer require abraham/twitteroauth`
// Run: `php cleaner.php` on your terminal
require __DIR__ . '/vendor/autoload.php';
use Abraham\TwitterOAuth\TwitterOAuth;
$handle = fopen(__DIR__ . '/tweets.csv', 'r');
$twitter = new TwitterOAuth(
'{CONSUMER_KEY}',
<?php
// all
function all (array $array, $initialize = true) {
return array_reduce($array, function ($carry, $item) {
return (bool) ($carry & $item);
}, $initialize);
}
function any (array $array, $initialize = false) {
return array_reduce($array, function ($carry, $item) {
<?php
date_default_timezone_set('Asia/Tokyo');
$result = `vagrant version`;
if (!preg_match('/([a-z0-9\.]+)\n/i', $result, $matches)) {
printf("Not installed vagrant\n");
return;
}
// vagrant version
<?php
define('READ_SIZE', 2 ** 24);
if (isset($argv[1], $argv[2])) {
$from = $argv[1];
$to = $argv[2];
if (!is_file($from)) {
printf("This is directory or not found file.\n");
return;
<?php
/**
* あなたがどれくらい今日仕事したのか調べるやつです。
*/
mb_internal_encoding('UTF-8');
$files = 0;
$lines = 0;
$bytes = 0;
$mbytes = 0;