Skip to content

Instantly share code, notes, and snippets.

<?php
class MailMockStreamWrapper
{
private $content = '';
private $position = 0;
public function stream_open($path)
{
stream_wrapper_restore("file");
user: nobody
file.custom-handler:
extension: .php
fastcgi.connect:
port: /var/run/php-fpm/php-fpm.sock
type: unix
compress: ON
file.index: [ 'index.html', 'index.htm', 'index.txt', 'index.php' ]
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE DeriveGeneric #-}
module Main where
import System.Environment (getArgs, getEnv)
import System.IO
import Network.HTTP.Conduit
import Network.URI
<?php
class Debugger {
private $transaction_id;
private $debug;
function __construct(bool $debug = false)
{
$this->transaction_id = 1;
$this->debug = $debug;
var AnnotatingErrorListener = function(annotations) {
antlr4.error.ErrorListener.call(this);
this.annotations = annotations;
return this;
};
AnnotatingErrorListener.prototype = Object.create(antlr4.error.ErrorListener.prototype);
AnnotatingErrorListener.prototype.constructor = AnnotatingErrorListener;
@tzmfreedom
tzmfreedom / sample-lexer.go
Created October 10, 2018 08:28
Sample Lexer by golang
package main
import (
"regexp"
)
func main() {
l := &Lexer{input: "=+*-/===abc=a1"}
tokens := []Token{}
for {
@tzmfreedom
tzmfreedom / mylogin_decode.php
Last active August 4, 2023 05:01
decode .mylogin.cnf to extract credential.
#!/usr/bin/php -q
<?php
$fp = fopen("../.mylogin.cnf", "r");
if (!$fp) {
die("Cannot open .mylogin.cnf");
}
# read key
# frozen_string_literal: true
class S3Client
def initialize(bucket_name:)
@bucket_name = bucket_name
end
def download(key:, filepath: nil)
return unless exist_key?(key)
if filepath
#!/usr/bin/env ruby
class Hoge
def foo
a = 123
(class << self; self; end).class_eval do
define_method(:bar) do
puts a
end
end
#!/usr/bin/env ruby
class LifeGame
attr_accessor :height, :width, :sleep_time
def initialize(height:, width:, sleep_time: 0.25)
@height = height
@width = width
@sleep_time = sleep_time
@field = Array.new(height) { Array.new(width) { rand(2) == 0 } }