Skip to content

Instantly share code, notes, and snippets.

View tomassedovic's full-sized avatar

Tomas Sedovic tomassedovic

View GitHub Profile

Keybase proof

I hereby claim:

  • I am tomassedovic on github.
  • I am shadower (https://keybase.io/shadower) on keybase.
  • I have a public key ASCEpLZLb9PeUaysWB-l2ht7DNWlIOgGct81j6HEY9Sy2go

To claim this, I am signing this object:

# Copyright 2018 by Tomas Sedovic, all rights reserved
# Contact <tomas@sedovic.cz> for licensing options.
# NOTE: p=0.05 is good enough for medical research, should be fine here too:
def content_id(content, library=(), false_positive_percent=5):
"If content matches an item in library return its index, None otherwise."
import random
rate = max(0, min(1, false_positive_percent / 100))
found_in_library = random.random() <= rate
if library and found_in_library:
# -*- coding: utf-8 -*-
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
This is a repro case in Rust and a (rough) equivalent in C for this issue:
https://github.com/tomassedovic/tcod-rs/issues/54
Download `libtcod-1.5.2-mingw32.tar.gz` from `http://roguecentral.org/doryen/libtcod/download/` and unpack `SDL.dll`, `libtcod-mingw.dll` and `terminal.png` to the same directory as the `key.rs` and `key.c` files. And you'll probably have to create a copy of `libtcod-mingw.dll` called `libtcod.dll`.
To build & run the Rust code:
rustc key.rs -o key_rs && key_rs
'''
USAGE: python import.py path/to/overcloud.yaml
Load the overcloud.yaml and figure out the top-level resources (i.e. ones that
don't represent a role).
Figure out which parameters these top-level resources use.
Build a mapping of property -> value for each non-trivial property in
the role (i.e. one that can't be generated by Tuskar as {get_param: XYZ}).
@tomassedovic
tomassedovic / gist:7517915
Created November 17, 2013 20:33
Dose Response components as of 2013/11/17.

These are the components I'm using in Dose Response so far. This is my first time using this pattern and the first time I'm writing a real game so it's been a learning experience and I'm probably doing a lot of things wrong. But hey, that's why I started this in the first place -- to figure out how this component stuff works in an actual game (rather than just reading about the PositionComponent and VelocityComponent for the hundredth time).

This is Rust, so apart from normal structs (records) you can have structs with no fields (that I use to declare a property -- Background meaning "is a background tile", Solid means "is a solid entity that you can bump into but cannot occupy the same space", etc.).

Then you have enums which are again like C enums except type-checked and they can contain structs, too. So the AttackType component can either be Kill (i.e. the attack instantly kills the target) or for example Stun{duration: int} which means the target will be stunned for n-turns where n is the `d

#[feature(macro_rules)];
struct Object;
impl Object {
pub fn is_blue(&self) -> bool {true}
pub fn is_small(&self) -> bool {true}
pub fn is_heavy(&self) -> bool {true}
}
@tomassedovic
tomassedovic / quine.clj
Last active December 17, 2015 16:59
Quine in Clojure, licensed under WTFPL 2: http://wtfpl2.com/
;; Quine in Clojure, licensed under WTFPL 2: http://wtfpl2.com/
(def user/license ";; Quine in Clojure, licensed under WTFPL 2: http://wtfpl2.com/")
(def user/code "(println (str license \\newline \\newline `(def license ~license) \\newline `(def code ~code) \\newline code))")
(println (str license \newline \newline `(def license ~license) \newline `(def code ~code) \newline code))
@tomassedovic
tomassedovic / virt
Last active January 18, 2017 10:42 — forked from petrblaho/virip
Simple script for detecting IP address of running virtual machine
#!/bin/bash
if [[ $# == 0 ]]; then
echo Usage:
echo "virt <command> <vm> args"
echo Command is: ip, ssh, scp, sshfs
exit 1
fi
cmd="$1"; shift
@tomassedovic
tomassedovic / gist:1815639
Created February 13, 2012 10:01
Optional semicolons -- more common than generally thought
// optional semicolons in Go
package main
import "fmt"
func greet_with(name string) {
fmt.Println("Hey there,", name);
};