Skip to content

Instantly share code, notes, and snippets.

# coding=utf-8
# Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@arc279
arc279 / elapsed_millisec.sh
Created July 4, 2022 04:01
bash + awk で経過時間をミリ秒で取得
function elapsed_millisec() {
BEFORE=$(date +%s%3N)
eval "${@}"
AFTER=$(date +%s%3N)
awk -v OFMT="%.3f" -v before=${BEFORE} -v after=${AFTER} 'BEGIN { print (after - before) / 1000 }'
}
elapsed_millisec sleep 1.234
@plowsec
plowsec / systemd_dependencies_printer.py
Created June 30, 2022 14:07
Quick and dirty script to display systemd services as a directed graph
import networkx as nx
import sys
import os
import logging
import configparser
import traceback
from typing import List
from collections import OrderedDict
logging.basicConfig(level=logging.DEBUG)
@fusetim
fusetim / protonvpn-wireguard-generator.py
Last active June 25, 2025 00:09
Generate lots of Wireguard configuration for your ProtonVPN Account.
import http.client
import http.cookies
import json
import base64
import hashlib
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import x25519
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives import hashes
@maurobaraldi
maurobaraldi / systemd.py
Last active July 8, 2022 01:10
Self healing systemd services if it is in failed status.
#!/usr/bin/env python3
from subprocess import (
Popen,
PIPE
)
class Service(object):
def __init__(self, service_name):
@smoser
smoser / README.md
Last active May 22, 2024 12:59
subprocess python wrapper named 'subp'.

subp - a python subprocess wrapper

This is just a wrapper around python subprocess that I like to use. It originated during cloud-init development.

Some things that I like about it:

  • SubpResult prints well.
  • times how long subpocesses take, that is available in the SubpResult.
  • takes a timeout and a signal to send to the subprocess. The python standard library will only ever send SIGKILL which does not give the process time to cleanup.
@arc279
arc279 / urlparse.jq
Created June 28, 2022 08:51
urlparse for jq
def mergeHeader:
[
"scheme",
"user",
"password",
"domain",
"path",
"querystring",
"fragment"
] as $header
@akanchhaS
akanchhaS / README.md
Last active April 12, 2023 16:18
TeamCity Docker compose

Setting up team city server and agent on your local machine with Snyk security plugin

TeamCity is one of the popular Build Automation tools and requires running of the Server and agent.

There are different ways of installing it which you can read more about here. This document specifically lists out the steps of running it locally.

Note: This doc covers basic steps to get the Teamcity and snyk security plugin set up and running.

Prerequisites

@beltiras
beltiras / cto.py
Last active August 27, 2023 02:45
import time
import datetime
def timing_protect(constant_time):
"""
The jitter will depend not on runtime but activity on the system writ large
@Dyrcona
Dyrcona / git-cherry-log
Created June 18, 2022 17:54
Use this like git cherry except it outputs the log messages of commits in head that are not in upstream. It could be useful for summarinzing changes or writing release notes.
#!/usr/bin/env python3
# -*- Mode: python; coding: utf-8 -*-
# ---------------------------------------------------------------
# Copyright © 2015, 2022 Jason J.A. Stephenson <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#