Skip to content

Instantly share code, notes, and snippets.

View mohshbool's full-sized avatar

Mohammad Shbool mohshbool

View GitHub Profile
// https://codeburst.io/javascript-array-distinct-5edc93501dc4
export const uniqueArray = (array) => {
console.log(array)
const result = []
const map = new Map()
for (const item of array) {
if(!map.has(item.imdbID)){
map.set(item.imdbID, true)
result.push({
imdbID: item.imdbID,
@mohshbool
mohshbool / ex26.rb
Created March 1, 2019 13:59
Exercise 26 in LearnRubyTheHardway solved
module Ex25
# This function will break up words for us.
def Ex25.break_words(stuff)
return stuff.split(' ')
end
# Sorts the words.
def Ex25.sort_words(words)
return words.sort()
@mohshbool
mohshbool / validateForm.js
Created April 18, 2019 16:24
Validate form function using jQuery@^3.x
const validateForm = () => {
$('input').each(function() {
const $this = $(this);
const $button = $('button');
if ($this.val() === '' || $this.val().length <= 0) {
$button.attr('disabled', 'disabled');
} else if (!$button.attr('disabled')) {
$button.removeAttr('disabled');
}
})
@mohshbool
mohshbool / input.js
Created May 12, 2019 12:49
React Native Input Component with Error messages and Icon support
import React from 'react'
import { View, Text, TextInput, StyleSheet} from 'react-native'
export default class Input extends React.Component {
focus() {
this.input.focus();
}
blur() {
this.input.blur();
@mohshbool
mohshbool / main.cpp
Last active December 27, 2021 18:22
#include <iostream>
#include <cstring>
#include <regex>
#include <queue>
#include <stack>
using namespace std;
class UserAccountType
{
#include <iostream>
using namespace std;
const int ROW_SIZE = 3;
const int COLUMN_SIZE = 3;
void CheckMatrix(int m[][COLUMN_SIZE], int ROW_SIZE)
{
if (COLUMN_SIZE != ROW_SIZE)
@mohshbool
mohshbool / DashedLine.tsx
Created April 25, 2024 17:57
<DashedLine/> React Native Component working on iOS and Android
import React, {FunctionComponent} from 'react';
import {StyleSheet, View, ViewStyle} from 'react-native';
interface Props {
size: number;
color: string;
axis?: 'horizontal' | 'vertical';
style?: ViewStyle;
width?: number;
}
@mohshbool
mohshbool / package-diff.js
Created May 22, 2024 11:22
A Node.js script to compare current installed version in your project with the latest version on the npm registry
const fs = require('fs');
const util = require('util');
const exec = util.promisify(require('child_process').exec);
// ANSI escape codes for colors
const colors = {
reset: '\x1b[0m',
red: '\x1b[31m',
green: '\x1b[32m',
yellow: '\x1b[33m',