Skip to content

Instantly share code, notes, and snippets.

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

Dennis Thompson atomicpages

🏠
Working from home
  • Writer
  • San Francisco, CA
View GitHub Profile
@Jaid
Jaid / migratingRules.md
Last active September 30, 2024 16:14
ESLint rules for migrating projects from CommonJS to ESM

ESLint rules

The ESM standard is considered stable in NodeJS and well supported by a lot of modern JavaScript tools.

ESLint does a good job validating and fixing ESM code (as long as you don't use top-level await, coming in ESLint v8). Make sure to enable the latest ECMA features in the ESLint config.

  • .eslint.json
{
@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)],
@bgadrian
bgadrian / set.go
Last active April 18, 2025 04:34
How to implement a simple set data structure in golang
type Set struct {
list map[int]struct{} //empty structs occupy 0 memory
}
func (s *Set) Has(v int) bool {
_, ok := s.list[v]
return ok
}
@sawapi
sawapi / AppDelegate.swift
Last active October 25, 2023 09:26
[Swift] Push Notification
//
// AppDelegate.swift
// pushtest
//
// Created by sawapi on 2014/06/08.
// Copyright (c) 2014年 sawapi. All rights reserved.
//
// iOS8用
import UIKit