Skip to content

Instantly share code, notes, and snippets.

<?php
$docs = $modx->getCollection('modDocument');
$pattern = '/www.xxx.com/(\d+)/';
$replacement = '[[~$1]]';
$count = 0;
foreach ($docs as $doc) {
$content = $doc->getContent();
$hash1 = sha1($content);
@snakebird
snakebird / command.txt
Last active August 29, 2015 14:15 — forked from nrk/command.txt
ffprobe in json
ffprobe -v quiet -print_format json -show_format -show_streams "lolwut.mp4" > "lolwut.mp4.json"
@snakebird
snakebird / VAAPI-hwaccel-encode-Linux-Ffmpeg&Libav-setup.md
Created May 5, 2017 21:06 — forked from Brainiarc7/VAAPI-hwaccel-encode-Linux-Ffmpeg&Libav-setup.md
This gist contains instructions on setting up FFmpeg and Libav to use VAAPI-based hardware accelerated encoding (on supported platforms) for H.264 (and H.265 on supported hardware) video formats.

Using VAAPI's hardware accelerated video encoding on Linux with Intel's hardware on FFmpeg and libav

Hello, brethren :-)

As it turns out, the current version of FFmpeg (version 3.1 released earlier today) and libav (master branch) supports full H.264 and HEVC encode in VAAPI on supported hardware that works reliably well to be termed "production-ready".

@snakebird
snakebird / corsproxy.php
Created January 24, 2019 12:39 — forked from dropmeaword/corsproxy.php
simple CORS proxy in php
<?php
error_reporting( error_reporting() & ~E_NOTICE ); // evil
// config
$enable_jsonp = false;
$enable_native = false;
$valid_url_regex = '/.*/';
// ############################################################################
@snakebird
snakebird / in_viewport.js
Created August 27, 2020 13:48 — forked from jjmu15/in_viewport.js
check if element is in viewport - vanilla JS. Use by adding a “scroll” event listener to the window and then calling isInViewport().
// Determine if an element is in the visible viewport
function isInViewport(element) {
var rect = element.getBoundingClientRect();
var html = document.documentElement;
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || html.clientHeight) &&
rect.right <= (window.innerWidth || html.clientWidth)
);
@snakebird
snakebird / README.md
Created February 17, 2021 13:05 — forked from laserbat/README.md

To use this script

  1. Install xdotool: $ sudo apt install xdotool

  2. Install this script to /usr/local/bin: $ sudo cp path/to/file/permafocus.sh /usr/local/bin/ (path/to/file should be replaced by the actual path to the folder containing script, for example ~/Downloads/)