Skip to content

Instantly share code, notes, and snippets.

View felipefpx's full-sized avatar

Felipe Porge Xavier felipefpx

View GitHub Profile
@felipefpx
felipefpx / step_1_getting_started_datomic.txt
Last active August 5, 2023 16:56
Getting Started with Datomic
### Download and setup
1. Initially, download the Datomic Pro version on the official website: https://docs.datomic.com/pro/getting-started/get-datomic.html
2. Unzip the zip file and move the folder for your desired path, in this case, it will be on `$HOME/datomic`
3. Prepare the config file on `$HOME/datomic/config`, there are some examples on `$HOME/datomic/config/samples`
4. Add the aliases to your terminal startup file (e.g. `~/.bashrc` or `~/.zshrc`) that will be useful for dealing with your Datomic:
```
# To start Datomic REPL:
alias datomic-repl="$HOME/datomic/bin/repl"
@felipefpx
felipefpx / gist:3d033af1ed2d7dbfd64fe62a85c82ee7
Created April 27, 2022 03:13
Remove file completely from git and history
git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch *file-path*" \
--prune-empty --tag-name-filter cat -- --all
git push --force --verbose --dry-run
git push --force
@felipefpx
felipefpx / AESCipher.java
Created October 24, 2021 20:52
AES/CBC/PKCS5Padding
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.security.*;
@felipefpx
felipefpx / FileUploader.kt
Created August 13, 2020 01:41
Upload files using OkHttp multi-part request
fun uploadFile(
url: String,
headers: Map<String, String>,
files: Map<String, Attachment>,
formDataParts: Map<String, Any>
): Request {
val body =
MultipartBody.Builder()
.setType(MultipartBody.FORM)
.apply {
@felipefpx
felipefpx / AnyRvAdapter.kt
Last active May 15, 2020 14:41
AnyRvAdapter - Recycler view adapter for any class that supports multiple view types
package me.porge.something.adapters
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
import kotlin.reflect.KClass
class AnyRvAdapter(
private val controllers: Map<KClass<*>, AnyRvItemController<*>>,
initialItems: List<Any> = emptyList(),
import android.util.Log
import androidx.test.espresso.IdlingRegistry
import com.jakewharton.espresso.OkHttp3IdlingResource
import okhttp3.Interceptor
import okhttp3.OkHttpClient
import okhttp3.Response
import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.MockWebServer
import okhttp3.mockwebserver.QueueDispatcher
import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
fun <T> LiveData<T>.blockingObserve(): T? {
val countDownLatch = CountDownLatch(1)
var result: T? = null
val observer = Observer<T> {
/*
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@felipefpx
felipefpx / coverage.sh
Created September 1, 2019 10:29
Jacoco Merged Report for Multimodule Android with Kotlin DSL
#!/bin/bash
clear
./gradlew clean mergedJacocoReport
./gradlew jacocoFullReport
REPORT_PATH="file://$(pwd)/build/reports/jacoco/jacocoFullReport/html/index.html"
echo ${REPORT_PATH} | pbcopy
echo "Report available at:"
echo ${REPORT_PATH}
echo "Report file path copied to clipboard. You can paste it in your favorite browser. :)"
@felipefpx
felipefpx / send_email.py
Last active May 7, 2018 14:23
This code sends an email with attachments using Python
import smtplib
import sys
from os.path import basename
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.utils import COMMASPACE, formatdate
# Usage: python send_email.py "me@mail.com" "pass" "receiver1@mail.com, receiver2@mail.com" "DEV" "ADT" "v1.2.3" "/Users/username/Desktop/log.txt,/Users/username/Desktop/dolog.txt"
send_from = sys.argv[1]