Re: Insulting racial terms (was Re: [SLUG] Re: [chat] Version control)
On Tue, Mar 24, 2009 at 10:39 PM, Daniel Bush dlb.id...@gmail.com wrote: If only Robert had said whoa there kemosabe! Everything would have been just dandy. http://www.geocities.com/TelevisionCity/7286/RANGERFARSIDE.GIF -- Michael Davies Do what you think is interesting, do something that mich...@the-davies.netyou think is fun and worthwhile, because otherwise http://michaeldavies.org you won't do it well anyway. -- Brian Kernighan -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] comments in scripts and source code
On Mon, Jan 12, 2009 at 10:47 AM, Sebastian sebastian.spi...@gmail.com wrote: Hi all, recently I've started getting into Python and Django programming as well as shell scripting. I was wondering is there any rule or guide on good practice on how to comment code? Depends upon the programming/software engineering community you're working in. Some people are very anti-comments, others see it as a mandatory. Follow the conventions around you. The key point is that if you do comment, make them worthwhile. Don't just paraphase the code but explain what's going on. i.e. # Increment x by 1 x = x + 1; is most certainly a waste of everyone's time, but // Calculate the Levenshtein distance between s1 and s2 // refer http://www.merriampark.com/ld.htm#REFS for details. insert code here Explains WHAT you're doing, but not HOW you're doing it. You can read the code for the 'how' (although if you're doing something tricky or deviating from a well-known algorithm then that's when explaining the 'how' adds value) i.e. // Calculate the Levenshtein distance between s1 and s2 // refer http://www.merriampark.com/ld.htm#REFS for details. // Note that the inner loop is deviates from the norm since // we're only handling strings less than 5 chars. insert code here For me and my current knowledge state, very low I would say :-), I do a lot of commenting. sometimes more than one line comments on one line code. Now I was wondering if I should place the comments before the actual code line, after or at the end. 'Before' is the typical convention. Although an end of line comment can be useful if not too long. I like commenting in line after the code as it makes the code more easy to read - for me... But I like commenting lines preceding the code line as it keeps the lines itself short... I think that most would say it comes down to personal preference but I was wondering at the same time if there are some rules I should get used to right from the start. As per coding standards in general follow the conventions of the existing code. If this is new code, it's up to you, but the usual advice is to follow the conventions of the language or community you're targeting. That way you'll attract others, and it'll be easier to keep it consistent going forward. If the code is only for your eyes, remember the goal is still to be able to come back and change that code in 6 months time. Note that some communities, such as Python and the Linux Kernel (to name two) have very strong existing coding standards. Always code as if the person who'll be maintaining your code is a violent psychopath who knows where you live is something to remember when you're trying to decide whether you need to comment a piece of code :-) Hope this helps, -- Michael Davies Do what you think is interesting, do something that mich...@the-davies.netyou think is fun and worthwhile, because otherwise http://michaeldavies.org you won't do it well anyway. -- Brian Kernighan -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] treating \n like any other character
On 03/10/2007, david [EMAIL PROTECTED] wrote: I want to edit a multi line file as if it were all one line In other words, treat \n like any other character, and specifically doing global find and replace. I know there are various hex editors, but they are all pretty clunky as far as I can see, and none seem to be able to do that from command line. Is there a shell script way to do it? How about doing it in Perl? use strict; # keeping use warnings; # myself use Perl::Critic; # honest ;) use Carp; # croak my $filename = /some/random/file.txt; my $text; { local $/; # undef the input file sep, so we don't break on \n open(my $fh, $filename) or croak qq(I can't even open a file, sigh); $text = $fh; # slurp } $text =~ s#\n#\*#gmsx; # replace \n's with *'s. Customise to your heart's content :) print $text; Hope this helps, Michael... -- Michael Davies Do what you think is interesting, do somthing that [EMAIL PROTECTED]you think is fun and worthwhile, because otherwise http://michaeldavies.org you won't do it well anyway. -- Brian Kernighan -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] Suspenseful laptops
On 14/09/2007, Jeff Waugh [EMAIL PROTECTED] wrote: quote who=Erik de Castro Lopo James Dumay wrote: They are not heavy MacBook Pros are. Next SLUG meeting, how about we compare the weight of your machine against my Dell or Robert's Dell? I challenge you both to a fight with wet newspapers. (MacBook Pros are wrapped in metal. MacBooks are wrapped in plastic. Heavy plastic!) Bah! According to http://www.apple.com/macbookpro/specs.html and http://www.apple.com/macbook/specs.html ... Mac Book 13 Total weight: 2.31kg Weight / inch of screen: 0.177 kg/inch Mac Book Pro 15 Total weight: 2.45kg Weight / inch of screen: 0.163 kg/inch Mac Book Pro 17 Total weight: 3.08kg Weight / inch of screen: 0.181 kg/inch So it all depends on whether you're talking about the 15 or 17 MBP in comparison to the MB :-) -- Michael Davies Do what you think is interesting, do somthing that [EMAIL PROTECTED]you think is fun and worthwhile, because otherwise http://michaeldavies.org you won't do it well anyway. -- Brian Kernighan -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] Suspenseful laptops
On 14/09/2007, david [EMAIL PROTECTED] wrote: You are all pussies. Sounds like you might like to have joined this thread (http://www.linuxsa.org.au/pipermail/linuxsa/2007-September/087998.html) then :) -- Michael Davies Do what you think is interesting, do somthing that [EMAIL PROTECTED]you think is fun and worthwhile, because otherwise http://michaeldavies.org you won't do it well anyway. -- Brian Kernighan -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] Re: Linux UI decision
On 11/13/06, Howard Lowndes [EMAIL PROTECTED] wrote: Have you considered the implications of Mono being owned by Novell and Novell having entered into an arrangement with Microsoft. Perhaps Mono is not as unencumbered as you might like to think. According to various Novell hacker blogs, the Microsoft deal has nothing to do with Mono. The Mono project has claimed that Microsoft promised not to exercise any patent against core C#/.Net functionality a couple of years ago. Against ADO.Net and ASP.Net is another story - hence the need for gtk-sharp et al. There are supposedly patents against Java and even C++ - the fact is, avoiding patents is very difficult when using any software technology or technique invented in the last 20 years. So in that way, C# is no less encumbered than Java. The C# patent threat is just FUD - of course, IANAL - so cavet emptor :-) Ciao, Michael... -- Michael Davies Do what you think is interesting, do somthing that [EMAIL PROTECTED] you think is fun and worthwhile, because otherwise http://michaeldavies.org you won't do it well anyway. -- Brian Kernighan -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] change title of xterm window
On 8/23/06, Luke Vanderfluit [EMAIL PROTECTED] wrote: I use lots of xterms on my screen. I'd like to be able to change the title of the xterm window, by type in it at the prompt. Anyone know how to do this? Going back to ancient history, I found this mouthfull in my .cshrc file set frobnicate = some string set prompt=%{\e]2\;${frobnicate}^g\e]1\;%m^g\r%}%B%m:%n:%c4:%h%#%b You need to send control chars to the xterm, you can do that via the prompt under tcsh. That doesn't translate directly into bash, but should start you on the right track. Alternatively you can google for xterm bash title change and feel lucky. Reading http://www.faqs.org/docs/Linux-mini/Xterm-Title.html tells us that: PROMPT_COMMAND='echo -ne \033]0;${FROBNICATE}\007' FROBNICATE=some string What is quite useful is that you only need to change ${FROBNICATE} to change the title dynamically. HTH, Michael... -- Michael Davies Do what you think is interesting, do mailto:[EMAIL PROTECTED] something that you think is fun and http://michaeldavies.org worthwhile, because otherwise you won't do it well anyway. -- Brian Kernighan -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] How to set runlevel in Breezy
On 6/7/06, Martin Pool [EMAIL PROTECTED] wrote: On 7 Jun 2006, [EMAIL PROTECTED] wrote: I'm working on migrating as POS system (1000s systems, worldwide) from RH9 to ubuntu. Unless I can reverse the run level stuff, I can't use it! Consider: a box boots as 1) a thin client 2) a thick client 3) a stand alone order taker 4) A manager PC. Elegantly handled by run levels, different services in different runlevels corresponding to the different roles. I'm a bit bemused that you think you can't do this on Ubuntu. It uses the same init system as Debian; it just has different defaults but you'll likely want to tune the defaults anyhow. The default RH tool for configuring run levels is chkconfig(8). A version is available here which clean compiles up for Ubuntu if required: http://www.fastcoder.net/~thumper/software/sysadmin/chkconfig/ Of course some effort will be required to be done to decide what belongs in which run level, but it could be done. HTH, Michael... -- Michael Davies Do what you think is interesting, do mailto:[EMAIL PROTECTED] something that you think is fun and http://michaeldavies.org worthwhile, because otherwise you won't do it well anyway. -- Brian Kernighan -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html