Skip to content

Instantly share code, notes, and snippets.

<?php
session_start();
require_once('lib.php');
/**
* So you can check with javascript something like
* if (data.type == 'error') // Hasn't worked
* if (data.type == 'success') // Work with data.value (this will be person)
*/
$response = ['type' => 'error'];
<?php
class Something {
public function myMethod($someVar, $anotherVar, Organisation $organisation) {
return redirect()->route('my.route', ['organisation' => $organisation->slug]);
}
}
@jellis
jellis / phantom.js
Created August 19, 2015 15:27
This is the code I used to scrape the ninemsn webpage with PhantomJS. Easy install.
var page = require('webpage').create(),
fs = require('fs'),
url = 'http://www.ninemsn.com.au/';
page.onResourceRequested = function(requestData, request) {
if (requestData['url'] !== url) {
console.log('Aborting ' + requestData['url']);
request.abort();
}
}
@jellis
jellis / pingdom-hipchat.php
Created August 25, 2016 04:23
Pingdom to HipChat communication
<?php
$hc_subdomain = 'my-subdomain';
$room = '12345';
$room_token = 'the-room-token';
if (!empty($_REQUEST['message'])) {
$message = json_decode($_REQUEST['message']);
package main
import (
"net/http"
"os"
"strings"
)
var token = "ABC123"
@jellis
jellis / main.yml
Last active October 14, 2016 00:32
---
- name: download certbot file
get_url: url=https://dl.eff.org/certbot-auto dest=/usr/local/sbin/certbot-auto owner=root group=root mode=0744 validate_certs=no
- name: install OS dependencies
shell: certbot-auto --os-packages-only --non-interactive
- include: ssl.yml
with_items: "{{ nginx_vhosts }}"
package main
import (
"fmt"
//"os"
"io/ioutil"
// "gopkg.in/src-d/go-git.v4"
"gopkg.in/yaml.v2"
)
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Config\Repository;
use Illuminate\Http\Request;
class ValidProxies
{
<?php
return [
/*
* Set trusted proxy IP addresses.
*
* Both IPv4 and IPv6 addresses are
* supported, along with CIDR notation.
*
* The "*" character is syntactic sugar
* within TrustedProxy to trust any proxy;
@jellis
jellis / PostgresLog.php
Last active November 16, 2017 03:52
Read RDS logs
<?php
class PostgresLog implements \Iterator
{
protected $fileHandle;
protected $line;
protected $i;