Skip to content

Instantly share code, notes, and snippets.

View twogood's full-sized avatar

David Eriksson twogood

View GitHub Profile
@alganet
alganet / opa.php
Created May 27, 2012 01:36
A HATEOAS, RESTful HTTP client for PHP.
<?php
use Respect\Http\Hypermedia as hy;
//All synopses from movies featuring Will Smith as an actor.
hy::with("netflix", "http://api.netflix.com/")
->with("schema", "http://schemas.netflix.com/")
->get("netflix/catalog/people", array('term' => 'Will Smith'))
->rel("schema/catalog/person/filmography")
->rel("schema/catalog/titles/synopsis")->send();
@MAOliver
MAOliver / AbstractSoapProvider
Created September 27, 2012 13:35
JAX-RS / Jersey Implementation of a SOAP consumer / producer. This lets you annotate your methods with application/soap+xml for soap 1.2 or text/xml for soap 1.1 and use it just like any other media type. Original idea from http://aruld.info/soap-over-res
package com.mao.jaxb.util;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
@jcavar
jcavar / TimeAgo
Created May 11, 2014 15:16
DateUtils getRelativeTimeSpanString method which cares about time zone
/**
* DateUtils getRelativeTimeSpanString methods which cares about time zone
* @param date date for which you want time ago
* @param timeZone time zone in which is date
* @return time ago string
*/
public static String timeAgoFromDate(Date date, TimeZone timeZone) {
TimeZone defaultTimeZone = TimeZone.getDefault();
TimeZone.setDefault(timeZone);
@dmorgantini
dmorgantini / AddNumbersService.java
Created August 13, 2012 14:37
Use SOAP with dropwizard
package com.example.helloworld.resources;
import javax.jws.WebMethod;
@javax.jws.WebService(
name = "AddNumbersPortType",
serviceName = "AddNumbersService",
targetNamespace = "http://duke.example.org")
@javax.jws.soap.SOAPBinding(
style = javax.jws.soap.SOAPBinding.Style.DOCUMENT,
@jerclarke
jerclarke / Google_OAuth2.php
Last active February 17, 2018 19:40
Google_OAuth2.php from Google Analyticator v.6.4.3 with modifications to fix "Fatal error: Uncaught exception 'Google_AuthException'" See revision history for details on what I changed to fix the error. See this wordpress.org support forum posting about the issue: http://wordpress.org/support/topic/solution-for-fatal-error-uncaught-exception-goo…
<?php
/*
* Copyright 2008 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("StandardSample.Tests")]
@JamesKyburz
JamesKyburz / node-inspect-docker
Last active July 29, 2018 13:54
debug server-base-docker processes with node --inspect-brk
#!/usr/bin/env bash
service=$1
if [ "`uname`" == "Darwin" ] && ! [ -x "$(command -v chrome-cli)" ]; then
brew install chrome-cli
fi
docker-compose kill $service
docker-compose rm -f $service
@andyvanee
andyvanee / Makefile
Created March 21, 2016 16:41
Export docker-machine environment variables in a makefile
#
# Run `make ENVIRONMENT=machinename` to override the default
#
ENVIRONMENT=default
TLS_VERIFY=$(shell docker-machine env $(ENVIRONMENT) | grep 'DOCKER_TLS_VERIFY=".*"' | cut -d\" -f2)
HOST=$(shell docker-machine env $(ENVIRONMENT) | grep 'DOCKER_HOST=".*"' | cut -d\" -f2)
CERT_PATH=$(shell docker-machine env $(ENVIRONMENT) | grep 'DOCKER_CERT_PATH=".*"' | cut -d\" -f2)
MACHINE_NAME=$(shell docker-machine env $(ENVIRONMENT) | grep 'DOCKER_MACHINE_NAME=".*"' | cut -d\" -f2)
export DOCKER_MACHINE_NAME=$(MACHINE_NAME)
@lisachenko
lisachenko / SplClassLoader.php
Created November 3, 2011 06:13 — forked from jwage/SplClassLoader.php
PSR-0 SplClassLoader
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.
@kevinswiber
kevinswiber / hal.json
Created July 7, 2012 14:56
JSON Siren vs. HAL Representations
{
"_links": {
"self": { "href": "/orders" },
"next": { "href": "/orders?page=2" },
"find": { "href": "/orders{?id}", "templated": true }
},
"_embedded": {
"orders": [{
"_links": {
"self": { "href": "/orders/123" },