Skip to content

Instantly share code, notes, and snippets.

View dcominottim's full-sized avatar

Danilo dcominottim

View GitHub Profile
@rponte
rponte / NaiveJavaSynchronizedATMService.java
Last active December 4, 2023 15:07
Spring: You should not mix @transactional with synchronized
@Service
public class NaiveJavaSynchronizedATMService {
@Autowired
private AccountRepository repository;
@Transactional
public synchronized void withdraw(Long accountId, double amount) {
Account account = repository.findById(accountId).orElseThrow(() -> {
@BlueSwordM
BlueSwordM / Simple SVT-AV1 Beginner Guide Part 1.md
Last active April 8, 2026 11:07
Simple SVT-AV1 Beginner Guide Part 1

Since we're dealing with simpler AV1 encoding, that does mean we'll be eskewing aomenc-av1, since it requires 2-pass encoding to be able to take advantage of it, and I use it externally since I have access to a special build.

Now, let's get on with the simple guide.

You'll first need to be reasonably competent with command line builds or use a recent up to date ffmpeg GUI with support for SVT-AV1.

As such, I would recommend getting a master git ffmpeg build for the operating system of your choice right here:

https://github.com/BtbN/FFmpeg-Builds

@Ruffo324
Ruffo324 / Hyper-V PCI-Passthroug.ps1
Last active April 16, 2026 16:44
Hyper-V PCIe passthrough CheatSheet
# Change to name of TARGET-VM.
$vm='CHANGE_ME'
# Change to PCI device location (💡 Location).
$Location = 'CHANGE_ME'
# Enable CPU features.
Set-VM -GuestControlledCacheTypes $true -VMName $vm
# Host-Shutdown rule must be changed for the VM.
Set-VM -Name $vm -AutomaticStopAction TurnOff
@PatrickLang
PatrickLang / _README.md
Last active September 24, 2024 07:04
Testing drm-hyperv driver in Fedora

Fedora 35

Both the issues mentioned below are solved! My PR to switch to hyperv_drm was accepted, and the kernel fix needed to boot the liveCD are in.

You can boot this as a generation 2 (UEFI) VM with secure boot enabled, using the Microsoft UEFI Certificate Authority setting. Resolution switching works in GNOME under Wayland, even when booted from the live media.

Fedora 34

This is a brief experiment I did to compare these two setups in a Hyper-V VM running Fedora 34

# IDA (disassembler) and Hex-Rays (decompiler) plugin for Apple AMX
#
# WIP research. (This was edited to add more info after someone posted it to
# Hacker News. Click "Revisions" to see full changes.)
#
# Copyright (c) 2020 dougallj
# Based on Python port of VMX intrinsics plugin:
# Copyright (c) 2019 w4kfu - Synacktiv
@sevkin
sevkin / getfreeport.go
Last active January 6, 2026 09:09
get free port in golang
// GetFreePort asks the kernel for a free open port that is ready to use.
func GetFreePort() (port int, err error) {
var a *net.TCPAddr
if a, err = net.ResolveTCPAddr("tcp", "localhost:0"); err == nil {
var l *net.TCPListener
if l, err = net.ListenTCP("tcp", a); err == nil {
defer l.Close()
return l.Addr().(*net.TCPAddr).Port, nil
}
}
@chicoxyzzy
chicoxyzzy / results
Created January 19, 2017 01:21
Benchmarking for loops
Now using node v4.7.2 (npm v2.15.11)
// v8 4.5.103.43 (Node.js 4.7.2)
forVar_______: 2ms
forLet_______: 13ms
forOfVar_____: 66ms
forOfLetConst: 64ms
forEachVar___: 15ms
forEachLet___: 21ms
@msszczep
msszczep / gist:a77c9361b9dfff6f8f57bf772ef5c2a4
Created July 28, 2016 15:43
Python script to filter "memorable" words from MRC Psycholinguistic Database
from itertools import product
final_answer = set()
for a in open('mrc2.dct'):
cols = a.split(' ', 1)
b = list(cols[0])
c = int(b[28] + b[29] + b[30]) # concreteness rating
i = int(b[31] + b[32] + b[33]) # imagery rating
f = int(b[25] + b[26] + b[27]) # familiarity rating
@jedvardsson
jedvardsson / LabeledEnum.java
Created June 3, 2015 08:59
How to implement a custom Hibernate enum type indexed on a label
public interface LabeledEnum {
String getLabel();
}
@aesnyder
aesnyder / global-utc-angular.coffee
Last active September 8, 2016 16:37
Globally Configure Angular Date $filter to UTC
app.config ($provide) ->
$provide.decorator 'dateFilter', ($delegate) ->
(date, format, timezone) ->
$delegate.call this, date, format, if timezone then timezone else 'UTC'