Skip to content

Instantly share code, notes, and snippets.

@jezhalford
jezhalford / gist:dd4c7e99e068ddfdc352dd1a7a7afaf9
Created January 23, 2019 11:44
indent-rainbow colours for grey indent shading in VSCode
{
"indentRainbow.colors": [
"rgba(16,16,16,0.2)",
"rgba(32,32,32,0.2)",
"rgba(48,48,48,0.2)",
"rgba(64,64,64,0.2)",
"rgba(80,80,80,0.2)",
"rgba(96,96,96,0.2)",
"rgba(112,112,112,0.2)",
"rgba(128,128,128,0.2)",
@jezhalford
jezhalford / grafana-text-panel-api.html
Last active March 11, 2018 21:49
Display API results in a grafana text panel
<!--
Heavily based on https://github.com/grafana/grafana/issues/1816#issuecomment-137827966,
with some simplification and modifications for newer version of Grafana
-->
<div>
<script type="text/javascript">
(function() {
// get a reference to the result container (this is a div at the bottom of this script)
var elem = $('#myPanel')
@jezhalford
jezhalford / sonar-csv.js
Last active December 11, 2015 11:56
Here's an easy to use tool that downloads issues from SonarQube and outputs them in CSV format
#!/usr/bin/env node
/*
* Downloads open issues from SonarQube and outputs them as a CSV file
*/
var request = require("request");
var json2csv = require("json2csv");
var util = require("util");
@jezhalford
jezhalford / cause-deadlock.php
Created August 6, 2015 13:42
Cause a MySQL Deadlock
<?php
/*
SQL -
CREATE TABLE innodb_deadlock_maker(a int primary key) engine=innodb;
*/
$dbA = new DB(); // Get two instances of whatever class you use to handle DB connections
$dbB = new DB(); // and do any initialisation you need
$dbA->connect(); // and open two separate connections
@jezhalford
jezhalford / trawl.sh
Created April 16, 2015 13:25
Trawl for broken links
wget --spider -o ./wget.log -r -p http://www.example.com
grep -B 2 '\.\.\. 40[0-9]\|\.\.\. 50[0-9]' wget.log | sed '/Reusing/d' | sed 's/^HTTP.*\.\.\. //' | sed 's/--.*-- //' | sed '/^--$/d' > broken-links.log
@jezhalford
jezhalford / constraints.sql
Created March 30, 2015 15:21
Get DROP and CREATE statements for all foreign key constraints on a given table.
-- source http://stackoverflow.com/a/13764961/86780
SELECT `DROP`,`CREATE` FROM (
SELECT
CONCAT("ALTER TABLE `", `K`.`TABLE_NAME`, "` DROP FOREIGN KEY `", `K`.`CONSTRAINT_NAME`, "`;") "DROP",
CONCAT("ALTER TABLE `",
`K`.`TABLE_NAME`,
"` ADD CONSTRAINT ",
"`fk_",
`K`.`TABLE_NAME`,
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/bin/sh
#
# Execute phing commands inside a vagrant VM, without having
# to `vagrant ssh` first.
#
CMD="cd /vagrant && phing $@"
vagrant ssh --command "cd /vagrant && $CMD"
@jezhalford
jezhalford / crontab2puppet.html
Last active December 21, 2015 07:28
Thing to turn crontabs into puppet manifests
<!doctype html>
<html>
<head>
<title>crontab2puppet - Convert a crontab to a puppet manifest.</title>
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</head>
<body style="padding: 20px">
<h1>crontab2puppet</h1>