Skip to content

Instantly share code, notes, and snippets.

View CraigChilds94's full-sized avatar
🏠
Working from home

Craig Childs CraigChilds94

🏠
Working from home
View GitHub Profile
@CraigChilds94
CraigChilds94 / README.md
Created June 11, 2018 16:10
Running Twofishes with Docker

Place the Docker Compose config file in the root of a project folder.

Ensure you've got your Docker Machine setup to use a large amount of memory, try 8GB.

Then run docker-compose up.

Once you've seen the serving http/json on port 8081 message come up, run curl http://0.0.0.0:8081/\?query\=Twatt,Scotland

@CraigChilds94
CraigChilds94 / jquery-svg.js
Created February 1, 2018 18:36
jQuery SVG replacement plugin
$.fn.SVG = function() {
var $img = $(this);
var imgID = $img.attr('id');
var imgClass = $img.attr('class');
var imgURL = $img.attr('src');
return new Promise(function(resolve, reject) {
$.get(imgURL, function(data) {
// Get the SVG tag, ignore the rest
var $svg = $(data).find('svg');
@CraigChilds94
CraigChilds94 / proxy.js
Created November 15, 2017 12:59
Object Proxy-ing
var myObject = {
testing: 'Hello',
};
var myProxiedObject = new Proxy(myObject, {
get: function(target, prop) {
console.log({ type: 'get', target, prop });
return Reflect.get(target, prop);
},
set: function(target, prop, value) {
@CraigChilds94
CraigChilds94 / color.go
Last active September 13, 2024 06:04
Hex to RGB conversion in Go
package main
import (
"fmt"
"strconv"
)
type Hex string
type RGB struct {

Keybase proof

I hereby claim:

  • I am craigchilds94 on github.
  • I am arcraig (https://keybase.io/arcraig) on keybase.
  • I have a public key ASD9qZ1FWPt1mdf02cJu9ccRuq9vNivraONG7IBLkxSzKQo

To claim this, I am signing this object:

<?php
if (!function_exists('dea_validate')) {
/**
* Validate a provided DEA number is valid.
*
* @param string $deaNumber
* @return boolean
*/
@CraigChilds94
CraigChilds94 / main.go
Last active May 1, 2023 21:19
GORM Example
import (
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/sqlite"
"encoding/json"
"fmt"
)
// The model.
type User struct {
gorm.Model
@CraigChilds94
CraigChilds94 / Duplicator.js
Created May 12, 2017 09:51
Row/Block duplicator prototype.
/**
* Duplicate a row by the click of an
* element. Pass a callback to grab the new
* row and handle it how you please.
*
* @param {string} selector
* @param {Function} callback
*/
function Duplicator(selector, callback) {
this.selector = selector;
@CraigChilds94
CraigChilds94 / Templater.js
Created January 24, 2017 14:45
jQuery Templater, when you don't need a whole engine.
/**
* Templater instance, pass in the selector for your template. And
* a key'd object with your data. Use "{{ key }}" in your template
* to replace values from this array.
*/
function Templater(template, data) {
this.template = template;
this.html = $(template).html();
this.data = data;
@CraigChilds94
CraigChilds94 / time_taken.php
Last active April 13, 2016 14:03
Work out time taken to run a block, give it a nice name/label and output a nice message.
<?php
/**
* Work out time taken to run a block, give it a nice name/label
* and output a nice message.
*
* @param string $name
* @param callable $call
* @return mixed
*/