Skip to content

Instantly share code, notes, and snippets.

@jd1378
jd1378 / theme_ripper.kt
Created November 17, 2023 21:21
theme ripper kotlin
@OptIn(ExperimentalStdlibApi::class)
fun ColorScheme.toListString(): String {
val sb = StringBuilder()
sb.append("val md_theme_light_primary = Color(0x"+ this.primary.toArgb().toHexString().uppercase() + ") \n")
sb.append("val md_theme_light_onPrimary = Color(0x"+ this.onPrimary.toArgb().toHexString().uppercase() + ") \n")
sb.append("val md_theme_light_primaryContainer = Color(0x"+ this.primaryContainer.toArgb().toHexString().uppercase() + ") \n")
sb.append("val md_theme_light_onPrimaryContainer = Color(0x"+ this.onPrimaryContainer.toArgb().toHexString().uppercase() + ") \n")
sb.append("val md_theme_light_inversePrimary = Color(0x"+ this.inversePrimary.toArgb().toHexString().uppercase() + ") \n")
sb.append("val md_theme_light_secondary = Color(0x"+ this.secondary.toArgb().toHexString().uppercase() + ") \n")
sb.append("val md_theme_light_onSecondary = Color(0x"+ this.onSecondary.toArgb().toHexString().uppercase() + ") \n")
@jd1378
jd1378 / ImgLazy.vue
Last active October 7, 2023 12:05
a lazy <img/> loader component for modern browsers with common requirements for Vue 3
/**
* Author: @jd1378 (https://github.com/jd1378)
* License: MIT
*/
<template>
<div class="relative" :class="wrapperClass">
<div
class="pointer-events-none absolute bottom-0 left-0 right-0 top-0 flex select-none items-center justify-center">
<slot v-if="loading" name="loading">
@jd1378
jd1378 / floating-ui-tooltip-directive.ts
Last active July 1, 2023 13:44
A floating UI tooltip directive for Vue 3 that reuses the created tooltip (good for when you have hundreds of components). uses tailwind, make sure to include the file in your settings or change classes to suit your needs.
/**
* Author: @jd1378 (https://github.com/jd1378)
* License: MIT
*/
import {
Placement,
arrow,
autoUpdate,
computePosition,
@jd1378
jd1378 / setup-android-sdk.sh
Last active July 10, 2022 17:01 — forked from piouson/setup-android-sdk.sh
Install Android SDK on Windows Bash (WSL)
cd ~
sudo apt-get install unzip zip
wget https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip
unzip commandlinetools-linux-6858069_latest.zip -d Android
rm commandlinetools-linux-6858069_latest.zip
sudo apt-get install -y lib32z1 openjdk-11-jdk # or adoptium jdk
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export PATH=$PATH:$JAVA_HOME/bin
printf "\n\nexport JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64\nexport PATH=\$PATH:\$JAVA_HOME/bin" >> ~/.bashrc
cd Android/cmdline-tools
@jd1378
jd1378 / authentication.hooks.js
Last active December 10, 2020 05:09
rate limit hooks
const RateLimiterMongo = require('rate-limiter-flexible/lib/RateLimiterMongo');
const { rateLimit } = require('feathers-fletching');
const { iff, isProvider } = require('feathers-hooks-common');
const mongoose = require('mongoose');
const maxWrongAttemptsByIPperDay = 100;
const maxConsecutiveFailsByUsernameAndIP = 5;
const limiterSlowBruteByIP = new RateLimiterMongo({
storeClient: mongoose.connection,
@jd1378
jd1378 / readme.md
Created October 23, 2020 14:04
cloudflare mass delete script

First figure out the zoneId by looking at network tab. then copy the function below to your browser console and use it.