Skip to content

Instantly share code, notes, and snippets.

Avatar

Ben Evans bencevans

View GitHub Profile
@bencevans
bencevans / Tabs2SpacesAndRemoveTrailingSpaces.sh
Created Jun 25, 2014
Tabs 2 Spaces + Remove Trailing Spaces in .js files
View Tabs2SpacesAndRemoveTrailingSpaces.sh
for file in split $(find -path "./*.js"); do
expand --tabs=2 $file | sed 's/[ \t]*$//' > "${file}_temp"
mv "${file}_temp" $file
rm "${file}_temp"
done
@bencevans
bencevans / gist:2857792
Created Jun 2, 2012
SQL Structure for RHoK_NDWI
View gist:2857792
-- phpMyAdmin SQL Dump
-- version 3.4.9
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jun 02, 2012 at 11:56 AM
-- Server version: 5.5.9
-- PHP Version: 5.3.6
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
@bencevans
bencevans / brunel-week.js
Created Oct 6, 2015
Get the Brunel Week Number in JavaScript
View brunel-week.js
var today = new Date()
var secondsInAWeek = 604800
var startDate = new Date(2015, 8, 20)
var weekNo = Math.ceil((today - startDate) / (secondsInAWeek * 1000))
console.log('Current Week Number: ' + weekNo)
@bencevans
bencevans / license
Created Jul 19, 2012 — forked from zzot/license
MIT License Generator
View license
#!/bin/sh -e
# Usage: license
# Prints an MIT license appropriate for totin' around.
#
# $ license > COPYING
#!/bin/sh
echo "Copyright (c) `date +%Y` Ben Evans
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@bencevans
bencevans / backup.php
Created Sep 26, 2012
PHP MySQL Backup Script
View backup.php
<?php
backup_tables('MYSQL_HOST','MYSQL_USER','MYSQL_PASS','MYSQL_DB');
/* backup the db OR just a table */
function backup_tables($host,$user,$pass,$name,$tables = '*')
{
$link = mysql_connect($host,$user,$pass);
View dabblet.html
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="http://stats.bensbit.co.uk/javascripts/bbar.js"></script>
<header>
<div class=container>
<h1>StatsBox</h1>
</div>
</header>
<div id="content" class=container>
View tld2whois.json
{
"ac":"whois.nic.ac",
"ae":"whois.nic.ae",
"af":"whois.nic.af",
"ag":"whois.nic.ag",
"al":"whois.ripe.net",
"am":"whois.amnic.net",
"as":"whois.nic.as",
"at":"whois.nic.at",
"au":"whois.aunic.net",
@bencevans
bencevans / gist:4036162
Last active Oct 12, 2015
localisedEstimate()
View gist:4036162
# localisedEstimate:
# targetlngLat (Array|Object) = Containing the latLng you require a definition for
# Example: [9, 10]
# surroundinglngLats (Array) = Local LngLats (objects) to be used when finding the value of target.
# Example: [{lng:9.21, lat:10.23, value:34}, {lng:8.5, lat:9.78, value:10}]
# valueKey (String) = Key used for value in surroundinglngLats Objects.
# Example: 'NDWI'
localisedEstimate = (targetlngLat, surroundinglngLats, valueKey) ->
@bencevans
bencevans / gist:4036327
Created Nov 8, 2012
Mongoose Bootstrap.coffee
View gist:4036327
mongoose = require 'mongoose'
db = mongoose.createConnection(config.mongo.host, config.mongo.db);
db.on 'error', console.error.bind(console, 'connection error:')
db.once 'open', () ->
console.log 'Connected to DB'
schemaFiles = fs.readdirSync './db/schemas'
for filename in schemaFiles
View dabblet.css
/**
* SoundForcast
*/
* { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; }
body {
background: linear-gradient(180deg, #111, #000);