Skip to content

Instantly share code, notes, and snippets.

@j-mcnally
j-mcnally / deploy.js
Created August 16, 2015 05:44
Using ember-deploy-s3 with Google Cloud Storage
module.exports = {
production: {
buildEnv: 'production', // Override the environment passed to the ember asset build. Defaults to 'production'
store: {
type: "S3",
accessKeyId: "XXX",
secretAccessKey: "XXX",
bucket: "bucket-index",
acl: 'public-read', //optional, e.g. 'public-read', if ACL is not configured, it is not sent
endpoint: "storage.googleapis.com",
@j-mcnally
j-mcnally / Demo.md
Created July 16, 2015 03:51
Hugo + CaddyServer + Heroku

Running Hugo in Theory

  • Use heroku caddybuild pack with git pull

  • Tell Caddy to pull from github repo

  • Post pull command, run hugo on files from git repo

  • Add / Edit articles using github ace editor or git push

  • Caddy pulls repo files and rebuilds hugo site.

TODO

@j-mcnally
j-mcnally / user.ex
Created June 17, 2015 21:35
Demo Controller
defmodule Struct.Api.V1.UserController do
use Phoenix.Controller
alias Poison, as: JSON
import Ecto.Query, only: [from: 2]
plug Struct.AuthenticationPlug
plug :action
def update(conn, _params) do
user = conn.assigns[:current_user]
if user do
@j-mcnally
j-mcnally / auth.ex
Created June 17, 2015 21:33
Authentication Plug
defmodule Struct.AuthenticationPlug do
alias Plug.Conn
alias Phoenix.Status
alias Phoenix.Controller.Errors
alias Poison, as: JSON
import Phoenix.Controller.Connection
import Plug.Conn
import Ecto.Query, only: [from: 2]
def init(opts), do: opts
@j-mcnally
j-mcnally / proxy.py
Last active August 29, 2015 14:19 — forked from bxt/proxy.py
# Originally from http://sharebear.co.uk/blog/2009/09/17/very-simple-python-caching-proxy/
#
# Usage:
# A call to http://localhost:80000/example.com/foo.html will cache the file
# at http://example.com/foo.html on disc and not redownload it again.
# To clear the cache simply do a `rm *.cached`. To stop the server simply
# send SIGINT (Ctrl-C). It does not handle any headers or post data.
import BaseHTTPServer
import hashlib
remote: Installing collected packages: markupsafe, six, PyYAML, webassets, itsdangerous, Jinja2, Werkzeug, python-frontmatter, hamlish-jinja, Flask-Assets, frozen-flask, gunicorn, flask
remote: Running setup.py install for markupsafe
remote: building 'markupsafe._speedups' extension
remote: gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/app/.heroku/python/include/python2.7 -c markupsafe/_speedups.c -o build/temp.linux-x86_64-2.7/markupsafe/_speedups.o
remote: gcc -pthread -shared build/temp.linux-x86_64-2.7/markupsafe/_speedups.o -o build/lib.linux-x86_64-2.7/markupsafe/_speedups.so
remote:
remote: Running setup.py install for PyYAML
remote: checking if libyaml is compilable
remote: gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/app/.heroku/python/include/python2.7 -c build/temp.linux-x86_64-2.7/check_libyaml.c -o build/temp.l
@j-mcnally
j-mcnally / invite.rb
Last active August 29, 2015 14:16
Automate Slack invites, for slack chat / community websites. Used by http://struct.tv
module Slack
class Invite
def call(options)
email = options[:email]
throw "You must call this method with an email" unless email.present?
invite = agent.post("https://#{ENV['SLACK_SUBDOMAIN']}.slack.com/api/users.admin.invite?t=#{Time.now.to_i}",
{"email" => email,
"token" => ENV['SLACK_API_TOKEN'],
"set_active" => "true",
"_attempts" => "1"
from waitlisted import reservation
res = reservation.create({'email': 'joe@gmail.com'})
print "Your position is " + res.position + " of " + res.total
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
.dt.pvx-ns.pvs
.wi-100.tc
.wi-10.fl
 
.wi-100.wi-20-ns.phn-ns.phx.fl
= fa_icon "users", class: "fa-5x"
.f3
Affiliate System
.f5
Lorem impsum