Skip to content

Instantly share code, notes, and snippets.

@ethanpil
ethanpil / example.php
Created August 3, 2016 20:27
HTML to PDF with PHP and wkhtmltopdf
<?php
/******
I was using tcpdf then mpdf for years, and then I discovered wkhtmltopdf and it changed my life.
If you can exec() then you will enjoy super fast operation, no more memory/process time outs,
and overall easier and better PDFs... Check out http://wkhtmltopdf.org/ ... binaries for most platforms.
******/
//Setup file parameters
$cwd = getcwd();
@ethanpil
ethanpil / chromecastbg.xml
Last active September 2, 2017 05:48
chromecastbg
<?xml version="1.0" encoding="utf-8"?>
<rss version = "2.0" xmlns:media = "http://search.yahoo.com/mrss/">
<channel>
<title>Chromecast BG</title>
<link>http://chromecastbg.alexmeub.com</link>
<description>Chromecast Bakground Images</description>
<item>
<title>John Cavacas</title>
@ethanpil
ethanpil / wp-secure.conf
Created May 12, 2017 16:16
Wordpress Security for NginX
# wp-secure.conf
#
#
# This file includes common security considerations for wordpress using nginx.
#
# The goal is to block actions which are usually dangerous to wordpress.
# Additionally, we block direct access to PHP files and folders which should not
# be accessed directly from a browser.
#
# Also have included exceptions for plugins that are known to require this access.
@ethanpil
ethanpil / regex.custom.pm
Created May 16, 2017 20:03
Custom regex rules for CSF/LFD and NginX plus Wordpress fail2ban plugin
#!/usr/bin/perl
###############################################################################
# Copyright 2006-2015, Way to the Web Limited
# URL: http://www.configserver.com
# Email: sales@waytotheweb.com
###############################################################################
sub custom_line {
my $line = shift;
my $lgfile = shift;
@ethanpil
ethanpil / gist:78e950942ef49bd254b40529b4b61f41
Created June 12, 2017 14:39
PHP Process Forks / Parallel Processing
<?php
// Source: https://www.stitcher.io/blog/process-forks
function async(Process $process) : Process {
socket_create_pair(AF_UNIX, SOCK_STREAM, 0, $sockets);
[$parentSocket, $childSocket] = $sockets;
if (($pid = pcntl_fork()) == 0) {
socket_close($childSocket);
socket_write($parentSocket, serialize($process->execute()));
@ethanpil
ethanpil / giphy
Created August 25, 2019 20:01
Bash Command to Download Giphy as GIF
giphy() {
#Thank you Eric - https://eric.blog/2019/01/12/how-to-download-a-gif-from-giphy/
[[ "$1" ]] || { echo "Error: Missing giphy url" >&2; return 1; }
curl -F "file=@$1" "$2"
curl "$1" --output ~/Downloads/giphy.gif
}
@ethanpil
ethanpil / dl.bat
Last active March 20, 2020 06:26
Windows Batch to Download Consecutive Files with Wget
@ECHO OFF
SetLocal EnableDelayedExpansion
FOR /L %%G IN (1, 1, 465) DO (
SET num=%%G
REM You can escape ampersands with ^ like this: ^&
wget -x --load-cookies cookies.txt --user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0" -O !num!.png https://website.com?year=2012^&page=!num!.png
REM Add a delay between each download
TIMEOUT /T 60 /NOBREAK
)
EndLocal
@ethanpil
ethanpil / gist:e5a82ea5ce92cc4ba860582193a4d570
Created March 22, 2020 23:22
ffmpeg windows batch convert all mp3 to mp4
for /f "tokens=1 delims=." %a in ('dir /B *.mp3') do ffmpeg -i "%a.mp3" -q:a 4 "%a.ogg"
@ethanpil
ethanpil / index.html
Created April 27, 2020 06:20
Flexbox Dead Center
<html>
<head>
<title>Flexbox Dead Center</title>
<style>
.deadcenter {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
height: 100%;

Using tar you can exclude directories by placing a tag file in any directory that should be skipped.

Create tag files,

touch /sys/.exclude_from_backup
touch /proc/.exclude_from_backup

Then,