Skip to content

Instantly share code, notes, and snippets.

View permissions_query
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
View benchmark.rb
#!/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
View updateProgress.swift
timer = NSTimer(timeInterval: updateInterval, target: self, selector: "updateProgress", userInfo: nil, repeats: true)
NSRunLoop.mainRunLoop().addTimer(timer, forMode: NSRunLoopCommonModes)
@MMercieca
MMercieca / .swift
Created Nov 20, 2015
func updateIntervals
View .swift
func updateIntervals() {
let now = NSDate()
let thisSlice = now.timeIntervalSinceDate(lastUpdate)
updateProgress(thisSlice)
ellapsedTime += thisSlice
if ellapsedTime >= nextAlarmTime {
alert()
}
@MMercieca
MMercieca / .swift
Created Nov 20, 2015
func timerFired
View .swift
func timerFired() {
if (mode == Mode.Running) {
updateIntervals()
updateProgress()
}
}
@MMercieca
MMercieca / CircleProgress.swift
Created Nov 20, 2015
Circular Progress track
View CircleProgress.swift
//
// CircleProgress.swift
// CircleProgress
//
// Created by Matthew Mercieca on 8/21/15.
// Copyright (c) 2015 Mutually Human. All rights reserved.
//
import UIKit
@MMercieca
MMercieca / UpdateIntervals1.swift
Created Nov 20, 2015
Update Intervals first try
View UpdateIntervals1.swift
func updateIntervals() {
if (intervals.count == 0) {
return;
}
let currentInterval = intervals.first!
if currentIntervalProgress == 0.0 {
currentColor = currentInterval.color()
speedLabel.text = currentInterval.description()
alertSpeed(currentInterval)
View IntervalLoop.swift
for _ in 1...3 {
for _ in 1...5 {
intervals.append(Speed.Jog)
intervals.append(Speed.Run)
intervals.append(Speed.Sprint)
}
intervals.append(Speed.Break)
}
...
View Speed.swift
//
// Speed.swift
// 30-20-10
//
// Created by Matthew Mercieca on 8/14/15.
// Copyright (c) 2015 Mutually Human. All rights reserved.
//
import UIKit