Skip to content

Instantly share code, notes, and snippets.

View Tgo1014's full-sized avatar
💻

Tiago Araujo Tgo1014

💻
  • Barcelona, Spain
  • 08:34 (UTC +02:00)
  • X @Tgo1014
View GitHub Profile
package jetpack.navigation.workaround
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.navigation.NavController
import androidx.navigation.ui.setupActionBarWithNavController
import com.google.android.material.bottomnavigation.BottomNavigationView
import java.lang.ref.WeakReference
fun launch(f: () -> Unit) {
GlobalScope.launch {
f.invoke()
}
}
inline fun <reified T> asyncAndWait(crossinline f: () -> T) = runBlocking {
return@runBlocking GlobalScope.async(Dispatchers.IO) {
f.invoke()
}.await()
private fun showBottomSheetMenu() {
val v = layoutInflater.inflate(R.layout.your_custom_layout_here, null)
val bottomSheet = GoogleBottomSheetDialog(this)
bottomSheet.setContentView(v)
bottomSheet.show()
}
This file has been truncated, but you can view the full file.
[03-03 13:02:12.321 2397:2397 I/vold]
Vold 3.0 (the awakening) firing up
[03-03 13:02:12.322 2397:2397 V/vold]
Detected support for: exfat ext4 ntfs vfat
[03-03 13:02:12.326 2397:2397 I/vold]
[libfs_mgr]fs_mgr_read_fstab_dt(): failed to read fstab from dt
[03-03 13:02:12.328 2397:2401 D/vold]
@Tgo1014
Tgo1014 / recursive_update.sql
Created April 4, 2017 14:38
Useful when updating a large quantities of rows from a big table
WHILE 1 = 1
BEGIN
UPDATE TOP(100000) A
SET CIA = CASE
WHEN DS_INDICADOR = 'AUTO' THEN LEFT(RIGHT(CD_ITEM,14),3)
WHEN DS_INDICADOR IN ('RE','RAMOS ELEMENTARES') THEN LEFT(RIGHT(CD_ITEM,10),3)
ELSE 0
END
FROM DB_PGC_PRODUCAO..TB_DM_INFO_GER_ANALITICO_HIST A
@Tgo1014
Tgo1014 / recursive_delete.sql
Created April 4, 2017 13:08
Delete a batch of rows from a table. Helpful when deleting large quantities of rows from a big table.
DECLARE @DT_ANOMES_REF INT = 201702
DECLARE @QTD_REG_BATCH INT = 0
DECLARE @ID INT = 0
SET @QTD_REG_BATCH = CEILING((SELECT COUNT(*) FROM DB_PGC_PRODUCAO..TB_VIDA_DBM WHERE DT_ANOMES_REF = @DT_ANOMES_REF) / 100000)
WHILE @ID <= @QTD_REG_BATCH -- Este número resulta no calculo [Qtde. Linhas a serem deletadas] / [100000]
BEGIN
;WITH CTE AS
(
@Tgo1014
Tgo1014 / script.sql
Created March 22, 2017 21:23
Auto reagendamento de job para o primeiro dia útil do mês seguinte após carregar tabela
DECLARE @DIA_UTIL INT
DECLARE @PROXIMO_DIA_UTIL VARCHAR(8)
DECLARE @PRIMEIRO_DIA_UTIL_MES_SEGUINTE VARCHAR(8)
/*****************************************************************************************************************/
--VERIFICA DIAS ÚTEIS
/*****************************************************************************************************************/
--TABELA DIAS UTEIS
IF OBJECT_ID('TEMPDB..#DIA_UTEIS_MES_ATUAL') IS NOT NULL
DROP TABLE #DIA_UTEIS_MES_ATUAL
@Tgo1014
Tgo1014 / Android - sendFile.java
Created April 28, 2016 01:37
Send a file from Android to Java Server
//first you need to create a socket and connect with a socket then use the following code
private OutputStream out = socket.getOutputStream();;
//you need to use the file you want to send as a param
public void sendMessage(File file) throws IOException {
if (out != null) {
byte[] bytes = new byte[(int) file.length()];
BufferedInputStream bis;
bis = new BufferedInputStream(new FileInputStream(file));
bis.read(bytes, 0, bytes.length);