Skip to content

Instantly share code, notes, and snippets.

@bricklife
bricklife / overwrite_main.py
Last active January 16, 2020 03:33
Overwriting main.py in LEGO Education SPIKE Prime Hub
import io
f = io.open('main.py', 'w')
f.write('''
import hub
import time
while True:
hub.display.show(hub.Image('00000:00000:00900:00000:00000:'))
time.sleep_ms(500)
@bricklife
bricklife / BLEPeripheral.swift
Created September 14, 2018 16:43
micro:bit simulator for Scratch 3.0
//
// BLEPeripheral.swift
// BLEPeripheral
//
// Created by ooba on 26/07/2017.
// Copyright © 2017 bricklife.com. All rights reserved.
//
import Foundation
import CoreBluetooth
//
// LineHeightLabel.swift
// LineHeightLabel
//
// Created by Shinichiro Oba on 20/06/2018.
// Copyright © 2018 bricklife.com. All rights reserved.
//
import UIKit
@bricklife
bricklife / ViewController.swift
Created March 8, 2018 01:45
UIPanGestureRecognizer on UIScrollView
//
// ViewController.swift
// PanOnScroll
//
// Created by Shinichiro Oba on 2018/03/08.
// Copyright © 2018 bricklife.com. All rights reserved.
//
import UIKit
@bricklife
bricklife / CollectionViewController.swift
Last active October 28, 2023 10:26
UITapGestureRecognizer in UICollectionView
//
// CollectionViewController.swift
// CollectionViewTouch
//
// Created by ooba on 30/01/2018.
// Copyright © 2018 ooba. All rights reserved.
//
import UIKit
import Foundation
import JSONRPCKit
struct CastError<ExpectedType>: Error {
let actualValue: Any
let expectedType: ExpectedType.Type
}
struct Subtract: JSONRPCKit.Request {
typealias Response = Int
@bricklife
bricklife / deeplink.mb
Last active January 12, 2018 16:25
deeplink
@bricklife
bricklife / Contents.swift
Last active December 19, 2017 23:34
Slider in Playgrounds
//: A SpriteKit based Playground
import PlaygroundSupport
import SpriteKit
class SliderNode: SKNode {
private let height: CGFloat
private let width: CGFloat
private var baseNode: SKNode
@bricklife
bricklife / Contents.swift
Last active December 19, 2017 23:34
Analog Joystick in Playgrounds
//: A SpriteKit based Playground
import PlaygroundSupport
import SpriteKit
class JoystickNode: SKNode {
private let radius: CGFloat
private var baseNode: SKNode
private var stickNode: SKNode
@bricklife
bricklife / LiveView.swift
Created September 26, 2017 00:50
PlaygroundBluetooth Example
//: A UIKit based Playground for presenting user interface
import UIKit
import CoreBluetooth
import PlaygroundBluetooth
import PlaygroundSupport
private let serviceUuid = CBUUID(string: "180F")
private let characteristicUuid = CBUUID(string: "2A19")