Skip to content

Instantly share code, notes, and snippets.

@vtim
vtim / push-apns.groovy
Created May 10, 2012 21:54
Quick Groovy-script for sending push-messages to an iOS-device
@Grapes(
@Grab(group='com.notnoop.apns', module='apns', version='0.1.6')
)
import com.notnoop.apns.APNS
import com.notnoop.apns.ApnsService
import com.notnoop.apns.PayloadBuilder
import com.notnoop.exceptions.NetworkIOException
@vtim
vtim / billing.rb
Last active December 11, 2015 08:19
My first ruby script (for: http://wolfslittlestore.be/2013/01/looking-for-shell-programming-expert/) Usage in terminal: ./billing.rb < input.txt > output.txt
#!/usr/bin/ruby
require 'date'
reLine1 = Regexp.new(/\[b([\d,]+)h\] (.*)/)
reLine2 = Regexp.new(/scheduled (.*)/)
@@hours = nil
@@title = nil
@@date = nil
@@totalHours = 0
@vtim
vtim / cal.rb
Created January 21, 2013 14:37
Query iCal events from MacRuby
#!/usr/local/bin/macruby
framework 'calendarstore'
thirty_days_ago = NSDate.dateWithString((Time.now - (30 * 3600 * 24)).to_s)
today = NSDate.date
store = CalCalendarStore.defaultCalendarStore
predicate = CalCalendarStore.eventPredicateWithStartDate(thirty_days_ago, endDate:today, calendars:CalCalendarStore.defaultCalendarStore.calendars)
store.eventsWithPredicate(predicate).each do |event|
@vtim
vtim / AutoLayout.m
Created May 23, 2014 20:41
Fixes label heights after rotation
- (void)viewDidLayoutSubviews
{
dispatch_async(dispatch_get_main_queue(), ^{
self.titleLabel.preferredMaxLayoutWidth = self.titleLabel.bounds.size.width;
self.dateAuthorLabel.preferredMaxLayoutWidth = self.titleLabel.bounds.size.width;
self.introLabel.preferredMaxLayoutWidth = self.titleLabel.bounds.size.width;
self.textLabel.preferredMaxLayoutWidth = self.titleLabel.bounds.size.width;
});
}