This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Expandable Form</title> | |
<style> | |
html, | |
body { | |
height: 75%; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const consoleColorLog = (colors: string[]) => { | |
const strings = colors.map((color: string) => `%c${color}`).join(" "); | |
const css = colors.map((color: string) => `color: ${color};`); | |
console.log.apply(console, [strings, css].flat()); | |
}; | |
// consoleColorLog(["#FFFFFF", "#AFD1F9", "#6CA4FF", "#006AFF", "#0515CD"]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useCallback } from "react"; | |
import { debounce } from "lodash"; | |
export const Input = () => { | |
const mySlowFunction = (value) => console.log(value); | |
const debouncedEventHandler = useCallback( | |
debounce((value) => mySlowFunction(value), 100), | |
[] | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const slugify = (string) => | |
string | |
.trim() | |
.toLowerCase() | |
.replace(/\s+/g, "-") | |
.replace(/ä/g, "ae") | |
.replace(/ö/g, "oe") | |
.replace(/ü/g, "ue") | |
.replace(/\u00df/g, "ss") | |
.replace(/[^a-z0-9-]/g, ""); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from qgis.utils import iface | |
from PyQt5.QtCore import QVariant | |
NAME_COLUMN = 'NAME' | |
NEIGHBORS_NAME_COLUMN = 'NEIGHBORS' | |
layer = iface.activeLayer() | |
layer.startEditing() | |
layer.dataProvider().addAttributes([QgsField(NEIGHBORS_NAME_COLUMN, QVariant.String)]) | |
layer.updateFields() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const hex2Rgb = (hexString) => { | |
const groups = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hexString); | |
return groups | |
? [ | |
parseInt(result[1], 16), | |
parseInt(result[2], 16), | |
parseInt(result[3], 16), | |
] | |
: null; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set up Node.js action: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs | |
# Set up Google Cloud auth action: https://github.com/google-github-actions/auth#usage | |
# Set up Google Cloud workload identity federation: https://github.com/marketplace/actions/authenticate-to-google-cloud#setting-up-workload-identity-federation | |
# Upload to Google Cloud Storage: https://github.com/google-github-actions/upload-cloud-storage | |
name: CI/CD | |
on: | |
push: | |
branches: ['main'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Adapted from https://stackoverflow.com/a/17838403/2037629 | |
// If possible, use getComputedStyle() instead: https://stackoverflow.com/a/64654744/2037629 | |
type TransformValues = { | |
translate?: string[]; | |
rotate?: string[]; | |
scale?: string[]; | |
}; | |
export const parseTransform = (string: string) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const canvas = document.getElementsByTagName('canvas')[0]; | |
const dataURL = canvas.toDataURL('image/png'); | |
const timestamp = Math.floor(Date.now() / 1000).toString(36).slice(2); | |
const link = document.createElement('a'); | |
link.download = `download-${timestamp}.png`; | |
link.href = dataURL; | |
link.click(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react'; | |
interface Props { | |
condition: boolean; | |
wrapper: Function; | |
children: React.ReactNode; | |
} | |
export const ConditionalWrapper: React.FC<Props> = ({ condition, wrapper, children }) => { | |
return condition ? wrapper(children) : children; |
NewerOlder