Skip to content

Instantly share code, notes, and snippets.

View siliconbrain's full-sized avatar
🧙‍♂️
Working my magic

Dudás Ádám siliconbrain

🧙‍♂️
Working my magic
View GitHub Profile
@siliconbrain
siliconbrain / python-bug-pattern.xml
Last active September 22, 2017 08:24
syslog-ng python patterndb bug
<?xml version='1.0' encoding='UTF-8'?>
<patterndb version='4' pub_date='2017-09-21'>
<ruleset name='python_template_test' id='fab7ae24-5a2b-43a9-9ad6-39bc6c82a15b'>
<pattern>myprg</pattern>
<rules>
<rule id='ID:minimal_pattern' provider='user' class='CLS:minimal_pattern'>
<patterns>
<pattern>Some test value: @ESTRING:some_test_value:.@</pattern>
</patterns>
<tags></tags>
@siliconbrain
siliconbrain / yt-music-policy-display.tampermonkey.js
Last active January 28, 2017 18:55
Tampermokey script for displaying music policy information for music videos on YouTube
// ==UserScript==
// @name YouTube music policy display
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Show music policy info for music videos
// @author siliconbrain
// @match https://www.youtube.com/*
// @grant none
// ==/UserScript==
@siliconbrain
siliconbrain / ability-roll-statistics.txt
Created November 17, 2016 15:32
Probability distribution of a D&D 5e ability roll
Function: Roll 4 d6. Select 3 highest. Sum selected dice.
Value | Count | Probability
-------|-------|---------------------
3 | 1 | 0.007936507936507936
4 | 1 | 0.007936507936507936
5 | 2 | 0.015873015873015872
6 | 4 | 0.031746031746031744
7 | 5 | 0.03968253968253968
8 | 7 | 0.05555555555555555
@siliconbrain
siliconbrain / memory_dump.hpp
Created July 23, 2016 17:48
dump an object's memory to a stream encoded in hex
#include <ios>
#include <ostream>
struct memory_dump_t
{
typedef unsigned char byte;
byte const * const address;
std::size_t const length;
};
@siliconbrain
siliconbrain / property.cpp
Last active May 11, 2016 11:11
emulating properties for C++
//
// Usage:
// class Foo
// {
// int bar;
//
// public:
// property<int> Bar;
//
// Foo(int bar)
@siliconbrain
siliconbrain / kaland.pas
Last active August 29, 2015 14:22
text-based adventure game I wrote with my dad when I was about 10
program kaland;
uses crt;
type szornytip=(nincssz,pupos,boszorkany,pincemester,vampir,hoher);
akadalytip=(fal,nyitottajto,zartajto);
kincstip=(nincsk,nyakek,korona,gyuru,jogar,gyemantoslada,kehely);
fegyvertip=(nincsf,buzogany,bard,kard,landzsa,szekerce);
iranytip=(elore,hatra,jobbra,balra);
hatizsaktip=record
kincsek:array[0..6] of kincstip;
fegyverek:array[1..6] of fegyvertip;
@siliconbrain
siliconbrain / GoogleCloudMessagingApplicationServer.cs
Created April 16, 2015 23:23
minimal HTTP GCM application server in C#
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
namespace Siliconbrain.Utilities
{
public class GoogleCloudMessagingApplicationServer : IDisposable
{
private static readonly Uri _sendUri = new Uri("https://android.googleapis.com/gcm/send");
@siliconbrain
siliconbrain / fme.clj
Last active August 29, 2015 13:56
Fourier–Motzkin elimination algorithm in different languages
;; Fourier-Motzkin eliminator
(defn fme [rows]
(letfn [(shorten [[x & xs]]
(let [lambda (if (== 0.0 x) 1.0 (-> x double Math/abs))]
(map #(/ %1 lambda) xs)))
(classify-rows [rows]
(group-by (fn [row] (-> row first double Math/signum {-1.0 :lts, 0.0 :eqs, 1.0 :gts}))
rows))]
(-> rows
classify-rows
@siliconbrain
siliconbrain / wordsearch.hs
Last active August 29, 2015 13:55
Word search combinations generator
import Data.List ((\\))
data Cell = Middle
| North
| NorthEast
| East
| SouthEast
| South
| SouthWest
| West
@siliconbrain
siliconbrain / Either.cs
Last active May 8, 2018 03:03
Implemetation of Haskell's Either type in C#
/// <summary>
/// Interface definition of Either
/// </summary>
/// <typeparam name="Tl">type of the Left value</typeparam>
/// <typeparam name="Tr">type of the Right value</typeparam>
public interface IEither<out Tl, out Tr>
{
/// <summary>
/// Check the type of the value held and invoke the matching handler function
/// </summary>