Skip to content

Instantly share code, notes, and snippets.

View weilinzung's full-sized avatar

Wei weilinzung

  • Canada
View GitHub Profile
@nicbet
nicbet / _Webpack-Fontawesome-Bootstrap-Phoenix.md
Last active April 28, 2020 05:43
Sass versions of Bootstrap 4 and Fontawesome 5 with Elixir / Phoenix Framework 1.3.x and 1.4.x using Webpack

SASS Versions of

  • Fontawesome 5
  • Bootstrap 4

in Phoenix 1.3 and 1.4 via Webpack

@eeichinger
eeichinger / clone-repos-generate.sh
Last active January 14, 2025 11:21
Generate a script to clone all repos within a specific project from bitbucket server and bitbucket cloud
# generate a script ./clone-repos.sh from a list of repos fetched via Bitbucket API
# note: requires 'curl' and 'jq' to be installed
set -e
echo -n '' > clone-repos.sh
chmod +x clone-repos.sh
ONPREM_USER=xxxxx
ONPREM_PASS=......
@wrburgess
wrburgess / exportToFile.ts
Created July 25, 2018 18:06
Using Firebase Functions to create and upload a text file to Firebase Storage using Node and firebase-admin
import * as path from 'path';
import * as os from 'os';
import * as fs from 'fs';
import * as admin from 'firebase-admin';
const exportToFile = async (req, _, next) => {
try {
const fileName = 'test002.csv';
const tempFilePath = path.join(os.tmpdir(), fileName);
@JanMalch
JanMalch / Angular - custom structural directives.md
Last active June 9, 2024 16:30
Writing your own structural directives with context variables

Writing your own structural directives with context variables

Complete code in math.directive.ts

After reading this you will be able to create a structural directive with inputs and context variables and use it like this:

<div *math="10; exponent: 3; let input; 
            let exponent = exponent; let r = root;
 let p = power; let ctrl = controller"&gt;
@wojtekmaj
wojtekmaj / find-scroll-container.js
Last active December 13, 2024 17:40
Find the nearest scrollable container.
const findScrollContainer = (element) => {
if (!element) {
return undefined;
}
let parent = element.parentElement;
while (parent) {
const { overflow } = window.getComputedStyle(parent);
if (overflow.split(' ').every(o => o === 'auto' || o === 'scroll')) {
return parent;
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'
})
@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.$$('*')
@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>
@kamlekar
kamlekar / form-submit.js
Last active September 11, 2024 11:11
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
@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/