Skip to content

Instantly share code, notes, and snippets.

View a11smiles's full-sized avatar

Joshua Davis a11smiles

View GitHub Profile
@a11smiles
a11smiles / 0_reuse_code.js
Created March 30, 2017 00:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

Adding Sinon to WebPack

  • Open your project (if you're using WebPack, obviously)

  • npm install sinon --save-dev

  • You should now have Sinon in your node modules and listed in your package.json file

  • In your tests, require Sinon: var sinon = require('sinon'); or import * as sinon from 'sinon';

@a11smiles
a11smiles / azdevop_init.py
Created July 22, 2020 16:34
Takes a newly created project, uploads a README.md, then sets it as the project's description. This uses the AzDO Python library.
from azure.devops.connection import Connection
from azure.devops.v5_1.core import TeamProject
from azure.devops.v5_1.git import GitPush, GitRefUpdate, GitCommit
from msrest.authentication import BasicAuthentication
from msrest.universal_http import ClientRequest
# Authenticate
credentials = BasicAuthentication('', token)
connection = Connection(base_url=f'https://dev.azure.com/{org}', creds=credentials)
$git = "cmd.exe /C git describe --abbrev=0 --tags";
$tag = (Invoke-Expression -Command:$git).substring(1);
$rev = $env:BUILD_BUILDNUMBER;
$build = "$tag-$rev";
Write-Host "$("##vso[build.updatebuildnumber]") $($build)";
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-173474946-1', 'auto');
ga('send', 'pageview');
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-173474946-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-173474946-1');
</script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
Promise.all([
new Promise((resolve) => {
var script = document.createElement('script');
script.src = "https://www.googletagmanager.com/gtag/js?id=UA-173474946-1";
script.async = true;
document.body.appendChild(script);
resolve();
import { Component, OnInit } from '@angular/core';
declare var ga: any;
@Component({
selector: 'app-first-page',
templateUrl: './first-page.component.html',
styleUrls: ['./first-page.component.scss']
})
export class FirstPageComponent implements OnInit {
import { Component, OnInit } from '@angular/core';
declare var gtag: any;
@Component({
selector: 'app-first-page',
templateUrl: './first-page.component.html',
styleUrls: ['./first-page.component.scss']
})
export class FirstPageComponent implements OnInit {