Skip to content

Instantly share code, notes, and snippets.

View n3tr's full-sized avatar

Jirat Ki. n3tr

View GitHub Profile
@n3tr
n3tr / ViewController.swift
Last active November 5, 2016 11:59
TouchBarItemsIdentifier
// ViewController.swift
fileprivate extension NSTouchBarCustomizationIdentifier {
static let counterTouchBar = NSTouchBarCustomizationIdentifier("com.n3tr.countertouchbar.counter")
}
fileprivate extension NSTouchBarItemIdentifier {
static let increase = NSTouchBarItemIdentifier("com.n3tr.countertouchbar.increase")
static let decrease = NSTouchBarItemIdentifier("com.n3tr.countertouchbar.decrease")
static let counter = NSTouchBarItemIdentifier("com.n3tr.countertouchbar.counter")
}
@n3tr
n3tr / WindowController.swift
Created November 5, 2016 11:54
Add OtherItemsProxy
override func makeTouchBar() -> NSTouchBar? {
let touchBar = NSTouchBar()
touchBar.delegate = self
touchBar.customizationIdentifier = .touchBar
touchBar.defaultItemIdentifiers = [.label, .fixedSpaceSmall, .otherItemsProxy]
return touchBar
}
fileprivate extension NSTouchBarCustomizationIdentifier {
static let windowBar = NSTouchBarCustomizationIdentifier("com.n3tr.countertouchbar.touchbar")
}
fileprivate extension NSTouchBarItemIdentifier {
static let label = NSTouchBarItemIdentifier("com.n3tr.countertouchbar.label")
}
class WindowController: NSWindowController {
// ...
extension WindowController: NSTouchBarDelegate {
func touchBar(_ touchBar: NSTouchBar, makeItemForIdentifier identifier: NSTouchBarItemIdentifier) -> NSTouchBarItem? {
switch identifier {
case NSTouchBarItemIdentifier.label:
// Create custom touch bar Item
let custom = NSCustomTouchBarItem(identifier: identifier)
custom.customizationLabel = "Label Title"
// Create label as NSTextField
let label = NSTextField(labelWithString: "Hello, TouchBar")
class WindowController: NSWindowController {
// ..
override func makeTouchBar() -> NSTouchBar? {
let touchBar = NSTouchBar()
touchBar.delegate = self
touchBar.customizationIdentifier = .touchBar
touchBar.defaultItemIdentifiers = [.label]
return touchBar
}
}
@n3tr
n3tr / id.swift
Last active October 30, 2016 15:27
WindowController.swift
fileprivate extension NSTouchBarCustomizationIdentifier {
static let windowBar = NSTouchBarCustomizationIdentifier("com.n3tr.countertouchbar.touchbar")
}
fileprivate extension NSTouchBarItemIdentifier {
static let label = NSTouchBarItemIdentifier("com.n3tr.countertouchbar.label")
}
class WindowController: NSWindowController {
// ...
import React from 'react'
const Button = (props) => {
return <button className="button" {...props} />
}
function isStateless(component) {
return !(component.prototype && component.prototype.render);
}
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/service-workerw.js').then(function(registration) {
// register success
console.log('ServiceWorker registration successful with scope: ', registration.scope);
}).catch(function(err) {
// registration failed :(
console.log('ServiceWorker registration failed: ', err);
});
}
@n3tr
n3tr / setup.sh
Created February 13, 2016 22:46
Install Spark + Zeppelin on EC2
# scala install
wget www.scala-lang.org/files/archive/scala-2.11.7.deb
sudo dpkg -i scala-2.11.7.deb
# sbt installation
echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 642AC823
sudo apt-get update
sudo apt-get install sbt
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
100.52144765853882,