Skip to content

Instantly share code, notes, and snippets.

View AntonioDiaz's full-sized avatar
🤓

Antonio Diaz Arroyo AntonioDiaz

🤓
View GitHub Profile
@AntonioDiaz
AntonioDiaz / CalendarAdapter.java
Created March 23, 2017 15:44
BaseExpandableListAdapter example
package com.adiaz.expandablelist;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;
import java.util.List;
@AntonioDiaz
AntonioDiaz / toolbar_main.xml
Created March 24, 2017 15:45
Add view inside toolbar.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:contentInsetLeft="0dp"
@AntonioDiaz
AntonioDiaz / DownloadPodcast.kt
Created August 14, 2018 11:17
Script download poscast.
package com.examples
import com.beust.klaxon.JsonArray
import com.beust.klaxon.JsonObject
import com.beust.klaxon.Parser
import com.examples.DownloadPodcast.Companion.NEXT_PUB_DATE_PUNTA_NORTE
import com.examples.DownloadPodcast.Companion.URL_PUNTA_NORTE
import java.io.BufferedInputStream
import java.io.File
import java.io.FileOutputStream
@AntonioDiaz
AntonioDiaz / generateInputStream.kt
Created January 18, 2021 12:26
generateInputStream for testing
private fun generateInputStream(): InputStream {
val bytesOutputStream = ByteArrayOutputStream()
val out = ZipOutputStream(bytesOutputStream, Charset.defaultCharset())
val writeEntry = ZipEntry("test.csv")
out.putNextEntry(writeEntry)
out.write("content".toByteArray())
out.closeEntry()
out.close()
return ByteArrayInputStream(bytesOutputStream.toByteArray())
}
@AntonioDiaz
AntonioDiaz / Update01.java
Created October 14, 2022 06:01
Update Mongo DB
@Test
public void testReplaceDocument() {
MongoCollection<Document> artists = testDb.getCollection("artists");
Bson queryFilter = new Document("_id", band1Id);
Document myBand = artists.find(queryFilter).iterator().tryNext();
Assert.assertEquals(
"Make sure that the band created in the database is"
+ " the same as the band retrieved from the database",
bandOne,
myBand);