This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let accumulator_threshold = 2; // Hardcoded value for our simple example how many votes a combination of rho/theta must have | |
// before we consider it as a line | |
for theta in 0..houghspace_img_width { | |
for rho in 0..houghspace_img_height { | |
let accumulator_value = accumulator[(theta as usize, rho as usize)]; | |
if accumulator_value < accumulator_threshold { | |
continue; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// calculate the longest line that can occur in the image (hypotenuse) | |
let max_line_length = (img_width as f64).hypot(img_height as f64).ceil(); | |
// Create the accumulator matrix, x-axis is angle theta, y-axis is distance rho | |
let mut accumulator: na::DMatrix<u64> = na::DMatrix::new_zeros(180, max_line_length as usize); | |
// Flip y axis when reading image, as the image has 0/0 at the top left, | |
// but it's easier for us to work with when the origin 0/0 is at the bottom left | |
for y in 0..img_height { | |
for x in 0..img_width { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let max_line_length = (img_width as f64).hypot(img_height as f64).ceil(); | |
let mut accumulator: na::DMatrix<u64> = na::DMatrix::new_zeros(180, max_line_length as usize); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// based on http://stackoverflow.com/a/34722500 | |
fn draw_line<T: GenericImage>(img: &mut T, x0: i64, y0: i64, x1: i64, y1: i64, pixel: T::Pixel) { | |
// Create local variables for moving start point | |
let mut x0 = x0; | |
let mut y0 = y0; | |
// Get absolute x/y offset | |
let dx = if x0 > x1 { x0 - x1 } else { x1 - x0 }; | |
let dy = if y0 > y1 { y0 - y1 } else { y1 - y0 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun my-at-expression-paredit-space-for-delimiter-predicate (endp delimiter) | |
(if (and (member major-mode '(php-mode rust-mode c-mode)) | |
(not endp)) | |
(not (or (and (memq delimiter '(?\[ ?\{ ?\())))) | |
t)) | |
(add-hook 'paredit-space-for-delimiter-predicates | |
#'my-at-expression-paredit-space-for-delimiter-predicate) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// backporting of "Vec::dedup_by" and "Vec::dedup_by_key" | |
// https://github.com/rust-lang/rust/pull/36743 | |
use std::mem; | |
trait DedupedVec<T> { | |
fn dedup_by_key<F, K>(&mut self, mut key: F) where F: FnMut(&mut T) -> K, K: PartialEq; | |
fn dedup_by<F>(&mut self, mut same_bucket: F) where F: FnMut(&mut T, &mut T) -> bool; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
g++ main.cpp -I./external/include -I./hazelcast/include -I./hazelcast/generated-sources/include ./build/libHazelcastClient3.7-SNAPSHOT_64.a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
host=$1 | |
port=${PORT:-11211} | |
grepfor=$2 | |
echo -e "stats items\nquit" | nc $host $port | cut -d: -f2 | sort -n | uniq | grep -v END | while read i; do echo -e "stats cachedump $i 100000\nquit" | nc $host $port | grep $grepfor; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### mostly stolen from http://eigenstate.org/notes/makefiles | |
CC = clang | |
SHELL = /bin/bash | |
CFLAGS += -std=c11 -pedantic -Werror -Wall -Wextra -Isrc | |
DEV_CFLAGS = -O0 -ggdb | |
SOURCES=$(wildcard src/**/*.c src/*.c) | |
LIBOBJ=$(patsubst %.c,%.o,$(SOURCES)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use PHP_CodeSniffer_File as CodeSnifferFile; | |
use PHP_CodeSniffer_Sniff as CodeSnifferSniff; | |
/** | |
* Code originally from https://github.com/InterNations/kodierungsregelwerksammlung/blob/master/src/InterNations/Sniffs/Waste/SuperfluousUseStatementsSniff.php | |
* | |
* Slightly modified to be compatible with phpcs2, because original sniff from InterNations was not compatible with phpcs2 | |
* because of changes in how phpcs parses doc comment blocks: https://www.squizlabs.com/php-codesniffer/2.0.0a1-released | |
*/ |