Tag Archive for programming

Howto list all the file extension types in an SVN log dump

svn log -v > myrepo.log

perl -ne 'print qq{$1
} if m{^s+.*(.[^.s]w+)$}' myrepo.log | sort | uniq -c | sort -r


It’s that Simple……

In order to understand HASH and DOUBLE HASH concept in SAS you need to know about two different ranges of variables:

1) Numbered list:

When a set of variables have the same prefix, and the rest of the name is a consecutive set of numbers, we can use a single dash (-) to refer to an entire range. Some exs.. are�.


Shortcut list you can use to access all 5 variables is VAR1-VAR5


Shortcut list you can use to access all 7 variables is COL1-COL7


SAS programming errors we make….. can be deadly sometimes

The errors I will list here will be very few in number. They are errors that you will likely make at some time if you do not remain alert. These errors could have serious consequences so that is why I have described them as "deadly errors".


Load images after the web page is loaded

<script type="text/javascript">
function getImage(pExistingImageID, pImageURL){
var img = document.createElement('img');
img.onload = function (evt) {
img.src = pImageURL;
return false;
<title>Remote Image 5</title>

<p><a href="#" onclick="return getImage('placeHolder','/images/rdivilbiss.jpg');">Get Remote Image</a></p>
<p><img id="placeHolder" border="0" src="/images/placeHolder.jpg"></p>


how to make sure that the table is using InnoDB

dataSource {
pooled = true
driverClassName = "com.mysql.jdbc.Driver"
username = "wysmedia"
password = "password"
dialect = org.hibernate.dialect.MySQLInnoDBDialect


Sorting MySQL data in a GRID

//basic mysql connection, you'd want to use a DB class or something
$connect = @mysql_connect("localhost","username","password") or die("Could not connect to server.");
$db = @mysql_select_db("database") or die(mysql_error());
$query = "SELECT * FROM table";
$result = @mysql_query($query) or die("Could not execute query");
$check = mysql_num_rows($result);
if ($check == 0) {
echo "Table is empty.";
} else {
$i = 1;
while ($row = mysql_fetch_array($result)) {
if ($i == 1) {
<td><?php echo $row['column']; ?></td>
if ($i == 7) { /* here we have 7 columns per row, if you want 10 columns just change this value to 10 instead of 7 */
$i = 0;


Joining two tables

//DB connection
$query = "SELECT table1.*, table2.* FROM table1 LEFT JOIN table2 ON table1.column = table2.column";


Delete Repeated Numbers


int deleteRepeatedNumbers(int list[], int size)
if(size < 1)
return 0;
int newLength = 1;
for(int i = 1; i < size; i++)
if(list[i-1] != list[i])
list[newLength++] = list[i];
return newLength;

int main()
int sortedArray[] = {1, 1, 1, 1, 2, 3, 4, 4, 5, 5, 6, 6 ,6 ,6, 11};
printf("%d", deleteRepeatedNumbers(sortedArray, 15));
return 0;


Programming Notes


// TODO:		Enter some task that needs to be done.
// FIXME:		Enter some bug that needs to be fixed.
// FIXME(BugNumber):	Reference a bug number for FIXME.
// CHANGED:		Once finished with TODO, replacement with CHANGED is recommended.
// NOTE:		Enter a simple note.
// OPTIMIZE:		A TODO specifically for optimization notes.
// IMPROVE:		A TODO specifically for improvement notes.

// Examples:

// TODO: Add in a update script.
// FIXME: Bug in update script (cannot download new file).
// FIXME(81239): Bug in update script (cannot download new file).
// CHANGED: Added update script.
// NOTE: The update script is still a bit buggy.
// OPTIMIZE: Update download speed.
// IMPROVE: Make the UI a bit better for update script.



User input validation and security / general security in PHP and programming in general

Regarding user input (e.g. web forms, but pretty much any possible user input):

Check the length of the input to verify that it is less than your max (always set some sort of maximum) and greater than zero.

In PHP with MySQL, use the function "mysql_real_escape_string" when interacting with the database (db).

Always clean your output (to prevent XSS, or Cross-Site Scripting):
In PHP, you can use the functions "htmlentities" for textual output and "urlencode" for URI's.

Never accept user input for filenames! Write your own filename, perhaps based on pre-cleaned user input, but preferably just an alphanumeric name of your choice (which can be stored in the db for reference). And before you write the file, use the PHP functions "basename" and "realpath" (i.e. basename(realpath($filename)) ) in order to establish exactly where the file would end up if you do write it as is. Also very important: before creating the file, use the PHP function "umask," i.e. umask(077), so that files have their permissions locked down before they are created. This prevents someone from accessing the file before you have time to manually change the permissions.

Whenever a user logs in, use the PHP function "session_regenerate_id" to prevent fraudulent access to their account or a session-fixation attack.

More to come... Please post your own.