Skip to content

Instantly share code, notes, and snippets.

View ajimae's full-sized avatar

Ajima Chukwuemeka ajimae

View GitHub Profile
@ajimae
ajimae / is-iphone-x.js
Created March 16, 2020 13:53 — forked from m-tymchyk/is-iphone-x.js
React Native / How to determine if on iPhone X or XR
// is-iphone-x.js
import { Dimensions, Platform } from 'react-native';
export function isIphoneX() {
const dim = Dimensions.get('window');
return (
// This has to be iOS
Platform.OS === 'ios' &&
@ajimae
ajimae / downgrade_Mongodb_replica_to_standalone.txt
Created June 15, 2020 13:24 — forked from marcoberri/downgrade_Mongodb_replica_to_standalone.txt
Migrate MongoDB ReplicaSet to single MongoDB Node
mongoserver:PRIMARY> rs.status();
{
"set" : "mongoserver",
"date" : ISODate("2016-02-02T10:47:07.510Z"),
"myState" : 1,
"members" : [
{
"_id" : 3,
"name" : "192.168.1.10:37017",
"health" : 1,
@ajimae
ajimae / start-mongo-replset.sh
Created June 23, 2020 22:01 — forked from joeytwiddle/start-mongo-replset.sh
Script to start a mongodb cluster with three shards, for MongoDB 3.4
#!/usr/bin/env bash
set -e
# This script will start three shards, a config server and a mongos, all on the current machine.
#
# It was written for Mongo 3.4, based on https://docs.mongodb.com/manual/tutorial/deploy-shard-cluster/
#
# This script is only for testing purposes. In production, you would run each of these servers on a different machine.
#
# The first time you run it, pass this variable for the initial setup:
@ajimae
ajimae / node_nginx_ssl.md
Created August 8, 2020 15:45 — forked from bradtraversy/node_nginx_ssl.md
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

#!/bin/bash
rm -fr ~/Library/Preferences/com.microsoft.VSCode.helper.plist
rm -fr ~/Library/Preferences/com.microsoft.VSCode.plist
rm -fr ~/Library/Caches/com.microsoft.VSCode
rm -fr ~/Library/Caches/com.microsoft.VSCode.ShipIt/
rm -fr ~/Library/Application\ Support/Code/
rm -fr ~/Library/Saved\ Application\ State/com.microsoft.VSCode.savedState/
# rmeove all extensions
@ajimae
ajimae / load.js
Created July 22, 2021 08:10 — forked from rayjanwilson/load.js
example node.js load test script
#!/usr/bin/env node
/*
Load test an api endpoint using sample json input data from a file. Sample json file should be one json string per line.
./load.js -c 2 -t 5 --rps 5 https://APIGATEWAYENDPOINT.execute-api.us-east-1.amazonaws.com/Prod/
-c concurrency
-t load test duration in seconds
--rps requests per second
@ajimae
ajimae / redact.ts
Created August 29, 2021 02:03
Redact sensitive data from a javascript object
type JsonObject = {
[key: string]: any;
};
const jsonObject: any = {
access_token: 'xseHuyOiup08EubvER',
Password: 12345,
refresh_token: 'ytuio.OplaxwRtU',
Authorization: 'az643hrbfj_rueik=='
};
@ajimae
ajimae / vscode_shortcuts.md
Last active August 29, 2021 22:19 — forked from bradtraversy/vscode_shortcuts.md
Helpful shortcuts for VSCode

VSCode Shortcuts

List of helpful shortcuts for faster coding

If you have any other helpful shortcuts, feel free to add in the comments of this gist :)

Official List of all commands

@ajimae
ajimae / json-processor.js
Created September 5, 2021 03:22 — forked from jozefcipa/json-processor.js
Process large JSON files with streams
import fs from 'fs'
import { Transform } from 'stream'
import JSONStream from 'JSONStream'
// Custom transform stream
const transformer = new Transform({
objectMode: true,
transform(jsonItem, encoding, callback) {
// your logic goes here...
// const updatedItem = {}
@ajimae
ajimae / Scroll to index Flatlist example.md
Created December 19, 2021 16:26 — forked from hungdev/Scroll to index Flatlist example.md
Scroll to index Flatlist example
import React, { Component } from 'react';
import { Text, View, FlatList, Dimensions, Button, StyleSheet } from 'react-native';

const { width } = Dimensions.get('window');

const style = {
  justifyContent: 'center',
  alignItems: 'center',
  width: width,