Skip to content

Instantly share code, notes, and snippets.

@mikelpr
mikelpr / installer.nsh
Created September 25, 2023 04:24
electron-builder nsis download and install Visual C++ redist 2015-2022 (x64)
;Inspired by:
; https://gist.github.com/bogdibota/062919938e1ed388b3db5ea31f52955c
; https://stackoverflow.com/questions/34177547/detect-if-visual-c-redistributable-for-visual-studio-2013-is-installed
; https://stackoverflow.com/a/54391388
; https://github.com/GitCommons/cpp-redist-nsis/blob/main/installer.nsh
;Find latests downloads here:
; https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist
!include LogicLib.nsh
@mikelpr
mikelpr / yt-tag.js
Created July 10, 2020 05:18
responsive YouTube embed
class YTEmbed extends HTMLElement {
static get observedAttributes() { return ['videoid', 'ratio']; }
constructor() {
super();
this.shadow = this.attachShadow({mode: "open"});
this.redraw();
}
attributeChangedCallback(name, oldValue, newValue) {
@mikelpr
mikelpr / rx-ble-scanner.kt
Last active October 3, 2017 04:16
Bluetooth LE scanner observable
import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothDevice
import io.reactivex.Observable
import java.util.concurrent.TimeUnit
data class BLEScanResult(val dev: BluetoothDevice,
val rssi: Int,
val scanRecord: ByteArray)
fun rxBLEScanner(btAdapter: BluetoothAdapter,
@mikelpr
mikelpr / vsync.kt
Created August 28, 2017 01:52
Android VSYNC observable
import android.view.Choreographer
import io.reactivex.Observable
import io.reactivex.Single
import io.reactivex.android.schedulers.AndroidSchedulers
val vsync: Observable<Long> = {
Single.create<Long>{emitter ->
Choreographer.getInstance().postFrameCallback{emitter.onSuccess(it)}
}
.toObservable()