Skip to content

Instantly share code, notes, and snippets.

View ElliottLandsborough's full-sized avatar

Elliott Lan ElliottLandsborough

View GitHub Profile
@ElliottLandsborough
ElliottLandsborough / style.css
Created November 8, 2020 01:33
rhythmaddict.co.uk custom css
/* changes from elliott */
/* make the titles white */
#tribe-events-content h1, #tribe-events-content h2 {
color: white;
}
/* make the text thats in the white box black */
.tribe-events-event-meta {
color: black;
@ElliottLandsborough
ElliottLandsborough / stackify.json
Last active April 16, 2020 11:24
Stackify custom instrumentation example for PHP
{
"instrumentation": [
{
"class": "Illuminate\\Support\\Collection",
"method": "map",
"trackedFunction": true,
"trackedFunctionName": "{{ClassName}}.{{MethodName}}"
},
{
"class": "Illuminate\\Support\\Collection",
@ElliottLandsborough
ElliottLandsborough / events.blade.php
Last active October 10, 2019 16:02
Some random examples
<section class="grid" id="eventGrid">
<div class="gridSizer"></div>
@foreach (getAllEvents(true) as $event)
<div class="event {!! ($loop->iteration > 1) ? 'extraMargin' : '' !!}">
<p style="background-color:#fff;color:#000;">--- example of including the post var from the context of events.blade.php</p>
@include('partials.blocks.sidekick', ['lolVariable' => $event])

Full Stack Test

We’d like you to build a simple message board. The message board is a single thread of posts and their comments. Users can post text messages. Users can also comment on these posts.

Specifications

  • Message board
    • Sorted list of all threads
    • Input to start new thread
  • Bonus: pagination of messages
// chooses a set of random ids. This set does not contain a fixed number of elements but they are around 20
$params = ['n' => $num_records, 'c' => $count, 'dc' => ($count * 2 < 20) ? 20 : $count * 2];
$results = DB::connection('mysql.huge_table')->select('SELECT id FROM atoms_in_universe WHERE RAND() * :n < :dc ORDER BY RAND() LIMIT 0,:c', $params);
@ElliottLandsborough
ElliottLandsborough / rofl.php
Created September 30, 2019 13:16
Rofl wordpress relative urls
<?php
namespace Api\Utils;
class RelativeUrls
{
public function __construct()
{
// get the path
$uri_path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
@ElliottLandsborough
ElliottLandsborough / CensorEngine.php
Last active August 29, 2019 10:38
PHP 7.3 advanced bad word filter
<?php
/**
* The Scunthorpe problem
*
* PHP version 7.3
*
* @category LolPHP
* @package LolPHP
* @author Elliott Landsborough <[email protected]>
* @license MIT https://opensource.org/licenses/MIT
@ElliottLandsborough
ElliottLandsborough / wp-versions.sh
Last active July 16, 2019 14:27
Bash script to check all wordpress versions
#!/bin/bash
LATEST_WORDPRESS=`curl -s http://api.wordpress.org/core/version-check/1.5/ | head -n 4 | tail -n 1`
find /home | grep "wp-includes/version.php" > /tmp/wplist1
for f in $(cat /tmp/wplist1); do
ver=$(grep "wp_version =" $f | cut -d\' -f2);
@ElliottLandsborough
ElliottLandsborough / compare.sh
Created May 31, 2019 08:26
Combine two text files and compare old vs new, replace if changed
#!/bin/bash
FILE="/home/user/replaceable.txt";
TMPFILE="/tmp/file.txt";
FILE1="/home/user/file1";
FILE2="/home/user/file2";
# generate new key in temp location
cat $FILE1 $FILE2 > $TMPFILE;
@ElliottLandsborough
ElliottLandsborough / letsencrypt.sh
Last active May 31, 2019 08:28
Ejabberd and znc with letsencrypt
#!/bin/bash
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
if test /etc/letsencrypt/live/domain.com/privkey.pem -nt /etc/ejabberd/ejabberd.pem ; then
cat /etc/letsencrypt/live/domain.com/privkey.pem /etc/letsencrypt/live/domain.com/fullchain.pem > /etc/ejabberd/ejabberd.pem
fi
if test /etc/letsencrypt/live/domain.com/privkey.pem -nt /home/znc/.znc/znc.pem ; then