Skip to content

Instantly share code, notes, and snippets.

View tejas-hosamani's full-sized avatar

Tejas H tejas-hosamani

View GitHub Profile
var docWidth = document.documentElement.offsetWidth;
[].forEach.call(
document.querySelectorAll('*'),
function(el) {
if (el.offsetWidth > docWidth) {
// el.style.outline = "1px solid red";
console.log(el, docWidth, el.offsetWidth);
}
}
// Usage: getCookie('cookie-name', ctx.req.headers.cookie)
export function getCookie(cname, cookieSourceString = "") {
if (typeof window !== "undefined") {
// eslint-disable-next-line no-param-reassign
cookieSourceString = document.cookie;
}
const name = cname + "=";
const decodedCookie = decodeURIComponent(cookieSourceString);
const ca = decodedCookie.split(";");
// Run this on browser console
var findUndefinedCSSClasses = (function () {
"use strict";
//get all unique CSS classes defined in the main document
let allClasses = Array.from(document.querySelectorAll('*'))
.map(n => Array.from(n.classList))
.reduce((all, a) => all ? all.concat(a) : a)
.reduce((all, i) => all.add(i), new Set());
class WiFiState
{
[string]$IPv4Address
[string]$IPv6Address
[string]$SSID
[string]$BSSID
[string]$State
[string]$Authentication
[string]$Channel
[string]$Signal
@tejas-hosamani
tejas-hosamani / pingNow.ps1
Created December 23, 2019 06:20
Monitor mobile WiFi and reconnect, if not available | Windows | Powershell
# 1) SSID of Wireless Network (CaSe Sensitive)
# netsh wlan show networks
$mySSID = 'Tejas'
# 2) Wireless Profile Name (CaSe Sensitive)
# netsh wlan show profile
$profileName = 'Tejas'
# 3) Name of Wireless Interface (CaSe Sensitive)
# netsh wlan show interfaces
@tejas-hosamani
tejas-hosamani / AsyncTest.js
Created December 19, 2019 02:37
To test if something is Async or not
// CREDIT: https://stackoverflow.com/questions/33289726/combination-of-async-function-await-settimeout
//Since Node 7.6, you can combine the functions promisify function from the utils module with setTimeout() .
//Node.js
const sleep = require('util').promisify(setTimeout)
//Javascript
const sleep = m => new Promise(r => setTimeout(r, m))
//Usage
(async () => {
Import-Module posh-git
# Chocolatey profile
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
Import-Module "$ChocolateyProfile"
}
$forePromptColor = 0
@tejas-hosamani
tejas-hosamani / powerShell-git.md
Last active September 17, 2019 04:27
These are steps to add `posh-git` on Windows PowerShell

You need to run two instances of PowerShell, one in Admistrator mode and another in regular mode.

In regular PowerShell:

NOTE: Remove -AllowPrerelease command if it doesn't work.

PowerShellGet\Install-Module posh-git -Scope CurrentUser -AllowPrerelease -Force

Then run

PowerShellGet\Update-Module posh-git
@tejas-hosamani
tejas-hosamani / php.ini
Last active September 7, 2019 07:28
php.ini for php7
[PHP]
;;;;;;;;;;;;;;;;;;;
; About php.ini ;
;;;;;;;;;;;;;;;;;;;
; PHP's initialization file, generally called php.ini, is responsible for
; configuring many of the aspects of PHP's behavior.
; PHP attempts to find and load this configuration from a number of locations.
; The following is a summary of its search order: