Skip to content

Instantly share code, notes, and snippets.

View gulshansainis's full-sized avatar
🎯
Focusing

Gulshan Saini gulshansainis

🎯
Focusing
  • India
View GitHub Profile
@gulshansainis
gulshansainis / javascript_bookmark.js
Created March 5, 2025 15:59
PDF with Dark mode and Focus area
javascript:(function(){ const existingOverlay = document.getElementById("focus-overlay"); if (existingOverlay) { existingOverlay.remove(); return; } const overlay = document.createElement("div"); overlay.id = "focus-overlay"; overlay.style = ` position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0, 0, 0, 0.5); /* Even lighter dark background */ z-index: 9999; pointer-events: none; display: flex; justify-content: center; align-items: center; `; const focusArea = document.createElement("div"); focusArea.style = ` width: 99vw; height: 40vh; background: rgba(255, 255, 255, 0.2); /* Lighter focus area */ box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5); backdrop-filter: brightness(1.8) contrast(1.5); /* Text more visible */ color: black; /* Darker text inside the focus area */ padding: 20px; display: flex; align-it
@gulshansainis
gulshansainis / template-tags.php
Created May 31, 2018 08:16
Twenty Seventeen Categories Are Not Displayed When We Have Single Category
/**
* Returns true if a blog has more than 1 category.
*
* @return bool
*/
function twentyseventeen_categorized_blog() {
$category_count = get_transient( 'twentyseventeen_categories' );
if ( false === $category_count ) {
// Create an array of all the categories that are attached to posts.
@gulshansainis
gulshansainis / functions.php
Last active May 30, 2018 17:20
Wordpress Twenty Seventeen Child Theme - functions.php
<?php
function my_theme_enqueue_styles() {
$parent_style = 'twentyseventeen-style'; // This is 'twentyseventeen-style' for the Twenty Seventeen theme.
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style ),
wp_get_theme()->get('Version')
'''
Write a program to calculate the credit card balance after one year if a person only pays the minimum monthly payment required by the credit card company each month.
The following variables contain values as described below:
balance - the outstanding balance on the credit card
annualInterestRate - annual interest rate as a decimal
monthlyPaymentRate - minimum monthly payment rate as a decimal
'''
The greatest common divisor of two positive integers is the largest integer that divides each of them without remainder. For example,
gcd(2, 12) = 2
gcd(6, 12) = 6
gcd(9, 12) = 3
gcd(17, 12) = 1
'''
The greatest common divisor of two positive integers is the largest integer that divides each of them without remainder. For example,
gcd(2, 12) = 2
gcd(6, 12) = 6
gcd(9, 12) = 3
gcd(17, 12) = 1
'''
We can use the idea of bisection search to determine if a character is in a string, so long as the string is sorted in alphabetical order.
First, test the middle character of a string against the character you're looking for (the "test character"). If they are the same, we are done - we've found the character we're looking for!
If they're not the same, check if the test character is "smaller" than the middle character. If so, we need only consider the lower half of the string; otherwise, we only consider the upper half of the string. (Note that you can compare characters using Python's < function.)
Implement the function isIn(char, aStr) which implements the above idea recursively to test if char is in aStr. char will be a single character and aStr will be a string that is in alphabetical order. The function should return a boolean value.
As you design the function, think very carefully about what the base cases should be.
# In this problem, you'll create a program that guesses a secret number!
# The program works as follows: you (the user) thinks of an integer between 0 (inclusive) and 100 (not inclusive).
# The computer makes guesses, and you give it input - is its guess too high or too low?
# Using bisection search, the computer will guess the user's secret number!
low = 0
high = 100
print('Please think of a number between ' + str(low) + ' and ' + str(high) + '!')
found = False
import random
guessTaken = 0
print('Hello! What is your name?')
myName = input()
print('Hello', myName ,', lets start a guess game where you need to guess between numbers 1 and 100')
number = random.randint(1, 100)
s = 'jzleuajreuvxhmwaer'
currString=''
lastString=''
i = 0
while(i+1<len(s)):
if(s[i]<=s[i+1]):
currString = currString + s[i]
if(i+2==len(s)):
currString += s[i+1]
else: