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 / MoveFile.ps1
Last active May 2, 2024 13:10
Powershell Script to Move all Recursive specified extensions files to Specific Folder
# define a count variable
$count = 0
# get first argument
$source = $args[0]
mkdir("../$source")
Get-ChildItem -Recurse -Filter "*.$source" | ForEach-Object {
# $json = Get-Content $_ -Raw | ConvertFrom-Json
# $json | ConvertTo-Json | Set-Content $_
Write-Host "Move to: ../$source/$($_.FullName | Split-Path -Leaf)"
$_.MoveTo("../$source/$($_.FullName | Split-Path -Leaf)")
@mrhammadasif
mrhammadasif / App.vue
Created April 16, 2024 13:35
Create Word Stok Game for Printing
<template>
<div id="app">
<div class="p-4 g-4 d-flex align-items-center">
<label class="p-0 m-0" for="">Rows</label>
<input v-model.number="rows" :min="2" :max="20" type="range" class="form-control ml-2 mr-4 m-0">
<label class="p-0 m-0" for="">Columns</label>
<input v-model.number="cols" min="2" step="1" max="20" type="range" class="form-control ml-2 m-0">
<button class="btn btn-primary ml-4" @click="regenKey">Regenerate!</button>
</div>
<table class="table-bordered" :key="key">
@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!"))