Skip to content

Instantly share code, notes, and snippets.

View tylergannon's full-sized avatar

Tyler Gannon tylergannon

  • Ciudad de Colon, Costa Rica
  • 22:31 (UTC -06:00)
View GitHub Profile
@tylergannon
tylergannon / config.py
Last active November 5, 2017 13:17
restful SGE sample configuration file
"""
module: config
Note that this module defines three classes for three different applications.
You are free in your own configurations, to define separate files.
# The Restfful SGE app only listens to the RestfulSgeConfig class.
Loads the application configuration file, checking the following places:
@tylergannon
tylergannon / stylesheet.rb
Created October 17, 2016 04:11
Example PDF style declaration
module Stylesheet
extend ActiveSupport::Concern
include PdfStylesheet
PAGE_BREAK_RULES = [nil, 600, 200, 200, 100, 100].freeze
MARGIN_TOP_MM = 25
MARGIN_BOTTOM_MM = 30
MARGIN_LEFT_MM = 25
MARGIN_RIGHT_MM = 25
@tylergannon
tylergannon / gist:7690997
Created November 28, 2013 12:19
Use HTTParty gem for making HTTP requests over unix domain sockets.
###########################################################
# net/socket_http.rb
###########################################################
module Net
# Overrides the connect method to simply connect to a unix domain socket.
class SocketHttp < HTTP
attr_reader :socket_path
# URI should be a relative URI giving the path on the HTTP server.
[dance_card_test] pwd 11:41:55 ☁ master ☂ ✖ ⚡ ✭
/Users/tyler/src/dev/dance_card_test
[dance_card_test] open github-mac://openrepo//`pwd` 11:41:57 ☁ master ☂ ✖ ⚡ ✭
The file /Users/tyler/src/dev/dance_card_test/github-mac:/openrepo/Users/tyler/src/dev/dance_card_test does not exist.
[dance_card_test] open github-mac://openrepo//Users/tyler/src/dev/dance_card_test 11:42:30 ☁ master ☂ ✖ ⚡ ✭
The file /Users/tyler/src/dev/dance_card_test/github-mac:/openrepo/Users/tyler/src/dev/dance_card_test does not exist.
[dance_card_test] open github-mac://openRepo/Users/tyler/src/dev/dance_card_test 11:43:02 ☁ master ☂ ✖ ⚡ ✭
The file /Users/tyler/src/dev/dance_card_test/github-mac:/openRepo/Users/tyler/src/dev/dance_card_test does not exist.
[dance_card_test] open github-mac://openRepo//Users/tyler/src/dev/dance_card_test 11:43:24 ☁ master ☂ ✖ ⚡ ✭
@tylergannon
tylergannon / gist:5801397
Created June 17, 2013 23:21
Managing JDBC resource objects carefully
public class DBHelper {
private static String serverip = "xxx";
private static String database = "xxx";
private static String dbuser = "xxx";
private static String password = "xxx";
public static void closeConnection(Connection connection) {
try { if (connection != null) connection.close(); }
catch (Exception e) {
// Do error stuff
@tylergannon
tylergannon / gist:5241972
Created March 25, 2013 23:49
A hectic stylesheet
body {
padding-top: 50px;
padding-left: 80px; }
.flash {
position: absolute;
left: 0%;
font-size: 50pt;
font-family: 'VT323', cursive;
top: 0; }
@tylergannon
tylergannon / gist:5240802
Last active December 15, 2015 09:49
Starting template for a rails app to be used for HTML app development.
# Write our own Gemfile.
file 'Gemfile', <<-CODE
source 'https://rubygems.org'
gem 'rails', '4.0.0.beta1'
group :assets do
gem 'sass-rails', '~> 4.0.0.beta1'
gem 'coffee-rails', '~> 4.0.0.beta1'
@tylergannon
tylergannon / gist:5240295
Created March 25, 2013 20:14
Gemfile for html apps
source 'https://rubygems.org'
gem 'rails', '4.0.0.beta1'
gem 'sqlite3'
group :assets do
gem 'sass-rails', '~> 4.0.0.beta1'
gem 'coffee-rails', '~> 4.0.0.beta1'
gem 'uglifier', '>= 1.0.3'
@tylergannon
tylergannon / gist:5240176
Created March 25, 2013 20:02
View Class for a MineSweeper Implementation.
class Game
constructor: (@size, @mines) ->
@size ?= 8
@mines ?= 10
@boom = false
@squares = (new Square(true) for num in [1..@mines])
for num in [@mines..(@size*@size)-1]
@squares.push(new Square(false))
@shuffle()
@tylergannon
tylergannon / gist:5067370
Created March 1, 2013 20:08
Lunar Dates in CoffeeScript
class LunarDate
constructor: (@year, @month, @day, @hour) ->
i = Date.parse(@getSolarDateString())
the_data = null
for data in LunarDate.date_table
if i < data[0]
days_diff = Math.floor((i - the_data[0]) / (24 * 60 * 60 * 1000))
@epoch = the_data[1]