Skip to content

Instantly share code, notes, and snippets.

View toyg's full-sized avatar
👔
c#-ing and python-ing

Giacomo Lacava toyg

👔
c#-ing and python-ing
View GitHub Profile
@toyg
toyg / MockUtils.java
Last active January 28, 2019 16:32
Utility methods to mock HTTP calls made with the Apache Commons HttpClient fluent interfaces. It allows simple specification of url, expected response, simple headers, and body. This is enough for my current needs, feel free to suggest other commonly-used sub-interfaces that should be mocked in this scenario.
package com.autoepm.versioner.common;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.fluent.Executor;
import org.apache.http.client.fluent.Response;
import org.apache.http.message.BasicHeader;
import org.mockito.ArgumentCaptor;
@toyg
toyg / o365_app.py
Last active July 7, 2019 14:32
Example Flask app showing how to manage a webapp-style authentication flow with python-o365(once/if my PR is accepted - in meantime, can be used with toyg/python-0365 on the webapp_flow branch)
# when testing locally, set environment variable OAUTHLIB_INSECURE_TRANSPORT to 1
# so you can use http://localhost... in redirect
import os
from O365 import Connection
from flask import Flask, redirect, request, url_for, abort
# O365 secrets
APP_ID = os.environ.get('O365_APP_ID')
APP_PWD = os.environ.get('O365_APP_PWD')
@toyg
toyg / colemak_specialchars.ahk
Last active June 22, 2020 08:54
Autohotkey script to turn CapsLock in a new independent meta key for special characters. Assumes a Colemak layout underneath.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetCapsLockState AlwaysOff
; left hand , top row
CapsLock & q::
Send £
@toyg
toyg / qwerty_specialchars.ahk
Last active June 22, 2020 08:58
Autohotkey script to turn CapsLock in a new independent meta key for special characters. Assumes a Qwerty layout underneath.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetCapsLockState AlwaysOff
; left hand , top row
CapsLock & q::
Send £
return