|
Tips&Tricks
|
|
Wednesday, 22 October 2008 |
|
I love SSH's port mapping features. They're a bit complex to figure out, but they can prove to be very handy. Once, I was updating a friends Fedora installation but I had to head home... He was behind a firewall and so I wouldn't be able to do remote access, even though sshd was running. Port mapping to the rescue! I logged in via SSH to my home machine and mapped his port 22 to a port on my local machine, so when I got home I was able to ssh to localhost and thereby get into his machine! I've come up with my favourite SSH command that combines a few tricks - it goes as follows: ssh -p port -l username hostname.or.ip -L lport:localhost:rport -D proxyport I'll run through it step-by-step: ssh -p port -l username hostname.or.ip
This instructs SSH to connect to hostname.or.ip on port as username. -L lport:localhost:rport
This maps rport on the remote machine to lport on localhost (aka the machine you're currently using). Essentially, connection to port lport on localhost is the same as connecting to the remote host on port rport. It's very useful for mapping services running on the remote machine (such as VNC) to the local machine over a secure channel. -D proxyport
This makes SSH act as a SOCKS 4 proxy on localhost using port proxyport, which is needed for allowing traffic on ports which would otherwise be blocked (ie BitTorrent, FTP, POP, SMTP, etc in places that only allow traffic on port 80)
For example: ssh -p 22 -l me myhost.homelinux.net -L 5905:localhost:5900 -D 5678 This maps the VNC screen :0 on myhost.homelinux.net (port 22, username "me") to the local VNC screen :6, and makes a SOCKS proxy on port 5678. If I connect to localhost:5906, it's the same as connecting to myhost.homelinux.net:5900 except thanks to SSH everything passes through an encrypted channel! |
|
|
Tips&Tricks
|
|
Monday, 18 August 2008 |
|
I've been working a lot on the new fwbackups branch, where my main goal was to make it faster, more versatile and cross-platform. I decided to write it in C++ and use Qt for the interface, since when combined with CMake it would be very easy to have it compiling on all platforms. Stick the code into a git repo and you've got cross-platform building with cross-platform revision control! If you're looking for a way to setup a cross-platform application, I've listed the steps I took below:
Step 1: Install the DependenciesBefore we begin, you'll have to install a few dependencies: Step 2: Create the git repositoryNow that you have Git installed, it's time to create the Git repository which will host your project. Open up a command line and type: - Linux (Applications Menu > System Tools > Terminal), Unix or Mac OS X (Macintosh HD > Applications > Utilities > Terminal):
mkdir -p ~/development/ProjectName cd ~/development/ProjectName git ini Microsoft Windows (Start > Run, type "cmd"): mkdir "My Documents" mkdir "My Documents\development" mkdir "My Documents\development\ProjectName" cd "My Documents\development\ProjectName" git init
This will initialize a git repository called ProjectName inside the "development" folder in your home. You can replace ProjectName with whatever you'd like, but just remember to replace all further instances of it in this tutorial with the same name.
If you'd like to share the project and authorize with other developers to commit to the Git repository, be sure to check out gitosis. Step 3: Directory LayoutWhile it's not required, I chose to use an out-of-source build to help keep the source directories clean and keep the build files for each platform separate. Inside your newly-created ProjectName folder, create the following directory tree: - build/
- pixmaps/
- src/
- translations/
Step 4: Configure CMake The last step is to configure CMake. When CMake is involked, it reads the CMakeLists.txt file and then automatically generates Makefiles for your platform. Use this template CMakeLists.txt file and save it in the ProjectName directory created earlier: # Name of the project project( ProjectName )
# Essentially, just split up your project version numbers by the dot. # These variables map version 0.0.1 of ProjectName. set( VERSION_MAJOR "0" ) set( VERSION_MINOR "0" ) set( VERSION_PATCH "1" )
if( APPLE ) # If we're running OS X, we need CMake 2.6.0 cmake_minimum_required(VERSION 2.6.0) set( CMAKE_OSX_ARCHITECTURES "ppc;i386" ) else( APPLE ) # Otherwise, CMake 2.4.8 is fine cmake_minimum_required( VERSION 2.4.8 ) endif( APPLE )
# This project requires Qt4 and Gettext # If your project does not use Qt or Gettext, simpy remove these lines. find_package( Qt4 REQUIRED ) find_package( Gettext REQUIRED )
# Enable all compiler warnings add_definitions( -Wall )
# Process the "src" subdirectory add_subdirectory(src) If you're using gettext for translations (as many open-source projects do) then all you need to change is the ProjectName at the beginning and the version number. You'll notice that "add_subdirectory(src)" is called, so the next step is to create the CMakeLists.txt in the ProjectName/src directory: # All cpp files go here set(SRC_FILES main.cpp ProjectName.cpp )
# Headers with signal/slot definitions go here # Remove me if not using Qt set(MOC_HDRS ProjectName.h )
# Qt designer interface files go here # Remove me if not using Qt set(UI_FILES interface/ProjectName.ui )
# Qt RC files go here, uncomment if applicable # Remove me if not using Qt #set(RC_FILES ProjectName.qrc)
# Remove me if not using Qt qt4_wrap_ui( UI_HDRS ${UI_FILES} ) qt4_wrap_cpp( MOC_SRCS ${MOC_HDRS} ) # If you're using Qt RC files, uncomment this too #qt4_add_resources( RC_SRC_FILES ${RC_FILES} ) # Includes the standard Qt libraries include( ${QT_USE_FILE} )
# Include your headers in the build and source directories # If you need to include more directories, add them here include_directories( ${ProjectName_BINARY_DIR}/src ${ProjectName_SOURCE_DIR}/src )
if( APPLE ) # Define some settings for the Bundle set( MACOSX_BUNDLE_BUNDLE_NAME ProjectName ) set( MACOSX_BUNDLE_GUI_IDENTIFIER "ProjectName" ) set( MACOSX_BUNDLE_ICON_FILE ProjectName.icns ) set( MACOSX_BUNDLE_INFO_STRING ""${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}", Copyright 2008 ProjectName team" ) set( MACOSX_BUNDLE_SHORT_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}" ) set( MACOSX_BUNDLE_LONG_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" ) set( MACOSX_BUNDLE_BUNDLE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" ) set( MACOSX_BUNDLE_COPYRIGHT "(C) 2005-2008 Stewart Adam" ) # create a bundle with an icon too! # If you're not using Qt, uncomment the next line and comment the line below it: #add_executable( ProjectName MACOSX_BUNDLE ${SRC_FILES} ) add_executable( ProjectName MACOSX_BUNDLE ${SRC_FILES} ${MOC_SRCS} ${RC_SRC_FILES} ${UI_HDRS} ) # Allows for bundle re-creation just by running "make". Also installs bundle icon add_custom_target( osx_bundle_dirs COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/ProjectName.app/Contents/Resources COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/ProjectName.app/Contents/MacOS COMMAND cp ../../../pixmaps/${MACOSX_BUNDLE_ICON_FILE} ${CMAKE_CURRENT_BINARY_DIR}/ProjectName.app/Contents/Resources/${MACOSX_BUNDLE_ICON_FILE} # Qt translations - uncomment this line when you need to install them to the bundle #COMMAND cp *.qm ${CMAKE_CURRENT_BINARY_DIR}/ProjectName.app/Contents/Resources/ ) add_dependencies( ProjectName osx_bundle_dirs ) # This tells cmake where to place files inside the bundle set_source_files_properties( ${ProjectName_RESOURCES} ${ProjectName_TRANSLATIONS} PROPERTIES MACOSX_PACKAGE_LOCATION Resources ) else( NOT APPLE ) # Builds a binary for windows (without cmdline showing), regular for Linux # If you need the cmdline showing, remove the WIN32 attribute # If you're not using Qt, uncomment the next line and comment the line below it: #add_executable( ProjectName WIN32 ${SRC_FILES} ) add_executable( ProjectName WIN32 ${SRC_FILES} ${MOC_SRCS} ${RC_SRC_FILES} ${UI_HDRS} ) endif( APPLE )
# Link Qt to the executable target_link_libraries( ProjectName ${QT_LIBRARIES} )
Step 5: Build the project Now that CMake is configured, you're good to go! To build the project, run: cd ~/development/ProjectName/build/osx cmake . ../../ make
If you'd like to build for Unix or Linux instead of Mac OS X, change the "build/osx" to "build/unix" or "build/linux" respectively. If you're running Windows, you need to reverse the slash direction and add an additional parameter to CMake: cd "My Documents\development\ProjectName\build\mingw" cmake . ..\..\ -G "MinGW Makefiles" make
|
|
|
fwbackups
|
|
Tuesday, 13 May 2008 |
|
First of all I wanted to mention I've registered #fwbackups on irc.freenode.net, so you you have an account feel free to come by and discuss and ideas, feedback or bugs. I've also been learning C++ (slowly) so I'm going to rewrite fwbackups into C++ but keep the interface the same. In other words, you shouldn't notice a thing except it being much, much faster! A friend also recently joined the development team, so hoepfully 1.44 won't take too long and we're planning to release with support for archives, direct copy as well as incremental backups à-la-Time Machine, have a backend plug-in system and have it run naitively in Mac OS X too! |
|
|
fwbackups
|
|
Monday, 03 March 2008 |
|
I've been thinking about the future of fwbackups, and the engines are causing me a bit of trouble. TimeVault is pretty cool and I'd like to implement something similar, but to do that I have to scrap the tar and tar+gz engines. I could also forget the TimeVault-like features for now and implement incremental backups. So, what do you think? I've got a poll running so you can vote for your preferred option on the left. On another note, 1.43.2rc1 will include a 'minimize to system tray' function so that fwbackups can serve as an applet :) |
|
|
fwbackups
|
|
Thursday, 29 November 2007 |
|
Because of time constrains, it's getting tougher to upkeep every one of my open source projects - If you'd like to help out developing one of them, please let me know. |
|
|
Tips&Tricks
|
|
Tuesday, 21 August 2007 |
|
This one's my fault for skipping through the Python docs, but I recently found __getattr__ which is incredibly useful. One of those nifty features I missed from PHP when programming Python was the $$name variables, where I could name a variable based on the content of another or retrieve variables from the string (name) stored in another variable. __getattr__ does just this, and even better - You can call functions or methods with it too! So here's my tip of the day: Both Python and __getattr__ are awesome  |
|
|
fwbackups
|
|
Sunday, 22 July 2007 |
|
fwbackups 1.43.1 is done... It includes a new "follow links" backup option, fixes several bugs present in 1.43.0 and also has a full set of documentation installed to /usr/share/gnome/help/fwbackups. Sorry for the inconvienience, but it turns out automatic backups in 1.43.0 doesn't work at all so if you're using automatic backup, it's a good idea to update to 1.43.1. |
|
|
fwbackups
|
|
Tuesday, 08 May 2007 |
|
This is the first relatively stable release of fwbackups and things seem to work nicely togther overall, so I've taken rev52 as release candidate one. Please let me know about any bugs, suggestions, etc. |
|
|
fwbackups
|
|
Monday, 30 April 2007 |
|
Well, slowly but surely I'm getting to that final fwbackups 1.43.0 release... I noticed import/export stopped working in fwbackups 1.43.0 beta3 this friday, so that's fixed in my local SVN and it'll go into RC1 when I figure I've fixed enough to put it out. The crontab should be in much better sync with sets too, and I've also made tar.gz use tar xfz instead of making a tar then gzip'ing it. I figure I'll go for RC1, RC2, RC3 then gold. I've also being thinking about the future of audio-convert-mod, or rather, the lack of it. It's getting pretty huge to maintain, and internationalizing it is getting troublesome. So, once I finish with fwbackups goodbye to audio-convert-mod and welcome to media-convert... A full pygtk app that handles many formats, and supports videos too :D |
|
|
audio-convert-mod
|
|
Thursday, 12 April 2007 |
What's the relation you might ask? One's a program offered in schools and the other is my audio conversion script... Well, I'll keep it short and sweet. The program is great, but the evaluations they make us write for about half our assignments take FOREVER. So I don't have much time to update my code anymore :/ Oh, and while I'm on the topic of IBO, I doubt anyone in IBO reads this regularly, but somebody I know was very suprised to hear they didn't give us the detailed evaluation rubrics for our Personal Project next year. Gladfully, he gave me a copy and also said I should give it to people I know! Ask me at school for the password and then you can download it. I've started working on a new audio-convert-mod, one that's rewritten in PyGTK and that doesn't only do audio - This one can do videos too! You can see the UI design I've made so far here. For now, let's just say it's "coming soon" though :D |
|
|
livna
|
|
Sunday, 25 March 2007 |
|
The devel branch of xorg-x11-drv-fglrx has just been duplicated over into FC-6, so the new FC-6 package using livna-config-display for all the file editing and configuration! This means it's generally faster, easier to use and now has many more features like automatic disabling of Composite and AIGLX in xorg.conf so DRI works out-of-the-box. Enjoy! |
|
|