Skip to content

Instantly share code, notes, and snippets.

View neverendingqs's full-sized avatar

Mark Tse neverendingqs

View GitHub Profile
@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())
+-----------------+ +-----------------+ +-----------------+
| | | | | |
| Sample App | | User / Browser | | Auth Server |
| | | | | |
+--------+--------+ +--------+--------+ +--------+--------+
| | |
| | |
| GET /auth | |
| <-----------------------------
@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
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
};
#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
[user]
name = firstName lastName
email = email
[core]
preloadindex = true
fscache = true
autocrlf = false
safecrlf = false
symlinks = true
commitGraph = true
@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 $_ }
}