Skip to content

Instantly share code, notes, and snippets.

View LutfiTekin's full-sized avatar
🎯
Focusing

Lütfi Tekin LutfiTekin

🎯
Focusing
  • Appsfactory
  • Leipzig Germany
View GitHub Profile
@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
@LutfiTekin
LutfiTekin / shuffle.java
Created March 29, 2018 15:46
Shuffle a string
public static String shuffle(String string) {
StringBuilder sb = new StringBuilder(string.length());
double rnd;
for (char c: string.toCharArray()) {
rnd = Math.random();
if (rnd < 0.34)
sb.append(c);
else if (rnd < 0.67)
sb.insert(sb.length() / 2, c);
else
@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"
<?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 / 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)
@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 / 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"))