Skip to content

Instantly share code, notes, and snippets.

<?php
class UserManager
{
protected $couchbase;
public function __construct(\Couchbase $couchbase)
{
$this->couchbase = $couchbase;
}
@zgolus
zgolus / UnderscoreToCamelCase
Last active August 29, 2015 14:01
underscore to camel case
<?php
$key = preg_replace_callback(
'#_(\S)#',
function ($matches) {
return strtoupper($matches[1]);
},
$key
);
@zgolus
zgolus / CORS
Created June 25, 2014 18:23
CORS handling with PHP
<?php
// Specify domains from which requests are allowed
header('Access-Control-Allow-Origin: *');
// Specify which request methods are allowed
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
/*
* jQuery < 1.4.0 adds an X-Requested-With header which requires pre-flighting
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W}%c %{g}]'
@zgolus
zgolus / tidy.ini
Created February 27, 2015 23:41
minimal tidy config
#based on http://tidy.sourceforge.net/docs/quickref.html
#HTML, XHTML, XML Options Reference
anchor-as-name: no #?
doctype: omit
drop-empty-paras: no
fix-backslash: no
fix-bad-comments: no
fix-uri:no
hide-endtags: yes #?
#input-xml: yes #?
@zgolus
zgolus / gist:79dc1571c02d3d392ba3
Created May 3, 2015 19:31
console debugging with phpstorm
export XDEBUG_CONFIG="idekey=PHPSTORM"
@zgolus
zgolus / gist:2b7a56c2bc3ae1f6051b
Created September 11, 2015 12:45
one line server
ncat -l 8080 -k -c 'printf 0'
@zgolus
zgolus / 0_reuse_code.js
Created January 12, 2016 07:31
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
import boto3
import pprint
def lambda_handler(event, context):
ec2 = boto3.client('ec2')
resp = ec2.describe_instances(
Filters=[
{
'Name': 'instance-state-name',
'Values': [
FROM fluent/fluentd:v0.12.29
RUN gem install fluent-plugin-elasticsearch -v 1.9.0 && \
gem install fluent-plugin-record-modifier -v 0.5.0
EXPOSE 24224
COPY fluent.conf /etc/fluent.conf
CMD fluentd -c /etc/fluent.conf -p /fluentd/plugins