Skip to content

Instantly share code, notes, and snippets.

View MinSomai's full-sized avatar
🇳🇵
from the land of Mountains, Nepal. Namaste!

Min Somai MinSomai

🇳🇵
from the land of Mountains, Nepal. Namaste!
View GitHub Profile
@MinSomai
MinSomai / .bashrc
Created June 15, 2020 14:01
my bashrc
#!/bin/bash
iatest=$(expr index "$-" i)
#######################################################
# SOURCED ALIAS'S AND SCRIPTS BY zachbrowne.me
#######################################################
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
@MinSomai
MinSomai / .vimrc
Created June 15, 2020 14:00
my vimrc
"" Vim commands e: $MYVIMRC
" Not compatible with vi
set nocompatible " required
filetype off " required
" ---------- VUNDLE -----------
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
"call vundle#begin('~/some/path/here')
@MinSomai
MinSomai / JavaScript Algorithms and Data Structures Projects: Telephone Number Validator.js
Created June 1, 2020 15:23
JavaScript Algorithms and Data Structures Projects: Telephone Number Validator
function telephoneCheck(str) {
let numbersOnly = str.replace(/[-\s]/g, "");
let numberLength = numbersOnly.length;
let hasBraces = /[)(]/g;
let bracesVal = str.match(hasBraces);
if(str.indexOf(")") == str.length-1) return false;
if(str[0] == '-') return false;
@MinSomai
MinSomai / JavaScript Algorithms and Data Structures Projects: Caesars Cipher.js
Created June 1, 2020 15:22
JavaScript Algorithms and Data Structures Projects: Caesars Cipher
function rot13(str) {
//65-90 A-Z
return str.split("").map(item=>{
let charCode = item.charCodeAt(item[0]);
if( charCode >= 65 && charCode <= 90 ){
let shift = 13;
if(charCode - shift < 65){
let minusBy = 65 - (charCode - shift);
@MinSomai
MinSomai / JavaScript Algorithms and Data Structures Projects: Roman Numeral Converter.js
Created June 1, 2020 14:29
JavaScript Algorithms and Data Structures Projects: Roman Numeral Converter
function convertToRoman(num) {
let roman = "";
let numCollection = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
let romanCollection = ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"];
while(num != 0){
num = solver(num);
}
function solver(num){
@MinSomai
MinSomai / JavaScript Algorithms and Data Structures Projects: Palindrome Checker.js
Created June 1, 2020 08:19
JavaScript Algorithms and Data Structures Projects: Palindrome Checker
function palindrome(str) {
let filterThese = /[^-_.,)(\s/]/g;
let newString = str.match(filterThese).map(item=> item.toLowerCase());
let reverseString = [...newString].reverse();
return newString.every((item, index)=>{
return item == reverseString[index];
@MinSomai
MinSomai / Intermediate Algorithm Scripting: Map the Debris.js
Created June 1, 2020 07:48
Intermediate Algorithm Scripting: Map the Debris
function orbitalPeriod(arr) {
var GM = 398600.4418;
var earthRadius = 6367.4447;
return arr.map(item=>{
// we need r which is the earthRadius + altitude
let r = item.avgAlt + earthRadius;
// time(t) = sqrt((4PI^2 r^3)/GM);
@MinSomai
MinSomai / Intermediate Algorithm Scripting: Make a Person.js
Created June 1, 2020 06:31
Intermediate Algorithm Scripting: Make a Person
var Person = function(firstAndLast) {
// Complete the method below and implement the others similarly
let firstName = firstAndLast.split(" ")[0];
let lastName = firstAndLast.split(" ")[1];
this.getFullName = function() {
return firstName + " " + lastName;
};
this.getFirstName = function(){
@MinSomai
MinSomai / Intermediate Algorithm Scripting: Arguments Optional.js
Created June 1, 2020 05:03
Intermediate Algorithm Scripting: Arguments Optional
function addTogether(a, b) {
if(b){
return typeof b!= 'number' ? undefined : a + b;
}else{
if(typeof a != 'number'){
return undefined;
}
return function(b){
return typeof b!= 'number' ? undefined : a + b;
}
@MinSomai
MinSomai / Intermediate Algorithm Scripting: Everything Be True.js
Created June 1, 2020 04:49
Intermediate Algorithm Scripting: Everything Be True
function truthCheck(collection, pre) {
let truthy = true;
collection.forEach(item=>{
if(!item[pre]){
truthy = false;
}
});
return truthy;