Skip to content

Instantly share code, notes, and snippets.

Avatar

James Cridland jamescridland

View GitHub Profile
@jamescridland
jamescridland / commandline
Created Jan 4, 2020
To add an image to a podcast
View commandline
ffmpeg -i podnews200103.mp3 -i podnews200103.jpeg -map 0:0 -map 1:0 -c copy -id3v2_version 3 -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (front)" podnews200103withart.mp3
@jamescridland
jamescridland / links.php
Created Nov 13, 2019
[MOD] get total clicks per link in a newsletter
View links.php
@jamescridland
jamescridland / chromebook-gatsby.md
Last active Feb 3, 2019
Chromebook setup for Gatsby
View chromebook-gatsby.md

This assumes you're running ChromeOS with Linux inside.

Turn on Linux

  • Hit the clock in the taskbar
  • Hit the settings cog
  • Type "Linux" in the search at the top
  • Press the big button that enables Linux ('turn on' then 'install').

Wait for a bit while it does its thing. (Wait for a bit, honestly, don't idly search the web, things will go wrong).

View total by useragent.sql
SELECT count(*),useragent FROM cloudfront_logs
WHERE "date" BETWEEN DATE '2019-01-01' AND DATE '2019-01-31'
AND uri LIKE '/audio/%' AND bytes>750000 GROUP BY useragent ORDER BY useragent
@jamescridland
jamescridland / reports.php
Last active Jul 26, 2019
An additional API for Sendy, that offers a report for a specific sent campaign
View reports.php
<?php include('../_connect.php');?>
<?php include('../../includes/helpers/short.php');?>
<?php
/*
---Little helper function from james@crid.land for reporting
Put this file in a new folder within the /api/ folder, called "reporting", and call it "reports.php". (Or whatever you like).
Call by POST to api/reporting/reports.php with the following mandatory elements
'api_key' => (your API key)
View example.php
$re = '/[\*].*(gimlet)(.+?\n\n)/';
$str = '* Google Play Music have [buttons for your podcasts](https://play.google.com/intl/en_us/badges-music/). Note, however, that outside the US, they just redirect to the front page of Google Play. One step forward, one step back.
* Recommended: [ReplyAll investigates Facebook](https://gimletmedia.com/episode/109-facebook-spying/) using your phone\'s microphone to spy on your conversations. And, how to stop them doing it, even though they\'re not.
* Event: on now in Austin TX, USA: [Media Tech Week](https://mediatechweek.live/)';
preg_match($re, $str, $matches);
var_dump($matches);
@jamescridland
jamescridland / ofcom.php
Created Oct 16, 2016
A quick check to see if Ofcom's txparams have updated themselves
View ofcom.php
<?php
// A small piece of code to check the Last-Modified header in PHP
// The below currently (on 16 October) returns:
// "Tue, 11 Oct 2016 11:26:59"
// ... so that's when it was last updated.
// I'm told that this URL is a permanent link. My assumption is that any update to the
// DAB, FM or AM data will produce an update for this main file; even though my own code
// actually just uses the .csv files.
View private.xml
<?xml version="1.0"?>
<root>
<devicevendordef>
<vendorname>LOGITECH</vendorname>
<vendorid>0x046d</vendorid>
</devicevendordef>
<deviceproductdef>
<productname>LOGITECH_R800</productname>
<productid>0xc538</productid>
@jamescridland
jamescridland / gist:a0783283b90550046f87
Created Sep 15, 2015
The easiest EU cookie solution code ever?
View gist:a0783283b90550046f87
<!--
Put this just under your <HEAD> in HTML.
Note - it displays once, and once only.
It requires you to run Google Analytics on your website.
If a user deletes their cookies, it'll appear again.
You can test it by going into Incognito Mode.
-->
<script type='text/javascript'>
@jamescridland
jamescridland / extract_info_from_googleplus.php
Last active Dec 29, 2015
This will scrape information from a Google+ page, if given a URL. The "followers" uses a class that doubtless will change; but you can hopefully see how it works.
View extract_info_from_googleplus.php
<?
$url['url']='https://plus.google.com/107170242245169064947/posts';
if (isset($url['url'])) {
$d = new DOMDocument();
@$d->loadHTML(file_get_contents($url['url']));
$xpath = new DOMXPath($d);
You can’t perform that action at this time.