Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View neverendingqs's full-sized avatar

Mark Tse neverendingqs

View GitHub Profile
@neverendingqs
neverendingqs / Git-RemovedMergedBranches.ps1
Created September 7, 2015 16:06
Delete all local branches that has been merged on remote.
# Can also add to PowerShell profile
function Git-RemovedMergedBranches {
git branch --merged |
? { $_ -NotMatch "^\*" } |
? { $_ -NotMatch "master" } |
% { $_.Trim() } |
% { git branch -d $_ }
}
[user]
name = firstName lastName
email = email
[core]
preloadindex = true
fscache = true
autocrlf = false
safecrlf = false
symlinks = true
commitGraph = true
#n::Run "C:\Program Files (x86)\Notepad++\notepad++.exe"
#c::Run "C:\Program Files\ConEmu\ConEmu64.exe"
#v:: ; Text–only paste from ClipBoard
Clip0 = %ClipBoardAll%
ClipBoard = %ClipBoard% ; Convert to text
Send ^v ; For best compatibility: SendPlay
Sleep 50 ; Don't change clipboard while it is pasted! (Sleep > 0)
ClipBoard = %Clip0% ; Restore original ClipBoard
VarSetCapacity(Clip0, 0) ; Free memory
D2LAppContextFactory appContextFactory = new D2LAppContextFactory();
ID2LAppContext appContext = appContextFactory.Create(appId, appKey);
UserContextProperties userContextProperties = new UserContextProperties() {
UserId = myUserId, // put your user ID here
UserKey = myUserKey, // put your user key here
Scheme = "https",
HostName = bsUrl,
Port = port
};
@neverendingqs
neverendingqs / Microsoft Sculpt Mobile Keyboard Remap
Last active July 9, 2022 01:09 — forked from tehshane/Microsoft Sculpt Mobile Keyboard Remap
AutoHotKey script that remaps the F1-F12 function keys on the Microsoft Sculpt Mobile keyboard to be pressed without having to use the Fn key. Disables some of the Windows 8 shortcuts, but leaves media keys intact.
; http://superuser.com/a/784683/502760
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#InstallKeybdHook
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; OPTIONAL: For those who use Home/End more than PgUp/PgDown, this flips their use with the Fn key.
; If you want the buttons to function as they are, add a semicolon (;) to the beginning of each line below.
; Home::PgUp
+-----------------+ +-----------------+ +-----------------+
| | | | | |
| Sample App | | User / Browser | | Auth Server |
| | | | | |
+--------+--------+ +--------+--------+ +--------+--------+
| | |
| | |
| GET /auth | |
| <-----------------------------
@neverendingqs
neverendingqs / brightspace-oauth2-whoami.py
Last active November 23, 2016 16:40
Brightspace "whoami" using OAuth 2.0 access token
import requests # requests==2.7.0
url = "http://localhost:44453/d2l/api/lp/1.0/users/whoami"
access_token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjBiOWU5Njg2LWRiYTctNDBkNS05MmRlLTYxNmVkNmYzZmJhMSJ9.eyJzdWIiOiIxNjkiLCJ0ZW5hbnRpZCI6IjNlZGE2ZTJhLWNmZjItNGE0OS1hZjQ5LWY4MmUzZWUzZTkxMSIsInNjb3BlIjoiY29yZToqOioiLCJqdGkiOiJlNDI0YjQyZi1hZTY5LTQ4ZGItYWUzMS00ZjhlZTQ1NDBkNmEiLCJpc3MiOiJodHRwczovL2FwaS5icmlnaHRzcGFjZS5jb20vYXV0aCIsImF1ZCI6Imh0dHBzOi8vYXBpLmJyaWdodHNwYWNlLmNvbS9hdXRoL3Rva2VuIiwiZXhwIjoxNDc5OTIxMTUxLCJuYmYiOjE0Nzk5MTc1NTF9.GznF7Wl-DQxJ3Qp7OPJ4PU_nhHzCzaHYcAFlgahLXyBhAqqAQWKYcrID8UB478iwL2ntYPCtJKLCsJp-ZzZ4QMNc0rwFSJ6_jpQ9W3ALYgIBhILuabG-Xkfdnv4Bi-ME4Q1RcNUvNuuP7ygaJtONc7S4hJtYagsmI9JOW46h-64nevDLijO4CJOIq9B27k_PjPzisAET0ziUD6swIvhX7rUz_nOmCWZJDP56Mi-LIMSd7GrTYP9dTnwvw_rmU_iliO8iOqSKtPaaYUBF9gK4Zulg93nNZDybZozM9sxlfvdRrnjDq6PPUCIbyG1zFwD3GH7-bE9HlemSElhuxyMqSg"
response = requests.get(url, headers={'authorization': "Bearer {}".format(access_token)})
print(response.json())
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:*:*")
@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"
],
@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: