Skip to content

Instantly share code, notes, and snippets.

View sandeshdamkondwar's full-sized avatar
🏠
Working from home

Sandesh Damkondwar sandeshdamkondwar

🏠
Working from home
View GitHub Profile
@sandeshdamkondwar
sandeshdamkondwar / styles.css
Created June 17, 2020 19:17 — forked from viclafouch/styles.css
A custom React Hook to help you implement a "light/dark mode" component for your application.
html[data-theme='dark'] {
--text-color: #f0F0F0;
--background-body: #1C1C1C;
--other-var: #111111;
}
html[data-theme='light'] {
--text-color: #111111;
--background-body: #FAFAFA;
--other-var: #ffffff;
@sandeshdamkondwar
sandeshdamkondwar / use-viewport.js
Created June 17, 2020 19:17 — forked from viclafouch/use-viewport.js
A custom React Hook for tracking the window width and to get the current viewport.
// hooks/use-viewport.js
import { useState, useEffect } from 'react'
export const MOBILE = 'MOBILE'
export const TABLET = 'TABLET'
export const DESKTOP = 'DESKTOP'
const getDevice = width => {
if (width < 768) return MOBILE
else if (width < 992) return TABLET
@sandeshdamkondwar
sandeshdamkondwar / use-clipboard-api.js
Created June 17, 2020 19:16 — forked from viclafouch/use-clipboard-api.js
A custom React Hook for writing and reading from the modern clipboard API
// hooks/use-clipboard-api.js
import { useState, useCallback } from 'react'
function useClipboardApi() {
const [content, setContent] = useState(null)
const askPermission = useCallback(async queryName => {
try {
const permissionStatus = await navigator.permissions.query(queryName)
return permissionStatus.state === 'granted'
@sandeshdamkondwar
sandeshdamkondwar / use-page-visibility.js
Created June 17, 2020 19:16 — forked from viclafouch/use-page-visibility.js
A custom React Hook to detect if the page is visible or not.
// hooks/use-page-visibility.js
import { useState, useLayoutEffect } from 'react'
function usePageVisibility() {
const [isPageVisible, setIsPageVisible] = useState(!document.hidden)
useLayoutEffect(() => {
const handleVisibility = () => {
setIsPageVisible(!document.hidden)
}
@sandeshdamkondwar
sandeshdamkondwar / use-scroll.js
Created June 17, 2020 19:15 — forked from viclafouch/use-scroll.js
A custom React Hook to handle the scroll of a DOM element.
// hooks/use-scroll.js
import { useEffect, useRef, useCallback, useState } from 'react'
function useScroll({ threshold = 450, isWindow = false, smooth = true } = {}) {
const [isAtBottom, setIsAtBottom] = useState(false)
const ref = useRef(isWindow ? window : null)
const goTop = useCallback(() => {
const element = ref.current
element.scrollTo({
@sandeshdamkondwar
sandeshdamkondwar / tblcitylist.sql
Created January 20, 2017 06:53 — forked from sivaprabug/tblcitylist.sql
MySQL database of Indian Cities and states,latitude and longitude..
-- phpMyAdmin SQL Dump
-- version 3.5.2.2
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Apr 08, 2013 at 02:48 PM
-- Server version: 5.5.27
-- PHP Version: 5.4.7
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
@sandeshdamkondwar
sandeshdamkondwar / wifiDance.sh
Created December 14, 2015 10:17 — forked from anuragpeshne/wifiDance.sh
bash script to
#!/bin/sh
let sleepTime="15*60";
while [ 1 ]
do
if [ $(( $RANDOM % 2)) == 0 ]
then
echo "switching to NTWRK1";
networksetup -setairportnetwork en1 {NTWRK_NAME} {NTWRK_PSWD}
else
module Jekyll
class GooglePlusEmbedTag < Liquid::Tag
@post = nil
@height = ''
@width = ''
def initialize(tag_name, markup, tokens)
if markup =~ /(https:\/\/plus.google.com\/\d+\/posts\/\w+)/i
@url = $1
#!/usr/bin/env bash
# script: watch
# author: Mike Smullin <mike@smullindesign.com>
# license: GPLv3
# description:
# watches the given path for changes
# and executes a given command when changes occur
# usage:
# watch <path> <cmd...>
#
#!/bin/bash
# Get the absolute path of the folder where this script exists.
curr_dir=`pwd`
dir=`dirname $0`
FILE_PATH=`cd $dir;pwd`
# Install node
apt-get install python-software-properties curl -y
add-apt-repository ppa:chris-lea/node.js-devel