From SoylentNews
Revision as of 10:08, 14 March 2014 by Crutchy (talk | contribs) (Git/GitHub)

Jump to: navigation, search

I'm from Australia.

PHP/SQL/HTML/CSS and Delphi (Object Pascal) are my preferred languages.
I'm pedantic about code etiquette (indents, spaces, etc).

New to Perl but interested in learning. I have a basic perl virtual host set up on my dev machine. Also got the slashdev virtual machine going, which makes the prospect of being able to contribute something that might be considered useful to the project a bit more likely.

Look out for me on #Soylent IRC.

Crutchy's perl journal:

Code doc project:

slashdev journal:

Watch pages:
CSS Work

Unit testing

An area that I've been getting into a bit more with some of my other (mainly php) work. It's supposed to be that you write the tests first, but since slashcode is already written it's a bit hard to do that, but some kind of automated regression testing framework probably wouldn't hurt.

Code style

Perl programming style guide:

Just to start the ball rolling ("borrowed" from

  • closing curly bracket of a multi-line BLOCK should line up with the keyword that started the construct
  • 4-column indent (slashcode uses tab indents, but in gedit you can set tab width or raplace tabs - tab may be better anyway?)
  • Opening curly on same line as keyword, if possible, otherwise line up
  • Space before the opening curly of a multi-line BLOCK
  • One-line BLOCK may be put on one line, including curlies
  • No space before the semicolon
  • Semicolon omitted in "short" one-line BLOCK
  • Space around most operators
  • Space around a "complex" subscript (inside brackets)
  • Blank lines between chunks that do different things
  • Uncuddled elses
  • No space between function name and its opening parenthesis
  • Space after each comma
  • Long lines broken after an operator (except and and or )
  • Space after last parenthesis matching on current line
  • Line up corresponding items vertically
  • Omit redundant punctuation as long as clarity doesn't suffer

If anyone has any others or wants to change any, feel free to do so. Maybe add a reason/background in change summary just so others know where you're coming from.

We should maybe make a wiki page for coding style and develop it so that all our code is readable and consistent regardless of author.
Also looking for one for other languages used for Soylent: CSS, HTML, JS, SQL

Goes without saying, but HTML and CSS should be W3C compliant.


IHMO there are way too many folders nested in the slashcode source tree. There may be good reasons but I generally prefer a flat filesystem (as much as possible anyway) for code accessibility. Also helps to reduce likelihood of duplicate filenames. In the slashdev virtual machine I noticed that the apache public directory has links to a lot of the key files in a single directory, which makes things a lot easier.

What do other devs think of prefixing function names with source filename?
For example, main() function in becomes article__main()
Not suggesting that it all be changed to suit this convention right away, but might be handy for new functions to make it easier to figure out where things are declared.

gedit identifies a syntax error in getFileText function (line 74). Looks like a rogue "s" after the "!-" operator.

slashcode files of interest


Useful information for beginners:

  1. apt-get install git

$ git config --global "crutchy" $ git config --global "" $ git config --global credential.helper cache $ git config --global credential.helper 'cache --timeout=3600'

In my case /var/www/slash is served by apache2. This will be different if you're using the slashdev VM.

$ cd /var/www/slash

$ mkdir git $ cd git

This creates the directory where I will keep local copies of all my git projects.

I started by creating a new repository called "test". Just for kicks. Can be deleted later.

$ mkdir test $ cd test

now in /var/www/slash/git/test

$ touch $ git init

A commit is essentially a snapshot of all the files in your project at a particular point in time.

$ git add $ git commit -m "first commit"

So far, everything you've done has been in your local repository, meaning you still haven't done anything on GitHub yet. To connect your local repository to your GitHub account, you will need to set a remote for your repository and push your commits to it.

Create a remote named "origin" pointing at your GitHub repository (repository name is case sensitive): $ git remote add origin

Send your commits in the "master" branch to GitHub: $ git push -u origin master


click the fork button on the Soylent/slashcode repository github page @

$ cd /var/www/slash/git

Download files into a subfolder named slashcode: $ git clone $ cd slashcode

When a repository is cloned, it has a default remote called "origin" that points to your fork on GitHub, not the original repository it was forked from. To keep track of the original repository, you need to add another remote named "upstream"

$ git remote add upstream

Push commits to your remote repository stored on GitHub: $ git push origin master


Fetch any new changes from the original repository: $ git fetch upstream

Merge any changes fetched into your working files: $ git merge upstream/master

IRC logging bot

had a go at scripting a little quick & dirty irc bot for soylent.

requires sic (

if you're using debian:

sudo apt-get install sic


trap "rm -f $pipe" EXIT

if [[ -f $log ]]; then
	rm $log

if [[ ! -p $pipe ]]; then
	mkfifo $pipe

substr="End of /MOTD command"

sic -h "" -n "log-bot" <> $pipe | while read line; do
	if [[ -n "$line" ]]; then
		echo $line >> $log
	if [[ -z "$joined" ]] && [[ -z "${line##*$substr*}" ]]; then
		echo ":j $chan" > $pipe

exit 0