Skip to content

Instantly share code, notes, and snippets.

View m4tthumphrey's full-sized avatar
🏂
Working...

Matt Humphrey m4tthumphrey

🏂
Working...
View GitHub Profile

How to setup a practically free CDN using Backblaze B2 and Cloudflare

⚠️ Note 2023-01-21
Some things have changed since I originally wrote this in 2016. I have updated a few minor details, and the advice is still broadly the same, but there are some new Cloudflare features you can (and should) take advantage of. In particular, pay attention to Trevor Stevens' comment here from 22 January 2022, and Matt Stenson's useful caching advice. In addition, Backblaze, with whom Cloudflare are a Bandwidth Alliance partner, have published their own guide detailing how to use Cloudflare's Web Workers to cache content from B2 private buckets. That is worth reading,

@milankragujevic
milankragujevic / youtube-extract-ids-from-playlist.js
Created July 28, 2017 00:30
To extract all the video IDs from a YouTube playlist. Open the playlist page, scroll down to the bottom, click load more, repeat until the end, then open Console and paste this code. Output is a list of video IDs from the page.
var els = document.getElementsByClassName('pl-video');
for(i = 0; i < els.length; i++) {
var el = els[i];
if(el) {
var src = el.getElementsByClassName('yt-thumb-clip')[0].getElementsByTagName('img')[0].src;
if(!src.match(/\.com\/vi\//g)) { continue; }
var id = src.split('.com/vi/')[1].split('/')[0];
console.log(id);
}
@Otienoh
Otienoh / ubuntu-server-setup-16.04-LAMP.md
Last active January 4, 2022 04:53
LAMP Server setup for Ubuntu 16.04 on Digital Ocean

Server setup for Ubuntu 16.04 on Digital Ocean

The setup installs the following software:

The setup installs the following software:

  • Apache
  • MySQL
  • PHP
  • Node
@m4tthumphrey
m4tthumphrey / streamed.php
Last active December 28, 2022 08:06
Laravel response macro for streamed responses with seeking support
<?php
Response::macro('streamed', function($type, $size, $name, $callback) {
$start = 0;
$length = $size;
$status = 200;
$headers = [
'Content-Type' => $type,
'Content-Length' => $size,
@m4tthumphrey
m4tthumphrey / Reader.php
Created April 16, 2014 16:18
Simple class to iterate a CSV file quickly, allowing the user to manipulate the value of each field
<?php
class Reader
{
protected $fields = [];
protected $filters = [];
public function read($file)
{
try {
@ericflo
ericflo / undo.js
Last active September 15, 2016 09:31
Adds undo capabilities into your React.js component.
var UndoMixin = {
getInitialState: function() {
return {
undo: []
};
},
handleUndo: function() {
if (this.state.undo.length === 0) {
return;
@philfreo
philfreo / gist:7257723
Created October 31, 2013 21:44
Facebook Perl source code from 2005. When browsing around thefacebook.com in 2005 the server spit out some server-side source code rather than running it. I believe this was for their old graph feature that let you visualize the graph between all your friends. The filename is `mygraph.svgz` and contains some gems such as a commented out "zuck" d…
#!/usr/bin/perl
use Mysql;
use strict;
use vars qw($school_name);
use vars qw($pass);
require "./cgi-lib.pl";
@cmuench
cmuench / create_map.php
Created April 5, 2013 13:12
Create map for PHPStorm
<?php
// Init framework
require 'app/Mage.php';
Mage::app();
// Factory methods to search for
$methods = array(
'Mage::helper',
'Mage::getModel',
'Mage::getResourceModel',
@barryvdh
barryvdh / _ide_helper.php
Last active May 6, 2024 07:45
Laravel IDE Helper for Netbeans / PhpStorm / Sublime Text 2 CodeIntel, generated using https://github.com/barryvdh/laravel-ide-helper
<?php
/**
* A helper file for Laravel 5, to provide autocomplete information to your IDE
* Generated for Laravel 5.5.13 on 2017-09-28.
*
* @author Barry vd. Heuvel <barryvdh@gmail.com>
* @see https://github.com/barryvdh/laravel-ide-helper
*/
namespace {
exit("This file should not be included, only analyzed by your IDE");
@ziadoz
ziadoz / awesome-php.md
Last active May 10, 2024 15:06
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.