Skip to content

Instantly share code, notes, and snippets.

@renexu
renexu / build_libvips.md
Created January 24, 2019 19:46
build latest libvips deb on ubuntu 18.04

These are the steps to build latest libvips (8.7.4) deb package on ubuntu 18.04

##1. install build scripts

# sudo apt install build-essential devscripts

##2. download vips source

@jaspal747
jaspal747 / SpoutHelper.php
Last active April 11, 2023 19:41
PHP Spout Helper - A helper class around php box/spout to format the header row as array keys like CSV column names. Inspired by: https://github.com/box/spout/issues/368
<?php
/**
*
* Inspired by: https://github.com/box/spout/issues/368
*
* Simple helper class for Spout - to return rows indexed by the header in the sheet
*
* Author: Jaspal Singh - https://github.com/jaspal747
@chriscpritchard
chriscpritchard / tutorial.md
Last active December 27, 2024 00:12
Technicolor DWA0120 - Obtain PPPOE Password
  1. Connect to the router via ssh, the username is "engineer" and the password is the access key on the bottom of your router
  2. You will be greeted with something akin to the following:
          |                 |           o             |
          |---  ,---. ,---. |---. ,---. . ,---. ,---. |     ,---. ,---.
          |     |---' |     |   | |   | | |     |   | |     |   | |
          `---' `---' `---' `   ' `   ' ` `---' `---' `---' `---' `
                     N E X T   G E N E R A T I O N   G A T E W A Y
     --------------------------------------------------------------------
    

NG GATEWAY SIGNATURE DRINK

@matdave
matdave / imageRotate.2.x.plugin.php
Last active October 2, 2023 07:35
MODX imageRotate Plugin
<?php
// run plugin OnFileManagerUpload
switch ($modx->event->name) {
case "OnFileManagerUpload":
if(!empty($files)){
foreach($files as $file){
if ($file['type'] != "image/jpeg" && $file['type'] != "image/png")
return;
// max number of pixels wide or high
$max_image_dimension = $modx->getOption('max_image_dimension',$scriptProperties,0);
@ryanburnette
ryanburnette / Caddyfile
Last active February 16, 2025 00:07
Caddy v2.1+ CORS whitelist
(cors) {
@cors_preflight{args.0} method OPTIONS
@cors{args.0} header Origin {args.0}
handle @cors_preflight{args.0} {
header {
Access-Control-Allow-Origin "{args.0}"
Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS"
Access-Control-Allow-Headers *
Access-Control-Max-Age "3600"
@HViktorTsoi
HViktorTsoi / ShadowHighlightCorrection.py
Last active April 11, 2025 15:39
Image shadow and highlight correction/adujstment with opencv.
import numpy as np
import cv2
def correction(
img,
shadow_amount_percent, shadow_tone_percent, shadow_radius,
highlight_amount_percent, highlight_tone_percent, highlight_radius,
color_percent
):
"""
@tasiot
tasiot / AppExtension.php
Last active January 5, 2024 16:56
Twig pluralize filter
<?php
namespace App\Twig;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
class AppExtension extends AbstractExtension
{
public function getFilters(): array
@hacfi
hacfi / xdebug
Created September 8, 2021 11:21
Xdebug toggle switch
#!/bin/bash
# put into /usr/local/bin/xdebug and make it executable: chmod +x /usr/local/bin/xdebug
# Usage:
# xdebug # toggle...switch on or off, depending of the current state
# xdebug on # enable xdebug
# xdebug off # disable xdebug
@ciaranmcnulty
ciaranmcnulty / notes.md
Last active March 25, 2024 06:36
Notes on using Docker on ARM Macs (November 2021)

Docker for Mac

On M1 machines, Docker for Mac is running a lightweight linux ARM VM, then running containers within that, so containers are essentially running natively. Don't be fooled by the fact the UI or binary CLI tools (e.g. docker) might require Rosetta.

Within that VM is an emulation layer called QEmu. This can be used by docker to run Intel containers. This does not use Rosetta at all, and has a roughly 5-6X performance penalty. (If you just upgraded your CPU this may result in a similar performance to your old machine!)

Pulling and running with Docker

Many images in public registries are multi-architecture. For instance at the time of writing on Docker Hub the php:8.0-cli image has the following digests:

@alfredbez
alfredbez / Intercept.php
Last active December 6, 2022 13:06
Testing stdout output with PHPUnit
<?php
class Intercept extends \php_user_filter
{
public static $cache = '';
public function filter($in, $out, &$consumed, $closing)
{
while ($bucket = stream_bucket_make_writeable($in)) {
self::$cache .= $bucket->data;
$consumed += $bucket->datalen;