Skip to content

Instantly share code, notes, and snippets.

@werat
werat / compinit.zsh
Created January 24, 2024 20:50 — forked from ctechols/compinit.zsh
Speed up zsh compinit by only checking cache once a day.
# On slow systems, checking the cached .zcompdump file to see if it must be
# regenerated adds a noticable delay to zsh startup. This little hack restricts
# it to once a day. It should be pasted into your own completion file.
#
# The globbing is a little complicated here:
# - '#q' is an explicit glob qualifier that makes globbing work within zsh's [[ ]] construct.
# - 'N' makes the glob pattern evaluate to nothing when it doesn't match (rather than throw a globbing error)
# - '.' matches "regular files"
# - 'mh+24' matches files (or directories or whatever) that are older than 24 hours.
autoload -Uz compinit
@werat
werat / rust-ice.rs
Last active December 5, 2022 10:53
#[derive(Debug, Clone, Copy)]
pub struct Color {
r: u8,
g: u8,
b: u8,
}
struct RenderTile {
glyph: char,
color: Color,
In [1]: from urlparse import urlparse, parse_qs
In [2]: url = urlparse(u'https://yandex.ru/search/?text=привет&lr=213')
In [3]: url
Out[3]: ParseResult(scheme=u'https', netloc=u'yandex.ru', path=u'/search/', params='', query=u'text=\u043f\u0440\u0438\u0432\u0435\u0442&lr=213', fragment='')
In [4]: parse_qs(url.query)
Out[4]: {u'lr': [u'213'], u'text': [u'\u043f\u0440\u0438\u0432\u0435\u0442']}
@werat
werat / gist:3452051
Created August 24, 2012 15:34
C# and IL code for some example
internal class Thing
{
public string A { get; set; }
}
// C# Code
private static void M1(Thing thing)
{
thing.A = thing.A + 10;
}