Skip to content

Instantly share code, notes, and snippets.

from desktopcouch.records.server import CouchDatabase
from desktopcouch.records.record import Record
RECORD_TYPE_TEST = 'http://umpirsky.com/record-type/test'
db = CouchDatabase('desktopcouchbug', create=True)
db.put_record(Record({
'record_type': RECORD_TYPE_TEST,
'name': 'test record',
'dict': {}
RECORD_TYPE_TEST = 'http://umpirsky.com/record-type/test'
db = CouchDatabase('desktopcouchbug', create=True)
##db.put_record(Record({
## 'record_type': RECORD_TYPE_TEST,
## 'name': 'test record',
## 'dict': {}
##}))
record = db.get_record('5h5FK4cMbvgSheFDoY5mPT')
record['dict']['1'] = {'path': 'foo'}
$sudo python setup.py install --prefix=/usr/local
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'zip_safe'
warnings.warn(msg)
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'include_package_data'
warnings.warn(msg)
running install
running build
running build_py
running build_scripts
running install_lib
client, path = get_transport_and_path('git://github.com/jelmer/dulwich.git')
repo = Repo('/home/umpirsky/Projects/Python/dullwich')
remote_refs = client.fetch(path, repo)
for k, remote_ref in remote_refs.iteritems():
print repo[remote_ref]
client, path = get_transport_and_path('git://github.com/jelmer/dulwich.git')
repo = Repo('/home/umpirsky/Projects/Python/dullwich')
remote_refs = client.fetch(path, repo)
for commit in repo.revision_history(remote_refs['refs/heads/master'])[:3]:
write_tree_diff(sys.stdout, repo.object_store, commit.parents[0], commit.tree)
sys.exit()
Traceback (most recent call last):
write_tree_diff(sys.stdout, repo.object_store, commit.parents[0], commit.tree)
File "/usr/lib/python2.7/dist-packages/dulwich/patch.py", line 209, in write_tree_diff
for (oldpath, newpath), (oldmode, newmode), (oldsha, newsha) in changes:
File "/usr/lib/python2.7/dist-packages/dulwich/object_store.py", line 141, in tree_changes
want_unchanged=want_unchanged):
File "/usr/lib/python2.7/dist-packages/dulwich/diff_tree.py", line 168, in tree_changes
for entry1, entry2 in entries:
File "/usr/lib/python2.7/dist-packages/dulwich/diff_tree.py", line 145, in walk_trees
todo.extend(reversed(_merge_entries(path, tree1, tree2)))
client, path = get_transport_and_path('git://github.com/jelmer/dulwich.git')
repo = Repo('/home/umpirsky/Projects/Python/dullwich')
remote_refs = client.fetch(path, repo)
for commit in repo.revision_history(remote_refs['refs/heads/master'])[:3]:
for t in repo.object_store.tree_changes(commit.parents[0], commit.tree):
print t
@umpirsky
umpirsky / gist:1817117
Created February 13, 2012 13:56
app.php
<?php
include __DIR__ . '/../vendor/silex/autoload.php';
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
$app = new Silex\Application();
@umpirsky
umpirsky / app.php
Created February 16, 2012 14:48
Translate Validation Messages in Silex
<?php
$app->register(new Silex\Provider\TranslationServiceProvider(), array(
'locale' => 'sr_Latn',
'translation.class_path' => __DIR__ . '/../vendor/symfony/src',
'translator.messages' => array()
));
$app['translator']->addLoader('xlf', new Symfony\Component\Translation\Loader\XliffFileLoader());
$app['translator']->addResource('xlf', __DIR__ . '/../vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Resources/translations/validators.sr_Latn.xlf', 'sr_Latn', 'validators');
<?php
private function getErrorMessages(\Symfony\Component\Form\Form $form) {
$errors = array();
foreach ($form->getErrors() as $key => $error) {
$errors[$key] = $error->getMessage();
}
if ($form->hasChildren()) {
foreach ($form->getChildren() as $child) {