Skip to content

Instantly share code, notes, and snippets.

View weilinzung's full-sized avatar

Wei weilinzung

  • Canada
View GitHub Profile
@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"
);
@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");
@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
@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";
@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)
@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) {...}

General structure

  • very similar to Website tests
import { isLegitAdmin } from 'utils/UserUtils'

describe('UserUtils', () => {
    it('`isLegitAdmin` returns false if no `user` is provided', () => {
        expect(isLegitAdmin()).toBe(false)
    })
@radarseven
radarseven / README.md
Created August 1, 2017 03:57 — forked from amir-rahnama/README.md
A simple Webpack (with Dev Server) + Gulp Configuration + LiveReload + Babel to playground where you can code ES6 without the need for React

A simple Webpack + Gulpfile configuration wihtout any need for React.js that assumes you have the following project structure:

node_modules/ bower_components/ scripts/

Entry script is in scripts/entry.js

You should run gulp && gulp build-dev and you are good to go.

@kohlmannj
kohlmannj / customDevServer.js
Created July 9, 2017 22:43
An example of using BrowserSync, webpack-dev-middleware, and webpack-hot-middleware together in a script that boots up a custom dev server
#! /usr/bin/env node
/* eslint-env node */
// Boot it up with:
// $ node customDevServer.js
// ...or:
// $ chmod +X customDevServer.js
// $ ./customDevServer.js
const webpack = require('webpack');
@AndrejsAbrickis
AndrejsAbrickis / .bowerrc
Last active March 20, 2019 00:35
Migrate from bower to webpack
{
"directory": "wwwroot/scripts/bower"
}