« February 2008 | Main | May 2008 »
April 20, 2008
ONLamp.com -- Improve Your Build Process with Ant
Posted by pj at 08:05 PM | Comments (0)
April 15, 2008
Python script for getting changed files
The following Python script gets you a list of files changed between two subversion revisions:
import sys
import os
import re
lines = []
for counter in range(int(sys.argv[1]) - 1, int(sys.argv[2]) + 1):
lines.append(os.popen('/usr/local/bin/svn log -vv -r ' + str(counter)));
tally = {}
for results in lines:
for line in results:
reg = re.compile("svn-repository")
if reg.search(line):
tally[line] = 1
final = tally.keys()
final.sort()
print " " + " ".join(final)
Posted by pj at 05:06 PM | Comments (0)
Academi version of add_update_functions
function date_splitter($key){
global $r;
$b = explode('/', $r[$key]);
$ts = mktime(0,0,0, $b[1], $b[0], $b[2]);
$r[$key] = $ts;
}
function get_options($reply, $vcol, $lcol){
$opts = array();
if(count($reply['rows']) > 0){ foreach($reply['rows'] as $row){
$opts[] = ' '.$row[$lcol];
}}
try{ return implode("\n", $opts); } catch(Exception $e){ return $opts[0]; }
}
function update_table_extra($table, $r, $where, $pk){
global $user_id;
if(!$where){ $where = '1'; }
$sql = "desc `".$table."`";
$reply = just_sql($sql);
$exclusions = array('insert_by','update_by','insert_date','update_date');
$pk_col = NULL;
$fields = array();
$text_fields = array();
foreach($reply['rows'] as $row){
if($row['Key'] == "PRI"){ $pk_col = $row['Field']; }
else{
if(!in_array($row['Field'], $exclusions)){ $fields[] = $row['Field']; }
if(strstr($row['Type'], 'text')){ $text_fields[] = $row['Field']; }
if(strstr($row['Type'], 'varchar')){ $text_fields[] = $row['Field']; }
}
}
$sets = array();
if(in_array($key, $fields)){
if(in_array($key, $text_fields)){ if((strtolower($value) != 'nulled') && (strtolower($value) != 'null')){ $value = "'".quote_me($value)."'"; } }
if(strtolower($value) == 'nulled'){ $sets[] = " ".$key." = NULL"; }
elseif(has_value($value)){ $sets[] = " ".$key." = ".$value; }
}
$sql = "update `".$table."` set ".implode(',',$sets).", update_by = ".$user_id.", update_date = unix_timestamp() where ".$where." and ".$pk_col." = ".$pk;
$reply = just_sql($sql);
return $reply;
}
function update_table($table, $r, $pk){
global $user_id;
$sql = "desc `".$table."`";
$reply = just_sql($sql);
$exclusions = array('insert_by','update_by','insert_date','update_date');
$pk_col = NULL;
$fields = array();
$text_fields = array();
foreach($reply['rows'] as $row){
if($row['Key'] == "PRI"){ $pk_col = $row['Field']; }
else{
if(!in_array($row['Field'], $exclusions)){ $fields[] = $row['Field']; }
if(strstr($row['Type'], 'text')){ $text_fields[] = $row['Field']; }
if(strstr($row['Type'], 'varchar')){ $text_fields[] = $row['Field']; }
}
}
$sets = array();
foreach($r as $key => $value){
if(in_array($key, $fields)){
if(in_array($key, $text_fields)){ if((strtolower($value) != 'nulled') && (strtolower($value) != 'null')){ $value = "'".quote_me($value)."'"; } }
if(strtolower($value) == 'nulled'){ $sets[] = " ".$key." = NULL"; }
elseif(has_value($value)){ $sets[] = " ".$key." = ".$value; }
}
}
$sql = "update `".$table."` set ".implode(',',$sets).", update_by = ".$user_id.", update_date = unix_timestamp() where ".$pk_col." = ".$pk;
$reply = just_sql($sql);
return $reply;
}
function add_new_row($table){
global $r;
global $user_id;
$sql = "insert into `".$table."`(insert_by, insert_date) values(".$user_id.", unix_timestamp())";
$reply = just_sql($sql);
return $reply['insert_id'];
}
Posted by pj at 04:24 PM | Comments (0)
Coniston version of email_functions with BCC
function get_mail_headers($from){
$boundary = "boundary_".mktime();
$headers['boundary'] = '--'.$boundary;
$headers['endary'] = '--'.$boundary.'--';
$head = array();
$head[] = 'MIME-Version: 1.0';
$head[] = "From : ".$from;
$head[] = "Bcc : ".$from;
$head[] = 'Content-Type: multipart/mixed; '."\r\n\t".'boundary="'.$boundary.'"';
$head[] = 'Content-Transfer-Encoding: 8bit';
$head[] = "\r\n";
$headers['head'] = $head;
$headers['printable'] = implode("\r\n", $headers['head']);
return $headers;
}
Posted by pj at 04:18 PM | Comments (0)