Skip to content

Instantly share code, notes, and snippets.

View louicoder's full-sized avatar
🏠
Working remotely

Musanje Louis Michael louicoder

🏠
Working remotely
View GitHub Profile
{"lastUpload":"2021-05-09T19:37:48.877Z","extensionVersion":"v3.4.3"}
const app = require('express')(),
env = require('dotenv').config(),
JWT = require('jsonwebtoken'),
bodyParser = require('body-parser');
// support parsing of application/json type post data
app.use(bodyParser.json());
//support parsing of application/x-www-form-urlencoded post data
app.use(bodyParser.urlencoded({ extended: true }));
@louicoder
louicoder / AndroidKeyEvents.txt
Created November 21, 2019 13:50
Key events to reload and access the developer menu while debugging on physical device without having to shake the phone. These can be added to your package.json file
"reload":"adb shell input keyevent 82 && adb shell input keyevent 66 && adb shell input keyevent 66",
"devmenu":"adb shell input keyevent 82",
"debug":"adb shell input keyevent 82 && adb shell input keyevent 61 && adb shell input keyevent 66 && adb shell input keyevent 66"
@louicoder
louicoder / WordToExcelScrapper.py
Last active January 30, 2020 07:39
Python script to read from Word document and populate data into an excel file
import xlsxwriter
import glob
from docx import Document
from pyautogui import alert
workbook = xlsxwriter.Workbook('LONG LISTING.xlsx')
worksheet = workbook.add_worksheet()
# SET COLUMN HEADERS
# --- table 1
@louicoder
louicoder / createBlobFromUri.js
Created March 22, 2020 10:50
Creating a blob file to upload to firebase storage bucket when using react-native-image-picker
// uri is the uri property on the response object from reactnative image picker
function convertUriToBlobFile = (uri) => {
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.onload = function () {
// return the blob
resolve(xhr.response);
// setBlob(xhr.response);
};
@louicoder
louicoder / copy_mongodb_collection.md
Last active September 25, 2020 08:34
Copy collection from one database to another.
  1. login to the mongodb shell.
  2. go to dabase using command use <database_name>.
db.<your_collection_name_to_copy>.find().forEach(function(yourVariableName){
   db.getSiblingDB('<your_destination_atabase>')['<new_collection_name>'].insert(yourVariableName);
});
@louicoder
louicoder / Box Shadow RN.js
Last active February 6, 2022 08:13
React native box show Shadow properties
// Properties need to obtain a box shadow effect in React native
const shadow = {
elevation: 4,
shadowOffset: { width: 3, height: 5 },
shadowColor: '#ccc',
shadowOpacity: 0.2,
shadowRadius: 10
};
@louicoder
louicoder / helperFunctions.js
Last active July 28, 2022 11:48
Helper Functions in Javascript
/**
* FUNCTION shuffles an array passed and return a shuffled array with
* new positions for all array elements.
* More in this shuffle techniques can be found here on link below
* https://bost.ocks.org/mike/shuffle/
*
* @param {Array} arr - array to be shuffled
* @returns {Array} array - new shuffled array.
*/
@louicoder
louicoder / quizFunctions.js
Last active July 24, 2021 09:17
Quiz functions to be added to animation quizzes
/**
* Function picks random number of specified elements in an array and will return
* random (n) numbers from the array length
*
* @param {Array} [arr=[...Array(100).fill().map((el,i) => i+1)]] - array of elements
* @param {Number} [count=7] - count of elements to be picked
*/
const pickRandomArrayElements = (arr, count = 7) => {
let _arr = [ ...arr ];
return [ ...Array(count) ].map(() => _arr.splice(Math.floor(Math.random() * _arr.length), 1)[0]);
@louicoder
louicoder / StickyView.js
Last active July 28, 2021 07:13
A sticky View for react native that sticks at the bottom of screen
import React from 'react';
import { StyleSheet, KeyboardAvoidingView, Platform, NativeModules } from 'react-native';
const { StatusBarManager } = NativeModules;
let statusBarHeight = 0;
if (Platform.OS === 'ios') {
StatusBarManager.getHeight((statusBarFrameData) => {
statusBarHeight = statusBarFrameData.height;
});