Skip to content

Instantly share code, notes, and snippets.

View mrhammadasif's full-sized avatar
😍
In love with JS

Hammad Asif mrhammadasif

😍
In love with JS
View GitHub Profile
@mrhammadasif
mrhammadasif / script.js
Created March 29, 2024 12:08
Remove all Songs from Playlist
var song = document.body.querySelectorAll( ".dropdown-trigger.ytmusic-menu-renderer" )
for ( var i = 0; i < song.length; i++ ) {
song[i].click(); var dropdown = document.body.querySelector( "ytmusic-menu-popup-renderer[slot='dropdown-content']" )
if ( dropdown != undefined ) {
var items = dropdown.querySelector( "tp-yt-paper-listbox#items" ).querySelectorAll( "ytmusic-menu-service-item-renderer" )
if ( items != null ) {
items.forEach( async ( element ) => {
if ( element.querySelector( 'yt-formatted-string' ).innerHTML == 'Remove from playlist' ) {
@mrhammadasif
mrhammadasif / eslint.js
Created October 23, 2022 09:30
For cleaning your code for brevity and nice style
...
'padding-line-between-statements': [
'error',
{
blankLine: 'always',
prev: [
'multiline-const', 'multiline-let', 'multiline-var', 'multiline-block-like', 'return', 'multiline-expression',
],
next: '*',
},
@mrhammadasif
mrhammadasif / .zshrc
Last active October 4, 2022 15:56
Generate fake data using Chance-CLI and copy to clipboard (MacOS)
fake() {
if [[ -z $1 ]]; then
echo "Provide a chance generator:"
exit 1
fi
tocopy=$(chance "$@")
echo $tocopy
echo $tocopy | tr -d '\n' | pbcopy
echo "\nCopied to Clipboard!"
}
@mrhammadasif
mrhammadasif / app.js
Created September 5, 2022 14:15
Dynamic Routes in json-server with CORS enabled for API server
const dynamicMiddleware = require( 'express-dynamic-middleware' )
const jsonServer = require( "json-server" )
const jsonFile = "db.json"
const server = jsonServer.create()
let router = jsonServer.router( jsonFile )
let dynamicRouter = dynamicMiddleware.create( router )
const defaults = jsonServer.defaults()
@mrhammadasif
mrhammadasif / settings.json
Created August 5, 2020 18:24
My VS Code Settings
{
"editor.fontSize": 13,
"editor.fontFamily": "'JetBrains Mono', monospace",
"editor.tabSize": 2,
"editor.detectIndentation": false,
"editor.renderLineHighlight": "all",
"editor.showFoldingControls": "always",
"editor.smoothScrolling": true,
"editor.stablePeek": false,
"emmet.includeLanguages": {
@mrhammadasif
mrhammadasif / check-version.js
Created July 28, 2020 13:34
Version Management for Vue SPA application to see for outdated content
import compareVersions from 'compare-versions';
fetch(process.env.BASE_URL + `version.json?_d=` + encodeURI(new Date().toJSON()), {
method: "GET",
headers: {
"pragma": "no-cache",
"cache-control": "no-store"
}
})
.then(resp => resp.json())
.then(json => {
@mrhammadasif
mrhammadasif / cheetay-order-response.json
Created March 13, 2020 12:00
Cheetay response for tracking order
{
"category": "food",
"meter_states": {
"quality_control": "status-pending",
"preparing": "status-current",
"on_the_way": "status-pending"
},
"delivery_time": "25",
"is_food_order": true,
"date_received": "2020-03-13 01:52:01 PM",
@mrhammadasif
mrhammadasif / gulp-plugin.js
Created February 13, 2019 11:02
gulp plugin for .env files
const through = require("through2")
function changeEnvToDev(val) {
return through.obj(function(file, encoding, callback) {
if (file.isNull()) return callback(null, file)
if (file.isStream()) {
//file.contents = file.contents.pipe(...
//return callback(null, file);
this.emit("error", new Error("Streams not supported!"))
@mrhammadasif
mrhammadasif / adaptive-payment-paypal-example.php
Created November 21, 2018 09:45
Adaptive Payment Paypal Example
<?php
class PayPal {
private $config;
private $urls = array(
"sandbox" => array(
"api" => "https://svcs.sandbox.paypal.com/AdaptivePayments/",
"redirect" => "https://www.sandbox.paypal.com/webscr",
),
"live" => array(
@mrhammadasif
mrhammadasif / BetterJump.cs
Created December 15, 2017 13:29
BetterJump in Unity
using System.Collections;
using UnityEngine;
public class BetterJump : MonoBehaviour {
public float FallMultiplier = 2.5f;
public float lowJumpMultiplier = 2f;
RigidBody2D rb;