Skip to content

Instantly share code, notes, and snippets.

View kicsipixel's full-sized avatar
🚜
Working hard...

Szabolcs Toth kicsipixel

🚜
Working hard...
View GitHub Profile
MKMapRect zoomRect = MKMapRectNull;
for (id <MKAnnotation> annotation in mapView.annotations) {
MKMapPoint annotationPoint = MKMapPointForCoordinate(annotation.coordinate);
MKMapRect pointRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 0, 0);
if (MKMapRectIsNull(zoomRect)) {
zoomRect = pointRect;
} else {
zoomRect = MKMapRectUnion(zoomRect, pointRect);
}
}
@kicsipixel
kicsipixel / gist:7485565
Created November 15, 2013 14:55
I am trying to make this work. Found here: http://help.mandrill.com/entries/23257181-Using-the-Mandrill-Ruby-Gem But I get the following error message all the time: "D, [2013-11-15T17:53:53.464938 #2046] DEBUG -- : HTTPI POST request to mandrillapp.com (excon) /Users/szabolcs/.rvm/gems/ruby-2.0.0-p195/gems/mandrill-0.0.4/lib/mandrill/api.rb:51:i…
require 'mandrill'
m = Mandrill::API.new 'myAPIKey'
message = {
:subject=> "Hello from the Mandrill API",
:from_name=> "Your name",
:text=>"Hi message, how are you?",
:to=>[
{
:email=> "recipient@theirdomain.com",
:name=> "Recipient1"
@kicsipixel
kicsipixel / ViewController.swift
Created April 28, 2016 18:21
Simple view-based NSTableView
import Cocoa
class ViewController: NSViewController {
@IBOutlet var tableView: NSTableView!
var data: [[String: String]]?
override func viewDidLoad() {
super.viewDidLoad()
@kicsipixel
kicsipixel / CustomButtonCell.swift
Created May 29, 2017 10:02
CustomUI controller
import Cocoa
class CustomButtonCell: NSButtonCell {
override func drawBezel(withFrame frame: NSRect, in controlView: NSView) {
if (self.isHighlighted) {
CustomUI.drawButtonPushed()
} else {
CustomUI.drawButton()
}
@kicsipixel
kicsipixel / CustomWindow.swift
Created November 13, 2018 18:07
Custom NSWindow
import Cocoa
class CustomWindow: NSWindowController {
override func windowDidLoad() {
super.windowDidLoad()
self.configureWindowAppearance()
}
@kicsipixel
kicsipixel / CustomWindowDarkMode.swift
Last active November 13, 2018 18:32
CustomWindow with Dark mode
import Cocoa
class CustomWindow: NSWindowController {
// This variable will hold our colours
var windowColor = NSColor(named: "WindowColor") {
didSet {
configureWindowAppearance()
}
}
@kicsipixel
kicsipixel / CustomWindowToolbar.swift
Created November 14, 2018 10:17
Custom Window with Toolbar image
import Cocoa
class CustomWindow: NSWindowController {
@IBOutlet var modeIndicator: NSToolbarItem!
var windowColor = NSColor(named: "WindowColor") {
didSet {
configureWindowAppearance()
}
@kicsipixel
kicsipixel / ViewController.swift
Created November 14, 2018 10:42
ViewController with NSAppearance KVO
import Cocoa
class ViewController: NSViewController {
private var appearanceChangeObservation: NSKeyValueObservation?
@IBOutlet var imageView: NSImageView!
override func viewDidLoad() {
super.viewDidLoad()
private var window: NSWindow?
func applicationDidFinishLaunching(_ aNotification: Notification) {
let windowSize = NSSize(width: 480, height: 240)
let screenSize = NSScreen.main?.frame.size ?? .zero
let rect = NSMakeRect(screenSize.width/2 - windowSize.width/2, screenSize.height/2 - windowSize.height/2, windowSize.width, windowSize.height)
window = NSWindow(contentRect: rect, styleMask: [.miniaturizable, .closable, .resizable, .titled], backing: .buffered, defer: false)
window?.title = "No Storyboard Window"
window?.makeKeyAndOrderFront(nil)
@kicsipixel
kicsipixel / Person.swift
Last active April 30, 2020 10:33
Cocoa Bindings
import Foundation
class Person: NSObject {
@objc dynamic var firstName: String
@objc dynamic var lastName: String
@objc dynamic var mobileNumber: String
init(firstName: String, lastName: String, mobileNumber: String) {
self.firstName = firstName
self.lastName = lastName