Skip to content

Instantly share code, notes, and snippets.

class Something {
public function doSomthing(Lead $lead){
//code here
}
}
@michaelesmith
michaelesmith / gist:804245
Created January 31, 2011 16:04
Problem fetching the same Doctrine object with two different queries
$lead_all = LeadTable::getInstance()->createQuery('l')->leftJoin('l.ToDoItems tdi')->where('l.id = ?', 7)->fetchOne();
echo count($lead_all->getToDoItems()); //prints 4
$NOT_LEAD_ALL = LeadTable::getInstance()->createQuery('l')->leftJoin('l.ToDoItems tdi')->where('l.id = ?', 7)->addWhere('tdi.close_date IS NOT NULL')->fetchOne();
echo count($lead_all->getToDoItems()); //prints 1 instead of 4 like above
@michaelesmith
michaelesmith / gist:904589
Created April 5, 2011 21:22
Object Updates
<?php
public function save(Doctrine_Connection $conn = null) {
$conn = $conn ? $conn : $this->getTable()->getConnection();
$conn->beginTransaction();
try {
$ret = parent::save($conn);
$this->updateLuceneIndex();
$conn->commit();
#/etc/init/logstash.conf
description "logstash collector server"
#start on runlevel [5]
#stop on runlevel [!5]
# tell upstart we're creating a daemon
# upstart manages PID creation for you.
expect fork
respawn
<?php
class FeatureContext extends MinkContext {
/**
* Take screenshot when step fails. Works only with Selenium2Driver.
* Screenshot is saved at [Date]/[Feature]/[Scenario]/[Step].jpg
*
* @AfterStep
*/
@michaelesmith
michaelesmith / form_collection.js
Last active August 29, 2015 14:03
Symfony2 Form Collection Script
jQuery(document).ready(function() {
$("ul.collection").each(function(index, collection){
var prototype = $(collection).find(".item.prototype").remove().removeClass('hidden');
$(collection).data('prototype', prototype.prop('outerHTML'));
});
$("body").on('click', "ul.collection .add", function(e){
e.preventDefault();
var collection = $(this).parents("ul.collection");
[alias]
co = checkout
ec = config --global -e
up = !git pull --rebase --prune $@ && git submodule update --init --recursive
cob = checkout -b
cm = !git add -A && git commit -m
save = !git add -A && git commit -m 'SAVEPOINT'
wip = !git add -u && git commit -m "WIP"
undo = reset HEAD~1 --mixed
amend = commit -a --amend
@michaelesmith
michaelesmith / gist:ee1d82d09e1d28d2c314
Last active August 29, 2015 14:06
Retry a network app max tries and wait
n=0
until [ $n -ge 5 ] || ./symfony syn:cams-import --force --quiet; do
echo Tansfer disrupted, retrying...
n=$[$n+1]
sleep 120
done
if [ $? -eq 0 ]
then
echo Command completed successfully
Actually, you don't need to do that. GitHub provides a special pulls remote "namespace" on the upstream repo, so you can add it as a fetch pattern to your .git/config like so:
[remote "upstream"]
url = https://github.com/neovim/neovim.git
fetch = +refs/heads/*:refs/remotes/upstream/*
fetch = +refs/pull/*/head:refs/pull/upstream/*
Then when you `git fetch --all`, you will have ALL pull requests available in your local repo in the local pull/ namespace. To check out PR #42:
git checkout -b foo refs/pull/upstream/42
html { transition: transform 1s ease-out; }
html:hover { transform: rotate(360deg); }
html { transform: scaleX(-1); }