Skip to content

Instantly share code, notes, and snippets.

View caseyamcl's full-sized avatar

Casey McLaughlin caseyamcl

View GitHub Profile
@caseyamcl
caseyamcl / example.php
Created December 21, 2018 18:23
PHPOAIPMH example of using metadata commands in the iterator.
<?php
$myEndpoint = \Phpoaipmh\Endpoint::build('http://WHATEVER-URL-SERVICE.com/...');
foreach ($myEndpoint->listRecords('oaidc') as $item) {
$data = $item->metadata->children('http://www.openarchives.org/OAI/2.0/oai_dc/');
$rows = $data->children('http://purl.org/dc/elements/1.1/');
// .. now do whatever..
}
@caseyamcl
caseyamcl / php-alpine.rsa.pub
Created September 15, 2017 14:56
Temporary
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvJHIjkW9Qo+aST95YwH5
dBgehdjcbacrO8TMquvHoGoa9yGHHnWmCxA2BtRoUcOPphjpY5bRVi5y179cheps
gmswORIFqFz8Nj0if/zOXTs+7sQ3Tq+cdtiuFM+u+ezAwWdPWgt8ZHF4BVoNpHrd
B4uxR8+23Ie24HAFMIsxNLI6erRrDvGvBmmv+iapyxkb/jrAb1vRjqc5Cu9Dq1aH
YchYhV9/Fp9dto9nZ6LG7LM0LA9pDu9eG1GavvRB7NDMyInudJyv/lbDYH0a6asJ
Af/aLz05NBSMtTYArJd9gZ0meYJVYCDACWPHKxsa/PXK0h9sVhXWSbKKritFLN6+
/wIDAQAB
-----END PUBLIC KEY-----
@caseyamcl
caseyamcl / run.php
Created September 17, 2015 20:32
Entity Generator for Doctrine?
<?php
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
require_once "vendor/autoload.php";
// Create a simple "default" Doctrine ORM configuration for Annotations
$isDevMode = true;
$config = Setup::createYAMLMetadataConfiguration(array(__DIR__), $isDevMode);
@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!!
<?php
class ContentItemMapper implements MapperInterface
{
private $isLoaded = false;
// ------------------------------------------------------
public function __construct(MapperCollection $mappers, IdentityMap $idMap, SplFileInfoToContentItem $transformer, $contentPath)
{
@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)
@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 / 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 / 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 / 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