Skip to content

Instantly share code, notes, and snippets.

View htmelvis's full-sized avatar
🕸️

Ed Wieczorek htmelvis

🕸️
View GitHub Profile
@htmelvis
htmelvis / isEqual.js
Created May 4, 2022 13:11
isEqual Object Equality
const isEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
// examples
isEqual({ a: 1, b: 2 }, { a: 1, b: 2 }); // true
isEqual({ a: 1, b: 2 }, { a: 1, b: 3 }); // false
// works with arrays too
isEqual([1, 2, 3], [1, 2, 3]); // true
isEqual([1, 2, 3], [1, 2, 4]); // false
@htmelvis
htmelvis / getParams.js
Created February 14, 2022 14:22
Get Query Params from URL
const getParameters = (URL) => {
URL = JSON.parse('{"' + decodeURI(URL.split("?")[1]).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') +'"}');
return JSON.stringify(URL);
};
getParameters(window.location)
// Result: { search : "easy", page : 3 }

Keybase proof

I hereby claim:

  • I am htmelvis on github.
  • I am edbmt (https://keybase.io/edbmt) on keybase.
  • I have a public key ASDYH-eq0PAGeH2fznBggNYRrcFiYAUrhlka-Dp5IArytAo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am htmelvis on github.
  • I am edbmt (https://keybase.io/edbmt) on keybase.
  • I have a public key ASDYH-eq0PAGeH2fznBggNYRrcFiYAUrhlka-Dp5IArytAo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am htmelvis on github.
  • I am htmelvis (https://keybase.io/htmelvis) on keybase.
  • I have a public key ASAV6FrNQK0Zl0R1gMHIHD4IWYCaam194OtilTajxec2Ego

To claim this, I am signing this object:

@htmelvis
htmelvis / package.json
Created November 14, 2017 18:39
NODE, JEST, REACT, WEBPACK PACKAGE.JSON EXAMPLE
{
"name": "Example",
"version": "1.0.0",
"description": "This is an example of a complex app using Jest",
"main": "index.js",
"scripts": {
"start": "npm-run-all --parallel watch:server watch:build",
"watch:build": "webpack -d --watch --progress --colors",
"watch:server": "nodemon \"server/server.js\" --watch \"./server\"",
"test": "jest",
@htmelvis
htmelvis / selectText.js
Created November 30, 2016 20:24
Select Text From Div on Click (jQuery)
function selectText(containerid) {
if (document.selection) {
var range = document.body.createTextRange();
range.moveToElementText(document.getElementById(containerid));
range.select();
} else if (window.getSelection) {
var range = document.createRange();
range.selectNode(document.getElementById(containerid));
window.getSelection().addRange(range);
}
{% if context == 'cart' or context == 'checkout' %}
<script type="text/javascript" charset="utf-8">
(function (FC, $) {
//Set the text of the newsletter subscribe button
FC.json.config.lang.checkout_newsletter_subscribe = "Don’t get left out! Stay up to date on our latest products and promotions.";
//set the default checked method to checked on the checkbox for subscribe
FC.customFlatRates = {};
@htmelvis
htmelvis / iterator.js
Created February 15, 2016 13:45
Timed Iteration in JavaScript
(function() {
var i = 0,
adArray = [13,14,15,16,17,18,19,110,111,112,113,114,115,116],
l = adArray.length;
(function iterator() {
console.log('Loop: ', i, ' Loop content: ', adArray[i]);
//update before evaluating the conditional
if (++i < l) {
setTimeout(iterator, 1500);
@htmelvis
htmelvis / gist:c0cef083ecc536473b4c
Created January 7, 2016 21:12
Whatsup: Alias for checking running port processes
# Check what server processes are currently running on a given port
function _checkForRunningServer(){
echo "Currently checking port: $1"
lsof -wni tcp\:$1;
#would like to expand to pass arg to kill said server ps
}
#register the alias in your .bashrc or .zshrc
alias whatsup=_checkForRunningServer