Skip to content

Instantly share code, notes, and snippets.

View evilthreads669966's full-sized avatar
💭
0x666

Chris Basinger evilthreads669966

💭
0x666
View GitHub Profile
@evilthreads669966
evilthreads669966 / ProxyPortScanner.kt
Created October 5, 2020 03:33
proxy port scanner
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import java.io.File
import java.net.InetSocketAddress
import java.net.Proxy
import java.net.Proxy.Type.SOCKS
import java.net.Socket
@evilthreads669966
evilthreads669966 / colors.xml
Last active December 4, 2021 15:52
2016 Google Now Stories Card Replication Attempt. For some reason it is using different colors. I used Ubuntu and Google colors however the layouts are using different colors on accident. I may come back and fix the colors.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="ubuntuOrange">#E95420</color>
<color name="ubuntuAuberdine">#772953</color>
<color name="ubuntuLightAuberdine">#77216F</color>
<color name="ubuntuMidAuberdine">#5E2750</color>
<color name="ubuntuDarkAuberdine">#2C001E</color>
@evilthreads669966
evilthreads669966 / Bar.kt
Last active February 26, 2022 15:28
value class with computed property. value classes may not have generic type parameters. nor can they have more than one "backed" property. If Bar is treated as an integer value at compile time, then how does it hold on to a reference to the computed property? Or better yet, how does a primitive value have a reference to the computed property?
@JvmInline
value class Bar(private val _foo: Int){
val computed: Int
get() = _foo.toString().length
}
@Throws(AssertionError::class)
fun testBar(){
val arg = 22
val argLength = arg.toString().length
@evilthreads669966
evilthreads669966 / KTX.kt
Last active February 26, 2022 18:02
type safe way for passing objects when performing a NavHostController's navigation function. saving the arguments to the navcontroller instead.
fun <T: Parcelable> NavHostController.putParcelables(key: String, parcelables: ArrayList<T>) = currentBackStackEntry?.arguments?.putParcelableArrayList(key, parcelables)
fun <T: Parcelable> NavHostController.getParcelables(key: String) = previousBackStackEntry?.arguments?.getParcelableArrayList<T>(key)
fun <T: Parcelable> NavHostController.putParcelable(key: String, parcelable: T) = currentBackStackEntry?.arguments?.putParcelable(key, parcelable)
fun <T: Parcelable> NavHostController.getParcelable(key: String) = previousBackStackEntry?.arguments?.getParcelable<T>(key)
@evilthreads669966
evilthreads669966 / main.kt
Created February 26, 2022 18:06
i don't know. i've been reading documentation.
suspend fun main() {
val users = listOf(user,me,otherUser)
users.first().apply {
addFriend(me)
addFriend(otherUser)
}
verticalList("Users", users){ user ->
userRow(user)
}
}
@evilthreads669966
evilthreads669966 / main.kt
Last active March 5, 2022 18:27
check register..just playing around
fun main(){
val user = User().apply {
val account = Account("Capital One", 12345)
createAccount(account)
val cocaCola = Vendor("Coca Cola")
createVendor(cocaCola)
val beverages = Category("beverages")
createCategory(beverages)
writeCheck(account, 1, cocaCola, beverages, 113.30)
}
@evilthreads669966
evilthreads669966 / main.kt
Last active March 6, 2022 02:45
observer
fun main(){
State.apply {
addObserver(StateView)
value = UiState.Created
value = UiState.Started
value = UiState.Resumed
value = UiState.Paused
value = UiState.Stopped
value = UiState.Destroyed
}
fun main() {
val builder = Sms.Builder()
val message = builder.from("5127208800").to("9727404318").body("Hey, what's up?").build()
message.send()
}
data class Sms private constructor(var to: String, var from: String, var body: String){
fun send(){}//TODO()
@evilthreads669966
evilthreads669966 / Main.kt
Last active March 6, 2022 23:29
prototype
fun main() {
val foo = Foo("foo","bar")
val bar = foo.copy(foo = "bar")
}
data class Foo(val foo: String, val bar: String)
@evilthreads669966
evilthreads669966 / Main.kt
Last active March 7, 2022 16:06
by delegation decorator
fun main() {
val writer = WriterImpl(0)
writer.draw()
writer.erase()
val copyright = Copyright(writer)
copyright.draw()
copyright.erase()
val permanent = Permanent(copyright)
permanent.draw()
permanent.erase()