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 / fizzbuzz.php
Created September 21, 2023 01:23
Crazy FizzBuzz written in PHP
<?php $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$${new class{public function __toString(){static$i=1;return($GLOBALS[$i]=(print($i%15?$i%5?$i%3?$i:"Fizz":"Buzz":"FizzBuzz")."\n")?$this:0)?$i++:0;}}};
<?php
$handle = fopen(__DIR__ . '/HelloWorld.yarv', 'r');
// see: https://github.com/ruby/ruby/blob/2f603bc4/compile.c#L11087
$magic = fread($handle, 4);
$majorVersion = unpack('V', fread($handle, 4))[1];
$minorVersion = unpack('V', fread($handle, 4))[1];
$fileSize = unpack('V', fread($handle, 4))[1];
$extraSize = unpack('V', fread($handle, 4))[1];
@m3m0r7
m3m0r7 / CrazyCalculator.php
Last active February 7, 2024 08:47
A calculator can calculates a sqrt function, factorial, power and usage big number calculation from user input that is written in PHP
<?php
function dt($v)
{
foreach ($v as $t) {
echo $t->value();
}
echo "\n";
}
<?php
$ffi = FFI::cdef(file_get_contents(__DIR__ . '/libusb.h'), '/usr/local/Cellar/libusb/1.0.24/lib/libusb-1.0.0.dylib');
$dh = $ffi->new('libusb_device_handle *');
$path = $ffi->new('uint8_t[8]');
$sdata = $ffi->new('uint8_t[255]');
$init = $ffi->libusb_init(null);
@m3m0r7
m3m0r7 / nfc-cardreader-example-written-in-php.php
Created October 8, 2021 06:06
Example for using libnfc with written in PHP
<?php
/**
* Reference:
* - http://www.libnfc.org/api/examples_page.html
* - https://github.com/nfc-tools/libnfc/blob/master/examples/nfc-poll.c
*
* Tested:
* - PaSoRi RC-S330
*
* Example Output:
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class Newrelic
{
public function handle(Request $request, \Closure $next)
<?php
declare(strict_types=1);
class Node
{
protected string $text;
protected array $params;
public function __construct(string $text, ...$params)
{
$this->text = $text;
@m3m0r7
m3m0r7 / danamo-lang.php
Created May 5, 2020 01:52
だなも言語 for animal crossing
<?php
class DanamoBuiltInFunction
{
public function 結果(array $node): int
{
['left' => $left, 'operator' => $operator, 'right' => $right] = $node['code'];
$left = $left['value'];
if ($right !== null) {
$right = $this->遡って計算($right);

Keybase proof

I hereby claim:

  • I am m3m0r7 on github.
  • I am m3m0r7 (https://keybase.io/m3m0r7) on keybase.
  • I have a public key ASAIFKEUupD1of1CVjzDGgOPjD-PUoIqPzG3p18XLLrfgwo

To claim this, I am signing this object:

package main
import (
"fmt"
"io/ioutil"
"os"
"strconv"
"strings"
)