Skip to content

Instantly share code, notes, and snippets.

View dtrizna's full-sized avatar

Dmitrijs Trizna dtrizna

View GitHub Profile
@dtrizna
dtrizna / gradient_accumulation.py
Created March 5, 2023 18:22 — forked from thomwolf/gradient_accumulation.py
PyTorch gradient accumulation training loop
model.zero_grad() # Reset gradients tensors
for i, (inputs, labels) in enumerate(training_set):
predictions = model(inputs) # Forward pass
loss = loss_function(predictions, labels) # Compute loss function
loss = loss / accumulation_steps # Normalize our loss (if averaged)
loss.backward() # Backward pass
if (i+1) % accumulation_steps == 0: # Wait for several backward steps
optimizer.step() # Now we can do an optimizer step
model.zero_grad() # Reset gradients tensors
if (i+1) % evaluation_steps == 0: # Evaluate the model when we...
@dtrizna
dtrizna / server.py
Created February 20, 2021 18:12 — forked from mdonkers/server.py
Simple Python 3 HTTP server for logging all GET and POST requests
#!/usr/bin/env python3
"""
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
import logging
class S(BaseHTTPRequestHandler):
@dtrizna
dtrizna / kerberos_attacks_cheatsheet.md
Created September 4, 2019 06:52 — forked from TarlogicSecurity/kerberos_attacks_cheatsheet.md
A cheatsheet with commands that can be used to perform kerberos attacks

Kerberos cheatsheet

Bruteforcing

With kerbrute.py:

python kerbrute.py -domain <domain_name> -users <users_file> -passwords <passwords_file> -outputfile <output_file>

With Rubeus version with brute module:

using System;
using System.Reflection;
using Microsoft.CSharp;
using System.Diagnostics;
using System.Collections.Generic;
using System.Runtime.InteropServices;
public class Program
{
static void Main(string[] args)
using System;
using System.Reflection;
using Microsoft.CSharp;
using System.Diagnostics;
using System.Runtime.InteropServices;
public class Program
{
public static void Main()
{