This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) | |
# ---------------------------------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val builder = MaterialDatePicker.Builder.dateRangePicker() | |
val picker = builder.setTitleText("test").build() | |
picker.addOnPositiveButtonClickListener { | |
"picked $it" logWith "Log" | |
} | |
picker.show(supportFragmentManager,null) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context | |
import android.content.SharedPreferences | |
import android.util.Log | |
private const val SHAREDPREF = "shared" | |
private const val FIRST_TIME = "firstime" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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 |