Skip to content

Instantly share code, notes, and snippets.

View ayrusme's full-sized avatar
🚀
Onwards and Upwards!

Surya Raman ayrusme

🚀
Onwards and Upwards!
View GitHub Profile
const calorieMap = {};
function calculateCalories() {
let spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
let calorieSheet = spreadsheet.getSheetByName("Calories");
let calorieValues = calorieSheet.getRange("A2:B").getDisplayValues();
for (let [index, item] of calorieValues.entries()) {
if (item[0].length && item[1].length) {
calorieMap[item[0].trim()] = parseFloat(item[1].trim());
function partition(arr, low, high) {
let pivot = arr[high];
let i = low - 1;
for (let j = low; j < high; j++) {
if (arr[j] <= pivot) {
// if the current element is less than or equal to the pivot,
// increment i and then swap the current element with arr[i]
i++;
[arr[i], arr[j]] = [arr[j], arr[i]];
}
@ayrusme
ayrusme / replaceUnicode.js
Created December 22, 2020 18:28
Unicode Regex Replace
const unicodeRegex = /(u[\d]{4,5})/gim;
let str =
"Hi thereu0021 I am super excited to have you hereu0021 🙏";
function replaceUnicode(str) {
return str.replace(unicodeRegex, (match, p1, offset, string) => {
return JSON.parse(`["\\${match}"]`)[0];
});
}
@ayrusme
ayrusme / proxy.js
Last active March 16, 2023 01:50
Alternate way to detect changes to any value in an Object
let initialObject = {
goingToChange: true,
firstKey: 'firstKey',
secondKey: 'secondKey',
thirdKey: 'thirdKey'
};
const changedProperties = [];
// define a setter to push to an array if a value inside object changes
@ayrusme
ayrusme / aowl.py
Created June 11, 2020 08:00
Art of War Legions Simulator for Pixel 2 XL
import subprocess
import time
while True:
subprocess.call("adb shell input tap 775 2385".split(" ")) # battle
time.sleep(2) # wait for ui to render
subprocess.call("adb shell input tap 775 2385".split(" ")) # continue
time.sleep(22) # wait for battle to end
@ayrusme
ayrusme / Free O'Reilly Books.md
Created February 5, 2019 03:20 — forked from ellerbrock/Free O'Reilly Books.md
Free O'Reilly Books

Free O'Reilly books and convenient script to just download them.

Thanks /u/FallenAege/ and /u/ShPavel/ from this Reddit post

How to use:

  1. Take the download.sh file and put it into a directory where you want the files to be saved.
  2. cd into the directory and make sure that it has executable permissions (chmod +x download.sh should do it)
  3. Run ./download.sh and wee there it goes. Also if you do not want all the files, just simply comment the ones you do not want.