Skip to content

Instantly share code, notes, and snippets.

View electricowl's full-sized avatar
💭
Big Data, Every Day.

Ian Lewis electricowl

💭
Big Data, Every Day.
  • Financial Services, Music Data, Ticketing
  • London
  • LinkedIn in/ianlewis
View GitHub Profile
@electricowl
electricowl / ruby-ftp-get-all-files.rb
Created September 19, 2018 16:24 — forked from beepony/ruby-ftp-get-all-files.rb
ruby ftp list all files
require 'net/ftp'
def scan(ftp, dir)
ftp.chdir(dir)
puts ftp.pwd + "/."
entries = ftp.list('*')
entries.each do |entry|
if entry.split(/\s+/)[0][0,1] == "d" then
scan(ftp, entry.split.last)
else
@electricowl
electricowl / reverse.es
Created May 23, 2016 11:32 — forked from mathieue/reverse.es
Simple apache read only reverse proxy on elasticsearch
<VirtualHost *:80>
ServerName es.yourhost.com
<Proxy balancer://main>
BalancerMember http://127.0.0.1:9200 max=1 retry=5
<Limit GET >
order deny,allow
deny from all
allow from 127.0.0.1
@electricowl
electricowl / async_gpt_purelyfootball.html
Last active August 29, 2015 14:25
Async GPT tags for PurelyFootball
<!-- The tags here are standard inline GPT tags -->
<!-- This is for the HTML <head> section -->
<!--
This calls aysnc GPT. This is the most user-friendly tagging option and decreases load time
If it isn't possible to include this in the HEAD section then drop it in above each of the
inline tags in the same code block.
-->
<head>
@electricowl
electricowl / pf-tags.js
Last active August 29, 2015 14:25
PF Tags
//Raw code to send to PurelyFootball:
// ## Ad slots to drop into the page
<!-- /1101651/Web-All-PurelyFootball-ROS-Leaderboard 320x50 (Multiples allowed)-->
<div class="fanatix-ad-slot-leaderboard" style='height:50px; width:320px;'>
</div>
<!-- /1101651/Web-All-PurelyFootball-ROS-MPU 300x250 (One Instance only)-->
<div id='fanatix-ad-slot-mpu1' style='height:250px; width:300px;'>
@electricowl
electricowl / chartbeat.php
Created July 9, 2015 12:44
Generic Wordpress code for Chartbeat.
<?php
/**
* @author Ian Lewis <ianlewis (at) electricowl.co.uk
* Chartbeat code - generic
* We will only use when it is single (article) page
*
* Some of the code is lifted from the Chartbeat WP plugin. Next step would be to
* make this into a lightweight plugin otherwise drop into functions.php inside your theme
* Ensure that you set chartbeat_account_id (below) to your own account!!!
*/
@electricowl
electricowl / implemented-pf2.html
Last active August 29, 2015 14:20
Purelyfootball adslots. Implemented
<!DOCTYPE html>
<html>
<head>
<title>PurelyFootball unified JS adslots</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
@electricowl
electricowl / statsd_functions
Created April 16, 2015 09:46
Simple way to add statsd logging to existing PHP code
<?php
/**
* Logging functions here.
*
*/
function get_socket() {
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_set_option($sock, SOL_SOCKET, SO_BROADCAST, 1);
return $sock;
@electricowl
electricowl / WP_exclude_from_feeds
Last active August 29, 2015 14:18
Wordpress snippet to exclude a particular category from feeds
<?php
// Exclude category "Exclude from all feeds"
function excludecatfeed( $query )
{
if( is_feed() )
{
$query->set( 'cat', '-5618' );
return $query;
}
@electricowl
electricowl / chunk_data
Created April 2, 2015 09:04
Chunk a pile of data into neat little batches (code snippet)
<?php
define('MAX_ENTRIES_PER_MAP', 5000);
// chunk the data
$chunks = array();
$chunk_data = array();
$chunk_count = 0;
while ($replay = $replays->fetch_array(MYSQLI_ASSOC)) {
if (0 == ($sitemap_counter % MAX_ENTRIES_PER_MAP)) {
server {
server_name grafana.*;
root /usr/share/grafana;
access_log /var/log/nginx/grafana-access.log timed_combined;
access_log /var/log/nginx/grafana-json.event.access.log json_event;
error_log /var/log/nginx/grafana-error.log;
location =/config.js {
alias /etc/grafana/config.js;