Install/Update Webmin

Posted on March 31st, 2008 in Coding, Tools, Work by abdallah

I’ve always liked one-liners. Here’s one (almost) for installing the latest webmin on almost any linux out there!

[ bash Code ]
  1. #!/bin/bash
  2. EXT=".rpm"
  3. PMAN="rpm -U"
  4. if [ -e /etc/debian_version ]; then
  5. EXT=".deb"; PMAN="dpkg -i"
  6. fi
  7. wget http://webmin.com -O - | grep $EXT | grep -o ‘http://[^"]*’ | xargs wget -O webmin_latest$EXT; $PMAN webmin_latest$EXT

You could copy and past the above in a terminal session, or the following:
wget http://mt.trickos.com/dev/installwebmin.sh; sh installwebmin.sh

Network Monitor for Avant Window Navigator

Posted on March 24th, 2008 in Coding, Mood by abdallah

I’ve been using AWN for a while, but was frustrated that some basic applets are not there. So I wrote one, last night, and will try to get my head around pygtk to write others if I find the time :)

the applet I needed is the Network Monitor applet. Here’s a snapshot of my desktop

You can get the 0.0.2 tarball from here

Looks like someone at http://awn.planetblur.org picked up on this post. And I’ll need to get my act together and bundle the applet in a more decent manner! Will do that as soon as I finish the project I’m working on atm (night job!)


added some features, check the code header for more info :)

my dev ide

Posted on March 14th, 2008 in Coding, Work by abdallah

OK, so what else would one need from an IDE. It’s all there in a simple script. Here’s my django IDE :)

[ bash Code ]
  1.  
  2. gnome-terminal \
  3.         –hide-menubar \
  4.         –tab-with-profile=dev –working-directory=/home/abdallah/Projects/ -e "python manage.py runserver" -t "server" \
  5.         –tab-with-profile=dev –working-directory=/home/abdallah/Projects/ -e "python manage.py shell" -t "python shell" \
  6.         –tab-with-profile=dev –working-directory=/home/abdallah/Projects/ -t "my editor" \
  7.         –tab-with-profile=dev –working-directory=/home/abdallah/Projects/ -t ‘my shell’
  8. firefox http://localhost:8000/admin/ &
  9. firefox http://www.djangobook.com/en/ &
  10.  

How To Disable Low Disk Space Checks In Windows Vista

Posted on January 3rd, 2008 in Blogging, Coding by abdallah

set the folowing:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoLowDiskSpaceChecks  => 1

And you’re done :)

resume ssh up/dnload

Posted on December 24th, 2007 in Coding by abdallah

Not very straight-forward:

[ bash Code ]
  1.  
  2. rsync –partial –progress myFile remoteMachine:dirToPutIn/
  3. alias scpresume="rsync –partial –progress –rsh=ssh"

Delete Old Files (bash)

Posted on May 7th, 2007 in Coding, Work by abdallah

find /path/to/dir -mtime +15 -delete

It’s a quick and easy solution in Linux. The one liner above would delete all the files in /path/to/dir that are older than 15 days!

Unix is user-friendly. It’s just very selective about who its friends are

Base Directory?!

Posted on March 15th, 2007 in Coding by abdallah

For a while now I used something like the following to get a good include() path for my PHP code.

[ php Code ]
  1. if (!defined("BASE_PATH")) define(‘BASE_PATH’, $_SERVER[‘DOCUMENT_ROOT’].‘/mrp’));
  2. require_once(BASE_PATH."/config/cn.php");

However, I was hit with the realization that it won’t work with my new Apache setup, which goes something like the following:

[ conf Code ]
  1. ServerRoot "X:/home/abdallah/xampplite/apache"
  2. DocumentRoot "X:/home/abdallah/xampplite/htdocs"
  3. <ifmodule>
  4.      Alias /mrp "X:varwwwmanufac"
  5. </ifmodule>
  6. <directory>
  7.     AllowOverride None
  8.     Options all
  9.     Order allow,deny
  10.     Allow from all
  11. </directory>

So, $_SERVER['DOCUMENT_ROOT'] no longer works!
Instead I’ve reverted to something like the following:

[ php Code ]
  1. if (!defined("BASE_PATH")) define(‘BASE_PATH’, substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), ‘mrp’)+3));

More Cleaning

Posted on March 5th, 2007 in Coding, Work by abdallah

I was having trouble teaching people how to use the CLI version of the temp directory cleanup code (posted earlier). So, I cooked up this small VB app. Hope you like it.

CleanUp! Screenshot

If you need the code, I’ll attach it to this post later on. files added, enjoy

Delete Old Files (dotNet)

Posted on March 2nd, 2007 in Coding, Work by abdallah

Umm, I needed some way to clean up the files on my Win2K* servers. So here’s a quickie in VB.NET, hope it helps.

[ vb Code ]
  1.  
  2. ‘ Written by Abdallah Deeb on 02-Mar-2007
  3. ‘ Use at your own risk, I am not liable for any damages or lost files if you use this code.
  4. Imports System
  5. Imports System.IO
  6. Module DeleteOld
  7.  
  8.     Sub Main()
  9.         Dim sr As StreamReader
  10.         Dim folderName As String
  11.         Dim files As System.Collections.ObjectModel.ReadOnlyCollection(Of String)
  12.         Dim fileName As String
  13.         Dim fInfo As System.IO.FileInfo
  14.         Dim fCreation As Date
  15.         Dim cfgLine As String()
  16.         Dim numberOfDays As Integer
  17.  
  18.         sr = New StreamReader("c:\DeleteOld.cfg")
  19.         Do
  20.             cfgLine = Split(sr.ReadLine(), "|", 2)
  21.             folderName = cfgLine(0)
  22.             numberOfDays = Int(cfgLine(1))
  23.             files = My.Computer.FileSystem.GetFiles(folderName, _
  24.                         FileIO.SearchOption.SearchAllSubDirectories)
  25.             For Each fileName In files
  26.                 fInfo = My.Computer.FileSystem.GetFileInfo(fileName)
  27.                 fCreation = fInfo.CreationTime
  28.                 If DateDiff(DateInterval.Day, fCreation, Now()) > numberOfDays Then
  29.                     My.Computer.FileSystem.DeleteFile(fileName)
  30.                 End If
  31.             Next
  32.  
  33.         Loop Until folderName Is Nothing
  34.         sr.Close()
  35.  
  36.     End Sub
  37.  
  38. End Module

jqModal Fix

Posted on February 20th, 2007 in Coding by abdallah

The thing I didn’t like in AJAX related stuff was that first I don’t know much Javascript, and second that there was no real way to debug the whole thing. Well, with some practice I think I’ll get to understand JS, especially with jQuery. As for debugging, enter Venkman! You’ll have to get used to it, but it doesn’t take that long to get it working for you.
I needed Venkman last night as I was trying to get the tabs and the jqModal plugins to play nice together. The code is beautiful, maintainable, and small! However, I wasn’t getting what I wanted and it got frustrating since no one seemed to be able to help.
So, after quite a bit of debugging and following the code around jQuery and jqModal (the tabs plugin is simply perfect, for what I need at least!) here was the solution:

[ javascript Code ]
  1. /*
  2. * jqModal - Minimalist Modaling with jQuery
  3. *
  4. * Copyright (c) 2007 Brice Burgess <bhb at iceburg.net>, http://www.iceburg.net
  5. * Licensed under the MIT License:
  6. * http://www.opensource.org/licenses/mit-license.php
  7. *
  8. * $Version: 2007.02.14 +r6
  9. * slightly modified by Abdallah Deeb <abdallah at funinc.org>
  10. */
  11.  
  12. (function($) {
  13. $.fn.jqm=function(o,x,y){
  14. var _o = {
  15. zIndex: 3000,
  16. overlay: 50,
  17. overlayClass: ‘jqmOverlay’,
  18. wrapClass: ‘jqmWrap’,
  19. closeClass: ‘jqmClose’,
  20. trigger: ‘.jqModal’,
  21. ajax: false,
  22. target: false,
  23. autofire: false,
  24. focus: false
  25. };
  26. $.jqm.serial++; s = $.jqm.serial;
  27. hash[s] = {c:$.extend(_o, o),active:false,w:this,o:false,u:$(‘input,select,button’,this)[0]||this[0],cb:[($.isFunction(x))?x:false,($.isFunction(y))?y:false]};
  28. $(_o.trigger).bind("click",{’s’:s},function(e) {
  29.     return (!hash[e.data.s][‘active’])?$.jqm.open(hash[e.data.s],this):false;});
  30. if(_o.autofire) $(_o.trigger).click();
  31. return this;
  32. }
  33. $.fn.jqmClose=function(){var p=this.parent();
  34.     this.hide().insertBefore(p); p.remove(); return this;}
  35. $.jqm = {
  36. open:function(h,trig){
  37.     var h.t=trig;
  38.     var c=h.c; h.cc=‘.’+c.closeClass;
  39.     var z=c.zIndex; if (c.focus) z+=10; if (c.overlay == 0) z-=5;
  40.     if(!$.isFunction(h.q)) h.q=function(){return $.jqm.close(h)};
  41.     h[‘active’]=true;
  42.  
  43.     var f=$(‘<iframe></iframe>’).css({‘z-index’:z-2,opacity:0});
  44.     var o=$(‘<div></div>’).css({‘z-index’:z-1,opacity:c.overlay/100}).addClass(c.overlayClass);
  45.     $([f[0],o[0]]).css({height:$.jqm.pageHeight(),width:‘100%’,position:‘absolute’,left:0,top:0});
  46.  
  47.     if (c.focus) { if($.jqm.x.length == 0) $.jqm.ffunc(‘bind’); $.jqm.x.push(s);
  48.         o=f.add(o[0]).css(‘cursor’,‘wait’);}
  49.     else if (c.overlay > 0){o.bind(‘click’, h.q); o=($.jqm.ie6)?f.add(o[0]):o;}
  50.     else o=($.jqm.ie6)?f.css(‘height’,‘100%’).prependTo(h.w):false;
  51.     if (o) h.o=o.appendTo(‘body’);
  52.  
  53.     h.w.wrap(‘<div class="’+c.wrapClass+‘" id="jqmID’+s+‘" style="z-index:’+z+‘"></div>’);
  54.     if (c.ajax) { var r=c.target; r=(r)?(typeof r == ’string’)?$(r,h.w):$(r):h.w;
  55.         var url=c.ajax; url=(url.substr(0,1) == ‘@’)?$(trig).attr(url.substring(1)):url;
  56.         r.load(url, function() {$(h.cc,h.w).bind(‘click’,h.q);}); }
  57.     else h.w.find(h.cc).bind(‘click’,h.q);
  58.  
  59.     (h.cb[0])?h.cb[0](h):h.w.show(); h.u.focus();
  60.     return false;
  61. },
  62. close:function(h){var h[‘active’] = false;
  63.     $(h.cc,h.w[0]).unbind(‘click’,h.q);
  64.     var x=$.jqm.x; if(x.length != 0) { x.pop();
  65.         if (x.length == 0) $.jqm.ffunc(‘unbind’); }
  66.     (h.cb[1])?h.cb[1](h):h.w.jqmClose(); if(h.o) h.o.remove();
  67.     return false;
  68. },
  69. pageHeight:function(){var d=document.documentElement;
  70.     return Math.max(document.body.scrollHeight,d.offsetHeight,d.clientHeight || 0,window.innerHeight || 0);
  71. },
  72. hash: {},
  73. serial: 0,
  74. x: [],
  75. f:function(e) { var s=$.jqm.x[$.jqm.x.length-1];
  76.     if($(e.target).parents(‘#jqmID’+s).length == 0) { hash[s].u.focus(); return false;} return true;
  77. },
  78. ffunc:function(t) {$()[t]("keypress",$.jqm.f)[t]("keydown",$.jqm.f)[t]("mousedown",$.jqm.f);},
  79. ie6:$.browser.msie && typeof XMLHttpRequest == ‘function’
  80. };
  81. var hash=$.jqm.hash;
  82. })(jQuery);
Next Page »