Skip to content

Instantly share code, notes, and snippets.

View dandelauro's full-sized avatar

dan delauro dandelauro

  • sarasota, fl
  • 05:50 (UTC -04:00)
View GitHub Profile
@dandelauro
dandelauro / s3-proxy.conf
Created June 10, 2016 15:11
Nginx server block for proxying S3
server {
listen 80;
server_name *.cogclient.com;
access_log /var/log/nginx/cogclient.access.log;
error_log /var/log/nginx/cogclient.error.log;
location / {
resolver 8.8.8.8;
set $bucket "happycog-static.s3-website-us-east-1.amazonaws.com";
rewrite ^([^.]*[^/])$ $1/ permanent;
@dandelauro
dandelauro / s3-deploy.sh
Created June 10, 2016 15:09
Bash script to copy files to S3
repo=$(basename "$PWD")
branch=$(git symbolic-ref --short -q HEAD)
aws s3 cp public/ s3://happycog-static/$repo/$branch --recursive --acl=public-read
if [[ "$branch" = "master" ]]; then
url="http://$obj.cogclient.com"
else
url="http://$branch.$repo.cogclient.com"
fi
slackText="$repo: $branch branch was just deployed to $url"
curl -X POST --data-urlencode "payload={\"text\": \"$slackText\"}" https://hooks.slack.com/services/XXXXXXXXXX/XXXXXXXXXX
@dandelauro
dandelauro / circle.yml
Created June 10, 2016 15:08
CircleCI project configuration for continuous S3 deployments.
machine:
node:
version: 5.10.0
dependencies:
override:
- npm install
- npm install -g grunt-cli
cache_directories:
- "node_modules"
test:
@dandelauro
dandelauro / .env
Last active April 23, 2016 00:24
using .env files and basic rewrite with the built-in php server
# add your env variables
DATABASE_HOST='127.0.0.1'
DATABASE_USER='root'
DATABASE_PASS='root'
DATABASE_NAME='database_name'
@dandelauro
dandelauro / HomeController.php
Created January 21, 2016 15:34
A sample "Home" controller using Twig and Mustache PHP templating.
<?php
namespace App\Http\Controllers;
class HomeController extends Controller
{
public function show()
{
$dataJsonAsPhpArray = array(
“title” => “This is my title.”,
“subTitle” => “There are many like it, but this one is mine.”,
@dandelauro
dandelauro / PatternLoader.php
Created January 21, 2016 04:05
A mustache php pattern loader for Laravel and Pattern Lab.
<?php
namespace App\Extensions\Mustache;
use Mustache_Loader;
class PatternLoader implements Mustache_Loader
{
private $baseDir;
private $patterns = array();
# API authentication
from social.apps.django_app.utils import strategy
from rest_framework.authtoken.models import Token
from rest_framework.views import APIView
from rest_framework import parsers
from rest_framework import renderers
from rest_framework.authentication import get_authorization_header
from rest_framework.response import Response
@dandelauro
dandelauro / bq.py
Created December 7, 2013 03:33
app engine / bigquery server to server authentication through service account
import httplib2
from apiclient.discovery import build
from oauth2client.client import SignedJwtAssertionCredentials
#
PROJECT_ID = '############'
SERVICE_ACCOUNT_EMAIL = '############-##################@developer.gserviceaccount.com'
SCOPE = 'https://www.googleapis.com/auth/bigquery'
P12_CERT = 'PATH/TO/###########################-privatekey.p12'
#