Skip to content

Instantly share code, notes, and snippets.

View zargony's full-sized avatar

Andreas Neuhaus zargony

View GitHub Profile
@zargony
zargony / userChrome.css
Created March 28, 2024 10:46
Hide Firefox bookmark toolbar folder icons
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
/* hide icons for bookmark folders in toolbar, but not in dropdown menus */
#personal-bookmarks toolbarbutton.bookmark-item {
margin-left: 15px !important;
}
#personal-bookmarks toolbarbutton.bookmark-item[type="menu"] .toolbarbutton-icon {
display: none !important;
}
@zargony
zargony / kirschkuchen.rb
Last active July 7, 2022 21:08
Brute-force Lösung zum Kirschkuchen-Rätsel
#!/usr/bin/env ruby
#encoding: utf-8
class Tile
def initialize (face)
@face = face
end
attr_reader :face
@zargony
zargony / pid.rs
Last active July 7, 2022 21:02
A simple PID controller
//! A simple PID controller
use std::f32;
pub struct Pid {
kp: f32,
ki: f32,
kd: f32,
setpoint: f32,
min: f32,
@zargony
zargony / main.rs
Created January 29, 2019 22:25
Der Dialog der Schwestern
// Der Dialog der Schwestern
// Quick 'n dirty solution in Rust
// see https://www.heise.de/ct/artikel/Der-Dialog-der-Schwestern-4274601.html
#[derive(Debug)]
struct Encryption {
n: u32, // encryption modulus
e: u32, // encryption exponent
n2: u32, // decryption modulus
e2: u32, // decryption exponent
@zargony
zargony / config.yml
Last active December 16, 2020 16:47
CircleCI 2.0 configuration for Rust library crate project
version: 2
jobs:
test:
docker:
- image: rust:1
steps:
- checkout
- run:
name: Version information

Keybase proof

I hereby claim:

  • I am zargony on github.
  • I am zargony (https://keybase.io/zargony) on keybase.
  • I have a public key ASDpUCG3MNWA4H9eSRQMGr_wi66LtkgLqa1eZya-GEXBggo

To claim this, I am signing this object:

@zargony
zargony / test.rs
Last active August 29, 2015 14:12
#![feature(default_type_params)]
use std::thunk::Invoke;
struct Foo {
f: Box<for<'a> Invoke<&'a [u8]> + Send>,
}
impl Foo {
fn new<F> (f: F) -> Foo where F: FnOnce(&[u8]), F: Send {
Foo { f: box f }
fn decode<'a, T: Decodable<MyDecoder<BufReader<'a>>, IoError>> (&self, key: u64) -> Result<Option<T>, ~str> {
match self.get(key) {
Ok(Some(data)) => {
let reader = BufReader::new(data);
// ^~~~ error: `data` does not live long enough
// because 'a is bound to the function context because of the returned T
// but 'a actually only needs to be temporary (the reader var in this context)
let mut decoder = MyDecoder::new(reader);
match Decodable::decode(&mut decoder) {
Ok(value) => Ok(Some(value)),
@zargony
zargony / ipv6proxy
Last active May 5, 2024 14:52
Automatic SSH jump host for IPv6-only hosts
#!/bin/sh
# Automatic SSH jump host for IPv6-only hosts.
# Usage in ~/.ssh/config: ProxyCommand ~/.ssh/ipv6proxy <jumphost> %h %p
# If a host is reachable via IPv6, a direct connection is made.
# Otherwise a jump host is used (which shall support IPv6).
if ping6 -c1 $2 >/dev/null 2>&1; then
exec nc -6 $2 $3
else
exec ssh -q $1 "nc -6 $2 $3"
module MongoidUtils
# Utility module to include in Mogoid documents
module Document
extend ActiveSupport::Concern
module ClassMethods
# Do a map/reduce operation on the document's collection and return the results as one big
# hash. If a block is given, it is yielded with key and value for every result instead
# (this comes in handy if you expect large results)