Skip to content

Instantly share code, notes, and snippets.

View basil2style's full-sized avatar
🎯
Focusing

Basil Alias basil2style

🎯
Focusing
  • Toronto, Canada
View GitHub Profile
@basil2style
basil2style / numwords.gs
Created January 18, 2023 04:22
Google app script to convert number to words
// JS code from https://stackoverflow.com/a/30522105
/**
* Convert number to words.
* @param {number} input the number for conversion.
* @return number in words.
* @customfunction
*/
function NUMWORDS(n) {
@basil2style
basil2style / rasomNote.js
Created July 20, 2021 19:29
Hackerrank Ransom Note Problem
/**
*Direct Link: https://www.hackerrank.com/challenges/ctci-ransom-note/problem
*/
function splitTextByReg(magazine, note) {
//Split both magazine words & note words by space -> Now we have two arrays
//From that arrays, check whether
let ransomNote = true;
// let magazineArr = magazine.split(" ");
// let noteArr = note.split(" ");
function splitTextByReg(text) {
let wordArr = text.split(/[\n,]/);
return wordArr[Math.floor(Math.random() * wordArr.length)];
}
let text = "Basil,Aisd, Blysil"
console.log(splitTextByReg(text));
const puppeteer = require("puppeteer");
(async () => {
try {
//Get the browser instance based on your computer
const browser = await puppeteer.launch({
headless: false,
executablePath:
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
});
/*
10
/ \
4 17
/ \ / \
1 9 12 18
let tree = {
"10": {
value: "10",
@basil2style
basil2style / mergeSortedArrayWithThird.js
Created May 18, 2021 13:42
Merge two sorted arrays into thrid array with O(n+m)
//Merge two sorted arrays into thrid array with O(n+m)
var merge = function (nums1, m, nums2, n) {
let i = 0,
j = 0,
k = 0;
let arr = [];
while (i < m && j < n) {
if (nums1[i] < nums2[j]) {
arr[k] = nums1[i];
class Stack {
constructor() {
this.data = [];
}
push(val) {
this.data.push(val);
console.log(this.data)
}
@basil2style
basil2style / missing-number.rb
Created September 14, 2020 11:26
Given range of 1 to N and an array of unique integers that are within that range, return the missing integers not found in the array
@arr = [1,3,4]
@n = 4
@missing_nums = []
(1..@n).each do |i|
if !@arr.include?(i)
@missing_nums.append(i)
end
end
puts @missing_nums
@basil2style
basil2style / Google Script Example.gs
Created August 6, 2018 03:04
Google script example with GET request to 3rd party URL and enter it on Google Sheets
var url = 'YOUR URL HERE';
function mainFunction() {
getAllUseruid();
}
function getAllUseruid(){
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 2;
@basil2style
basil2style / gs
Created August 6, 2018 03:01
Cron Scheduler in Google Script
#This is a cron job scheduler wrintten in Google App Script which insert Success and timestamp to Google Sheet if its
#successfully fetch the url otherwise it will return Error
var sheet = 'Sheet1';
function myFunction() {
var url = 'YOUR URL HERE';
var options = {
'method': 'get'
};
try {