Skip to content

Instantly share code, notes, and snippets.

View StephenOTT's full-sized avatar
:shipit:
...

Stephen Russett StephenOTT

:shipit:
...
View GitHub Profile
@StephenOTT
StephenOTT / Time Tracking Reporting options.md
Last active August 29, 2015 13:57
Time Tracking Reporting Options for GitHub Time Tracking
  • Get all Issues Time

  • Get all Issues Budget Get all issues Time and Budget (meta report that merges output from two previous reports)

  • Get a Issue Time

  • Get a Issue Budget Get a Issue Time and Budget (meta report that merges output from two previous reports)

  • Get all Issues Time for a Milestone

  • Get all Issues Budget for a Milestone

@StephenOTT
StephenOTT / task lists.rb
Last active January 1, 2016 02:19
Get Tasks from a GitHub Issue Body or Comment using RegEx to parse issue body or issue comment for a task.
def get_comment_tasks (commentBody, taskStatus = :incomplete)
tasks = []
startStringOpen = /\-\s\[\s\]\s/
startStringClosed = /\-\s\[x\]\s/
endString = /[\r\n]|\z/
if taskStatus == :incomplete
tasksInBody = commentBody.scan(/#{startStringOpen}(.*?)#{endString}/)
@StephenOTT
StephenOTT / octokit date issue.rb
Created December 16, 2013 22:53
Code sample showing GitHub API issue with the Code Commits Octokit.rb Octokit.commits() returned date fields
require 'octokit'
commits = Octokit.commits("StephenOTT/Test1")
commitComments = Octokit.commit_comments("StephenOTT/Test1", "b08156d2327b47c5bfb2543b224cd6aee726add5")
commits.each do |x|
puts x.attrs[:commit].attrs[:author].attrs[:date]
end
@StephenOTT
StephenOTT / GChart Literal Object Code Gen.rb
Last active December 26, 2015 17:49
Ruby code for generating Google Chart JS Literal Objects. Comes with sample code at bottom.
require 'json'
class GenerateGDataTable
def initialize
@columnArray = []
@rowArray = []
end
@StephenOTT
StephenOTT / Determine Missing Months between Two Dates - Ruby
Last active December 23, 2015 14:09
Ruby Method for getting the Dates/months (this version is designed for getting months/First day of each month, and then parse out day later) between two dates. Example: Provide Date A and Date B and get month and Year(s) between two dates. Does not return Date A and Date B, only the dates between those dates. See: https://github.com/StephenOTT/a…
def addMissingMonths (datesHash)
count = 0
datesHash.keys.each do |x|
result = []
if x != datesHash.keys.last
(x+1.month).upto(datesHash.keys[count+1]-1.month) do |a|
# result << [a.month,a.year]
result << [a.at_beginning_of_month]
end
@StephenOTT
StephenOTT / gist:6614278
Last active December 23, 2015 09:28
Sample of groupdate question Causing formatting changes Comment out require 'groupdate' to see different in terminal output
require 'date'
require 'groupdate'
class DateManipulate
def initialize
@creationDateCount = [{"_id"=>{"year"=>2012, "month"=>10}, "number"=>53}, {"_id"=>{"year"=>2012, "month"=>12}, "number"=>58}, {"_id"=>{"year"=>2011, "month"=>8}, "number"=>8}, {"_id"=>{"year"=>2012, "month"=>11}, "number"=>75}, {"_id"=>{"year"=>2011, "month"=>9}, "number"=>58}, {"_id"=>{"year"=>2013, "month"=>9}, "number"=>67}, {"_id"=>{"year"=>2013, "month"=>6}, "number"=>561}, {"_id"=>{"year"=>2012, "month"=>9}, "number"=>102}, {"_id"=>{"year"=>2013, "month"=>5}, "number"=>609}, {"_id"=>{"year"=>2012, "month"=>7}, "number"=>84}, {"_id"=>{"year"=>2010, "month"=>12}, "number"=>1}, {"_id"=>{"year"=>2013, "month"=>7}, "number"=>595}, {"_id"=>{"year"=>2013, "month"=>3}, "number"=>253}, {"_id"=>{"year"=>2012, "month"=>6}, "number"=>129}, {"_id"=>{"year"=>2012, "month"=>2}, "number"=>95}, {"_id"=>{"year"=>2012, "month"=>4}, "number"=>50}, {"_id"=>{"year"=>2013, "month"=>8}, "number"=>736}, {"_id"=>{"year"=>2013, "month"=>1}, "number"=>242
@StephenOTT
StephenOTT / gist:6458046
Created September 6, 2013 00:27
Analysis methods for Mongodb for Health Data
def analyzeRestaurantNameCount
return restaurantNameCount = @coll.aggregate([
{ "$project" => {doc:{str:{fs_fnm: 1}}}},
{ "$group" => {_id: "$doc.str.fs_fnm", number: { "$sum" => 1 }}},
{ "$sort" => {"_id" => 1 }}
])
end
def analyzeRestaurantCategoryCount
restaurantCategoryCount = @coll.aggregate([
@StephenOTT
StephenOTT / gist:6446293
Created September 5, 2013 05:07
Old code for converting date formats from XML format into proper format for Mongodb - Originally built for use with City of Ottawa Health Inspection data but was dropped in favour of xpath and conversion during variable creation
def convertDatesForMongo(parsedXML)
# Fixes Date Strings in Facility/Restarant information
# If statement is used to ensure that the date is not null otherway the strptime would throw a exception if it was null
# If Statement is only used because of data inconsistancies with Health Inspection Data
if parsedXML["doc"]["str"]["fs_fcr_date"] != nil
parsedXML["doc"]["str"]["fs_fcr_date"] = DateTime.strptime(parsedXML["doc"]["str"]["fs_fcr_date"][0..-5], '%Y-%m-%d %H:%M:%S').to_time.utc
end
if parsedXML["doc"]["str"]["fs_fefd"] != nil
@StephenOTT
StephenOTT / gist:6312278
Created August 22, 2013 20:20
Ruby version of xml parsed for health inspection with multiple inspections and comment/qtext xml version: https://gist.github.com/StephenOTT/6312264
{"numFound"=>"1",
"start"=>"0",
"doc"=>
{"str"=>
{"app_id"=>"fsi",
"fs_fa_en"=>"Ottawa West",
"fs_fa_fr"=>"Ottawa Ouest",
"fs_facd"=>"OTW",
"fs_faid"=>"9DC7C571-6145-47B1-B837-85E1F6A26244",
"fs_fcr"=>"YES",
@StephenOTT
StephenOTT / gist:6312264
Created August 22, 2013 20:19
health inspection Single record with multiple inspection comments and question text
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/templates/xslt/inspections/inspections_details_en.xsl"?>
<response>
<result numFound="1" start="0">
<doc>
<str name="app_id">fsi</str>
<str name="fs_fa_en">Ottawa West</str>
<str name="fs_fa_fr">Ottawa Ouest</str>
<str name="fs_facd">OTW</str>
<str name="fs_faid">9DC7C571-6145-47B1-B837-85E1F6A26244</str>