Skip to content

Instantly share code, notes, and snippets.

View neverendingqs's full-sized avatar

Mark Tse neverendingqs

View GitHub Profile
@neverendingqs
neverendingqs / simple-example.js
Created August 17, 2018 02:05
2017/03/13/ensure-all-nock-interceptors-are-used.html - simple-example.js
'use strict';
const request = require('superagent');
const express = require('express');
const app = express();
app.get('/', function(req, res) {
request
.get('https://www.example.com')
.then(response => res.send(response.text));
@neverendingqs
neverendingqs / summary.js
Last active August 17, 2018 02:04
2017/03/13/ensure-all-nock-interceptors-are-used.html - summary.js
// Example for mocha; translate as needed for your favourite test framework
afterEach(function() {
...
if(!nock.isDone()) {
this.test.error(new Error('Not all nock interceptors were used!'));
nock.cleanAll();
}
...
});
@neverendingqs
neverendingqs / workingexample.json
Last active August 17, 2018 01:37
2017/09/24/aws-lambda-notprincipal - workingexample.json
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyObjectDeleteWithWhitelist",
"Effect": "Deny",
"NotPrincipal": {
"AWS": [
"arn:aws:iam::123456789012:role/my-lambda-role",
"arn:aws:sts::123456789012:assumed-role/my-lambda-role/my-lambda-function"
@neverendingqs
neverendingqs / nonworkingexample.json
Last active August 17, 2018 01:37
2017/09/24/aws-lambda-notprincipal - nonworkingexample.json
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyObjectDeleteWithWhitelist",
"Effect": "Deny",
"NotPrincipal": {
"AWS": [
"arn:aws:iam::123456789012:role/my-lambda-role"
]
@neverendingqs
neverendingqs / example.json
Last active August 17, 2018 01:35
2017/09/24/aws-lambda-notprincipal - example.json
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyObjectDeleteWithWhitelist",
"Effect": "Deny",
"NotPrincipal": {
"AWS": [
"arn:aws:iam::123456789012:role/SuperRoleOne",
"arn:aws:iam::123456789012:role/SuperRoleTwo"
$ git grep --break -p authCodeScope
src/lib/utility.js=module.exports = {
src/lib/utility.js: authCodeScope: process.env.DEFAULT_AUTH_CODE_SCOPE,
src/lib/views.js=var index = function(req, cookie, error) {
src/lib/views.js: authCodeScope: cookie.authCodeScope,
src/server.js=app.post('/auth', function(req, res) {
src/server.js: cookie.authCodeScope = req.body.scope;
@neverendingqs
neverendingqs / git-perms-change-windows.txt
Created January 12, 2018 16:26
Changing file permissions in Git on Windows
# Taken from http://blog.lesc.se/2011/11/how-to-change-file-premissions-in-git.html on January 12, 2018
>git ls-tree HEAD
100644 blob 55c0287d4ef21f15b97eb1f107451b88b479bffe script.sh
>git update-index --chmod=+x script.sh
>git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
@neverendingqs
neverendingqs / LICENSE
Last active September 3, 2017 22:34
Batching (Native) Promise calls in serial
MIT License
Copyright (c) 2017 Mark Tse
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@neverendingqs
neverendingqs / s3-no-delete-policy.json
Last active April 9, 2017 20:29
S3 No Delete Bucket Policy
{
"Id": "a3769712-3b2a-47e8-8206-85cdaf882384",
"Version": "2012-10-17",
"Statement": [
{
"Sid": "NoDelete",
"Action": [
"s3:Delete*",
"s3:PutBucketPolicy"
],
Dim client As New RestSharp.RestClient("https://auth.brightspace.com/core/connect/token")
' Must use basic auth
client.Authenticator = new HttpBasicAuthenticator("(client id)", "(client secret)");
Dim req As New RestSharp.RestRequest(Method.POST)
req.AddHeader("Content-Type", "application/x-www-form-urlencoded")
req.AddHeader("Accept", "application/json")
req.AddParameter("grant_type", "refresh_token")
req.AddParameter("refresh_token", "(manually obtained refresh token)")
req.AddParameter("scope", "Application:*:* Core:*:* Data:*:*")