This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a2_table = Arel::Table.new(:a2_table) | |
composed_a2 = Arel::Nodes::As.new(a2_table, assignments_subquery) | |
tasks = Task.arel_table | |
query = tasks.join(a2_table).on(tasks[:id].eq(a2_table[:assigned_to_id])) | |
.where(a2_table[:assigned_to_type].eq('Task')) | |
.with(composed_a2) | |
.project(Arel.sql('tasks.id AS id, tasks.paper_id AS paper_id, a2_table.role_id AS role_id, a2_table.permission_id AS permission_id')) | |
binding.pry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'benchmark' | |
command= "#{ARGV.shift} &> /dev/null" | |
run_times = ARGV.shift.to_i | |
usage = "benchmark.rb <command> <times_to_run>" | |
unless run_times > 0 | |
fail usage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for _ in 1...3 { | |
for _ in 1...5 { | |
intervals.append(Speed.Jog) | |
intervals.append(Speed.Run) | |
intervals.append(Speed.Sprint) | |
} | |
intervals.append(Speed.Break) | |
} | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
timer = NSTimer(timeInterval: updateInterval, target: self, selector: "updateProgress", userInfo: nil, repeats: true) | |
NSRunLoop.mainRunLoop().addTimer(timer, forMode: NSRunLoopCommonModes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func updateIntervals() { | |
let now = NSDate() | |
let thisSlice = now.timeIntervalSinceDate(lastUpdate) | |
updateProgress(thisSlice) | |
ellapsedTime += thisSlice | |
if ellapsedTime >= nextAlarmTime { | |
alert() | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func timerFired() { | |
if (mode == Mode.Running) { | |
updateIntervals() | |
updateProgress() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// CircleProgress.swift | |
// CircleProgress | |
// | |
// Created by Matthew Mercieca on 8/21/15. | |
// Copyright (c) 2015 Mutually Human. All rights reserved. | |
// | |
import UIKit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func updateIntervals() { | |
if (intervals.count == 0) { | |
return; | |
} | |
let currentInterval = intervals.first! | |
if currentIntervalProgress == 0.0 { | |
currentColor = currentInterval.color() | |
speedLabel.text = currentInterval.description() | |
alertSpeed(currentInterval) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Speed.swift | |
// 30-20-10 | |
// | |
// Created by Matthew Mercieca on 8/14/15. | |
// Copyright (c) 2015 Mutually Human. All rights reserved. | |
// | |
import UIKit |