Skip to content

Instantly share code, notes, and snippets.

Okke Timm okket

Block or report user

Report or block okket

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Reflections.swift
import Foundation
func typestring(x : Any) -> String
{
if let obj = x as? NSObject {
return NSStringFromClass((x as NSObject).dynamicType)
}
// Native Swift
switch x {
View QuickLook.swift
// Custom QuickLook objects in Playground, see
// http://ericasadun.com/2014/06/26/swift-adding-custom-quick-look-to-your-classes/
import UIKit
@objc class BezierCircle {
var color : UIColor
var path : UIBezierPath
var radius : Double
init (_ radius : Double, _ color : UIColor = UIColor.redColor()) {
View TableView.swift
import UIKit
class PlainTableViewController: UITableViewController {
var dataSource = String[]()
override func viewDidLoad() {
super.viewDidLoad()
dataSource = ["one","two","three"]
tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell")
View Dockerfile
FROM iojs:1.5.0
RUN npm install -g bower
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY bower.json /usr/src/app/
RUN bower install --allow-root
@okket
okket / gist:fca8983296c031ea4eb6
Last active Aug 29, 2015
libvirt get ip address
View gist:fca8983296c031ea4eb6
# Method 1:
#
# https://rwmj.wordpress.com/2010/10/26/tip-find-the-ip-address-of-a-virtual-machine/
arp -an | grep $(virsh dumpxml $VIRTUAL_MACHINE_NAME | grep '<mac' | grep -o '\([0-9a-f][0-9a-f]:\)\+[0-9a-f][0-9a-f]') | grep -o '\([0-9]\{1,3\}\.\)\+[0-9]\{1,3\}'
# Method 2: (needs guest-agent)
#
# http://dustymabe.com/2013/07/14/find-guest-ip-address-using-qemu-guest-agent/
@okket
okket / Links
Last active Jan 27, 2016
WWDC 2015 HD Videos Download Links
View Links
View WebKit.swift
// WebKit Window in 30 lines of Swift code
// see http://practicalswift.com/2014/06/27/a-minimal-webkit-browser-in-30-lines-of-swift/
import Cocoa
import WebKit
let application = NSApplication.sharedApplication()
application.setActivationPolicy(NSApplicationActivationPolicy.Regular)
let window = NSWindow(contentRect: NSMakeRect(0, 0, 800, 600), styleMask: NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask, backing: .Buffered, defer: false)
window.center()
window.title = "Minimal Swift WebKit Browser"
View application.controller.js
import Ember from 'ember';
var counter=1;
export default Ember.Controller.extend({
model: [{id: 2, mark: 'blue'},{id: 1, mark: 'red'}],
appName: 'Ember Twiddle',
count: counter,
shipmentType: 'regularDelivery',
actions: {
View application.controller.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
View application.controller.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
You can’t perform that action at this time.