Skip to content

Instantly share code, notes, and snippets.

protocol ExpressibleByString {
init(_ string: String)
}
extension String: ExpressibleByString {
init(_ string: String) {
self = string
}
}
@gmk57
gmk57 / 1 ViewBindingDelegates.kt
Last active June 29, 2025 07:54
Kotlin delegates for Android View Binding with usage examples
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.viewbinding.ViewBinding
@soujohnreis
soujohnreis / URLProtocolMock.swift
Last active October 11, 2024 16:19
Mock URLSession using URLProtocol
class URLProtocolMock: URLProtocol {
/// Dictionary maps URLs to tuples of error, data, and response
static var mockURLs = [URL?: (error: Error?, data: Data?, response: HTTPURLResponse?)]()
override class func canInit(with request: URLRequest) -> Bool {
// Handle all types of requests
return true
}
override class func canonicalRequest(for request: URLRequest) -> URLRequest {
@br3ndonland
br3ndonland / github-actions-notes.md
Last active September 30, 2025 19:09
Getting the Gist of GitHub Actions
class BaseViewController<V: BaseViewModel<M>, M: Persistable>: UIViewController {
let viewModel: V
let disposeBag = DisposeBag()
private var progress: MBProgressHUD?
required init(viewModel: V) {
self.viewModel = viewModel
@knight7024
knight7024 / Syberoid in Arduino
Last active February 19, 2022 17:44
Syberoid
// From http://www.instructables.com/id/How-to-easily-play-music-with-buzzer-on-arduino-Th/
// NB: ALL NOTES DEFINED WITH STANDARD ENGLISH NAMES, EXCEPT FROM "A"
//THAT IS CALLED WITH THE ITALIAN NAME "LA" BECAUSE A0,A1...ARE THE ANALOG PINS ON ARDUINO.
// (Ab IS CALLED Ab AND NOT LAb)
#define C0 16.35
#define Db0 17.32
#define D0 18.35
#define Eb0 19.45
#define E0 20.60
@knight7024
knight7024 / Yeeduino.ino
Last active August 3, 2019 23:44
Yee in Arduino Buzzer
// From http://www.instructables.com/id/How-to-easily-play-music-with-buzzer-on-arduino-Th/
// NB: ALL NOTES DEFINED WITH STANDARD ENGLISH NAMES, EXCEPT FROM "A"
//THAT IS CALLED WITH THE ITALIAN NAME "LA" BECAUSE A0,A1...ARE THE ANALOG PINS ON ARDUINO.
// (Ab IS CALLED Ab AND NOT LAb)
#define C0 16.35
#define Db0 17.32
#define D0 18.35
#define Eb0 19.45
#define E0 20.60
@hwigyeom
hwigyeom / Startup.cs
Created November 21, 2017 14:50
ASP.NET Core 에서 한글 문자열이 인코딩되어 출력되는 문제 해결
services.Configure<WebEncoderOptions>(options =>
{
options.TextEncoderSettings = new TextEncoderSettings(UnicodeRanges.All); // 한글이 인코딩되는 문제 해결
});
@jimschubert
jimschubert / .gitignore
Last active March 27, 2025 09:49
Prototyping a Flags/Bitmasks implementation in Kotlin 1.1.1
META-INF/
*.class
@klarson2
klarson2 / ZoomLayout.java
Last active January 5, 2023 00:04 — forked from anorth/ZoomLayout.java
Pinch-zoomable Android frame layout -- modified to center the zoom based on the user's gesture
package au.id.alexn;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
import android.widget.FrameLayout;