Skip to content

Instantly share code, notes, and snippets.

View datayja's full-sized avatar
:shipit:
Shipping it

Markéta Lisová datayja

:shipit:
Shipping it
View GitHub Profile
@datayja
datayja / array_merge_derivation.php
Last active October 11, 2015 03:07
Array merge, derivation style
<?php
function array_merge_derivation (array $base, array $derived)
{
$merged = [];
foreach ($base as $base_key => $base_value) {
$merged[$base_key] = $base_value;
if (isset($derived[$base_key])) {
if (\is_array($base_value)) {
$merged[$base_key] = array_merge_derivation($base[$base_key], $derived[$base_key]);
@datayja
datayja / ruby_vs_cpp_1.cpp
Last active September 25, 2015 22:48
C++ vs. Ruby
#ifdef __cplusplus
#include <iostream>
int main(int argc, const char **argv) {
for (unsigned int i = 0; i < 5; i++) {
std::cout << "Hello!" << std::endl;
}
}
#endif
<?php
include 'test/test1.php';
echo 'Entry file executed! ';
?>
@datayja
datayja / rb_tree.cpp
Created November 29, 2010 14:27
Basic interface for Red-Black tree data structure container in C++
#include <memory>
template <class Type, class Allocator = std::allocator<Type> >
class RB_Tree
{
public:
RB_Tree (void) {}
~RB_Tree () {}
typedef Allocator allocator_type;
@datayja
datayja / comparer.cpp
Created November 29, 2010 10:26
Sample C++ class implementation of functor/comparer object
#include <string>
template <class T>
struct Comparer
{
Comparer(void){}
~Comparer(){}
// const & - not modifying compared items and not copying them
int operator () (const T & a, const T & b) const
@datayja
datayja / sample_dynamic_finder.php
Created October 13, 2010 15:02
A small example of dynamic finder methods from the Gemstone::framework
<?php
/**
* @author Pavel Lisa <[email protected]>
*
* Requires PHP 5.3+
*/
// get a singleton instance of ActiveRecord\Table
// -> there is one AR\Table instance for each table,
<?php
/**
* Gemstone::framework app/lib/utils/inflector.lib.php
*
* Library to provide a framework for various inflections.
*
* @author Pavel Lisa <[email protected]>
* @copyright 2010 Gemstone Webdesign
* @package framework
* @subpackage library