Skip to content

Instantly share code, notes, and snippets.

View LutfiTekin's full-sized avatar

Lütfi Tekin LutfiTekin

View GitHub Profile
@LutfiTekin
LutfiTekin / NetworkMonitor.kt
Created September 11, 2025 11:37
Android Kotlin NetworkMonitor: Combine ConnectivityManager + Firebase .info/connected into a StateFlow<Boolean>
package your.package.util
import android.content.Context
import android.net.ConnectivityManager
import android.net.Network
import android.net.NetworkCapabilities
import android.net.NetworkRequest
import com.google.firebase.database.DataSnapshot
import com.google.firebase.database.DatabaseError
import com.google.firebase.database.FirebaseDatabase
@LutfiTekin
LutfiTekin / departures.sh
Created May 5, 2025 17:35
load departures from given station using deutsche bahn api
#!/usr/bin/env bash
set -euo pipefail
# ----------------------------------------------------------------
# departures.sh — fetch scheduled departures via Timetables 'plan' endpoint only
# Includes ICE, RE, S-Bahn (S), buses, etc.
# Supports filtering by ICE, RE, S and a rolling window in hours
# Deduplicates entries and limits output count
# Adds color highlighting: time (black), train number (red), destination (yellow)
# ----------------------------------------------------------------
@LutfiTekin
LutfiTekin / Groovy
Created September 30, 2021 09:46
Control Lights with Gradle Build
//under project level gradle
classpath 'org.codehaus.groovy.modules.http-builder:http-builder:0.5.2'
//app level gradle under android {}
def put = new URL("http://[hue bridge ip]/api/[hue username key]/lights/[light number]/state").openConnection();
def message = '{"on": true,"xy":[0.400,0.922]}'
put.setRequestMethod("PUT")
put.setDoOutput(true)
put.setRequestProperty("Content-Type", "application/json")
put.getOutputStream().write(message.getBytes("UTF-8"))
@LutfiTekin
LutfiTekin / ObservableList.kt
Last active April 29, 2020 10:36
Notify observers when list elements changed
import java.util.*
class ObservableList<T>(private val wrapped: MutableList<T>): MutableList<T> by wrapped, Observable() {
override fun add(element: T): Boolean {
if (wrapped.add(element)) {
setChanged()
notifyObservers()
return true
}
return false
@LutfiTekin
LutfiTekin / DateRangePickerExample.kt
Created February 5, 2020 07:29
DateRangerPicker
val builder = MaterialDatePicker.Builder.dateRangePicker()
val picker = builder.setTitleText("test").build()
picker.addOnPositiveButtonClickListener {
"picked $it" logWith "Log"
}
picker.show(supportFragmentManager,null)
<?php
if(preg_match_all('/\p{C}/u', $ty_json, $out, PREG_OFFSET_CAPTURE))
{
echo "<pre>\n";
foreach($out[0] AS $k => $v) {
echo "detected ".bin2hex($v[0])." @ offset ".$v[1]."\n";
}
echo "</pre>";
}
//https://stackoverflow.com/a/15423899
@LutfiTekin
LutfiTekin / LocalData.kt
Last active April 28, 2021 01:08
Kotlin Sharedpreferences
import android.content.Context
import android.content.SharedPreferences
import android.util.Log
private const val SHAREDPREF = "shared"
private const val FIRST_TIME = "firstime"
@LutfiTekin
LutfiTekin / RandomNicknames.swift
Last active December 20, 2022 21:28
Including 1124 adjectives and 4554 nouns | English
//
// RandomNames.swift
//
// Created by Lütfi Tekin on 27.12.2017.
//
class RandomNickNames{
static let adjectiveList = ["aback","abaft","abandoned","abashed","aberrant","abhorrent","abiding","abject","ablaze","able","abnormal","aboard","aboriginal","abortive","abounding","abrasive","abrupt","absent","absorbed","absorbing","abstracted","absurd","abundant","abusive","acceptable","accessible","accidental","accurate","acid","acidic","acoustic","acrid","actually","ad","hoc","adamant","adaptable","addicted","adhesive","adjoining","adorable","adventurous","afraid","aggressive","agonizing","agreeable","ahead","ajar","alcoholic","alert","alike","alive","alleged","alluring","aloof","amazing","ambiguous","ambitious","amuck","amused","amusing","ancient","angry","animated","annoyed","annoying","anxious","apathetic","aquatic","aromatic","arrogant","ashamed","aspiring","assorted","astonishing","attractive","auspicious","automatic","available","average","awake","aware","awesome","awful","axiomatic","bad","barbarou