Skip to content

Instantly share code, notes, and snippets.

@kicken
kicken / Dockerfile
Created September 18, 2022 00:55
Practice docker stuff.
FROM php:7.4-fpm as php
ARG user
ARG uid
ARG nodejs_latest=latest
# Install dependencies
RUN apt update && apt install -y --no-install-recommends git unzip subversion
# Install node / npm
@kicken
kicken / HTML2PDF.php
Created August 14, 2022 02:20
HTML to PDF Conversion using NodeJS and Puppeteer.
<?php
class HTML2PDF {
private string $node;
private string $script;
private string $baseHref;
private bool $enableBackgrounds = false;
private string $orientation = self::PORTRAIT;
private string $format = self::LETTER;
private string $header = '';
@kicken
kicken / parallel.php
Created April 3, 2021 06:27
Parallel command execution
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Promise\Promise;
use function GuzzleHttp\Promise\all;
use function GuzzleHttp\Promise\queue;
const CMD1 = 'd:\Software\Packages\ffmpeg\bin\ffmpeg.exe -i title_t01.mkv -map 0:0 -vcodec h264 -crf 18 -map 0:1 -acodec copy t1.mp4';
@kicken
kicken / Crawler.php
Created February 14, 2021 20:03
Simple Crawler Example
<?php
class Crawler {
private $linkQueue;
private $linkExtractor;
public function __construct(){
$this->linkExtractor = new LinkExtractor;
}
@kicken
kicken / washpost.js
Created January 22, 2021 01:27
Script to break through The Washington Post paywall
//Inject with an addon such as [Custom Style Script](https://addons.mozilla.org/en-US/firefox/addon/custom-style-script/)
window.addEventListener('DOMContentLoaded', function(e){
var body = document.body;
var articleBody = document.querySelector('.article-body');
var remainderContent = document.querySelector('.remainder-content');
body.addEventListener('click', function(){
var paywall = document.querySelector('.paywall-overlay');
if (paywall && paywall.parentNode){
paywall.parentNode.removeChild(paywall);
}
@kicken
kicken / nytimes.js
Created January 22, 2021 01:26
Script to break through New York Times paywall.
// Inject with an addon such as [Custom Style Script](https://addons.mozilla.org/en-US/firefox/addon/custom-style-script/)
window.addEventListener('DOMContentLoaded', function(e){
var content = document.querySelectorAll('[name=articleBody] > div');
document.body.addEventListener('click', function(e){
var banner = document.getElementById('gateway-content');
if (!banner){
return;
}
var parent = banner.parentNode;
@kicken
kicken / markTime.php
Created March 1, 2018 02:43
Time logging
<?php
function markTime($label){
static $points = [];
static $firstRun = true;
if ($firstRun){
$firstRun = false;
register_shutdown_function(function () use (&$points){
$firstPoint = reset($points);