This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset=utf-8 /> | |
<title>Sketch</title> | |
<style> | |
article, aside, figure, footer, header, hgroup, | |
menu, nav, section { display: block; } | |
</style> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.2/raphael-min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size(100, 100); | |
// drawing surface with no background | |
PGraphics pg = createGraphics(100, 100); | |
pg.beginDraw(); | |
pg.background(255); | |
pg.blendMode(DIFFERENCE); | |
pg.fill(255); | |
pg.noStroke(); | |
pg.ellipse(40, 50, 30, 30); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func formatDate(date: NSDate, format: String = "yyyy-MM-dd hh:mm:ss Z") -> String { | |
let formatter = NSDateFormatter() | |
formatter.dateFormat = format | |
return formatter.stringFromDate(date) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print("Device Connected \(device.addressString)") | |
let services = device.services?[1] as? IOBluetoothSDPServiceRecord | |
let report = services?.getAttributeDataElement(518)?.getArrayValue() | |
let reportDict = report?[0] as? IOBluetoothSDPDataElement | |
let reportDescriptorElement = reportDict?.getArrayValue()[1] as? IOBluetoothSDPDataElement | |
if let reportDescriptor = reportDescriptorElement?.getDataValue() { | |
var data = [UInt8](count: reportDescriptor.length, repeatedValue: 0) | |
reportDescriptor.getBytes(&data, length: reportDescriptor.length) | |
print(hex(data)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func keyCodeToString(keyCode: CGKeyCode) -> String { | |
let curKeyboard = TISCopyCurrentKeyboardInputSource().takeRetainedValue() | |
let ptr = TISGetInputSourceProperty(curKeyboard, kTISPropertyUnicodeKeyLayoutData) | |
let keyboardLayoutPtr = UnsafePointer<UCKeyboardLayout>(ptr) | |
var deadKeyState: UInt32 = 0 | |
var actualStringLength = 0 | |
var unicodeString = [UniChar](count: 255, repeatedValue: 0) | |
let status = UCKeyTranslate(keyboardLayoutPtr, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
switch type { | |
case .Null: | |
// system defined events | |
guard let nsEvent = NSEvent(CGEvent: event) else | |
{ print("failed nsvent"); break } | |
print("Null event \(binary(type.rawValue))"); | |
print(nsEvent) | |
break | |
case .KeyDown: print("KeyDown event \(binary(type.rawValue))"); break | |
case .KeyUp: print("KeyUp event \(binary(type.rawValue))"); break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let keys = [kIOHIDTransportKey, kIOHIDVendorIDKey, kIOHIDVendorIDSourceKey, kIOHIDProductIDKey, kIOHIDVersionNumberKey, kIOHIDManufacturerKey, kIOHIDProductKey, kIOHIDSerialNumberKey, kIOHIDCountryCodeKey, kIOHIDStandardTypeKey, kIOHIDLocationIDKey, kIOHIDDeviceUsageKey, kIOHIDDeviceUsagePageKey, kIOHIDDeviceUsagePairsKey, kIOHIDPrimaryUsageKey, kIOHIDPrimaryUsagePageKey, kIOHIDMaxInputReportSizeKey, kIOHIDMaxOutputReportSizeKey, kIOHIDMaxFeatureReportSizeKey, kIOHIDReportIntervalKey, kIOHIDSampleIntervalKey, kIOHIDBatchIntervalKey, kIOHIDRequestTimeoutKey, kIOHIDReportDescriptorKey, kIOHIDResetKey, kIOHIDKeyboardLanguageKey, kIOHIDAltHandlerIdKey, kIOHIDBuiltInKey, kIOHIDDisplayIntegratedKey, kIOHIDProductIDMaskKey, kIOHIDProductIDArrayKey, kIOHIDPowerOnDelayNSKey, kIOHIDCategoryKey, kIOHIDMaxResponseLatencyKey, kIOHIDUniqueIDKey, kIOHIDPhysicalDeviceUniqueIDKey] | |
for key in keys { | |
if let prop = IOHIDDeviceGetProperty(device, key) { | |
print("\t" + key + ": \(prop)") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# Copyright (C) 2015 Arthur Yidi | |
# License: BSD Simplified | |
import sys | |
import struct | |
import socket | |
import time | |
from threading import Thread | |
from math import sin, cos | |
from array import array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from subprocess import check_output, CalledProcessError | |
import argparse | |
parser = argparse.ArgumentParser() | |
parser.add_argument("port", help="Port Number") | |
parser.add_argument("-n", "--dry-run", action="store_false", help="run without killing processes") | |
args = parser.parse_args() | |
# lsof |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const bodyFontToDynamicTypeSize = { | |
"14px": "xSmall", | |
"15px": "Small", | |
"16px": "Medium", | |
"17px": "Large", | |
"19px": "xLarge", | |
"21px": "xxLarge", | |
"23px": "xxxLarge", | |
"28px": "AX1", | |
"33px": "AX2", |
OlderNewer