Skip to content

Instantly share code, notes, and snippets.

@n-ramdi
n-ramdi / worker.js
Created April 29, 2021 08:27
Cloudflare worker to bypass Instagram new cross-origin policy on images (fixes net :: ERR_BLOCKED_BY_RESPONSE )
// Instagram started setting cross-origin-resource-policy: same-origin when it sees bad referer headers.
// this change leads to ERR_BLOCKED_BY_RESPONSE error and broken images if instagram image is embedded to external website.
// to mitigate this, simple image proxy can be used.
// Steps to install this worker:
// 1. Create CNAME cdn.<yourdomain.com> in your CloudFlare panel
// 2. Create new worker and put the code below into the worker code
// 3. Setup worker route so the worker launches on your cdn. subdomain.
// 4. Modify your image urls from
// https://scontent-arn2-1.cdninstagram.com/v/t51.2885-15/sh0xxx.jpg
// to:
@sykesm
sykesm / transform-leases.pl
Last active April 22, 2022 07:59
Transform dnsmasq leases to ISC lease file format.
#!/usr/bin/perl
use NetAddr::IP;
use POSIX qw(strftime);
my $dnsmasq_leases_path = '/var/run/dnsmasq-dhcp.leases';
my $dhcpd_leases_path = '/var/run/dhcpd.leases';
my $network_names_path = '/opt/vyatta/config/active/service/dhcp-server/shared-network-name';
my %networks_by_subnet;
@einkoro
einkoro / CustomWordPressValetDriver.php
Last active November 11, 2022 11:01
Custom WordPress Valet driver for installs that aren't in the root project directory
<?php
class CustomWordPressValetDriver extends WordPressValetDriver
{
/**
* Custom suffix for site path.
*
* @var string
*/
const sitePathSuffix = '/www';
@einkoro
einkoro / wp-config.php
Last active December 15, 2021 18:50
Easy WP SSL configuration: HTTPS and HTTP with reverse proxying support
<?php
/**
* The base configurations of the WordPress.
*
* This file has the following configurations: MySQL settings, Table Prefix,
* Secret Keys, WordPress Language, and ABSPATH. You can find more information
* by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
*
* This file is used by the wp-config.php creation script during the
@einkoro
einkoro / disable_admin_user_notifications.php
Last active January 29, 2020 15:32
Must-use plugin to disable new user and password reset email notifications to administrators.
<?php
/**
* Plugin Name: WP Disable Admin User Notifications
* Plugin URI: http://bitpiston.com/
* Description: Disables new user and password reset notification emails sent to administrators.
* Author: BitPiston Studios
* Author URI: http://bitpiston.com/
* Version: 1.0
* Licence: BSD
*/
@einkoro
einkoro / site.conf
Created May 6, 2014 06:25
Oyster fastcgi with nginx
server {
listen 80;
listen [::]:80;
server_name bitpiston.com;
root /home/bitpiston/www;
#access_log /var/log/nginx/bitpiston.com-access.log;
access_log off;
error_log /var/log/nginx/bitpiston.com-error.log;
@einkoro
einkoro / acf_object_cache_fix.php
Last active July 23, 2018 13:08
Must-use plugin for WordPress to flush fields and post meta when using Advanced Custom Fields
<?php
/**
* Plugin Name: WP ACF Obj Cache Fix
* Plugin URI: http://bitpiston.com/
* Description: Fix for Advanced Custom Fields expiry with 3rd party Object Caches.
* Author: BitPiston Studios
* Author URI: http://bitpiston.com/
* Version: 1.1.1
* Licence: BSD
*/
@einkoro
einkoro / password_bcrypt.php
Last active May 10, 2016 16:52
Must-use plugin for WordPress to swap phpass to PHP 5.5's new password_hash and password_verify using bcrypt
<?php
/**
* Plugin Name: WP PASSWORD_BCRYPT
* Plugin URI: http://bitpiston.com/
* Description: Replaces wp_hash_password and wp_check_password's phpass hasher with PHP 5.5's password_hash and password_verify using bcrypt.
* Author: BitPiston Studios
* Author URI: http://bitpiston.com/
* Version: 1.2
* Licence: BSD
*/
@cjonstrup
cjonstrup / Laravel\app\commands\ViewsCommand.php
Last active August 1, 2019 21:17
Clear Laravel 4.* app/storage/views artisan views:clear
<?php
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
class ViewsCommand extends Command {
/**
* The console command name.
*
* @var string
@dkubb
dkubb / ssl.nginxconf
Last active April 11, 2019 03:56
Nginx SSL configuration (PFS, HSTS, SPDY, BREACH mitigation, FIPS compliant)
ssl_certificate cert.pem;
ssl_certificate_key cert.key.pem;
ssl_trusted_certificate cert.ca.pem;
ssl_dhparam cert.dh.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers FIPS@STRENGTH:!aNULL:!eNULL;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;