Skip to content

Instantly share code, notes, and snippets.

@cookpete
cookpete / csv2table.php
Last active October 11, 2015 10:28
Convert CSV to HTML table
function csv2table($file, $delimiter = ','){
$handle = fopen($file, 'r');
while($line = fgetcsv($handle)) $str .= '<tr><td>'.implode('</td><td>', $line).'</td></tr>';
fclose($handle);
return '<table>'.$str.'</table>';
}
@cookpete
cookpete / parse-params.js
Last active December 13, 2015 16:49
Create a global object containing key/value pairs of URL parameters
function parseParams(string){
var obj = {};
string.replace(/[?&]?([^=]+)=([^&]*)/g, function(m,k,v) { obj[k] = v; });
return obj;
}
var url = parseParams(location.search);
// Build an object of versions (to the nearest float) from a user agent style string
// Supports irregular version numbers like 1_2_3
// parseVersions("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36");
// returns { "Mozilla": 5, "Intel Mac OS X": 10.8, "AppleWebKit": 537.36, "Chrome": 27, "Safari": 537.36 }
function parseVersions(string) {
var versions = {};
string.replace(/\b([a-z][a-z\s]+).\b(\d+[^a-z]\d+)/gi, function(match, software, version) {
versions[software] = parseFloat(version.replace(/\D+/g, '.'));
@cookpete
cookpete / load-save.php
Last active August 29, 2015 13:56
Super simple loading and saving of PHP data, with compression
function load($path){
return json_decode(uncompress(file_get_contents($path)));
}
function save($data, $path){
$fh = fopen($path, 'w');
fwrite($fh, compress(json_encode($data)));
fclose($fh);
}
function compress($string){
return gzdeflate($string, 9);
mkdir DIR_NAME
cd DIR_NAME
git init --bare
echo -e '#!/bin/sh\nGIT_WORK_TREE=/var/sites/SITE_PATH/public_html/DIR_NAME git checkout -f' > hooks/post-receive
chmod +x hooks/post-receive
cd ..
# Generate keys if you haven't done so already
ssh-keygen -t rsa
# Append key to file on remote server
cat ~/.ssh/id_rsa.pub | ssh user@host 'mkdir -p .ssh && cat >> .ssh/authorized_keys'

Changelog

All notable changes to this project will be documented in this file.

Generated by auto-changelog.

17 August 2017

  • Bug Fix: Error message is stripped if stack exists #49
  • fix: Error message is stripped if stack exists b32f9b3
  • Bump to @rc.1 0342294
@cookpete
cookpete / blank-check-movies.json
Created December 3, 2018 10:32
Data dump from Blank Check podcast movie analysis
This file has been truncated, but you can view the full file.
[
{
"adult": false,
"backdrop_path": "/v6lRzOActebITc9rizhNAdwQR1O.jpg",
"belongs_to_collection": {
"id": 10,
"name": "Star Wars Collection",
"poster_path": "/iTQHKziZy9pAAY4hHEDCGPaOvFC.jpg",
"backdrop_path": "/d8duYyyC9J5T825Hg7grmaabfxQ.jpg"
},
@cookpete
cookpete / film-list.txt
Created December 3, 2018 10:55
List of films included in Blank Check film analysis
Star Wars: Episode I - The Phantom Menace (1999)
The Judge (2014)
Star Wars: Episode II - Attack of the Clones (2002)
The Fantastic Four (1994)
Fantastic Four (2005)
Fantastic Four: Rise of the Silver Surfer (2007)
Fantastic Four (2015)
Star Wars: Episode III - Revenge of the Sith (2005)
Star Wars (1977)
The Empire Strikes Back (1980)
movie movie runtime episode runtime episode no series ratio
My Neighbor Totoro 86 151 233 Howl's Moving Podcastle 1.76
The Keep 96 168 218 Michael Mannsplaining/Cast of the Podhicans 1.75
Stop Making Sense 88 138 248 Stop Making Podcasts 1.57
Space Jam 88 134 185 Other 1.52
Porco Rosso