Skip to content

Instantly share code, notes, and snippets.

View iamsainikhil's full-sized avatar
👨‍💻
A good developer is always learning…

Sai Nikhil iamsainikhil

👨‍💻
A good developer is always learning…
View GitHub Profile
@iamsainikhil
iamsainikhil / responsive-request-desktop-site.js
Last active January 30, 2022 19:31 — forked from dtipson/responsive-request-desktop-site.js
How to make responsive sites better respect the "Request a desktop site" feature on modern mobile browsers.
/*
Enable the "Request Desktop Site" functions on mobile chrome (android and iOS) allow users to see desktop layouts on responsive sites.
Note that this is distinct from "opt out of mobile!" buttons built into your site:
this is meant to work with the browser's native opt-in/opt-out functionality.
Since these functions work, in part, by simply spoofing the user agent to pretend to be desktop browsers,
all we have to do is just remember that the browser once claimed to be android earlier in the same session and
then alter the viewport tag in response to its fib.
Here's an example viewport tag <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
@iamsainikhil
iamsainikhil / dateDifference.ts
Last active August 23, 2020 04:44
To calculate the difference between two dates in Years, Months, Days, Hours, Minutes, Seconds, Milliseconds using JavaScript / TypeScript
dateDifference(actualDate, value: boolean) {
// Calculate time between two dates:
const date1 = actualDate; // the date you already commented/ posted
const date2: any = new Date(); // today
let r = {}; // object for clarity
let message: string;
const diffInSeconds: number = Math.abs(date2 - date1) / 1000;
const days: number = Math.floor(diffInSeconds / 60 / 60 / 24);
@iamsainikhil
iamsainikhil / print.css
Created July 21, 2020 09:04
Print styles
.wrapper {
max-width: 612px;
height: 100%;
background: #fff;
}
.report-wrapper {
margin-right: 3rem;
margin-left: 3rem;
}
.report-title {
@iamsainikhil
iamsainikhil / urban_areas.json
Last active February 26, 2020 03:34
Mappings of Urban Areas to slug:urban_area of Teleport City Info API
{
"Aarhus": "aarhus",
"Adelaide": "adelaide",
"Albuquerque": "albuquerque",
"Almaty": "almaty",
"Amsterdam": "amsterdam",
"Anchorage": "anchorage",
"Andorra": "andorra",
"Ankara": "ankara",
"Asheville": "asheville",
@iamsainikhil
iamsainikhil / iso3166_codes.json
Last active February 2, 2020 23:38
ISO 3166 country codes
[{"Code": "AF", "Name": "Afghanistan"},{"Code": "AX", "Name": "\u00c5land Islands"},{"Code": "AL", "Name": "Albania"},{"Code": "DZ", "Name": "Algeria"},{"Code": "AS", "Name": "American Samoa"},{"Code": "AD", "Name": "Andorra"},{"Code": "AO", "Name": "Angola"},{"Code": "AI", "Name": "Anguilla"},{"Code": "AQ", "Name": "Antarctica"},{"Code": "AG", "Name": "Antigua and Barbuda"},{"Code": "AR", "Name": "Argentina"},{"Code": "AM", "Name": "Armenia"},{"Code": "AW", "Name": "Aruba"},{"Code": "AU", "Name": "Australia"},{"Code": "AT", "Name": "Austria"},{"Code": "AZ", "Name": "Azerbaijan"},{"Code": "BS", "Name": "Bahamas"},{"Code": "BH", "Name": "Bahrain"},{"Code": "BD", "Name": "Bangladesh"},{"Code": "BB", "Name": "Barbados"},{"Code": "BY", "Name": "Belarus"},{"Code": "BE", "Name": "Belgium"},{"Code": "BZ", "Name": "Belize"},{"Code": "BJ", "Name": "Benin"},{"Code": "BM", "Name": "Bermuda"},{"Code": "BT", "Name": "Bhutan"},{"Code": "BO", "Name": "Bolivia, Plurinational State of"},{"Code": "BQ", "Name": "Bonaire, Sint E
@iamsainikhil
iamsainikhil / index.html
Last active May 16, 2019 17:28
A Robust Weather App using JavaScript by Sai Nikhil | CodePen -> https://codepen.io/iamsainikhil/pen/BqNzbM
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>A Robust Weather App using JavaScript by Sai Nikhil</title>
<link href="https://fonts.googleapis.com/css?family=Space+Mono" rel="stylesheet">
<style>
#app {
display: flex;
@iamsainikhil
iamsainikhil / index.html
Last active April 22, 2019 15:11
Formatting Dates// source https://jsbin.com/yobomin
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Formatting Dates</title>
</head>
<script src="https://cdn.jsdelivr.net/momentjs/2.14.1/moment-with-locales.min.js"></script>
<body>
<script id="jsbin-javascript">
@iamsainikhil
iamsainikhil / The Technical Interview Cheat Sheet.md
Created August 29, 2018 19:07 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@iamsainikhil
iamsainikhil / reactionTest.html
Last active August 9, 2018 03:51
Reaction Tester Game
<!DOCTYPE html>
<html>
<head>
<title>Reaction Tester</title>
<style>
.canvas-wrapper {
display: flex;
margin: 10px auto;
}
@iamsainikhil
iamsainikhil / randomFigures.html
Created August 9, 2018 01:35
Randomly Generated Canvas Figures
<!DOCTYPE html>
<html>
<head>
<title>Random Figures</title>
<style>
.canvas-wrapper {
display: flex;
margin: 10px auto;
}