Skip to content

Instantly share code, notes, and snippets.

View slidenerd's full-sized avatar

slidenerd slidenerd

View GitHub Profile
@slidenerd
slidenerd / RecyclerViewAdapter.java
Last active September 24, 2024 15:14
A single adapter that supports Cursor + an optional header + optional footer
import android.database.Cursor;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
public abstract class RecyclerCursorAdapter<U, V extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements OnSwipeListener {
//The number of headers to be displayed by default if child classes want a header
public static final int HEADER_COUNT = 1;
//The number of footers to be displated by default if child classes want a footer
@slidenerd
slidenerd / sqlite_benchmarks.py
Created May 1, 2018 10:58
Python SQLite Benchmarks
import sqlite3
import time
import random
import string
import os
import timeit
from functools import wraps
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
import threading
import os
@slidenerd
slidenerd / flatten.js
Created August 19, 2016 13:32
Inspired from gdibble
function flattenObject(ob) {
let toReturn = {};
let flatObject;
for (let i in ob) {
console.log(i+ ' ' + typeof(ob[i]));
if (!ob.hasOwnProperty(i)) {
continue;
}
//Exclude arrays from the final result
//Check this http://stackoverflow.com/questions/4775722/check-if-object-is-array
@slidenerd
slidenerd / 1.mongodb-aws-setup-guide.md
Created June 20, 2019 11:45 — forked from calvinh8/1.mongodb-aws-setup-guide.md
MongoDB Setup Guide for AWS EC2 Instances with Auth Enabled
@slidenerd
slidenerd / benchmarks.js
Created May 14, 2018 12:43
JS Dynamic Table Insert Rows Benchmark with different methods
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.min.css" />
</head>
<body>
<div id="status"></div>
<table id = "data" class="d-none">
</table>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/platform/1.3.4/platform.js"></script>
@slidenerd
slidenerd / mongodbtestalerts.js
Created May 12, 2018 06:58
test mongodb alerts with aggregation pipeline
const
fs = require('fs'),
fse = require('fs-extra'),
MongoClient = require('mongodb').MongoClient,
mongoose = require('mongoose'),
ObjectID = require('mongodb').ObjectID,
request = require('request')
const includes = ["AUD", "BRL", "CAD", "CHF", "CLP", "CNY", "CZK", "DKK", "EUR", "GBP", "HKD", "HUF", "IDR", "ILS", "INR", "JPY", "KRW", "MXN", "MYR", "NOK", "NZD", "PHP", "PKR", "PLN", "RUB", "SEK", "SGD", "THB", "TRY", "TWD", "USD", "ZAR"]