Skip to content

Instantly share code, notes, and snippets.

View mpdroog's full-sized avatar

MP Droog mpdroog

View GitHub Profile
@mpdroog
mpdroog / http-dump.php
Last active December 4, 2020 09:36
Dump HTTP-request for easy debugging if head/body is properly set
<?php
/**
* Dump received HTTP-request to console for quickly
* seeing what we're trying to send.
*/
$address = '127.0.0.1';
$port = 8080;
$sock = socket_create(AF_INET, SOCK_STREAM, 0);
socket_bind($sock, $address, $port) or die('Could not bind to address');
<?php
// Search&Replace all occurrences of a given string
// Got tired of all the harship with sed -i so made this
// small script to get the same result.
$search = "Fn";
$replace = "Shared";
$rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('.'));
foreach ($rii as $file) {
if (in_array($file->getFilename(), [".", "..", "findreplace.php", ".git"])) continue; // Ignored files (in curdir)

Keybase proof

I hereby claim:

  • I am mpdroog on github.
  • I am mpdroog (https://keybase.io/mpdroog) on keybase.
  • I have a public key ASCAECt2B8dGFQJtmjIIPjKV_tBYUUT6Hj23-ug-YCVTNwo

To claim this, I am signing this object:

[Unit]
Description=Headless Chrome
Requires=network.target
After=multi-user.target
[Service]
LimitNOFILE=100
Restart=on-failure
Type=simple
@mpdroog
mpdroog / toml.po.php
Created December 27, 2018 13:29
TOML-config to PO-file for Poedit
<?php
/**
* TOML to PO converter.
*/
$args = $_SERVER["argv"];
if ($args[0] === "php") {
array_shift($args);
}
array_shift($args);
$args = array_values($args); // php-file
@mpdroog
mpdroog / http_query.go
Created June 10, 2016 18:29
SELECT-query through Go without types
package sql
import (
"database/sql"
"net/http"
"github.com/julienschmidt/httprouter"
"log"
"github.com/mpdroog/invoiced/writer"
)