Skip to content

Instantly share code, notes, and snippets.

Avatar

Frankie Jarrett fjarrett

View GitHub Profile
@peterlafferty
peterlafferty / IntegrationTest.php
Last active Aug 30, 2019
example integration test in PHPUnit which starts the build in web server
View IntegrationTest.php
<?php
use PHPUnit\Framework\TestCase;
use Symfony\Component\Process\Process;
use GuzzleHttp\Client;
class IntegrationTest extends TestCase
{
/** @var Process */
private static $process;
@danielbachhuber
danielbachhuber / thrasher-v2.php
Created Jun 5, 2017
Thrash APCu until it can no longer allocate memory
View thrasher-v2.php
<?php
/**
* Thrash APCu until it can no longer allocate memory
*/
header("Cache-Control: no-cache, no-store, must-revalidate");
header("Pragma: no-cache");
header("Expires: 0");
View return-value-5.2.php
<?php
function __return_value( $value ) {
return create_function( '', sprintf( 'return %s;', var_export( $value, true ) ) );
}
@Jamesits
Jamesits / caddy.sh
Last active Dec 28, 2020
Install Caddy Server on Ubuntu with Systemd.
View caddy.sh
# Should work on all Debian based distros with systemd; tested on Ubuntu 16.04+.
# This will by default install all plugins; you can customize this behavior on line 6. Selecting too many plugins can cause issues when downloading.
# Run as root (or sudo before every line) please. Note this is not designed to be run automatically; I recommend executing this line by line.
apt install curl
curl https://getcaddy.com | bash -s personal dns,docker,dyndns,hook.service,http.authz,http.awses,http.awslambda,http.cache,http.cgi,http.cors,http.datadog,http.expires,http.filemanager,http.filter,http.forwardproxy,http.geoip,http.git,http.gopkg,http.grpc,http.hugo,http.ipfilter,http.jekyll,http.jwt,http.locale,http.login,http.mailout,http.minify,http.nobots,http.prometheus,http.proxyprotocol,http.ratelimit,http.realip,http.reauth,http.restic,http.upload,http.webdav,net,tls.dns.auroradns,tls.dns.azure,tls.dns.cloudflare,tls.dns.cloudxns,tls.dns.digitalocean,tls.dns.dnsimple,tls.dns.dnsmadeeasy,tls.dns.dnspod,tls.dns.dyn,tls.
@adamwathan
adamwathan / troubleshooting.md
Last active Jan 19, 2021
Troubleshooting Valet on macOS Sierra
View troubleshooting.md

Troubleshooting Valet on Sierra

Common Problems

Problem: I just see "It works!"

Apache is running on port 80 and interfering with Valet.

  1. Stop Apache: sudo /usr/sbin/apachectl stop
  2. Restart Valet: valet restart
@jimmyrolando
jimmyrolando / Cors.php
Last active Oct 24, 2020
Cors/Preflight Middleware for Laravel 5.2
View Cors.php
<?php
namespace App\Http\Middleware;
use Closure;
use Symfony\Component\HttpFoundation\Response;
class Cors
{
/**
@fjarrett
fjarrett / unautop-func.php
Last active Aug 6, 2021
Inverse behavior to the wpautop() function found in WordPress
View unautop-func.php
<?php
/**
* Replaces paragraph elements with double line-breaks.
*
* This is the inverse behavior of the wpautop() function
* found in WordPress which converts double line-breaks to
* paragraphs. Handy when you want to undo whatever it did.
*
* @see wpautop()
@fjarrett
fjarrett / sample.html
Last active Jun 13, 2016
HTML Sample Page Content
View sample.html
<div id="top"></div>
<p>The purpose of this HTML is to help determine what default settings are with CSS and to make sure that all possible HTML Elements are included in this HTML so as to not miss any possible Elements when designing a site.</p>
<hr />
<h1 id="headings">Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
@stelabouras
stelabouras / loadAssetToInstagram.m
Last active Mar 18, 2021
Loads a Camera Roll Asset to Instagram (works for both photos & videos)
View loadAssetToInstagram.m
- (void)loadCameraRollAssetToInstagram:(NSURL*)assetsLibraryURL andMessage:(NSString*)message
{
NSString *escapedString = [assetsLibraryURL.absoluteString urlencodedString];
NSString *escapedCaption = [message urlencodedString];
NSURL *instagramURL = [NSURL URLWithString:[NSString stringWithFormat:@"instagram://library?AssetPath=%@&InstagramCaption=%@", escapedString, escapedCaption]];
[[UIApplication sharedApplication] openURL:instagramURL];
}
@jtsternberg
jtsternberg / db.php
Last active Mar 26, 2018
Simplified WordPress DB drop-in replacement for persistent database connections
View db.php
<?php
/**
* Simplified WordPress DB drop-in replacement for persistent database connections
* (If https://core.trac.wordpress.org/attachment/ticket/31018/31018-2.diff gets into core)
*
* Actual working version right now would look like: https://gist.github.com/jtsternberg/eec4ab95e11ce9be4807
*
* WordPress Trac Ticket {@link https://core.trac.wordpress.org/ticket/31018}
*/