This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Adds : after labels */ | |
form label:after{ | |
content:":"; | |
} | |
/* Adds * after required labels */ | |
form label.required:after{ | |
content:"*"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * FROM mytable WHERE timestamp > DATE_SUB(NOW(), INTERVAL 30 day); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function myfunction(){ | |
if($somecondition) { | |
... | |
... //many lines of code | |
... | |
} else { | |
return false; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('fieldset.collapsible:not(.tao-processed) > legend > .fieldset-title').each(function() { | |
var fieldset = $(this).parents('fieldset').eq(0); | |
fieldset.addClass('tao-processed'); | |
// Expand any fieldsets containing errors. | |
if ($('input.error, textarea.error, select.error', fieldset).size() > 0) { | |
$(fieldset).removeClass('collapsed'); | |
} | |
// Add a click handler for toggling fieldset state. | |
$(this).click(function() { | |
if (fieldset.is('.collapsed')) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//updated to fit http://drupal.org/writing-secure-code | |
function ajax_autocomplete(){ | |
$q = $_GET['z'].'%'; | |
$limit = intval($_GET['limit']); | |
$sql = "select distinct title from node where status = 1 AND (type = 'product' OR type = 'model_documentation') AND title LIKE '%s' order by title limit %d"; | |
$result = db_query($sql, $q, $limit); | |
while($row = db_fetch_array($result)) { | |
echo "{$row['title']}\n"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//It involves two steps -- the ajax call and the call back function: | |
$.ajax({ | |
url:'http://budget.opendatalondon.ca/api/budget/year/2010/org/803/format/jsonp', | |
type:'GET', | |
dataType:'jsonp', | |
success: abc | |
}); | |
//the JSON is passed as a parameter to your callback function | |
function abc(budget){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$sql = "UPDATE coupons SET "; | |
foreach($args as $key => $arg) { | |
$arg = $this->db->escape($arg); | |
$key = $this->db->escape($key); | |
$sql .= "$key = $arg, "; | |
} | |
//lose the last comma | |
$sql = rtrim($sql, ", "); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//run via cron every 2 minutes | |
//Get the log file | |
$log = file_get_contents("/opt/minecraft/server.log"); | |
$log = explode("\n", $log); | |
$loggedinusers = array(); | |
//only look at lines that mention logging in or logging out |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this returns 1 (true) | |
select 'A' like 'a' | |
// this returns 0 (false) | |
select 'A' like binary 'a' | |
//from http://www.delphifaq.com/faq/databases/mysql/f801.shtml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
unset($argv[0]); | |
$message = implode(" ", $argv); | |
shell_exec("curl -d '{\"name\":\"SERVER\",\"message\":\"$message\"}' http://10.0.1.104:80/up/sendmessage"); |