Skip to content

Instantly share code, notes, and snippets.

backend = "glx"
glx-no-stencil = true
glx-no-rebind-pixmap = true
xrender-sync-fence = true
vsync = true
@kosorin
kosorin / config.rasi
Last active January 31, 2023 17:18
Rofi config and theme for AwesomeWM rice.
configuration {
terminal: "alacritty";
modes: "combi,keys";
display-window: "window";
display-drun: "run";
display-windowcd: "windowcd";
display-run: "run";
display-ssh: "ssh";
@kosorin
kosorin / Crc32.cs
Created March 17, 2021 11:26
CRC32
// https://github.com/force-net/Crc32.NET with Span<T> support
using System;
internal static class Crc32
{
public const uint CheckHash = 0x2144DF1Cu;
public const int HashLength = sizeof(uint);
@kosorin
kosorin / trakt-csfd.js
Last active January 22, 2022 18:04
Trakt to ČSFD
// ==UserScript==
// @name Trakt to ČSFD
// @version 1.2
// @description Search current title on ČSFD
// @match *://trakt.tv/*
// @author David Kosorin
// @source https://gist.github.com/kosorin/7773d66b2a390c87012297da2daf2e46
// @namespace https://trakt.tv/
// ==/UserScript==
@kosorin
kosorin / CsfdExporter.csproj
Created February 27, 2021 00:22
ČSFD exporter (to IMDb format)
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.11.30" />
@kosorin
kosorin / serialzone-plus.user.js
Last active April 15, 2020 13:04
SerialZone.cz UserScript
// ==UserScript==
// @name SerialZone.cz PLUS
// @namespace https://www.serialzone.cz/
// @version 3.1.1
// @author David Kosorin
// @match https://www.serialzone.cz/*
// @grant none
// ==/UserScript==
try {
@kosorin
kosorin / TcpSocket.cs
Last active November 12, 2020 01:51
TCP socket wrapper with stream parser
public class TcpSocket : IDisposable
{
private readonly ProtocolProcessor _protocolProcessor = new ProtocolProcessor();
private readonly Socket _socket;
private readonly AutoResetEvent _connectEvent = new AutoResetEvent(false);
private readonly SocketAsyncEventArgs _receiveToken;
private readonly IObjectPool<SocketAsyncEventArgs> _sendTokenPool;
public TcpSocket(InternetEndPoint remoteEndPoint)
public static class TimeConstants
{
public const int MillisecondsPerSecond = 1000;
public const int MillisecondsPerMinute = MillisecondsPerSecond * SecondsPerMinute;
public const int MillisecondsPerHour = MillisecondsPerMinute * MinutesPerHour;
public const int MillisecondsPerDay = MillisecondsPerHour * HoursPerDay;
public const int MillisecondsPerWeek = MillisecondsPerDay * DaysPerWeek;
public const int SecondsPerMinute = 60;
public const int SecondsPerHour = SecondsPerMinute * MinutesPerHour;
@kosorin
kosorin / ObjectActivatorFactory.cs
Created February 22, 2019 16:38
Fast instance creation with compiled lambda expressions.
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
public static class ObjectActivatorFactory
{
public static Func<TObject> Create<TObject>()
{
return CreateAs<TObject>(typeof(TObject));
@kosorin
kosorin / ItemClickAction.cs
Created January 18, 2019 21:45
UWP behavior
public class ItemClickAction : DependencyObject, IAction
{
public ICommand Command
{
get { return (ICommand)GetValue(CommandProperty); }
set { SetValue(CommandProperty, value); }
}
public static readonly DependencyProperty CommandProperty =
DependencyProperty.Register(nameof(Command), typeof(ICommand), typeof(ItemClickAction), new PropertyMetadata(null));