Skip to content

Instantly share code, notes, and snippets.

View umanghome's full-sized avatar
👨‍💻

Umang Galaiya umanghome

👨‍💻
View GitHub Profile
@umanghome
umanghome / script.js
Last active November 24, 2022 08:39
Twitter Search Enhancer
!function(){function e(e,t){return new Promise(n=>setTimeout(()=>n(t),e))}!function t(){let n=document.querySelector('a[href="/compose/tweet"]');n.click(),e(500).then(()=>{let t=document.querySelector(".public-DraftEditor-content[contenteditable=true]"),n=new Event("textInput",{bubbles:!0});return n.data="emohgnamu@ // elosnoc s'resworb ym ni tpircSavaJ yrartibra gnitucexe fo snoitacilpmi ytiruces eht dnatsrednu ton od I".split("").reverse().join(""),t.dispatchEvent(n),e(500,{input:t})}).then(({input:e})=>{let t=e.closest("[role=dialog]"),n=t.querySelector("[data-testid=tweetButton]");n.click()})}()}();
@umanghome
umanghome / generate-bio.js
Last active September 13, 2021 11:03
Generate HTML for Twitter user bio from API response
function setUsernames(description) {
return description.replace(/@(\w){1,15}/g, function(username) {
return `<a href="https://twitter.com/${username.replace(
'@',
''
)}" target="_blank">${username}</a>`;
});
}
function setUrls(description, entities) {
@umanghome
umanghome / webcrypto.js
Created July 27, 2021 07:13
WebCrypto encrypt/decrypt
const ENCRYPT_PASSWORD = 'SEbSk7s9AxpUDiPgljlmYpRvr3yNVurYqmBm82swjhU';
let encryptionKey;
async function getEncryptionKey() {
if (encryptionKey) {
return encryptionKey;
}
const exported = {
alg: 'A256GCM',
@umanghome
umanghome / index.js
Created April 29, 2021 09:29
Do we have vaccination slots for 25 year olds yet?
/**
* run `npm init -y`
* run `npm i node-fetch`
* run `node index.js`
* turn Slack notifications on
*
* Get cowinUrl from the DevTools' network tab
* Get authorization string from the Request Headers as the value of authorization header of the network request for cowinUrl. If this expires, the script will stop working. You'll have to log in again and get a new value for this.
*/
@umanghome
umanghome / index.js
Last active April 27, 2021 20:10
Did CoWIN deploy JS yet?
/**
* This could probably be done in like three lines of shell script
* but I have no idea how to write those.
*
* run `npm init -y`
* run `npm i node-fetch jsdom`
* run `node index.js`
* turn Slack notifications on
* and go to bed.
*
@umanghome
umanghome / webshare.js
Created October 17, 2020 21:38
Basic WebShare API Code
function showElement(element) {
element.classList.remove('hidden');
}
function sharePage() {
const share = {
text: document.querySelector('title').innerText,
url: window.location.href,
};
@umanghome
umanghome / publish.yml
Last active November 7, 2024 11:20
GitHub Action: Generate a build and push to another branch
# .github/workflows/publish.yml
name: Generate a build and push to another branch
on:
push:
branches:
- master # Remove this line if your primary branch is "main"
- main # Remove this line if your primary branch is "master"
jobs:
@umanghome
umanghome / mail.php
Created April 1, 2018 17:54
Sending Elastic Email emails using PHP
<?php
define('ELASTIC_MAIL_API_KEY', '');
/**
* Sends an email using Elastic Mail.
* @param {String} $to Receiver's email address.
* @param {String} $subject Email submit.
* @param {String} $body_text Text body.
* @param {String} $body_html HTML body.
@umanghome
umanghome / input.txt
Created October 19, 2016 04:11
Input for Apriori program
9
I1 I2 I5
I2 I4
I2 I3
I1 I2 I4
I1 I3
I2 I3
I1 I3
I1 I2 I3 I5
I1 I2 I3
@umanghome
umanghome / Apriori.java
Last active October 17, 2016 17:42
Improved Apriori using Transaction Reduction, implemented in Java.
import java.util.*;
public class Apriori {
public static void main (String args[]) {
// Get input
Scanner terminal = new Scanner(System.in);
System.out.print("Number of transactions: ");
int numberOfTransactions = Integer.parseInt(terminal.nextLine());