Skip to content

Instantly share code, notes, and snippets.

View g105b's full-sized avatar

Greg Bowler g105b

View GitHub Profile
<?php
/**
* Serve Wordpress locally without having to configure a web server.
*
* You need to have the database served as configured in wp-config.php, then
* run php -S 0.0.0.0:8080 wp-router.php to serve, and access localhost:8080 or
* your.computers.ip:8080 in a browser.
*
* Make sure in the database that within the `wp_options` table, the `siteurl`
* and `home` values are both "/".

Keybase proof

I hereby claim:

  • I am g105b on github.
  • I am g105b (https://keybase.io/g105b) on keybase.
  • I have a public key whose fingerprint is 90EF 3167 AFE2 0F52 A63D 4070 0239 1184 CE3F 61A6

To claim this, I am signing this object:

@g105b
g105b / key-sync.sh
Created January 27, 2017 15:09
Sync authorized_keys with Github public keys
#!/bin/bash
GITHUB_USERNAME=#PUT_YOUR_USERNAME_HERE
TMP=/tmp/existing_cron
crontab -l > $TMP
echo "*/10 * * * * /usr/bin/wget https://github.com/$GITHUB_USERNAME.keys -O ~/.ssh/authorized_keys" >> $TMP
crontab $TMP
rm $TMP
@g105b
g105b / curlpool.sh
Last active March 11, 2024 06:17
Pool 100 parallel curl requests at a time
#!/bin/bash
target=${1:-http://example.com}
while true # loop forever, until ctrl+c pressed.
do
for i in $(seq 100) # perfrom the inner command 100 times.
do
curl $target > /dev/null & # send out a curl request, the & indicates not to wait for the response.
done
wait # after 100 requests are sent out, wait for their processes to finish before the next iteration.
@g105b
g105b / index.php
Created January 21, 2019 16:15
SSE
<?php
header("Access-Control-Allow-Origin: *");
$accept = $_SERVER["HTTP_ACCEPT"];
if($accept === "text/event-stream") {
header("Content-Type: text/event-stream");
header('Cache-Control: no-cache');
$i = 0;
while($i < 10) {
$time = time();
<?php
$startTime = microtime(true);
$workingDir = "_bm";
$runs = [
100,
1000,
10000,
100000,
];
@g105b
g105b / gpg_steps.md
Created June 17, 2019 19:49
Use GPG to sign commits in PhpStorm on Ubuntu
  1. Generate key
gpg --gen-key #use the same name and email address as on Github
  1. Output key(s)
gpg --list-secret-keys --keyid-format LONG
@g105b
g105b / index.html
Created September 19, 2019 10:26
Binding nested lists example
<p>More bind examples</p>
<p>Nested list example:</p>
<ul>
<li data-template>
<p data-bind:text>Make name</p>
<ul>
<li data-template data-bind:text>Model name</li>
@g105b
g105b / wpa_supplicant.conf
Created November 16, 2019 17:46
Automatically connect Raspberry Pi to an open but hidden wifi network
# /etc/wpa_supplicant/wpa_supplicant.conf
# or put wpa_supplicant.conf inside the boot directory
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="60"
scan_ssid=1
key_mgmt=NONE
@g105b
g105b / bootstrap
Last active December 6, 2019 10:59
Lambda runtime entrypoint for PHP.Gt WebEngine
#!/opt/bin/php
<?php
require __DIR__ . "/vendor/autoload.php";
use Gt\Fetch\Http;
use Gt\Fetch\Response\BodyResponse;
while(true) {
$payload = null;
$invocationId = null;