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 / dropdown_BR.vb
Last active December 4, 2024 09:33
DataSet Business Rule for Menu Component in OneStream 8.5+
Imports System
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.Common
Imports System.Globalization
Imports System.IO
Imports System.Linq
Imports Microsoft.VisualBasic
Imports OneStream.Finance.Database
Imports OneStream.Finance.Engine
@toyg
toyg / dropdown.vb
Last active December 4, 2024 09:28
DataSet Service rule for Menu Component in OneStream 8.5+
Imports System
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.Common
Imports System.Globalization
Imports System.IO
Imports System.Linq
Imports Microsoft.VisualBasic
Imports OneStream.Finance.Database
Imports OneStream.Finance.Engine
@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
@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 / 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 / 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 / nic_metrics.ps1
Created November 2, 2017 12:06
Manually set Windows "Metrics" values for network cards. When a server has multiple cards, you are often forced to disable Windows' automatic "metrics", to make sure EPM traffic goes on the right interface.
# To use this script, rename LAN, BACKUP etc to match relevant network card names
# in your environment (you can add or remove lines as well),
# and set values to match your metric preference (1 is the preferred card).
# All cards not mentioned here will be set to 100.
$cards = @{} # don't touch this line
$cards.LAN = 1
$cards.BACKUP = 99
@toyg
toyg / query_EPM_COMPONENTS.ps1
Created November 2, 2017 12:06
Query a Foundation database to retrieve EPM Component data from SQLServer. This uses the .NET SqlClient assembly, so will work from any .NET 2.0 computer
#requires -Version 1
$SQLconn = New-Object -TypeName System.Data.SqlClient.SqlConnection -ArgumentList ('server=ardy-sql01; database=foundation; uid=EPMSQL; pwd=Hyp3r10n')
$SQLconn.Open()
$SQLcmd = $SQLconn.CreateCommand()
$SQLcmd.CommandType = [System.Data.CommandType]::Text
$SQLcmd.CommandText =
'SELECT COMPONENT_NAME, PROPERTY_NAME, PROPERTY_VALUE FROM HSS_COMPONENT_PROPERTY_VALUES inner join HSS_COMPONENT on HSS_COMPONENT_PROPERTY_VALUES.COMPONENT_ID = HSS_COMPONENT.COMPONENT_ID order by component_name asc'
$data = $SQLcmd.ExecuteReader()
$dataTable = New-Object -TypeName 'System.Data.DataTable'
@toyg
toyg / Get-ServiceUpTime.ps1
Created November 2, 2017 12:05
PowerShell Function to query each service and show the start time from the associated process
function Get-ServiceUpTime
{
[CmdletBinding()]
param
(
# Name of Computer(s) to query
[Parameter(Mandatory = $false,
Position = 1,
ValueFromPipelineByPropertyName = $true)]
[string[]]$ComputerName = $env:COMPUTERNAME,
@toyg
toyg / error.txt
Created October 21, 2017 20:33
waifu2pico
/usr/local/Cellar/cmake/3.9.0/bin/cmake -H/Users/toyg/Dev/waifu2x-dev -B/Users/toyg/Dev/waifu2x-dev --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/Cellar/cmake/3.9.0/bin/cmake -E cmake_progress_start /Users/toyg/Dev/waifu2x-dev/CMakeFiles /Users/toyg/Dev/waifu2x-dev/CMakeFiles/progress.marks
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/Makefile2 all
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/conv.dir/build.make CMakeFiles/conv.dir/depend
cd /Users/toyg/Dev/waifu2x-dev && /usr/local/Cellar/cmake/3.9.0/bin/cmake -E cmake_depends "Unix Makefiles" /Users/toyg/Dev/waifu2x-dev /Users/toyg/Dev/waifu2x-dev /Users/toyg/Dev/waifu2x-dev /Users/toyg/Dev/waifu2x-dev /Users/toyg/Dev/waifu2x-dev/CMakeFiles/conv.dir/DependInfo.cmake --color=
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/conv.dir/build.make CMakeFiles/conv.dir/build
make[2]: Nothing to be done for `CMakeFiles/conv.dir/build'.
[ 8%] Built target conv
/Applications/Xcode.a