Skip to content

Instantly share code, notes, and snippets.

View ersin-ertan's full-sized avatar
🔥
GCP/Firebase + Android Professional

Ersin Ertan ersin-ertan

🔥
GCP/Firebase + Android Professional
View GitHub Profile
@ersin-ertan
ersin-ertan / keyboardLayout.json
Created March 23, 2024 01:23
GCP Workstations Visual Studio Code keyboard layout for Dvorak users
// Defines the keyboard layout used in Code OSS in the browser environment.
// Open Code OSS and run "Developer: Inspect Key Mappings (JSON)" from Command Palette.
// Once you have the keyboard layout info, please paste it below.
{
"layout": {
"model": "pc105",
"group": 0,
"layout": "us",
@ersin-ertan
ersin-ertan / secLight.kt
Created September 1, 2023 02:22
Update the light every second
val pre = """
- type: device.command.ColorAbsolute
color:
spectrumRGB: """
val post = """
devices: Light strip - myRm
- type: time.delay
for: 1 sec"""
var counter = 194
@ersin-ertan
ersin-ertan / sampleFade.rb
Last active December 21, 2022 00:43
Sonic pi sample fader both in and out
define :_togglePan do |pan|
if pan == -1 then pan = 1 else pan = -1 end
return pan
end
define :_calcFadedAmp do |isFadeIn, amp, ampFade|
if isFadeIn == true then amp += ampFade else amp -= ampFade end
return amp
end
@ersin-ertan
ersin-ertan / NullSinkForDefault.pa
Created June 15, 2018 22:18
Creates null output to route the loopback of your configured mic and system out
pacmd load-module module-null-sink
pacmd load-module module-loopback
pacmd load-module module-loopback
@ersin-ertan
ersin-ertan / Sieve.kt
Last active February 16, 2018 23:56
using Sequence<Int>
import kotlin.coroutines.experimental.buildSequence
import kotlin.system.measureTimeMillis
fun sieve(isPrime: Int, ints: Sequence<Int>): Boolean = with(ints.first()) {
return when {
isPrime < 2 -> false
isPrime == 2 -> true
isPrime == this -> true
isPrime.rem(2) == 0 -> false
// isPrime.and(1) == 0 -> false // same way to check if number is even
package function
var Function = { function:Function<*> -> val function = function.javaClass.newInstance() as Function<*> }
fun Function(Function:Function<*>):(Function<*>) -> Function<*> = { Function ->
fun Function<*>.Function(Function:Function<*>):Function<*> = (function.Function.javaClass.newInstance() as ((Function<*>) -> Function<*>)?)!!
(Function(Function = function.Function(Function)).Function(Function = function.Function(Function = function.Function(Function = function.Function)(Function))) as Function<*>).Function(Function)
}
@ersin-ertan
ersin-ertan / public.kt
Created September 26, 2017 19:38
public
interface Public {
public fun public():Public
}
public class public public constructor(public:Public):Public by object:Public {
public override fun public():Public {
return object:Public {
public override fun public():Public {
return Public@this.public()
}
@ersin-ertan
ersin-ertan / CallingActivityOrView.java
Last active January 26, 2017 19:35
Generic dialogframent to take in arguments, size itself, and set anything as its listener
@Override protected void onViewBound(@NonNull View view) {
super.onViewBound(view);
TestDialog.reAttachListener(getActivity(), TestDialog.class, this);
btnShowDialog.setOnClickListener(v -> {
TestDialog gd = new TestDialogBuilder(R.dimen.dialog_add_inspection_item_height,
R.dimen.dialog_add_inspection_item_width, R.string.camera, R.string.title).build();
TestDialog.show(getActivity(), gd, this);
Verifying that "ersin_ertan.id" is my Blockstack ID. https://onename.com/ersin_ertan
@ersin-ertan
ersin-ertan / ChainingRxWithCallback.java
Last active August 29, 2016 04:46
Type specific chaining with anonymous functions
Api api = new Api() {
@Override Single<String> getKey() {
return Single.just("apiKey");
}
};
api.getKey().flatMap(new Func1<String, Single<String>>() {
@Override public Single<String> call(String key) {
return Single.create(new Single.OnSubscribe<String>() {
@Override public void call(final SingleSubscriber<? super String> singleSubscriber) {