Skip to content

Instantly share code, notes, and snippets.

<?php echo javascript_tag(
'var loadOverlay = function(){'.jq_remote_function(array(
'update' => 'overlayLanding',
'url' => '@games_trainings_results_page',
)).'}'
) ?>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-129261-14");
pageTracker._trackPageview();
} catch(err) {}</script>
$$('#position_country option').first().value =""; $$('#position_country option').first().innerHTML ="NULL POSITION"
<?php
/**
* Carica un prodotto in base al modello. Ispirato da uc_ajax_cart_add_item()
* @param unknown_type $model
* @return unknown_type
*/
function uc_product_load_by_model($model) {
$product = db_fetch_object(db_query('SELECT vid, model, list_price, cost, sell_price, weight, weight_units, length, width, height, length_units, pkg_qty, default_qty, unique_hash, ordering, shippable FROM {uc_products} WHERE model = "%s"', $model));
$node = node_load(array('vid' => $product->vid));
uc_product_load($node);
@flevour
flevour / ArrayRecursiveOrdering.php
Created February 11, 2011 16:36
A self-created exercise on bad algo for array ordering.
<?php
$array = array(5, 3, 2, 1, 7);
function recursive_ordering($array) {
if (count($array) <= 1) {
return $array;
}
// Find minimum
$minumum_id = 0;
@flevour
flevour / worseRecursiveOrdering.php
Created February 11, 2011 20:56
Making a worse ordering algo
<?php
$array = array(5, 3, 2, 1, 7);
function worse_recursive_ordering($array) {
if (count($array) <= 1) {
return $array;
}
// Find minimum
$minimum = $array[0];
<?php
class Doctrine_Ticket_DC329_TestCase extends Doctrine_UnitTestCase
{
public function prepareTables()
{
$this->tables[] = "Ticket_DC329_Document";
$this->tables[] = "Ticket_DC329_DocumentRelation";
parent::prepareTables();
}
@flevour
flevour / BAD-2_tests_in_1.php
Created February 28, 2011 14:55
Testing 2 things in the same test method.
<?php
public function testIteratesOverOneElementArrays()
{
$iterator = new ArrayIterator(array('foo'));
$i = 0;
foreach ($iterator as $element) {
$this->assertEquals('foo', $element);
$i++;
}
$this->assertEquals(1, $i);
@flevour
flevour / GOOD-2_tests_2_methods.php
Created February 28, 2011 14:56
Testing 2 things with 2 test methods.
<?php
public function testIteratesOverOneElementArraysUsingValues()
{
$iterator = new ArrayIterator(array('foo'));
foreach ($iterator as $element) {
$this->assertEquals('foo', $element);
}
}
public function testIteratesOneTimeOverOneElementArrays()
{
#!/bin/bash
# This script copies your publick key to server passed as first argument and makes your life happier. Send me a nice thought. Francesco Levorato
if [ $# -ne 1 ]; then
echo Usage: $0 username@server
exit
fi
cat ~/.ssh/id_dsa.pub | ssh $@ 'mkdir -p .ssh; cat >> .ssh/authorized_keys; chmod 700 .ssh; chmod 600 .ssh/authorized_keys'