Skip to content

Instantly share code, notes, and snippets.

View ShivrajRath's full-sized avatar

Shivraj Rath ShivrajRath

View GitHub Profile
@ShivrajRath
ShivrajRath / clean-twitter.js
Created October 14, 2021 21:46
Clean Twitter (Removes Promoted Ads and distractions)
const removeEl = (el, query) => {
if (el) {
if (query) {
el[query].remove();
} else {
el.remove();
}
}
};
removeEl(document.querySelector("header"));
@ShivrajRath
ShivrajRath / css-reset.css
Created July 26, 2019 15:52
Minimal CSS Reset
html {
box-sizing: border-box;
font-size: 16px;
}
*, *:before, *:after {
box-sizing: inherit;
margin: 0;
padding: 0;
}
@ShivrajRath
ShivrajRath / algoAssert.js
Last active June 18, 2019 04:06
Code to run quick assertion on your function algorithms
const equalityCheck = function(input1, input2) {
if (typeof input1 !== typeof input2) {
return false;
}
if (input1 === input2) {
return true;
}
if (Array.isArray(input1) && Array.isArray(input2)) {
return input1.reduce((acc, el, index) => acc && el === input2[index], true);
}
javascript:(function()%7Bconst%20%24html%20%3D%20document.querySelector(%22html%22)%3Bconst%20%24body%20%3D%20document.querySelector(%22body%22)%3B%24html.style.overflowY%20%3D%20%22scroll%22%3B%24html.style.overflow%20%3D%20%22scroll%22%3B%24body.style.overflowY%20%3D%20%22scroll%22%3B%24body.style.overflow%20%3D%20%22scroll%22%3Bdocument.querySelectorAll(%22*%22).forEach((el)%20%3D%3E%20%7Bconst%20cs%20%3D%20getComputedStyle(el)%3Bconst%20elPos%20%3D%20cs.position%3Bconst%20filter%20%3D%20cs.filter%3Bif%20(%5B%22fixed%22%2C%20%22sticky%22%5D.includes(elPos))%20%7Bel.parentNode.removeChild(el)%3B%7Dif%20(filter%20%26%26%20filter.match(%2Fblur%2F))%20%7Bel.style.setProperty(%22filter%22%2C%20%22none%22)%3B%7D%7D)%7D)()
@ShivrajRath
ShivrajRath / box-model.less
Created May 22, 2017 22:47
Generates a utility of padding, margins, width and font sizes
/ ............................................................
// .for
.for(@i, @n) {.-each(@i)}
.for(@n) when (isnumber(@n)) {.for(1, @n)}
.for(@i, @n) when not (@i = @n) {
.for((@i + (@n - @i) / abs(@n - @i)), @n);
}
// ............................................................
@ShivrajRath
ShivrajRath / sortLinesByLength.html
Created August 4, 2015 13:35
Sorts a bunch of lines in a paragraphs by their length
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Sort Lines By Length</title>
<style>
.center {

Getting Started with NPM (as a developer)

If you haven't already set your NPM author info, now you should:

npm set init.author.name "Your Name"
npm set init.author.email "you@example.com"
npm set init.author.url "http://yourblog.com"

npm adduser

@ShivrajRath
ShivrajRath / clone.js
Last active August 29, 2015 14:23
Object Cloning
/**
* Clones an object and retains the prototype chain
* @param {Object} fromObj Object to be cloned
* @returns {Object} Cloned Object
*/
function cloneObj(fromObj) {
var toObj, i;
if (fromObj && typeof fromObj === 'object') {
@ShivrajRath
ShivrajRath / codeInMarkdown.md
Last active August 29, 2015 14:23
Code in Markdown
(function(){
  var message = 'Hello Javascript';
  console.log(message);
})();
{
    "11": {
 "value": [3, 6, 8],
@ShivrajRath
ShivrajRath / argumentsAsArray.js
Last active August 29, 2015 14:13
Curious case of JavaScript function arguments
/**
* Running the array reverse function on arguments object
*/
function reverseArgs(){
return Array.prototype.reverse.call(arguments);
}
reverseArgs(12,34,55);
// OUTPUT
// [55, 34, 12]