Skip to content

Instantly share code, notes, and snippets.

View weilinzung's full-sized avatar

Wei weilinzung

  • Canada
View GitHub Profile
@katowulf
katowulf / app.component.ts
Last active October 16, 2024 04:59
Dynamically set page title based on active route in Angular 4
// This can probably be simplified somehow. Not sure why I need to add it in the component to init the service.
import { Component, OnInit } from '@angular/core';
import {TitleService} from "./@core/utils/title.service";
@Component({...})
export class AppComponent implements OnInit {
constructor(private titleService: TitleService) {...}
@akexorcist
akexorcist / index.js
Last active September 13, 2024 19:03
Axios post method requesting with x-www-form-urlencoded content type. See https://axios-http.com/docs/urlencoded
const axios = require('axios')
/* ... */
const params = new URLSearchParams()
params.append('name', 'Akexorcist')
params.append('age', '28')
params.append('position', 'Android Developer')
params.append('description', 'birthdate=25-12-1989&favourite=coding%20coding%20and%20coding&company=Nextzy%20Technologies&website=http://www.akexorcist.com/')
params.append('awesome', true)
@taylorbryant
taylorbryant / purgecss-tailwind-gulp-example.js
Last active December 19, 2024 15:46
Use PurgeCSS with Tailwind & Gulp (Inspired by @andrewdelprete)
const atimport = require("postcss-import");
const { dest, src, task } = require("gulp");
const postcss = require("gulp-postcss");
const purgecss = require("@fullhuman/postcss-purgecss");
const tailwindcss = require("tailwindcss");
const TAILWIND_CONFIG = "./tailwind.config.js";
const SOURCE_STYLESHEET = "./src/style.css";
const DESTINATION_STYLESHEET = "./build/style.css";
@DamirPorobic
DamirPorobic / rename-branch.sh
Created April 24, 2018 12:57
Script for renaming branches
#!/usr/bin/bash
GIT_CMD="$(which git)"
GIT_BRANCH="$GIT_CMD branch"
GIT_PUSH_ORIGIN="$GIT_CMD push origin"
GIT_FETCH_ORIGIN="$GIT_CMD fetch origin"
GIT_REMOTE_PRUNE="$GIT_CMD remote prune origin"
GIT_CHECK_BRANCH="$GIT_CMD show-ref refs/heads" # append /branch_name
# Check if the user has provided input
@jeromecoupe
jeromecoupe / webstoemp-gulpfile.js
Last active April 11, 2025 08:17
Gulp 4 sample gulpfile.js. For a full explanation, have a look at https://www.webstoemp.com/blog/switching-to-gulp4/
"use strict";
// Load plugins
const autoprefixer = require("autoprefixer");
const browsersync = require("browser-sync").create();
const cp = require("child_process");
const cssnano = require("cssnano");
const del = require("del");
const eslint = require("gulp-eslint");
const gulp = require("gulp");
@pieterdv
pieterdv / get-aad-token.js
Created May 30, 2018 12:01
Login through Azure AD with puppeteer
function getAadToken(user, password, identifier) {
return puppeteer.launch({ headless: true }).then(async browser => {
try {
const page = await browser.newPage();
await page.goto("SITEURL");
await page.click(
"LOGINBUTTON"
);
@saschwarz
saschwarz / commands.js
Last active August 31, 2022 07:16
Automated Azure AD login and session token capture to json file for reading by Cypress commands. Heavily inspired by https://gist.github.com/pieterdv/82773fbe036719479d76ab0a4985dc3b
const API = Cypress.env('API');
const headers = {
Authorization: '',
};
Cypress.Commands.add('loginUser', () => {
return cy.readFile('aad-tokens.json')
.then(creds => {
// set auth headers so test setup calls are authorized
@CodingDoug
CodingDoug / README.md
Last active November 6, 2022 09:29
Example code from the video "Use async/await with TypeScript in Cloud Functions"

Example code from the video "Use async/await with TypeScript in Cloud Functions"

This is the example code from my video about using async/await with Cloud Functions. I've placed it here in a gist so it's easier to compare the "before" and "after" states for each case.

Watch the video here

The code in this project is licensed under the Apache License 2.0.

Copyright 2018 Google LLC
@VhMuzini
VhMuzini / component.html
Created June 7, 2018 17:48
Implement FITBOUNDS to AGM-MAP
<agm-map #agmmap
[latitude]="lat"
[longitude]="lng"
[maxZoom]="25"
[zoom]="3"
[zoomControl]="true"
[fitBounds]="bounds"
[mapTypeId]="'roadmap'"
[mapTypeControl]="true"
[fullscreenControl]="true"
import Eventbus from '../launcher/services/eventbus'
// This comes from https://developers.google.com/web/tools/workbox/guides/advanced-recipes
// It allows activating the new service worker right away on reload
if ('serviceWorker' in navigator) {
window.addEventListener('load', function () {
navigator.serviceWorker.register('/sbvr-service-worker.js')
.then(function (registration) {
// Track updates to the Service Worker.
if (!navigator.serviceWorker.controller) {