Skip to content

Instantly share code, notes, and snippets.

View jlozovei's full-sized avatar
👨‍💻
Need a bug? Talk to me!

Julio Lozovei jlozovei

👨‍💻
Need a bug? Talk to me!
View GitHub Profile
@sindresorhus
sindresorhus / esm-package.md
Last active May 4, 2024 15:48
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@micheam
micheam / codesandbox.html
Last active January 18, 2022 02:06
Hugo shortcode for CodeSandbox Embed.
{{ $defaultWidth := "100%" }}
{{ $defaultHeight := "500px" }}
{{ if .IsNamedParams }}
<iframe
src="https://codesandbox.io/embed/{{ .Get "id" }}?codemirror=1&fontsize=13&hidenavigation=1&theme=dark&view=preview"
style="width:{{ with .Get "width" }}{{.}}{{ else }}100%{{ end }}; height:{{ with .Get "height" }}{{.}}{{ else }}{{ $defaultHeight }}{{ end }}; border:0; border-radius: 4px; overflow:hidden;"
title="{{ with .Get "title" }}{{.}}{{ else }}{{ .Get "id" }}{{ end }}"
allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
@koganas
koganas / _grid.css
Last active August 17, 2020 16:05
Infinite column flexbox grid - Using PostCSS and postcss-for
/* Grid */
$totalColumns: 12;
$col: calc(100 / $totalColumns)%;
$space: 2rem;
.container {
max-width: $maxWidth;
margin: 0 auto;
position: relative;
display: flex;
import Document from 'next/document'
import { ServerStyleSheet } from 'styled-components'
export default class MyDocument extends Document {
static async getInitialProps (ctx) {
const sheet = new ServerStyleSheet()
const originalRenderPage = ctx.renderPage
try {
ctx.renderPage = () =>
@cjzopen
cjzopen / Organization json-ld
Last active March 29, 2023 17:03
Organization json-ld example
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [{
"@type": "Organization",
"@id": "https://www.example.com/#organization",
"name": "{{ your name }}",
"url": "https://www.example.com/",
"address": "{{ address }}",
"email": "{{ email }}",
@siddharthkrish
siddharthkrish / version.sh
Created July 3, 2017 15:14
simple bash script to increment the version number of the format major.minor.build
#!/bin/bash
version="$1"
major=0
minor=0
build=0
# break down the version number into it's components
regex="([0-9]+).([0-9]+).([0-9]+)"
if [[ $version =~ $regex ]]; then
@mjangda
mjangda / ngrok-and-jetpack.md
Last active February 7, 2023 07:57
How to connect ngrok to your local WordPress environment (props @DanReyLop)

How to develop with Jetpack locally with ngrok

To connect Jetpack in your local installation, you'll need a way for WP.com servers to reach your server. That can be done in a number of different ways:

  • You can open your router's ports and use your public IP
  • You can use some kind of Dynamic DNS provider.

But these options fall short of ngrok, which is a "localhost tunnel". It basically allows the Internet to hit a local port on your machine without worrying about ports or IPs.

As long as ngrok is running, Jetpack / WP.com will be able to communicate with your local site. This will allow remote modules like Site Search and Manage to work.

@andyexeter
andyexeter / bump_version.sh
Last active November 14, 2022 14:55
Bash script to increment version numbers in multiple files
#!/usr/bin/env bash
# Usage: ./bump_version.sh <major|minor|patch> - Increments the relevant version part by one.
#
# Usage 2: ./bump_version.sh <version-from> <version-to>
# e.g: ./bump_version.sh 1.1.1 2.0
set -e
# Define which files to update and the pattern to look for
@beaucharman
beaucharman / throttle.js
Last active November 12, 2022 15:39
An ES6 implementation of the throttle function. "Throttling enforces a maximum number of times a function can be called over time. As in 'execute this function at most once every 100 milliseconds.'" - CSS-Tricks (https://css-tricks.com/the-difference-between-throttling-and-debouncing/)
function throttle(callback, wait, immediate = false) {
let timeout = null
let initialCall = true
return function() {
const callNow = immediate && initialCall
const next = () => {
callback.apply(this, arguments)
timeout = null
}
@jay3126
jay3126 / Study: Multi-File Bash Scripting and Paths.md
Created May 29, 2016 10:26 — forked from Jeff-Russ/Study: Multi-File Bash Scripting and Paths.md
Study: including other bash scripts from relative paths and absolute paths

Bash Scripting:

Managing Pathnames in Multi-file Bash Projects

Paths can get somewhat muddled up when you execute a Bash script with dependencies. Each script, when executed, is executed at a certain location as demonstrated by echoing pwd from the script. This is the directory assumed if ever you try to source (aka .) from that script.

This location is subject to change as it traces back to the ORIGINAL caller. By "ORIGINAL" I don't mean the location script that called it, or even the location of the script that called the script that called it, I mean the working directory of the first to initiate the chain of calls, which might be the user in the terminal or the location of the clicked executable.

Thing to consider:

  1. The caller's location