Skip to content

Instantly share code, notes, and snippets.

View vishwarajanand's full-sized avatar
😎
¯\_(ツ)_/¯

Vishwaraj Anand vishwarajanand

😎
¯\_(ツ)_/¯
View GitHub Profile
@vishwarajanand
vishwarajanand / yt_video_availability.js
Created February 17, 2022 04:34
JS snippet to check whether a YouTube video is available or not
// Load a YT URL like https://www.youtube.com/watch?v=XYZABC
let is_not_available = ["video unavailable", "video isn't available"].
some(needle =>
document.getElementById("contents").textContent.toLowerCase().includes(needle));
@vishwarajanand
vishwarajanand / print_log.js
Created January 11, 2022 06:36
npm log checker script
console.log("Date", new Date());
console.log("npm works fine!");
' Helps set print area of a worksheet so that print preview doesn't overflow
Public Sub PrintExcelSelection()
Dim ws As Worksheet: Set ws = ThisWorkbook.ActiveSheet
With ws.PageSetup
.Orientation = xlLandscape
.Zoom = False
.FitToPagesTall = 1
.FitToPagesWide = 1
.PrintArea = ActiveCell.CurrentRegion.Address
@vishwarajanand
vishwarajanand / splitting_excel_workbook.md
Last active August 22, 2019 07:29
Split excel workbook into several files with fewer rows

I faced some difficulty in splitting a large Excel file into several smaller ones with fewer rows. Here is a quick solutions for the same:

Open file to split -> Developer menu -> Visual Basic menu -> Insert menu -> new module submenu -> paste the following code and click on green run button.

Sub Test()
  Dim wb As Workbook
  Dim ThisSheet As Worksheet
  Dim NumOfColumns As Integer
  Dim RangeToCopy As Range
@vishwarajanand
vishwarajanand / CreativePerformance.js
Last active June 29, 2019 04:51
Creative performance Facebook Scripting Engine script
Logger.log('Starting script to generate creatives impressions performance');
let creatives_performance_map = {};
const account = AdAccount.myAccount();
const campaigns = account.getCampaigns()
.loadName()
.loadId()
.setEffectiveStatus(['ACTIVE'])
.execute();
@vishwarajanand
vishwarajanand / nginx.conf for CORS
Created July 17, 2018 11:34
Excerpts from my nginx config which helped me to skip CORS issue where cross origin requests are not allowed
server {
# Nginx listens at this address, http://172.17.0.1:4321
listen 4321;
server_name 172.17.0.1;
# Nginx listens to this location when calls are made to http://172.17.0.1:4321/location1
location ~ /location1 {
# we could have set any server here, lets call this server 1.
proxy_pass http://172.17.0.1:1234;
# add a header for host, keep it same all across
Write a Python program that implements the ‘Shiritori" (first letter. last letter) game. In this game, a person starts with a word. and the next person has to come up with a word that starts with the last letter of the previous word. (e.g.. If the first person starts with "apple", the next person has to come up with a word that starts with the letter ‘e'.)
Rules of the game:
1. Word must be a valid word.
2. Word must not have been used before.
3. Word must begin with the last letter of the previous word.
The Python program should take in an input word and check whether it exists in the database of words. If the word does not violate any rule of the game. it is deemed valid and the game continues. Else. the game ends.
The database of words would be the provided "word_list.txt" file. The program should open the "word_list.txt" file for reading, then read and store the contents of the file into a suitable Python data type.
@vishwarajanand
vishwarajanand / main.py
Created June 2, 2018 14:31
RandomNumbersArray created by vishwaraj00 - https://repl.it/@vishwaraj00/RandomNumbersArray
"""
Write a Python program that generates a list containing integers of random values. The program should take in user inputs for the list length and range of integer values. User-defined functions should be used in the program. The program should print out:
1. The generated list
2. List length
3. Largest integer
4. Smallest integer
5. Total sum of the integers in the list
6. Average of the integers in the list