Skip to content

Instantly share code, notes, and snippets.

Justin McNally j-mcnally

Block or report user

Report or block j-mcnally

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@j-mcnally
j-mcnally / Demo.md
Created Jul 16, 2015
Hugo + CaddyServer + Heroku
View Demo.md

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 Jun 17, 2015
Demo Controller
View user.ex
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 Jun 17, 2015
Authentication Plug
View auth.ex
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
View 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
View gist:edc37a5524288430d7b7
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 Aug 29, 2015
Automate Slack invites, for slack chat / community websites. Used by http://struct.tv
View invite.rb
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"
View test
from waitlisted import reservation
res = reservation.create({'email': 'joe@gmail.com'})
print "Your position is " + res.position + " of " + res.total
View gist:b5e60d1465d17e083fd1
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.
View test.haml
.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
View gist:a8c1d1b4145070a27266
needle.post('http://leadpophq.com/external/forms/abc', {"a": "b"})
.on('end', function(response) {
console.log(response)
})
You can’t perform that action at this time.