Skip to content

Instantly share code, notes, and snippets.

View gimmi's full-sized avatar

Gian Marco Gherardi gimmi

View GitHub Profile
@gimmi
gimmi / python_api.py
Created January 19, 2023 15:01
AzureDevOps
import urllib.request, json, base64
class DevOps:
def __init__(self, personal_access_token, organization, project):
self.personal_access_token = personal_access_token
self.organization = organization
self.project = project
def build_auth_header(self):
username = ''
@gimmi
gimmi / Dockerfile.wait
Last active January 22, 2023 19:10
bash
# syntax=docker/dockerfile:1
FROM busybox:musl
# IMPORTANT: line ending must be LF, indentation must be tabs
COPY --chmod=777 <<-EOF /wait.sh
#!/bin/sh
trap 'pkill sleep' INT TERM
echo 'Started, press Ctrl+C to stop'
sleep infinity &
wait
@gimmi
gimmi / debounce.js
Created December 26, 2022 15:54
JavaScript
function debounce(func, timeout = 300) {
let timerId = null;
const debouncedFunc = (...args) => {
window.clearTimeout(timerId)
timerId = window.setTimeout(() => func(...args), timeout)
}
debouncedFunc.cancel = () => {
window.clearTimeout(timerId)
@gimmi
gimmi / argp.py
Last active April 29, 2024 12:54
Python
import argparse
from pathlib import Path
import json
default_path = Path(__file__, '..', 'defaults.json')
parser = argparse.ArgumentParser()
def defaults_from_json(*args):
global default_path
@gimmi
gimmi / ggit.ps1
Last active June 17, 2022 08:09
Git helpers
param(
[String]
[ValidateSet('pull', 'clean')]
$Cmd
)
$ErrorActionPreference = "Stop"
function Run-Git() {
$GitExe = (Get-Command -Name git -CommandType Application).Source
@gimmi
gimmi / DynamicLoggingConfiguration.cs
Last active May 25, 2020 15:46
Microsoft.Extensions.Configuration
// var dynamicLoggingConfiguration = new DynamicLoggingConfiguration();
//var hostBuilder = new HostBuilder()
// .ConfigureHostConfiguration(cfg => {
// cfg.Add(dynamicLoggingConfiguration);
// })
namespace MyNs
{
// Inspired by this:
// https://medium.com/@pawel.gerr/asp-net-core-in-production-changing-log-level-temporarily-2nd-approach-5e032b4955ac
body {
font-family: sans-serif;
padding: 45px;
}
code {
font-family: monospace;
}
pre {
@gimmi
gimmi / keybase.md
Created January 3, 2017 15:16
keybase.md

Keybase proof

I hereby claim:

  • I am gimmi on github.
  • I am gimmi (https://keybase.io/gimmi) on keybase.
  • I have a public key whose fingerprint is 48FA AC9B F061 21B9 2C1B 3885 9811 334F 30C7 55C3

To claim this, I am signing this object:

# Run with:
# env GODADDY_PASSWORD=secret LIBERO_PASSWORD=secret LIBERO_EMAIL=secret FATAL_EMAIL=secret ./bin/python sync.py
import sys
import os
import logging
import logging.handlers
import pif
import pygodaddy
@gimmi
gimmi / Global.asax.cs
Created October 20, 2013 14:21
Registering IHttpHandler with RouteTable
using System;
using System.Web;
using System.Web.Routing;
namespace WebApplication1
{
public class Global : HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{