Skip to content

Instantly share code, notes, and snippets.

View danysantiago's full-sized avatar

Daniel Santiago danysantiago

View GitHub Profile
@danysantiago
danysantiago / ViewModelCoroutineScope.kt
Created November 16, 2023 15:13
HiltViewModel coroutine scope binding via ViewModelLifecycle
// Qualifier to distinguish from other app coroutines
@Qualifier
@Retention(AnnotationRetention.RUNTIME)
annotation class ViewModelCoroutineScope
@Module
@InstallIn(ViewModelComponent::class)
class VMScopeModule {
@Provides
@ViewModelCoroutineScope
@danysantiago
danysantiago / BoundedQueue.java
Created November 12, 2013 20:10
A bounded queue implementation for the KCPB Fellow Application
/**
* A bounded queue implementation for the KCPB Fellow Application
* @author Daniel Santiago
*/
public class BoundedQueue<E> {
private Node<E> head;
private Node<E> tail;
private int size;
private int maxSize;
@danysantiago
danysantiago / AndroidHttpRequest
Created October 26, 2013 14:43
Simple Android HTTP Request callback
package icom5016.modstore.http;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.InvalidParameterException;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
@danysantiago
danysantiago / database.js
Last active July 26, 2017 20:06
Database Singleton Object - database.js is used throughout the app to access the db object. Using mongodb native drivers the db object contains a pool of connections that are used to make requests to the db. To use this singleton object simply require it and either call getDB() or setDB(). The idea is to use setDB in app.js just after we connect…
/**
Database Singleton Object
database.js is used throughout the app to access the db object. Using mongodb
native drivers the db object contains a pool of connections that are used to
make requests to the db. To use this singleton object simply require it and
either call getDB() or setDB(). The idea is to use setDB in app.js just
after we connect to the db and receive the db object, then in any other file we
need the db require and call getDB
**/