Skip to content

Instantly share code, notes, and snippets.

@iqbmo04
iqbmo04 / ultimate-ut-cheat-sheet.md
Created September 9, 2021 12:05 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai, Sinon, and Jest
@iqbmo04
iqbmo04 / gitcreate.sh
Created August 1, 2021 23:33 — forked from robwierzbowski/gitcreate.sh
A simple litte script. Create and push to a new github repo from the command line.
#!/bin/bash
# https://gist.github.com/robwierzbowski/5430952/
# Create and push to a new github repo from the command line.
# Grabs sensible defaults from the containing folder and `.gitconfig`.
# Refinements welcome.
# Gather constant vars
CURRENTDIR=${PWD##*/}
GITHUBUSER=$(git config github.user)
@iqbmo04
iqbmo04 / setWindow.cypress.js
Created July 6, 2021 23:00 — forked from subtleGradient/setWindow.cypress.js
Test multiple popup windows and iframes with Cypress, including window.open
/*
The MIT License
Copyright 2020 Thomas Aylott <oblivious@subtlegradient.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF O
@iqbmo04
iqbmo04 / support.js
Created March 16, 2021 14:31 — forked from NicholasBoll/support.js
Cypress assertion to compare colors
const compareColor = (color, property) => (targetElement) => {
const tempElement = document.createElement('div');
tempElement.style.color = color;
tempElement.style.display = 'none'; // make sure it doesn't actually render
document.body.appendChild(tempElement); // append so that `getComputedStyle` actually works
const tempColor = getComputedStyle(tempElement).color;
const targetColor = getComputedStyle(targetElement[0])[property];
document.body.removeChild(tempElement); // remove it because we're done with it
@iqbmo04
iqbmo04 / node_create_a_redirect_server.md
Created March 7, 2021 22:27 — forked from leommoore/node_create_a_redirect_server.md
Create a redirect server in Node.js

#Create a redirect server in Node.js

'use strict'

var http = require('http');

var mappings = {
 g: 'http://www.google.com'
@iqbmo04
iqbmo04 / proxy.js
Created March 7, 2021 21:18 — forked from cmawhorter/proxy.js
Node script to forward all http requests to another server and return the response with an access-control-allow-origin header. Follows redirects.
// Simple proxy/forwarding server for when you don't want to have to add CORS during development.
// Usage: node proxy.js
// Open browser and navigate to http://localhost:9100/[url]
// Example: http://localhost:9100/http://www.google.com
// This is *NOT* for anything outside local development. It has zero error handling among other glaring problems.
// This started as code I grabbed from this SO question: http://stackoverflow.com/a/13472952/670023
@iqbmo04
iqbmo04 / getProperty.js
Created March 4, 2021 15:43 — forked from jasonrhodes/getProperty.js
Get a nested object property by passing a dot notation string as the property name
/**
* A function to take a string written in dot notation style, and use it to
* find a nested object property inside of an object.
*
* Useful in a plugin or module that accepts a JSON array of objects, but
* you want to let the user specify where to find various bits of data
* inside of each custom object instead of forcing a standardized
* property list.
*
* @param String nested A dot notation style parameter reference (ie "urls.small")
@iqbmo04
iqbmo04 / javascript-remove-accents.js
Created October 28, 2020 13:00 — forked from marcelo-ribeiro/javascript-remove-accents.js
An Javascript function to remove accents, spaces and set lower case from an input string.
function slugify (str) {
var map = {
'-' : ' ',
'-' : '_',
'a' : 'á|à|ã|â|À|Á|Ã|Â',
'e' : 'é|è|ê|É|È|Ê',
'i' : 'í|ì|î|Í|Ì|Î',
'o' : 'ó|ò|ô|õ|Ó|Ò|Ô|Õ',
'u' : 'ú|ù|û|ü|Ú|Ù|Û|Ü',
'c' : 'ç|Ç',
@iqbmo04
iqbmo04 / javascript-remove-accents.js
Created October 28, 2020 13:00 — forked from marcelo-ribeiro/javascript-remove-accents.js
An Javascript function to remove accents, spaces and set lower case from an input string.
function slugify (str) {
var map = {
'-' : ' ',
'-' : '_',
'a' : 'á|à|ã|â|À|Á|Ã|Â',
'e' : 'é|è|ê|É|È|Ê',
'i' : 'í|ì|î|Í|Ì|Î',
'o' : 'ó|ò|ô|õ|Ó|Ò|Ô|Õ',
'u' : 'ú|ù|û|ü|Ú|Ù|Û|Ü',
'c' : 'ç|Ç',
@iqbmo04
iqbmo04 / Test.java
Created July 22, 2020 13:54 — forked from madan712/Test.java
Marshalling and unmarshalling of Hashtable using Holder class
import java.io.StringReader;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Hashtable;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;