Skip to content

Instantly share code, notes, and snippets.

🙌
writing code

Callum Jones callumj

🙌
writing code
Block or report user

Report or block callumj

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

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 Jul 14, 2017
window_test
View index.html
<html>
<head>
<style type="text/css">
td, th {
text-align: center;
}
.view {
cursor: pointer;
}
@callumj
callumj / collate_excel.rb
Created Jan 4, 2017
Collate multiple CSV into sheets in one Excel workbook using RubyXL
View collate_excel.rb
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 Dec 12, 2014
Stripe final invoice example
View ex.rb
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 Jul 14, 2014
Ansible examples
View 1prep.yml
---
# 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
View merge.go
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 Mar 19, 2014
Helper code for ASP.NET MVC alternating
View Helper.cs
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)
View playlist_hinting.h
@protocol PlaylistHinting<NSObject>
- (SCItem *)nextItemAfter:(SCItem *)item;
@end
@callumj
callumj / README.md
Created Mar 11, 2014
TearUp/Down databases in NUnit tests
View README.md

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.

You can’t perform that action at this time.