Skip to content

Instantly share code, notes, and snippets.

View nickgartmann's full-sized avatar

Nick Gartmann nickgartmann

View GitHub Profile
@nickgartmann
nickgartmann / clone-database
Last active August 29, 2015 13:59
Bash script to capture and clone a heroku database into a local development database.
if test -z $1 || test -z $2
then
printf "Usage: clone-database heroku-app-name database-name\n"
exit
fi
echo "Capturing backup"
heroku pgbackups:capture -e -a $1
echo "Pulling dump"
curl -o /tmp/$1-latest.dump `heroku pgbackups:url -a $1`
@nickgartmann
nickgartmann / Gemfile
Created June 24, 2014 14:45
Rake task to grab recently updated cordova projects from github
gem 'rest-client', '~> 1.6.7'
gem 'nokogiri'
@nickgartmann
nickgartmann / application.js
Created October 4, 2014 00:12
Stack trace when trying to use websockets on phoenix 0.4.1
var socket = new Phoenix.Socket("/ws");
socket.join("ship", "topic", {}, function(channel) {
channel.on("connect", function(message) {
console.log("joined")
})
});
defmodule Pew.Ship do
use Phoenix.Channel
:timer.apply_interval(1000, __MODULE__, :gc, [])
def gc() do
IO.puts "stuff"
end
def join(socket, "join", msg) do
@nickgartmann
nickgartmann / localdocker
Last active August 29, 2015 14:08
Put localdocker into your hosts file on OS X
#! /bin/bash
# Get the ip from boot2docker
boot2docker_ip=$(sudo -u $SUDO_USER boot2docker ip 2>&1 | awk '{ print $NF }' | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n//g')
hosts=`cat /etc/hosts | sed "s/^.*localdocker.*$//g"`
echo "$hosts" > /etc/hosts
echo "$boot2docker_ip localdocker" >> /etc/hosts
var socket = new Phoenix.Socket(PewMiddle.config.socketPath);
PewMiddle.requestGame = function(username, callback) {
socket.join(PewMiddle.config.channel, "lobby", {username: username}, function(channel) {
var player = null;
channel.on("player:created", function(message) {
player = message;
});
channel.on("game:created", function(game) {
callback(game.id, player);
17:06:25.586 [error] #PID<0.258.0> running Spacegame.Endpoint terminated
Server: localhost:4000 (http)
Request: GET /ws
** (exit) an exception was raised:
** (ErlangError) erlang error: [reason: %Protocol.UndefinedError{description: nil, protocol: String.Chars, value: %{"thin" => "one"}}, mfa: {Phoenix.Endpoint.CowboyHandler, :websocket_handle, 3}, stacktrace: [{String.Chars, :impl_for!, 1, [file: 'lib/string/chars.ex', line: 3]}, {String.Chars, :to_string, 1, [file: 'lib/string/chars.ex', line: 17]}, {Logger, :truncate, 2, [file: 'lib/logger.ex', line: 492]}, {Logger, :log, 3, [file: 'lib/logger.ex', line: 404]}, {Spacegame.GameChannel, :event, 3, [file: 'web/channels/game.ex', line: 44]}, {Phoenix.Channel.Transport, :dispatch, 4, [file: 'lib/phoenix/channel/transport.ex', line: 102]}, {Phoenix.Channel.Transport, :dispatch, 4, [file: 'lib/phoenix/channel/transport.ex', line: 67]}, {Phoenix.Transports.WebSocket, :ws_handle, 2, [file: 'lib/phoenix/transports/websocket.ex', line: 45]}], msg: {:text, "{\"cha
var fs = require( 'fs' ),
Encoder = require( 'node-html-encoder' ).Encoder,
MachineGroupService = require( '../../core/services/MachineGroupService.js' ),
ApplicationService = require( '../../core/services/ApplicationService.js' ),
path = require( 'path' ),
walk = require('../utilities/DirectoryWalker.js'),
ApplicationService = require( '../../core/services/ApplicationService.js' ),
appService = new ApplicationService(),
uaParser = require('ua-parser');
setPlaylist: function( tracks, icd_id, callback ) {
//use track to find album and track number
//all tracks on album with higher track number than
//this should be added to `media_playlist` table
//( maybe clear `media_playlist` out first? )
// console.log( 'AudioRepository.setPlaylist(): not yet implemented!!' );
var q = squel.delete().from( 'media_playlist' ).where("ecms_id=" + icd_id);
this._delete( q.toString(), function( result ) {
var i = 0;
defimpl Plug.Exception, for: Ecto.NoResultsError do
def status(_exception), do: 404
end