Skip to content

Instantly share code, notes, and snippets.

Avatar

slidenerd slidenerd

View GitHub Profile
@slidenerd
slidenerd / 1.mongodb-aws-setup-guide.md
Created Jun 20, 2019 — forked from calvinh8/1.mongodb-aws-setup-guide.md
MongoDB Setup Guide for AWS EC2 Instances with Auth Enabled
View 1.mongodb-aws-setup-guide.md
@slidenerd
slidenerd / benchmarks.js
Created May 14, 2018
JS Dynamic Table Insert Rows Benchmark with different methods
View benchmarks.js
<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
test mongodb alerts with aggregation pipeline
View mongodbtestalerts.js
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"]
@slidenerd
slidenerd / sqlite_benchmarks.py
Created May 1, 2018
Python SQLite Benchmarks
View sqlite_benchmarks.py
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 Aug 19, 2016
Inspired from gdibble
View flatten.js
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 / RecyclerViewAdapter.java
Last active Jul 10, 2020
A single adapter that supports Cursor + an optional header + optional footer
View RecyclerViewAdapter.java
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