Skip to content

Instantly share code, notes, and snippets.

View callumj's full-sized avatar
🙌
writing code

Callum Jones callumj

🙌
writing code
View GitHub Profile

Keybase proof

I hereby claim:

  • I am callumj on github.
  • I am callumj (https://keybase.io/callumj) on keybase.
  • I have a public key whose fingerprint is 27C2 6E66 2C8B 759D C7C8 98AC 9CDF BAFF 07E0 F16D

To claim this, I am signing this object:

@callumj
callumj / index.html
Last active July 14, 2017 22:58
window_test
<html>
<head>
<style type="text/css">
td, th {
text-align: center;
}
.view {
cursor: pointer;
}
@callumj
callumj / collate_excel.rb
Created January 4, 2017 18:15
Collate multiple CSV into sheets in one Excel workbook using RubyXL
files = Dir.glob("#{ENV["FOLDER"]}/**.csv").sort
files.each do |file|
worksheet = workbook.add_worksheet(file.gsub("#{ENV["FOLDER"]}/", "").gsub(".csv", "").gsub("*", ""))
row_indx = 0
CSV.foreach(file) do |row|
row.each_with_index do |cell, cell_indx|
worksheet.add_cell(row_indx, cell_indx, cell)
end
row_indx += 1
end
@callumj
callumj / ex.rb
Created December 12, 2014 22:28
Stripe final invoice example
Params: {"id"=>"evt_15918WAOjoYioo6eh6ubIhG3", "created"=>1418420384, "livemode"=>false, "type"=>"invoice.payment_failed", "data"=>{"object"=>{"date"=>1418416740, "id"=>"in_1590BkAOjoYioo6e7zU6p7za", "period_start"=>1418416740, "period_end"=>1418416740, "lines"=>{"object"=>"list", "total_count"=>2, "has_more"=>false, "url"=>"/v1/invoices/in_1590BkAOjoYioo6e7zU6p7za/lines", "data"=>[{"id"=>"ii_1590BkAOjoYioo6eFYIKO43B", "object"=>"line_item", "type"=>"invoiceitem", "livemode"=>false, "amount"=>121999, "currency"=>"usd", "proration"=>false, "period"=>{"start"=>1418416740, "end"=>1418416740}, "subscription"=>nil, "quantity"=>nil, "plan"=>nil, "description"=>"Host 'rails-4198' 122 hours at 1000.00c/hour", "metadata"=>{}}, {"id"=>"ii_1590BkAOjoYioo6em1eascIv", "object"=>"line_item", "type"=>"invoiceitem", "livemode"=>false, "amount"=>136999, "currency"=>"usd", "proration"=>false, "period"=>{"start"=>1418416740, "end"=>1418416740}, "subscription"=>nil, "quantity"=>nil, "plan"=>nil, "description"=>"Host 'test2-9598'
@callumj
callumj / 1prep.yml
Created July 14, 2014 13:04
Ansible examples
---
# Configures the system for deploying My School Day
- name: Ensure backend directory exists
file: path=/apps/backend state=directory owner=app group=apps mode=0770
- name: Ensure shared directory exists
file: path=/apps/shared state=directory owner=app group=apps mode=0770
- name: Ensure shared sub directories exist
@callumj
callumj / merge.go
Last active August 29, 2015 13:59
Merge
func mergeIntoBaseArchive(baseArchive ArchiveInfo, basedir string, contents []string, file string) {
var mapped map[string]bool
mapped = make(map[string]bool)
for _, item := range contents {
stripped := strings.Replace(item, basedir, "", 1)
mapped[stripped] = true
}
// tar pntr for copy
dupe, dupeErr := os.Create(file)
@callumj
callumj / Helper.cs
Created March 19, 2014 07:15
Helper code for ASP.NET MVC alternating
public class OddEvenWrapper<T>
{
public T Object { get; set; }
public bool Even { get; set; }
}
public static IEnumerable<OddEvenWrapper<T>> AlternateOddEven<T>(IEnumerable<T> list)
{
bool even = false;
foreach(T obj in list)
@callumj
callumj / playlist_hinting.h
Created March 17, 2014 14:04
PlaylistHinting
@protocol PlaylistHinting<NSObject>
- (SCItem *)nextItemAfter:(SCItem *)item;
@end
@callumj
callumj / README.md
Created March 11, 2014 09:31
TearUp/Down databases in NUnit tests

Database helper for NUnit tests

I've found the need to interact with an actual database context during my NUnit tests (as opposed to abstracting away), I couldn't find any ways to achieve this so I've written my own simple TestHelper.

Basically this give you access to TestHelper.testContext, which will create the context and migrate the test database for the first time.