Skip to content

Instantly share code, notes, and snippets.

View jirevwe's full-sized avatar
🏠
Working from home

Raymond Tukpe jirevwe

🏠
Working from home
View GitHub Profile
@jirevwe
jirevwe / mongoose-walk.ts
Last active June 7, 2019 17:45
Walks through the records in a mongoose collection using a number of cursors
const start_time = performance.now();
const count: number = 1000;
const wallets: Wallet[] = [];
const walletCount = await WalletModel.find({}).estimatedDocumentCount();
// create a cursor for every `currentIndex` documents in the collection
const getNthCursor = async (currentIndex: number) =>
await WalletModel.find({ deleted_at: undefined }, { timeout: false })
.lean()
import redis, { RedisClient } from "redis";
import { promisify } from "util";
export class Redis implements IRedis {
redis: RedisClient;
hdel: (hash: string, field: string) => Promise<any>;
hget: (hash: string, field: string) => Promise<string>;
hgetall: (key: string) => Promise<object>;
hset: (hash: string, field: string, value: any) => Promise<any>;
quit: () => Promise<void>;
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image"
@jirevwe
jirevwe / app_version.gradle
Last active January 9, 2019 13:22 — forked from IliaEremin/app_version.gradle
Npm version for gradle
// Utility function to get version properties
def getVersionProps() {
def versionPropsFile = file('gradle.properties')
if (!versionPropsFile.exists()) {
versionPropsFile.createNewFile()
}
def versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
return versionProps
}
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:layout_width="0dp"
<android.support.v7.widget.CardView
android:id="@+id/backdrop"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@color/transparent"
app:cardCornerRadius="8dp"
app:cardElevation="8dp"
app:layout_constraintEnd_toStartOf="@+id/guidelineRight"
app:layout_constraintHorizontal_bias="0.0"
@jirevwe
jirevwe / man.js
Created October 23, 2018 14:39
Mongoose Schema Inheritance
const mongoose = require('mongoose')
const { PersonSchema } = require('./person')
class ManSchema extends PersonSchema {
constructor(obj, options) {
super(obj, options)
this.add({ age: { type: String, required: true } })
}
}
@jirevwe
jirevwe / check_params.js
Last active October 19, 2018 17:42
Params not valid
exports.paramsNotValid = (...args) => args
.map(param => param !== undefined && param != null && param !== '')
.includes(false)
@jirevwe
jirevwe / CustomTextInputLayout.kt
Created July 25, 2018 08:15
TextInputLayout temporary workaround for helper text showing
package com.fxmallam.app.utils.widgets
import android.content.Context
import android.content.res.ColorStateList
import android.graphics.Rect
import android.support.design.widget.TextInputLayout
import android.support.v4.view.ViewCompat
import android.support.v4.view.ViewPropertyAnimatorListenerAdapter
import android.support.v4.view.animation.FastOutSlowInInterpolator
import android.text.TextUtils
@jirevwe
jirevwe / AndroidManifest.xml
Last active October 23, 2018 14:54
Some Fix for Unexpected Service Shutdown
<!-- KitKat Fix Activity -->
<activity
android:name=".player.KitKatFixActivity"
android:allowTaskReparenting="true"
android:alwaysRetainTaskState="true"
android:clearTaskOnLaunch="true"
android:enabled="true"
android:excludeFromRecents="true"
android:finishOnTaskLaunch="true"
android:noHistory="true"