Skip to content

Instantly share code, notes, and snippets.

View ParkinT's full-sized avatar

Thom Parkin ParkinT

View GitHub Profile
#!/usr/bin/env ruby
require 'open-uri'
require 'json'
print 'Github Username: '
username = gets.chomp
# get gists
puts 'Downloading gists list'
gists_str = open("https://api.github.com/users/#{username}/gists").read
#!/usr/bin/env ruby
# gem install sinatra --no-document
# gem install github-markdown --no-document
# usage: ruby markedown.rb then, in Nitrous, simply select 'Preview -> Port 3000' on the menu
require 'sinatra'
require 'github/markdown'
# Set port for compatability with Nitrous.IO
configure :development do
require 'webrick'
Port = 3000
Directory = Dir::pwd
WEBrick::HTTPServer.new(
Port: Port,
DocumentRoot: Directory
).start
#!/usr/bin/env ruby
# Author : Emad Elsaid (https://github.com/blazeeboy)
require 'json'
require 'open-uri'
require 'uri'
require 'net/http'
CODE_LIMIT = 10
$url = "https://eval.in/"
$languages = {
@ParkinT
ParkinT / README.md
Created April 19, 2014 03:02
Rails app will not start after Capistrano deploy on Digital Ocean Droplet. Error "504 Gateway Timeout"

Symptoms

A previously working Rails app, after a successful Capistrano deploy cycle, stops responding and the server returns the http status code 504.

Troubleshooting

I was able to successfully access the Droplet by way of SSH. Looking at the logs I noticed the unicorn server was having trouble [re]starting.

tail -f /home/unicorn/log/unicorn.log
@ParkinT
ParkinT / Autoparts_Menu.png
Last active August 29, 2015 14:01
Constructing Web-facing pages, from Github Gists, on Bl.ocks.org - Nitrous-Charged
Autoparts_Menu.png
module Bacon
class Context
def expect(obj)
Bacon::Should.new(obj)
end
end
end
@ParkinT
ParkinT / NitrousCharged.png
Last active August 29, 2015 14:01
Recently, I needed to make changes to a MySQL database on a deployed application. My development setup is on a Nitrous.IO box but I found it necessary to make a quick surgical edit of the database {the client had messed up an input and it was easiest to simply edit the record's association}
NitrousCharged.png
@ParkinT
ParkinT / Net-SSH-Authentication.md
Last active August 29, 2015 14:02
Recently I encountered a strange error in a capistrano script that has always worked in the past. Apparently, it was the result of an update to the net-ssh gem on my Nitrous box

Nitrous-Charged Gist Cap Deploy rollback on Net::SSH::Authentication error

I use Nitrous as my primary development environment. The ability to work on any one of a number of projects at any time and from anywhere is simply too convenient to overlook. {As a matter of fact, I am writing this on a Nitrous box from a hospital bed!}

On a site I have been maintaining and continuously updating (on a drogo - Ruby/Rails Nitrous box), my capistrano deploy script failed one day.

One day my Capistrano deploy for the site returned [deploy:update_code] exception while rolling back: Capistrano::ConnectionError, connection failed for: ...

The error message was a bit confusing because it pointed to SSH authentication

@ParkinT
ParkinT / DockerCLIalias
Last active August 29, 2015 14:07 — forked from caike/Dockerfile
# ~/.bash_aliases
# Kill all running containers.
alias dockerkill='docker kill $(docker ps -a -q)'
# Delete all stopped containers.
alias dockercleanc='printf "\n>>> Deleting stopped containers\n\n" && docker rm $(docker ps -a -q)'
# Delete all untagged images.
alias dockercleani='printf "\n>>> Deleting untagged images\n\n" && docker rmi $(docker images -q -f dangling=true)'