Skip to content

Instantly share code, notes, and snippets.

View eonist's full-sized avatar
🎯
Focusing

André J eonist

🎯
Focusing
View GitHub Profile
@eonist
eonist / Retina Mac Icon
Last active March 17, 2016 02:13
Creates Retina Mac Icon
//terminal script:(takes 3 sec to setup) http://stackoverflow.com/questions/12306223/how-to-manually-create-icns-files-using-iconutil
//or drag and drop solution (sketchy website, download is a hex file, no link to devs): https://iconverticons.com/online/
Here's a script to convert a 1024x1024 png (named "Icon1024.png") to the required icns file. Save it to a filed called "CreateICNS.src" in the folder where your png file is then in terminal "cd" to the same folder and type "source CreateICNS.src" to call it:
mkdir MyIcon.iconset
sips -z 16 16 Icon1024.png --out MyIcon.iconset/icon_16x16.png
sips -z 32 32 Icon1024.png --out MyIcon.iconset/[email protected]
sips -z 32 32 Icon1024.png --out MyIcon.iconset/icon_32x32.png
sips -z 64 64 Icon1024.png --out MyIcon.iconset/[email protected]
@eonist
eonist / QuartzOuterShadow.swift
Created December 10, 2015 16:53
Quartz Outer shadow (playground)
import Cocoa
import XCPlayground
import XCTest
class FlippedView:NSView {//Organizes your view from top to bottom
override var flipped:Bool {
get {
return true
}
@eonist
eonist / QuartzInnerShadow.swift
Created December 10, 2015 16:55
Quartz Inner Shadow (playground)
import Cocoa
import XCPlayground
import XCTest
/*
shadow.shadowColor = NSColor.blackColor().colorWithAlphaComponent(1.0)
shadow.shadowOffset = NSMakeSize(0.1, 0.1)
shadow.shadowBlurRadius = 15
*/
extension NSShadow{
@eonist
eonist / NSView overlapping interaction
Created December 15, 2015 07:24
The following code demonstrates how you can handle overlapping tracking areas
import Cocoa
/*
let a = TempNSView(frame:NSRect(0,0,100,100))
a.name = "a"
addSubview(a)
let b = TempNSView(frame:NSRect(50,50,100,100))
b.name = "b"
@eonist
eonist / TranslucentWin.swift
Created January 27, 2016 14:09
Translucent NSWindow Example
class TranslucentWin:NSWindow, NSApplicationDelegate, NSWindowDelegate{
/**
*
*/
override init(contentRect: NSRect, styleMask aStyle: Int, backing bufferingType: NSBackingStoreType, `defer` flag: Bool) {
super.init(contentRect: Win.sizeRect, styleMask: NSTitledWindowMask|NSResizableWindowMask|NSMiniaturizableWindowMask|NSClosableWindowMask|NSFullSizeContentViewWindowMask, backing: NSBackingStoreType.Buffered, `defer`: false)
self.contentView!.wantsLayer = true;/*this can and is set in the view*/
self.backgroundColor = NSColor.greenColor().alpha(0.2)
self.opaque = false
self.makeKeyAndOrderFront(nil)//moves the window to the front
@eonist
eonist / TheEventSystem.swift
Last active April 8, 2016 18:27
A simple event system that propagates events through hierarchical classes
import Foundation
/*
* TODO: Implement the immediate variable if its needed (it would be a way to get assert the 1-level down immediate child an event came from, rather than the origin child which can be many levels deeper in the hirarchy)
*/
class Event{
static var update:String = "eventUpdate"/*Idealy I would name this change but apparently then subclasses can name their const the same*/
var type:String
var origin:AnyObject/*origin sender of event, this could also be weak if you discover a memory leak*/
/*var immediate:Any?*///prev sender of event, may be implemented in the future if needed
@eonist
eonist / markdown.textexpander
Created February 29, 2016 21:59
markdown.textexpander
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>groupInfo</key>
<dict>
<key>expandAfterMode</key>
<integer>0</integer>
<key>groupName</key>
<string>markdown</string>
- [ ] %| | mtd
[%filltext:name=the title:default=here%](%clipboard) | lnk
![%filltext:name=img:default=img%](%clipboard) | img
```%filltext:name=lang% %| ``` | fence
**%clipboard** | bld
~~%clipboard~~ | strike
<img width="%filltext:name=width:default=320%" alt="%filltext:name=img:default=img%" src="https://dl.dropboxusercontent.com/u/2559476/%clipboard"> | rimg
``` %clipboard%| ``` | fe
* [[%clipboard]] | sbi
_%clipboard_ | italic
@eonist
eonist / swift_factory_pattern.swift
Created March 7, 2016 14:49
swift factory pattern
import Foundation
protocol ILayout{
init(_ args:Double...)
}
class Fillet:ILayout{
required init(_ args:Double...){
Swift.print("Fillet: " + "\(args.count)")
}
}
class Margin:ILayout{
@eonist
eonist / CVDisplayLinkOutputCallback.swift
Created March 10, 2016 19:23 — forked from eyeplum/CVDisplayLinkOutputCallback.swift
CVDisplayLinkOutputCallback in Swift
private func createDisplayLink() {
CVDisplayLinkCreateWithActiveCGDisplays(&displayLink)
guard let displayLink = displayLink else {
return
}
let callback: CVDisplayLinkOutputCallback = { (_, _, _, _, _, userInfo) -> CVReturn in
let myView = Unmanaged<MyView>.fromOpaque(COpaquePointer(userInfo)).takeUnretainedValue()
dispatch_async(dispatch_get_main_queue()) {
myView.update()