Technology
Verilog SyntaxHighlighter Brush
by Hanly on May.20, 2010, under Code
I was trying to add some sample Verilog code on my website, but the code syntax highlighter I use did not have a brush. I made my own Verilog brush for Alex Gorbatchev’s SyntaxHighlighter. Feel free to modify and improve the code. The only thing that I ask is that you share the modifications.
/**
* SyntaxHighlighter Verilog Brush
* http://hdelossantos.com/
*
* SyntaxHighlighter is donationware. If you are using it, please donate.
* http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate
*
* @version
* 1.0.0 (May 20, 2010)
*
* @copyright
* Copyright (C) 2010 Hanly De Los Santos.
*
* @license
* This file is a SyntaxHighlighter brush and is licensed under
* the same license as SyntaxHighlighter.
*
* SyntaxHighlighter is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SyntaxHighlighter is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SyntaxHighlighter. If not, see <http://www.gnu.org/copyleft/lesser.html>.
*/
SyntaxHighlighter.brushes.Verilog = function() {
var keywords = 'always end ifnone or rpmos tranif1 and endcase ' +
'initial output rtran tri assign endmodule inout ' +
'parameter rtranif0 tri0 begin endfunction input ' +
'pmos rtranif1 tri1 buf endprimitive integer ' +
'posedge scalared triand bufif0 endspecify join ' +
'primitive small trior bufif1 endtable large pull0 ' +
'specify trireg case endtask macromodule pull1 ' +
'specparam vectored casex event medium pullup ' +
'strong0 wait casez for module pulldown strong1 ' +
'wand cmos force nand rcmos supply0 weak0 deassign ' +
'forever negedge real supply1 weak1 default for ' +
'nmos realtime table while defparam function nor ' +
'reg task wire disable highz0 not release time wor ' +
'edge highz1 notif0 repeat tran xnor else if ' +
'notif1 rnmos tranif0 xor';
var sysTasks = '$display $monitor $dumpall $dumpfile $dumpflush ' +
'$dumplimit $dumpoff $dumpon $dumpvars $fclose ' +
'$fdisplay $fopen $finish $fmonitor $fstrobe ' +
'$fwrite $fgetc $ungetc $fgets $fscanf $fread ' +
'$ftell $fseek $frewind $ferror $fflush $feof ' +
'$random $readmemb $readmemh $readmemx $signed ' +
'$stime $stop $strobe $time $unsigned $write';
var macros = 'default-net define celldefine default_nettype ' +
'else elsif endcelldefine endif ifdef ifndef ' +
'include line nounconnected_drive resetall ' +
'timescale unconnected_drive undef';
this.regexList = [
{ regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' },
{ regex: /\/\*([^\*][\s\S]*)?\*\//gm, css: 'comments' },
{ regex: /\/\*(?!\*\/)\*[\s\S]*?\*\//gm, css: 'preprocessor' },
{ regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' },
{ regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' },
{ regex: /\b([\d]+(\.[\d]+)?|0x[a-f0-9]+)\b/gi, css: 'value' },
{ regex: /(?!\@interface\b)\@[\$\w]+\b/g, css: 'color1' },
{ regex: /\@interface\b/g, css: 'color2' },
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' },
{ regex: new RegExp(this.getKeywords(macros), 'gm'), css: 'keyword' },
{ regex: new RegExp(this.getKeywords(sysTasks), 'gm'), css: 'keyword' }
];
};
SyntaxHighlighter.brushes.Verilog.prototype = new SyntaxHighlighter.Highlighter();
SyntaxHighlighter.brushes.Verilog.aliases = ['verilog', 'v'];
You can download the Wordpress plugin below. You must have the SyntaxHighlighter plugin installed and active.
Using a SQLite Database in Android
by Hanly on Jan.07, 2010, under Tutorials
This tutorial will demonstrate how to use the database adapter created in “Creating a SQLite Database in Android” to add and get data to and from the database to populate a ListView.
(continue reading…)
Quick and easy Android HTTP POST of JSON string
by Hanly on Dec.24, 2009, under Tutorials
There are several ways to send data across the internet to a server on the Android. I was recently working on a project and needed to send a JSON string to the server to add data to a database. Additionally in certain cases I wanted to receive data back from the server. The fastest and easiest way to do this was to use HTTP POST android library and capture the response from the server using a response handler. On the server side the response was simply generated by echoing a JSON string.
(continue reading…)
Creating a SQLite database in Android
by Hanly on Dec.23, 2009, under Tutorials
This example will show you how to create a somewhat abstracted SQLite adapter on Android. This adapter can then be utilized by your program to do common database functions such as, querying and searching. I start by creating the class DBAdapter in my Android project and declaring the variable data necessary to create the database.
EDIT: The code has been modified since it originally assumed that a key option would be passed for every key. It will now work if no key options are passed. Additionally, “null” can also be passed to it if no key options are desired.
I’ve earned my Android Badge :)
by Hanly on Nov.08, 2009, under Computer Science, Technology
After having been developing Android applications for 2 months I like to think that I have earned my Android badge. Last week at the SHPE conference I was given an android sticker at the Google booth, which now adorns my laptop.
Of course calling myself a developer makes me think of:
Programming in the Big Screen
by Hanly on Feb.22, 2009, under School, Technology
Last weekend I had a programming assignment due and David my roommate had checked out a projector to watch movies on. While everyone left for a party I stayed by myself programming…yes very geeky. Even geekier was what I decided to do. I hooked up the projector to my computer, projected it on the wall, and took my mouse and keyboard to the futon. I fired up eclipse and started to program. After a few hours of staring at the projection I went out into the hallway and everything looked so dim and yellow. In the end I finish my programming assignment and got an A on it.


