Skip to content

Instantly share code, notes, and snippets.

View agileapplications's full-sized avatar

Tobias Miesel agileapplications

  • Agile Applications Tobias Miesel
  • Zurich, Switzerland
View GitHub Profile
@agileapplications
agileapplications / AppDelegate.swift
Last active April 14, 2021 07:54
Sample implementation to receive unencrypted ably messages via native Apple Push Notification Service (APNS) delivered by ably in foreground and background.
//
// AppDelegate.swift
// swift-ios
//
import Foundation
import UIKit
import Ably
class AppDelegate: NSObject, UIApplicationDelegate, ARTPushRegistererDelegate, UNUserNotificationCenterDelegate {
@agileapplications
agileapplications / gist:4023561
Created November 6, 2012 08:52
Basecamp SCRUM Calculator
// add this code as a bookmark and use it on a basecamp project page
javascript: if ($('body').find('ul#calculation').length > 0) {
var list = $('body').find('ul#calculation');
list.empty();
} else {
var list = $('<ul>').attr('id', 'calculation');
$('body').append(list);
}
@agileapplications
agileapplications / PrimeFinder
Created October 25, 2010 20:38
Sum all prime numbers until a given number
class PrimeFinder
def initialize
@prime_list = []
@prime_sum = 0
end
def prime?(number)
sqrt = Math.sqrt(number).to_i
@prime_list.each do |prime|
if prime <= sqrt
def authenticates_many(name, options = {})
options[:session_class] ||= name.to_s.classify.constantize
options[:relationship_name] ||= options[:session_class].klass_name.underscore.pluralize
class_eval <<-"end_eval", __FILE__, __LINE__
def #{name}
find_options = #{options[:find_options].inspect} || #{options[:relationship_name]}.scope(:find)
find_options.delete_if { |key, value| ![:conditions, :include, :joins].include?(key.to_sym) || value.nil? }
@#{name} ||= Authlogic::AuthenticatesMany::Association.new(#{options[:session_class]}, find_options, #{options[:scope_cookies] ? "self.class.model_name.underscore + '_' + self.send(self.class.primary_key).to_s" : "nil"})
end
end_eval