Skip to content

Instantly share code, notes, and snippets.

@mvark
mvark / location.html
Created January 9, 2024 07:35
Simple JavaScript code sample to detect location through an API call to IPAPI web service
<!DOCTYPE html>
<html>
<head>
<title>Location Detection</title>
</head>
<body>
<div id="userDetails"></div>
<script>
@mvark
mvark / SnippetsCompact.js
Last active January 2, 2024 17:08
This is compact code version of Snippets Bookmarklet that saves snippets you need with custom names & retrieves them with a single click
javascript:(function(){function g(t){return prompt(t)}d=localStorage;a=g('Enter "get" or "set": ');if(a=="get"){k=d.length?[...Array(d.length)].map(i=>d.key(i)).filter(k=>k.startsWith('z_')):[];k=g("Keys: "+k+"\nEnter key:");if(d.getItem(k))document.getElementById("prompt-textarea").value=d.getItem(k);else alert("Key does not exist!")}else if(a=="set"){k="z_"+g("Enter new key: ");v=g("Enter value to store:");d.setItem(k,v)}else alert("Invalid action")})()
@mvark
mvark / snippets.js
Created January 2, 2024 16:35
Snippets Bookmarklet saves snippets you need with custom names & retrieves them with a single click
javascript:(function(){
//The getInput function is defined to prompt the user for input.
function getInput(text){return prompt(text)}
//the localStorage will be used to store & retrieve keys and values.
d = localStorage;
//The user is prompted to enter either "get" or "set" to choose the action.
a = getInput('Enter "get" or "set": ');
@mvark
mvark / MLA2023.csv
Last active December 5, 2023 14:00
Winners of the Telangana Legislative Assembly Elections 2023
Constituency MLA Party
Achampet Dr CHIKKUDU VAMSHI KRISHNA Indian National Congress
Adilabad PAYAL SHANKER Bharatiya Janata Party
Alair ILAIAH BEERLA Indian National Congress
Alampur VIJAYUDU Bharat Rashtra Samithi
Amberpet KALERU VENKATESH Bharat Rashtra Samithi
Andole C. DAMODAR RAJANARSIMHA Indian National Congress
Armur Paidi Rakesh Reddy Bharatiya Janata Party
Asifabad KOVA LAXMI Bharat Rashtra Samithi
Aswaraopeta ADINARAYANA. JARE Indian National Congress
javascript:function e(){const t=200,n=e=>e?e.split(/\s+/).length:0,o=(e,t,n)=>{const o=e/t,r=n/e;return.39*o+11.8*r-15.59},r=()=>window.getSelection().toString().trim()||document.body.innerText.trim(),s=r(),l=n(s),a=Math.ceil(l/t),i=s.split(/[.!?]+/).length,c=s.split(/[aeiouy]+/i).length-1,d=o(l,i,c);alert(`Word Count: ${l}\nReading Time: ${a} min\nReadability Level (Flesch-Kincaid Grade Level): ${d.toFixed(2)}`)}e();
@mvark
mvark / ReadabilityLevel.js
Last active November 15, 2023 03:27
Bookmarklet code to calculate Word Count, Estimated Reading Time and Readability Level (Flesch-Kincaid Grade Level)
// Code generated by ChatGPT
javascript:function estimateReadability() {
const wordsPerMinute = 200;
// Function to get word count from text
const getWordCount = text => text ? text.split(/\s+/).length : 0;
// Function to calculate readability level
const getReadabilityLevel = (wordCount, sentenceCount, syllableCount) => {
const averageWordsPerSentence = wordCount / sentenceCount;
@mvark
mvark / EstimatedReadingTimeCompact.js
Created November 13, 2023 07:36
Compact version of Bookmarklet code to calculate Word Count & Estimated Reading Time
javascript:(function(wpm = 200){const st = window.getSelection().toString().trim(),tw = st ? st.split(/\s+/).length : document.body.innerText.split(/\s+/).length,et = Math.ceil(tw / wpm);alert(`Word count: ${tw}\nEstimated reading time: ${et} minutes`);})();
@mvark
mvark / EstimatedReadingTime.js
Last active November 15, 2023 03:27
Bookmarklet code to calculate Word Count & Estimated Reading Time
// Code generated by Bard
// IIFE (Immediately Invoked Function Expression) is used to encapsulate the code within a function to avoid polluting the global namespace and execute it immediately
//default parameter is used to set the initial value of the wordsPerMinute variable to 200 assuming assuming that words-per-minute rate for reading. You can adjust this value based on your preferred reading speed.
javascript:(function(wordsPerMinute = 200) {
// selected text from the webpage is trimmed of any leading or trailing whitespaces
const selectedText = window.getSelection().toString().trim();
// We proceed to calculate the estimated reading time based on the selected text or all words in the body
// single ternary expression is used instead of if statements
@mvark
mvark / download.ps
Created November 25, 2022 08:26
PowerShell script to download a list of files that have a predictable number pattern
# PowerShell script to download a list of files that have a predictable number pattern 1.jpg, 2.jpg etc..
$baseUri = "https://somesite.com/files/"
for ($i = 1; $i -lt 9; $i++) {
{
$f = $baseUri + $i + ".jpg"
$Downloadpath = "C:\temp\" + $i + ".jpg"
Write-Output "Processing file: $f"
Invoke-WebRequest -Uri $f -Outfile $Downloadpath
}
@mvark
mvark / Skribbl-words.csv
Last active February 9, 2026 03:37
skribbl.io word list
word count
ace 3
ant 3
arm 3
ash 3
axe 3
bad 3
bag 3
bar 3
bat 3