Skip to content

Instantly share code, notes, and snippets.

View yuliantoeric's full-sized avatar

Eric Yulianto yuliantoeric

View GitHub Profile
@yuliantoeric
yuliantoeric / Gemfile
Created August 30, 2019 13:01
Rake + Minitest
source 'https://rubygems.org'
ruby '2.6.3'
gem 'rake', '~> 12.3.3'
gem 'minitest', '~> 5.11.3'
gem 'minitest-reporters', '~> 1.3.8'
@yuliantoeric
yuliantoeric / oled.py
Created May 22, 2017 08:42
Microbit-Micropython snippet for SSD1306
# Adapted from https://github.com/fizban99/microbit_ssd1306
from microbit import i2c, Image
OLED_ADDR = 0x3c
oled_screen = bytearray('b\x40') + bytearray(512)
def oled_initialize():
for c in ([0xae], [0xa4], [0xd5, 0xf0], [0xa8, 0x3f], [0xd3, 0x00], [0 | 0x0], [0x8d, 0x14], [0x20, 0x00], [0x21, 0, 127], [0x22, 0, 63], [0xa0 | 0x1], [0xc8], [0xda, 0x12], [0x81, 0xcf], [0xd9, 0xf1], [0xdb, 0x40], [0xa6], [0xd6, 1], [0xaf]):
i2c.write(OLED_ADDR, b'\x00' + bytearray(c))
@yuliantoeric
yuliantoeric / rtc.py
Last active November 23, 2022 21:07
Microbit-Micropython snippet for DS1307 real-time clock
from microbit import i2c
RTC_ADDR = 0x68
def bcd2bin(v):
return v - 6 * (v >> 4)
def bin2bcd(v):
return v + 6 * (v // 10)
@yuliantoeric
yuliantoeric / todo_warning_swift.sh
Last active March 26, 2018 07:24
Xcode run script to generate warning for TODO: and FIXME: tags in swift
#!/bin/sh
# To install in Xcode, add "New Run Script Phase" to the target "Build Phases"
TAGS="TODO:|FIXME:"
echo "searching ${SRCROOT} for ${TAGS}"
find "${SRCROOT}" \( -name "*.h" -o -name "*.m" -o -name "*.swift" \) -print0 \
| xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$" \
| perl -p -e "s/($TAGS)/ warning: \$1/"