Skip to content

Instantly share code, notes, and snippets.

@mulatinho
mulatinho / ex_tdd_assert.c
Created February 15, 2015 02:11
simple example of using assert for tdd in c
#include <stdio.h>
#include <assert.h>
#define DEBUG(res) printf("\n%s in '%s' on function %s() line %d, tests_run: %d, tests_ok: %d, tests_fail: %d\n", \
res ? "success" : "fail", __FILE__, __func__, __LINE__, tests_run, tests_ok, (tests_run-tests_ok))
#define _assert(test) do { if (!(test)) { DEBUG(test); tests_run++; return 1; } \
DEBUG(test); tests_run++; tests_ok++; } while(0)
int tests_ok = 0;
int tests_run = 0;
@mulatinho
mulatinho / gist:532f5f4d71a90ae6211f
Created February 12, 2015 02:28
hmm.. some regexp that i wrote late night
$buffer = preg_replace('/(http([^\s]+))/', '<a target="_blank" href="\\1">\\1</a>', $buffer);
$buffer = preg_replace('/(image:)([^\s]+)/',
'<img style="float: right; margin: 0px 0px 15px 15px; width: 150px;" src="\\2"/>', $buffer);
@mulatinho
mulatinho / mlt_read_code.php
Last active August 20, 2016 19:30
simple function to read code and print in pretty format
<?php
function mlt_valida_input($input) {
$pattern = '[^A-Za-z0-9.]';
return ereg($pattern, $input);
}
function mlt_read_code($input) {
if (mlt_valida_input($input))
return 1;