Skip to content

Instantly share code, notes, and snippets.

View weilinzung's full-sized avatar

Wei weilinzung

  • Canada
View GitHub Profile
@sindresorhus
sindresorhus / esm-package.md
Last active July 24, 2024 08:34
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.
@cecilemuller
cecilemuller / example.yml
Created October 20, 2020 01:49
Run Docker Compose + in Github Action
name: Test
on:
push:
branches:
- main
- features/**
- dependabot/**
pull_request:
branches:
@soberich
soberich / bulk_clone_bitbucket.sh
Created April 30, 2020 18:54
Bulk clone repos in Bitbucket REST Api 2.0
# prerequisites: `httpie`, `jq`, GNU's `parallel`. e.g. brew install <package>
# there is max 100 page length n pages where n is 100 length page. Execute one one by one (there is no way you'll get more than 100 times parallelization)
# in `.values[].links.clone[1].href` `1` is for SSH, where `0` would be for HTTPS.
http https://<user>:<pass>@api.bitbucket.org/2.0/repositories/<account_name> pagelen==100 page==<page_num> | jq -r '.values[].links.clone[1].href' | parallel git clone
# Voila it takes approx 1-2 minutes to clone a 100 repos.
import { GCS_BUCKET_NAME_MEDIA } from '../config/storage';
import { MediaGenerateThumbsOnWrite } from './media-thumbs.function';
import { ObjectMetadata } from 'firebase-functions/lib/providers/storage';
import { ObjectWritableMock } from 'stream-mock';
import { DownloadResponse } from '@google-cloud/storage';
// tslint:disable-next-line
const { Storage } = require('@google-cloud/storage');
jest.mock('@google-cloud/storage');
@Ashung
Ashung / code.js
Last active March 31, 2024 04:52
Figma Snippets
let layer = figma.currentPage.selection[0];
let vectorPaths = layer.vectorPaths.map(item => {
return {windingRule: 'NONZERO', data: item.data}
})
layer.vectorPaths = vectorPaths
layer.exportAsync({
format: 'SVG'
}).then(uint8Array => {
@palozano
palozano / rsync_usage.md
Last active June 13, 2023 15:50
Rsync usage

Notes on using rsync

First, install it, using apt, yum, pacman, etc.

Local usage

Imagine we want to back up files from Directory1 to Directory2, and both are on the same hard drive (this would work the same if the directories are on two different drives). There are several different ways to do this, depending on what kind of backups (i.e., options you want to give rsync) you want to configure. The most general, will be this:

$ rsync -av --delete /Directory1/ /Directory2/
@kamlekar
kamlekar / form-submit.js
Last active February 1, 2024 15:16
Form submit - Hubspot edition
function callAjax(payload){
//- formSelector
//- portalId
//- formGUID
//- hideMessageTime
//- callback
//
var $form = $(payload.formSelector);
var form = $form[0];
var url = "https://api.hsforms.com/submissions/v3/integration/submit/" + payload.portalId + "/" + payload.formGUID
@th0r
th0r / angular-in-view-directives.html
Last active February 9, 2023 17:45
Angular `InView` directives
<!-- wInViewRoot directive is needed to specify the `root` for `IntersectionObserver` and some other it's options e.g. `margin` -->
<div class="container" wInViewRoot="viewport">
Any content can be here
<w-in-view-item>
<!-- Content will be replaced by a placeholder <div> with the same height as original content.
Also `InViewItemComponent`s change detector will be detached when it become invisible which means
all the content's change detectors won't be reachable and will be inactive as well. -->
</w-in-view-item>
...or any other content can be here
<w-in-view-item>
@shkaper
shkaper / index.js
Created November 21, 2018 12:42
puppeteer screenshot all DOM nodes
const puppeteer = require('puppeteer')
;(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://youtube.com');
// get a list of all elements - same as document.querySelectorAll('*')
const elements = await page.$$('*')
postForm('http://example.com/api/v1/users', 'form#userEdit')
.then(data => console.log(data))
function postForm(url, formSelector) {
const formData = new FormData(document.querySelector(formSelector))
return fetch(url, {
method: 'POST', // 'GET', 'PUT', 'DELETE', etc.
body: formData // a FormData will automatically set the 'Content-Type'
})