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 / _breakpoints.scss
Last active August 29, 2015 14:06
A nice way to do breakpoints in Sass
//
// Primary breakpoints
// ===================
// Define the projects breakpoints here. Some sensible defualts are included.
//
/**
* Less than
* =========
*
@CraigChilds94
CraigChilds94 / retrieve.php
Created January 13, 2015 13:42
Handy function to parse a php file and store the result without outputting it.
<?php
/**
* Include a php file, and return the
* parsed content. Allows you to use php
* files instead of custom templating
* engines such as blade.
*
* Takes an array of data to pass to the included
* file and calls extract() on it.
@CraigChilds94
CraigChilds94 / gist:4ef05074960c59c2bf3a
Created January 22, 2016 21:26 — forked from dsibilly/gist:2992412
Node.js clustered HTTP server example
(function () {
'use strict';
var cluster = require('cluster'),
http = require('http'),
os = require('os'),
/*
* ClusterServer object
@CraigChilds94
CraigChilds94 / array_helpers.php
Last active March 1, 2016 16:42
Useful array functions.
<?php
/**
* Only get the values for keys which
* exist in the array.
*
* Example: array_only_keys(['a' => 'b', 'c' => 'd'], ['a']); // returns ['a' => 'b']
*
* @param Array $haystack The array you want values from
* @param Array|String $keys Array of keys, or a key which you want from the haystack
@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
*/
@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 / 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 / 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
<?php
if (!function_exists('dea_validate')) {
/**
* Validate a provided DEA number is valid.
*
* @param string $deaNumber
* @return boolean
*/

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: