Skip to content

Instantly share code, notes, and snippets.

View ajaymenon0's full-sized avatar
🏚️
Working from Home

Ajay Menon ajaymenon0

🏚️
Working from Home
View GitHub Profile
@Evavic44
Evavic44 / Buymeacoffee.md
Last active January 7, 2025 21:47
Buymeacoffee widget React
import React, { useEffect } from "react";

export default function Buymeacoffee() {
	useEffect(() => {
		const script = document.createElement("script");
		const div = document.getElementById("supportByBMC");
		script.setAttribute("data-name", "BMC-Widget");
		script.src = "https://cdnjs.buymeacoffee.com/1.0.0/widget.prod.min.js";
		script.setAttribute("data-id", "evavic44");
@tomsoderlund
tomsoderlund / Map.js
Last active December 3, 2024 17:40
Using fitBounds in ReactMapGL to center points on map
import React, { useState } from 'react'
import ReactMapGL, { Marker } from 'react-map-gl'
import { WebMercatorViewport } from '@deck.gl/core'
const getBoundsForPoints = (points, { width = 200, height = 500, padding = 0 } = {}) => {
// Calculate corner values of bounds
const pointsLong = points.map(point => point.coordinates._long)
const pointsLat = points.map(point => point.coordinates._lat)
const cornersLongLat = [
[Math.min(...pointsLong), Math.min(...pointsLat)],
@mauroao
mauroao / readLineAssync.js
Last active April 26, 2025 12:17
Node.js - Read line from stdin asynchronously (async / await)
const readline = require('readline');
const readLineAsync = () => {
const rl = readline.createInterface({
input: process.stdin
});
return new Promise((resolve) => {
rl.prompt();
rl.on('line', (line) => {
@alfonmga
alfonmga / mixpanel-proxy.js
Created November 3, 2018 20:28
node.js proxy server to serve mixpanel.js lib from our own domain
const got = require('got')
const cors = require('@koa/cors')
const Koa = require('koa')
const KoaRouter = require('koa-router')
const globalTunnel = require('global-tunnel-ng')
const { PROXY } = process.env
if (PROXY) {
const [ host, port ] = PROXY.split(':')
@iaincollins
iaincollins / Google Spreadsheet.js
Last active May 30, 2021 16:03
Example Node.js code to append to a Google Spreadsheet every hour
/**
* Append data to a Google Spreadsheet
*
* You will need a file called '.env' with the following values:
*
* - GOOGLE_ID (Google oAuth Client ID)
* - GOOGLE_SECRET (Google oAuth Client Secret)
* - GOOGLE_REFRESH_TOKEN (Google oAuth Refresh Token)
* - GOOGLE_SPREADSHEET_ID (Google Spreadsheet ID)
*
@lopspower
lopspower / README.md
Last active May 15, 2025 02:53
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@guilherme
guilherme / gist:9604324
Last active October 10, 2024 18:27
Git pre-commit hook that detects if the developer forget to remove all the javascript console.log before commit.
#!/bin/sh
# Redirect output to stderr.
exec 1>&2
# enable user input
exec < /dev/tty
consoleregexp='console.log'
# CHECK
if test $(git diff --cached | grep $consoleregexp | wc -l) != 0
then
@joyrexus
joyrexus / README.md
Last active March 22, 2025 12:57 — forked from liamcurry/gist:2597326
Vanilla JS equivalents of jQuery methods

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@stiucsib86
stiucsib86 / gist:6150321
Created August 4, 2013 13:31
[Google Maps v3] Get Rectangle area with computeArea
var _computeRectangleArea = function(bounds) {
if (!bounds) {
return 0;
}
var sw = bounds.getSouthWest();
var ne = bounds.getNorthEast();
var southWest = new google.maps.LatLng(sw.lat(), sw.lng());
var northEast = new google.maps.LatLng(ne.lat(), ne.lng());
var southEast = new google.maps.LatLng(sw.lat(), ne.lng());
var northWest = new google.maps.LatLng(ne.lat(), sw.lng());
@nick-thompson
nick-thompson / Metronome.js
Created January 16, 2013 21:25
A reliable metronome library using HTML5 Web Workers to maintain the tick interval even when the parent thread is run in the background. In early 2011, both Firefox and Chrome clamped the minimum wait time for setTimeout and setInterval to one second when running in a tab that is not the active tab for its window.
/*!
* Metronome.js
*
* A reliable metronome using HTML5 Web Workers to maintain the tick
* interval even when the parent thread is run in the background.
*
* For details, see:
* http://pivotallabs.com/chrome-and-firefox-throttle-settimeout-setinterval-in-inactive-tabs/
*