Skip to content

Instantly share code, notes, and snippets.

View stevenmaguire's full-sized avatar
:shipit:
Resolving those deltas...

Steven Maguire stevenmaguire

:shipit:
Resolving those deltas...
View GitHub Profile
@stevenmaguire
stevenmaguire / arrays.js
Created June 26, 2012 02:08
js-assessment responses
if (typeof define !== 'function') { var define = require('amdefine')(module); }
define(function() {
return {
indexOf : function(arr, item) {
return arr.indexOf(item)
},
sum : function(arr) {
var total = 0;
@stevenmaguire
stevenmaguire / js-palindrome-checker.js
Created July 29, 2012 01:31
JavaScript method to determine if a word is a palindrome
function isPalindrome(word) {
var letters = word.split('');
var length = letters.length;
for (i in letters) {
if (letters[i] != letters[(length-1)-i]) return false;
}
return true;
}
@stevenmaguire
stevenmaguire / ISBN13to10.sql
Last active February 19, 2021 15:36
MySQL function to convert ISBN13 to ISBN10
DROP FUNCTION IF EXISTS `ISBN13to10`;
delimiter //
CREATE FUNCTION `ISBN13to10`(isbn13 VARCHAR(50)) RETURNS varchar(50) CHARSET utf8
BEGIN
DECLARE isbn10 VARCHAR(13);
DECLARE i VARCHAR(13);
DECLARE sum INT;
DECLARE chk INT;
DECLARE chkchar VARCHAR(3);
@stevenmaguire
stevenmaguire / ISBN10to13.sql
Last active May 31, 2023 12:18
MySQL function to convert ISBN10 to ISBN13
DROP FUNCTION IF EXISTS `ISBN10to13`;
delimiter //
CREATE FUNCTION `ISBN10to13`(isbn10 VARCHAR(50)) RETURNS varchar(50) CHARSET utf8
BEGIN
DECLARE isbn13 VARCHAR(13);
DECLARE i INT;
DECLARE chk INT;
IF (LENGTH(ISBN10) > 10) THEN
RETURN ISBN10;
@stevenmaguire
stevenmaguire / laravel-nearby-locations-query-scope.php
Last active March 28, 2020 22:40
Laravel (Illuminate) query builder scope to list neighboring locations within a given distance from a given location
<?php
/**
* Query builder scope to list neighboring locations
* within a given distance from a given location
*
* @param Illuminate\Database\Query\Builder $query Query builder instance
* @param mixed $lat Lattitude of given location
* @param mixed $lng Longitude of given location
* @param integer $radius Optional distance
a
ii
about
above
according
across
39
actually
ad
adj
DELIMITER ;
DROP FUNCTION IF EXISTS urlencode;
DELIMITER |
CREATE FUNCTION urlencode (s VARCHAR(4096)) RETURNS VARCHAR(4096)
DETERMINISTIC
CONTAINS SQL
BEGIN
DECLARE c VARCHAR(4096) DEFAULT '';
DECLARE pointer INT DEFAULT 1;
DECLARE s2 VARCHAR(4096) DEFAULT '';
DELIMITER ;
DROP FUNCTION IF EXISTS urldecode;
DELIMITER |
CREATE FUNCTION urldecode (s VARCHAR(4096)) RETURNS VARCHAR(4096)
DETERMINISTIC
CONTAINS SQL
BEGIN
DECLARE c VARCHAR(4096) DEFAULT '';
DECLARE pointer INT DEFAULT 1;
DECLARE h CHAR(2);

Requirements

  • Docker Machine + Docker
  • curl
  • A Virtualbox-driven Docker Machine whose name is store in an env var $DOCKER_MACHINE_NAME.

Usage

http://git.io/vcj2P is a shortened url for the raw plist file.