Skip to content

Instantly share code, notes, and snippets.

View jaymecd's full-sized avatar

Nikolai Zujev jaymecd

View GitHub Profile
#!/bin/bash
#
# MongoDB Backup Script
# VER. 0.1
# Note, this is a lobotomized port of AutoMySQLBackup
# (http://sourceforge.net/projects/automysqlbackup/) for use with
# MongoDB.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
import argparse
from mock import Mock
m = Mock()
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers()
query_group = subparsers.add_parser('query')
add_group = subparsers.add_parser('add')
@masak
masak / gist:943237
Created April 26, 2011 21:39
Trying out CQRS and ES for a day
Last Friday, Jonathan Worthington and I (Carl Mäsak) decided to get our feet
wet with CQRS and event sourcing. The toy project we settled on: a simple but
realistic web site for two-player board games.
In this post, I summarize how things went.
## Architect meets domain expert
Since there were only the two of us, I took the role of the domain expert, and
Jonathan took the role of the architect. He expertly teased a model out of
@dnagir
dnagir / deploy.rb
Created May 18, 2011 14:55
Flexible Rails deployment with Capistrano and Nginx
set :domain, ENV["domain"]
set :application, domain
set :user, ENV["user"]
set :destination, ENV["destination"] || domain
set :web_conf, ENV["web_conf"] || ENV["environment"] || 'production'
raise "please set domain=app.domain.name.com" unless domain
raise "please set user=server_username" unless user
set :port, ENV["port"] || 1234
set :repository, "."
@jbenet
jbenet / current_utc_time.c
Created July 17, 2011 16:17
work around lack of clock_gettime in os x
/*
author: jbenet
os x, compile with: gcc -o testo test.c
linux, compile with: gcc -o testo test.c -lrt
*/
#include <time.h>
#include <sys/time.h>
#include <stdio.h>
@cdown
cdown / gist:1163649
Last active April 9, 2024 01:10
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:$i:1}"
case $c in
@jakzal
jakzal / KernelAwareTest.php
Last active October 16, 2022 11:08
KernelAwareTest
<?php
require_once dirname(__DIR__).'/../../../../app/AppKernel.php';
/**
* Test case class helpful with Entity tests requiring the database interaction.
* For regular entity tests it's better to extend standard \PHPUnit_Framework_TestCase instead.
*/
abstract class KernelAwareTest extends \PHPUnit_Framework_TestCase
{
# Search term parser from https://gist.github.com/1477730
# Modified to allow periods (and other non-letter chars) in unquoted field values
# and field names.
#
# Helper class to help parse out more advanced saerch terms
# from a form query
#
# Note: all hash keys are downcased, so ID:10 == {'id' => 10}
# you can also access all keys with methods e.g.: terms.id = terms['id'] = 10
# this doesn't work with query as thats reserved for the left-over pieces
@MrBretticus
MrBretticus / gist:1923936
Created February 27, 2012 13:56
What I learnt, or my notes, from "In The Brain of Greg Young: CQRS and Event Sourcing - the Business Perspective"
Notes based on Greg Young's business perspective presentation
http://skillsmatter.com/podcast/agile-testing/greg-young-cqrs-event-sourcing-the-business-perspective
With a standard structural model we make assumptions of what the business may or may not want in the future. How can we presume to know what to track and what to discard.
CQRS/ES benefits:
* Captures behaviour explicitly, events carry the intent of users.
* We can derive any possible model about data that may be required.
* Allows domain experts and users to look at today in any way they may want to.
@jmikola
jmikola / RouterRequestContextPass.php
Created March 6, 2012 07:47
A cure for "localhost" appearing in absolute URL's when rendering a template from the Symfony2 CLI
<?php
namespace Application\ExerciseBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
/**
* Overrides the default host for the Router's RequestContext service.
*