Thursday, November 6, 2008

Load different application based on ip address in CI(CodeIgniter)

You can modify the default index.php that comes with codeigniter to load a different application based on ip address. Why would I want to do that? You ask. Well, this would allow you to host the main application on a single internal server. While allowing your other servers that face client application. What this means is that you can create the meat of multiple different sites/domain and host them on the one. Then you can access this internal server from the childs and they will display data to the clients. Basically you would create a domain/site, host one file on it to get site based on domain and other options and display it to client. You can also create some basic caching capability.

Add this basic code in your index.php file:

if($_SERVER["REMOTE_ADDR"]=="192.168.1.5")
$application_folder = "app";
else
$application_folder = "application";
Of course you could create an array and setup multiple domains with the index.php file that receives the site and sends it to the client. Everything would go thru the uri string and you can implement a highly encrypted string and licensing to the internal server with all apps on it. Then just make sure that same index.php file is on all supported domains. :)

Templated Modulated CMS


GOOGLE IT!

#1

Templated Modulated CMS


BACK IN BUSINESS(CMS project is resuming)


This PHP project partly taking place on codeigniter forum(I need to update my current public code in forum). This project utilizes CodeIgniter, ModularExtensions, Smarty Template System and CodeIgniter Views give you much power in accessing and passing/placing data. Custom Smarty Functions, Custom Modules. Template Management(Public Online Project is not current with my Client Templates). There are still alot more things I can do to compliment the Project Online. Documentation/User Guide, Examples, Public CODE still need update. Looking To GET PAID to write a complete Templated Modulated CMS for YOU. Possible to turn into eCommerce Application with little work of adding features. I started using Code Igniter for fun, in year 2005.Possible to make multiple domains/sites access single primary domain for multiple sites(done in background), also utilize cache. There alot of options in how you can utilize this project in your business/project needs. With some custom coding you can make random or default template showup. It's easy to take any Free Template Online and Split it up in to this CodeIgniter Application smarty/ci views.






sample _template_theme function which loads css and/or js data from db or file system(based on config)

tmcms has support for custom built modules

Allows you to mix Smarty and PHP syntax together in template views stored in db or filesystem

Dynamic Server Configuration

Module Method Mapping, This function maps all uri variables to appropriate modules and methods

A Simple Content Template

Basic Template Theme Function

Loading Template / Themes From FileSystem

Multi-Language Support - Store Language Variable in flat Files or Database

Custom Smarty Functions

generic views that loads all parsed smarty code

Tuesday, November 4, 2008

gconf-editor

gconf-editor: like regedit for gnome, open it from terminal by typing gconf-editor I wasn't able to find a clickable item from menu to get this. Not that you can't add it. Yeah this is some real basic stuff isn't it? Well who cares. I didn't know about it before. I came from a KDE/Slackware background to Gnome/Ubuntu. Change is good.

Enable horizontal scroll for mouse pad:
/desktop/gnome/peripherals/mouse/pad_horiz_scroll

gedit as a powerful web development tool

All I have to say is WOW. I wish I knew this earlier. I was messing around with gedit's external tools and came to a stump when trying to configure external tools to do svn commit for me. What did I do? I googled about it and found this great article on configuring gedit for development. Now I can use this tool more effectively than what I have been using(kwrite,kate,stock gedit configuration and screem). I have to say that gedit is by far the best one. Plus you can create python plugins to run inside of it. I think my dreams have just come true. :) Now that I think about it. About the only thing gedit can't do is cook, clean and drive my car. Who knows maybe one day it will. Ah, whatever. You should read this great article though. It can make development on linux with less headaches. Dreamweaver? whats that?

You can find the article here:
micahcarrick.com/09-29-2007/gedit-html-editor.html


This is my external tool I came up with to do svn commit from gedit. Currently you need to type the file to commit or a . (dot) to commit whole directory. Maybe someone knows how to fix this mistake. But it works for now so I have to stick with it until I fix it. Yay, now I can commit from gedit. :) The file is below. You can place this file in ~.gnome2/gedit/tools/ and use it as an extenal tool or in gedit goto tools->external tools and type it in manually, minus comments after shebang.

file: svn-commit

#!/bin/sh
# [Gedit Tool]
# Comment=svn commit
# Name=svn commit
# Shortcut=F11
# Applicability=all
# Output=output-panel
# Input=document

svn ci -m exec `zenity --entry --title="Commit" --text="Enter Commit Message"`


EDIT:
Okay, I fixed it after looking at the commit log. Use this one below and not the one above since it's the new updated version that allows you to commit changes to svn repository from gedit. I don't know why I had to say that. But there you go. Notice the dot on the end. Although, you may want to change it to commit a single file instead of the cwd. If so then you can use $GEDIT_CURRENT_DOCUMENT_PATH instead. Just as a note for all my readers. I use my blog posts as a reminder for me for how I did certain things so that I don't have to re-google and re-research my finding again.



#!/bin/sh

svn ci -m "`zenity --entry --title="Commit" --text="Enter Commit Message"`" .



you might also want this as well:



#!/bin/sh

svn add $GEDIT_CURRENT_DOCUMENT_PATH



It's also not very hard to run python from external tools as well. See example below:



#!/bin/sh

python -c "
import os
os.system('ifconfig')
"


After having learned this about gedit. I have a feeling that I'm going to dwell on it alot more and come up with some plugins hopefully. That depends on how swamped I am with everything else though. Look for plugins in the near future. Hopefully one that can cook and clean. hehehe, jk. :)

Monday, November 3, 2008

.vimrc for python and php editing

Here is my .vimrc that I use for editing python scripts. I mostly use nano, but slowly I'm switching to vim. Anyway, here tis.


syntax enable
filetype indent on
set background=dark
set number
set tabstop=4
set textwidth=0
set nowrap
set et
set sw=4
set smarttab
set scrolljump=5
set showmode
set showmatch
map :w\|!python % #press F2 to run script
map :w:!svn commit #press CTRL-C to commit changes


It's still a work in progress. Seeing as I'm just getting in the swing of things vim. If you want a vim cheat sheet you can find it HERE

If you want to have a vimrc file for PHP Editing Click HERE

Enjoy!

svn update every 15 seconds

There's alot of different ways to go about doing this. update svn repo on a timed basis. You can create a small script (1), add it to cron to run every minute or you can just run the script with an infinite loop with sleep 15. (2)

(1) create a new file and call it svn_update.sh
put this inside of the script(I know it clunky, but it works):

#!/bin/sh
svn update $1
sleep 15
svn update $1
sleep 15
svn update $1
sleep 15
svn update $1
sleep 15

Now create a cron to run this script every minute, add this to /etc/crontab:

* * * * * root /dir/to/svn_update.sh /var/www/some_project



That is one way. But that way you have a cron running every minute executing this script when you may not need it, Plus this actually is not 15 seconds really. It turns out to be more like 30 or 45 seconds. Depending on your environment.

(2)This is another way:

Create a file named svn_update.sh and put this in it:

#!/bin/sh
while true;do date && svn update $1 && sleep 15;done


Now when you need to work on your project just start this script and it will update your project directory for you every 16 seconds.

You can run this script in the background like this:

/dir/to/svn_update.sh /var/www/my_big_project_1 &

Like I said there's alot of different way to achieve this and results may vary. That really goes for anything in this world though. Enjoy. Back to my book translation project I go. :)

Oh yeah, make sure to make this script executable.

chmod +x /dir/to/svn_update.sh

You can insert >/dev/null in there somewhere if you don't want verbose output. I like verbose, but it gets annoying sometimes.

egenix python modules

This command will install all egenix python modules on ubuntu for you.

quoted from egenix website:
"eGenix™ is a leading provider of Python-based development tools, products and consulting services.

Our products cover many different application spaces, including database interfacing, fast text processing, and simplifying many everyday tasks in Python, Zope and Plone programming."

sudo apt-get install `apt-cache search egenix|awk '{ print $1 }'|xargs`

Sunday, November 2, 2008

Ubuntu 8.10 Released

New Ubuntu 8.10 has been released.
ubuntu.com
Downloading and installing in vmware server I am.

Here are some good links on python programming, if anyone is interested in this kinda stuff.
techbooksforfree.com/linux.shtml
openbookproject.net
gnosis.cx/TPiP/
www.awaretek.com/tutorials.html
cbel.com/python_programming_language/
They are sites I've been hanging out at lately.