Skip to content

Instantly share code, notes, and snippets.

View cpliakas's full-sized avatar

Chris Pliakas cpliakas

  • Greater Boston Area
View GitHub Profile
@cpliakas
cpliakas / simple-logger.go
Last active August 29, 2015 14:20
Stoopid simple leveled logger fo Go
package main
import (
"io"
"io/ioutil"
"log"
"os"
)
const (
@cpliakas
cpliakas / drupal-workflow-alter-roles
Created December 2, 2014 05:42
Patch to Drupal Workflow module to alter roles
diff --git a/includes/Entity/WorkflowState.php b/includes/Entity/WorkflowState.php
index 3b01bc1..c064adb 100644
--- a/includes/Entity/WorkflowState.php
+++ b/includes/Entity/WorkflowState.php
@@ -363,6 +363,9 @@ class WorkflowState extends Entity {
$roles = array_merge(array(WORKFLOW_ROLE_AUTHOR_RID), $roles);
}
+ // Allow modules to add or remove roles based on their own business logic.
+ drupal_alter('workflow_user_roles', $roles, $user, $entity_type, $entity);
@cpliakas
cpliakas / goamz-dynamodb
Created November 13, 2014 21:58
Using Goamz to put an item in DynamoDB
package main
import (
"fmt"
"github.com/crowdmob/goamz/aws"
"github.com/crowdmob/goamz/dynamodb"
)
const (
@cpliakas
cpliakas / gorilla-mux-json
Created November 1, 2014 21:08
Gorilla Mux return JSON payload
package main
import (
"log"
"net/http"
"github.com/bitly/go-simplejson"
"github.com/gorilla/mux"
)
@cpliakas
cpliakas / goriall-mux-github-auth
Created October 30, 2014 18:01
Gorilla Mux w/ GitHub authentication
package main
import (
"flag"
"log"
"net/http"
"os"
"github.com/gorilla/mux"
"github.com/stretchr/gomniauth"
@cpliakas
cpliakas / gorilla-mux-example
Last active August 29, 2015 14:08
Gorilla Mux
package main
import (
"log"
"net/http"
"github.com/gorilla/mux"
)
func main() {
@cpliakas
cpliakas / martini-example
Last active August 29, 2015 14:08
Martini snippet, read SSH key w/ command line args
package main
import (
"flag"
"io/ioutil"
"os/user"
"code.google.com/p/go.crypto/ssh"
"github.com/cpliakas/test/hmac"
"github.com/go-martini/martini"
@cpliakas
cpliakas / ant-composer.xml
Created November 26, 2013 01:20
Apache Ant tagets for Composer commands.
<?xml version="1.0" encoding="UTF-8"?>
<project name="Composer Targets" default="build">
<property name="builddir" value="${basedir}/build"/>
<property name="composer" value="${builddir}/composer.phar"/>
<target name="php-check">
<condition property="php" value="php">
<not>
<isset property="${php}"/>
@cpliakas
cpliakas / git-ssh-wrapper
Created January 9, 2013 22:47
An SSH wrapper written in PHP useful when set as the GIT_SSH variable.
#!/usr/bin/env php
<?php
require_once __DIR__ . '/../vendor/autoload.php';
try {
// Get the arguments passed through the command line.
$args = (!empty($_SERVER['argv'])) ? $_SERVER['argv'] : array();
if (!isset($args[0])) {
$args[0] = $_SERVER['PHP_SELF'];
@cpliakas
cpliakas / vagrant-ubuntu-1204
Created October 11, 2012 00:44
Vagrant base box script for Ubuntu 12.04
#!/bin/sh
# curl -L https://bit.ly/vagrant-setup-ubuntu > vagrant-setup.sh
# sudo sh vagrant-setup.sh
set -e
# Add the vagrant user as a password-less sudoer.
TMPFILE=$(mktemp)
echo "vagrant ALL=(ALL) NOPASSWD: ALL" > $TMPFILE