Skip to content

Instantly share code, notes, and snippets.

View ForceTower's full-sized avatar
😋
Legendary nice meme

João Sena ForceTower

😋
Legendary nice meme
  • Feira de Santana
  • 20:28 (UTC -03:00)
View GitHub Profile
@ForceTower
ForceTower / Binding.kt
Created June 24, 2021 22:58
Image on bottom nav item
private fun setupProfileOnBottomNav() {
val menuView = binding.bottomNav[0] as BottomNavigationMenuView
val itemView = menuView[2] as BottomNavigationItemView
val icon = itemView.findViewById<ImageView>(R.id.icon)
Glide.with(this)
.load("https://avatars1.githubusercontent.com/u/9421614?s=460&u=499efd7b66284bd4436bc74dd982c52f9e076740&v=4")
.circleCrop()
.into(icon)
}
@ForceTower
ForceTower / LoadImageBottomNav.kt
Created May 19, 2021 15:19
How to load an image into a bottom nav icon
private fun setupProfileOnBottomNav() {
val menuView = binding.bottomNav[0] as BottomNavigationMenuView
val itemView = menuView[2] as BottomNavigationItemView
val icon = itemView.findViewById<ImageView>(R.id.icon)
Glide.with(this)
.load("https://avatars1.githubusercontent.com/u/9421614?s=460&u=499efd7b66284bd4436bc74dd982c52f9e076740&v=4")
.circleCrop()
.into(icon)
}
@ForceTower
ForceTower / donut.c
Created March 12, 2021 11:43
gcc -o donut donut.c -lm
k;double sin()
,cos();main(){float A=
0,B=0,i,j,z[1760];char b[
1760];printf("\x1b[2J");for(;;
){memset(b,32,1760);memset(z,0,7040)
;for(j=0;6.28>j;j+=0.07)for(i=0;6.28
>i;i+=0.02){float c=sin(i),d=cos(j),e=
sin(A),f=sin(j),g=cos(A),h=d+2,D=1/(c*
h*e+f*g+5),l=cos (i),m=cos(B),n=s\
in(B),t=c*h*g-f* e;int x=40+30*D*
import com.google.firebase.firestore.CollectionReference
import com.google.firebase.firestore.DocumentReference
import com.google.firebase.firestore.Query
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.cancel
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.channels.sendBlocking
import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.suspendCancellableCoroutine
import okhttp3.Call
import okhttp3.Callback
import okhttp3.Response
import java.io.IOException
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException
suspend fun Call.executeSuspend() = suspendCancellableCoroutine<ResponseBody> { continuation ->
this.enqueue(object : Callback {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
window.insetsController?.apply {
systemBarsBehavior = WindowInsetsController.BEHAVIOR_SHOW_BARS_BY_SWIPE
hide(WindowInsets.Type.systemBars())
}
} else {
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
@ForceTower
ForceTower / GoogleApiExtensions.kt
Last active September 24, 2020 22:13
Usefull Firebase Kotlin suspend stuff
import com.google.android.gms.tasks.Task
import com.google.firebase.auth.AuthResult
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.firestore.CollectionReference
import com.google.firebase.firestore.DocumentReference
import com.google.firebase.storage.CancellableTask
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.channels.sendBlocking
import kotlinx.coroutines.flow.callbackFlow
import * as functions from "firebase-functions"
import * as moment from "moment"
const messages = [
{
message: "Bom dia",
attachments: [
{
name: "bom dia",
source:
from Crypto.Cipher import AES
from Crypto.Util import Counter
def encrypt_file(key, in_filename, out_filename=None, chunksize=64 * 1024):
if not out_filename:
out_filename = in_filename + '.enc'
counter = Counter.new(nbits=128, initial_value=0)
encryptor = AES.new(key, AES.MODE_CTR, counter=counter)
import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.ShortBufferException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.nio.ByteBuffer;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;