Skip to content

Instantly share code, notes, and snippets.

View caseyamcl's full-sized avatar

Casey McLaughlin caseyamcl

View GitHub Profile
@caseyamcl
caseyamcl / where_exists.sql
Created October 11, 2011 13:18
MySQL WHERE Exists
SELECT * FROM orders AS orders_table
WHERE EXISTS
(
SELECT * FROM orders_actions AS actions_table
WHERE actions_table.orders_id = orders_table.id
AND
(
actions_table.action = 'order_created'
OR actions_table.action = 'order_pending'
)
@caseyamcl
caseyamcl / index.php
Created April 12, 2012 02:00
Casey's Development Server Homepage
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Development Server!</title>
<style type='text/css'>
h1, h2 {
font-family: Verdana, sans-serif;
text-align: center;
}
@caseyamcl
caseyamcl / drush_makefile
Created May 3, 2012 19:06
Casey's Drupal Development Kickstarter (ensure drush 5.x+ is installed first)
; ----------------
; Generated makefile from http://drushmake.me
; Permanent URL: http://drushmake.me/file.php?token=005dea072d80
; ----------------
;
; This is a working makefile - try it! Any line starting with a `;` is a comment.
; Core version
; ------------
; Each makefile should begin by declaring the core version of Drupal that all
@caseyamcl
caseyamcl / fakemail
Created January 2, 2014 16:08
Fakemail - A simple BASH script for piping mail to a /tmp/fakemail/DATE
#!/bin/bash
#Make the output directory if not exists
if [ ! -d /tmp/fakemail ];
then
mkdir -p /tmp/fakemail
fi
#Create today's fakemail file
OUTPUTFILE=/tmp/fakemail/`date +'%F'`.txt
@caseyamcl
caseyamcl / sample.html
Last active December 9, 2022 23:44
Sample HTML Content
<!-- Need to add form elements and apply styles:
http://coding.smashingmagazine.com/2007/05/10/70-expert-ideas-for-better-css-coding/
http://www.threestyles.com/tutorials/css-tips-for-better-typography/
-->
<h1>This is the Example Content H1 Tag</h1>
<p>
The HTML example content is designed to provide some dummy content to help
you design your typography and general CSS styles, and to ensure that you've
accounted for <em>every single</em> HTML5 tag in your stylesheet.
@caseyamcl
caseyamcl / primes.c
Created June 26, 2014 14:46
Simple C Program
#include<stdio.h>
int main()
{
int n, i = 3, count, c;
printf("Enter the number of prime numbers required\n");
scanf("%d",&n);
if ( n >= 1 )
@caseyamcl
caseyamcl / bbreceiver.py
Created July 31, 2014 13:53
BB Receiver Public GIST
#!/usr/bin/env python
# -------------------------------------------------------------------
#
# Simple HTTP Server to listen to requests from Bitbucket
#
# @author Casey McLaughlin <caseyamcl@gmail.com>
#
# Usage:
# - To run the server: python server.py [/path/to/working/repo/directory] [port] [logfile]
# - Port is optional and defaults to 8085
@caseyamcl
caseyamcl / pw
Last active March 1, 2021 13:44
Linux CLI Password Generator
#!/bin/bash
#
# Need to generate passwords frequently on the Linux CLI?
#
# This script creates a password and copies it to the clipboard.
#
# 1. Ensure you have 'pwgen' and 'xclip' installed
# (sudo apt-get install pwgen xclip)
# 2. Download this script and make it executable:
# (sudo wget -O /usr/bin/pw https://gist.githubusercontent.com/caseyamcl/53f0c91e9ef1b42abb57/raw/pw && sudo chmod 755 /usr/bin/pw)
<?php
class ContentItemMapper implements MapperInterface
{
private $isLoaded = false;
// ------------------------------------------------------
public function __construct(MapperCollection $mappers, IdentityMap $idMap, SplFileInfoToContentItem $transformer, $contentPath)
{
@caseyamcl
caseyamcl / come-on-really.md
Created February 19, 2015 18:20
Ahhhhhhhhh!!!!

HOLY GAWD PEOPLE..

  • Don't write all your new code on the production machine!
  • Use a VCS!
  • Document your functions using DocBlocks!
  • Document your API (at least LIST the endpoints)... I have to decipher the meaning from your code, and that isn't really clear
  • Use a single identifier as the primary ID in the API for a resource (ie don't return a list of group ids for listing groups and then expect the group name as the identifying parameter for modifying a group)
  • Use a consistent model for representing the same data model in different endpoints!
  • Don't concatenate fields in the API results unless there is a good reason to (e.g first name and last name)
  • Don't expose the underlying database logic. This is leaky abstraction, especially when you do it inconsistently!!