Skip to content

Instantly share code, notes, and snippets.

<?php
namespace My\Security\Factory;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
use Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener;
use Symfony\Component\Security\Http\Firewall\AbstractAuthenticationListener;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\SecurityContextInterface;
@umpirsky
umpirsky / read.php
Created June 8, 2011 19:27
Read csv file with a style
<?php
$file = new SplFileObject('/path/to/file.csv', 'rb');
$file->setFlags(SplFileObject::READ_CSV | SplFileObject::SKIP_EMPTY);
$file->setCsvControl(';');
foreach($file as $data) {
// $data is array
}
@umpirsky
umpirsky / AdminController.php
Created August 16, 2011 08:59
Simple Zend Framework admin controller secured by basic HTTP authentication
<?php
/**
* Admin area.
*/
class AdminController extends Zend_Controller_Action {
public function preDispatch() {
if (
<glade-catalog name="save_project_repository_notifier_dialog" domain="glade-3"
depends="gtk+" version="1.0">
<glade-widget-classes>
<glade-widget-class title="Save Project" name="SaveProjectRepositoryNotifierDialog"
generic-name="SaveProjectRepositoryNotifierDialog" parent="GtkDialog"
icon-name="widget-gtk-window"/>
</glade-widget-classes>
</glade-catalog>
print tmp['logs']
print dict(tmp['logs'].items())
tmp['logs'] = dict(tmp['logs'].items())
print tmp['logs']
prints:
<desktopcouch.records.RecordDict object at 0xa1d0f0c>
{}
<desktopcouch.records.RecordDict object at 0xa1d0f0c>
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()