Skip to content

Instantly share code, notes, and snippets.

@KlassenKonstantin
KlassenKonstantin / EmojiBg.kt
Created November 16, 2024 10:07
EmojiBg in KMP
@Composable
fun EmojiFont() = FontFamily(
Font(Res.font.noto_emoji_light, FontWeight.Light),
Font(Res.font.noto_emoji_reg, FontWeight.Normal),
Font(Res.font.noto_emoji_med, FontWeight.Medium),
)
val testEmojis =
persistentListOf("🍇", "🍅", "🥬", "🍞", "🧀", "🥚", "🥩", "🍫", "🍕", "🍷", "🧃", "🧼", "🧻", "🧴", "🍏")
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
WindowCompat.setDecorFitsSystemWindows(window, false)
super.onCreate(savedInstanceState)
setContent {
ColorPickerTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
@dellisd
dellisd / Test.kt
Created June 9, 2022 16:37
Explicit Backing Fields
class Test {
val names: List<String>
field: MutableList<String> = mutableListOf<String>()
fun doThing() {
names.add("Hello!")
}
}
fun main() {
@spacepatcher
spacepatcher / Breach Compilation (1.4 billion credentials) in Postgres.md
Last active April 8, 2025 15:34
Breach Compilation (1.4 billion credentials) in Postgres.md

What would you need:

Hardware requirements

@layerlre
layerlre / IDCardUtil.java
Created March 27, 2017 06:25
Validate thai ID card
public class IDCardUtil {
public static boolean isValid(String idCard){
if (idCard.length()!=13){
return false;
}
int sum = 0;
for (int i = 0; i < 12; i++) {
sum += Character.getNumericValue(idCard.charAt(i))*(13-i);
}
@peerapongsam
peerapongsam / Gson Dynamic Key Deserializer.java
Last active August 1, 2020 13:01
Gson Dynamic Key Deserializer
package me.peerapong.android_dynamicjsonkey;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
@guillermomuntaner
guillermomuntaner / CutCopyPaste.java
Last active May 13, 2024 05:44
EditText which notifies of Cut, Copy and Paste events via an attachable listener
import android.content.Context;
import android.util.AttributeSet;
import android.widget.EditText;
/**
* Original:
* An EditText, which notifies when something was cut/copied/pasted inside it.
* @author Lukas Knuth
* @version 1.0
*
@zhenyanghua
zhenyanghua / code.gs
Created July 15, 2014 19:55
Googlemaps + Google Sheets + Google Forms
var SPREADSHEET_ID='Google Sheets ID';
var SHEET_NAME = 'Google Sheets Table Name';
function doGet(request) {
var callback = request.parameters.jsonp;
var range = SpreadsheetApp.openById(SPREADSHEET_ID).getSheetByName(SHEET_NAME).getDataRange();
var json = callback+'('+Utilities.jsonStringify(range.getValues())+')';
return ContentService.createTextOutput(json).setMimeType(ContentService.MimeType.JAVASCRIPT);
}