Error whil creating super user in django1.4 on MAC

I got the following error while trying to create a super user from shell for django1.4.

File "/Library/Python/2.7/site-packages/django/contrib/auth/management/__init__.py", line 85, in get_system_username
    return getpass.getuser().decode(locale.getdefaultlocale()[1])
TypeError: decode() argument 1 must be string, not None

This problem was rectified by running this command in terminal before adding the user
export LANG="en_US.UTF-8"

I’m guessing this character encoding problem while running syncdb is the reason for the following error while accessing admin section of django1.4

DoesNotExist at /admin/
Site matching query does not exist.
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.4
Exception Type: DoesNotExist
Exception Value:
Site matching query does not exist.
Exception Location: /Library/Python/2.7/site-
packages/Django-1.4-py2.7.egg/django/db/models/query.py in get, line
366
Python Executable: /usr/bin/python
Python Version: 2.7.1
Python Path:
['/Users/mohammedelsebaey/a/mysite1',
'/Library/Python/2.7/site-packages/Django-1.4-py2.7.egg',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/
python27.zip',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7
/plat-darwin',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7
/plat-mac',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7
/plat-mac/lib-scriptpackages',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/
python',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7
/lib-tk',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7
/lib-old',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7
/lib-dynload',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/
python/PyObjC',
'/Library/Python/2.7/site-packages']

If i’m wrong you can solve the above problem by running this code i django shell

from django.contrib.sites.models import Site
Site.objects.create(pk=1)
Posted in Django, PYTHON | Tagged , | Leave a comment

How to start stop apache on MAC OSX

start Apache
apachectl start
Stop Apache
apachectl stop
Restart Apache
apachectl restart

If the above commands don’t work, try these

/etc/init.d/httpd start
/etc/init.d/httpd stop
/etc/init.d/httpd restart

You can also start the web server from the system preferences. Open system preferences, go to sharing and then enable web sharing

starting webserver in mac osx

starting webserver in mac osx

Posted in Apache | Tagged | Leave a comment

Where is httpd.conf file in Mac OSX Lion

On mac httpd.conf file is located in the directory /etc/apache2/. You can access it through terminal if you want to navigate to it through finder, on finder toolbar goto go->go to folder and type in /etc/apache2

Open hidden folders in mac osx

Navigate to hidden folders in MAC


Navigating to system files on MAC OSX

Navigating to system files on MAC OSX

Posted in OSX, Web Development | Tagged , , | Leave a comment

Make command not found in Mac OSX

If you get a -bash: make: command not found error while trying to compile from source, you have to install xcode and then in xcode goto preferences->downloads and install xcode developer tools

installing command line tools on MAC OSX

installing command line tools on MAC OSX



Download Xcode

I’m not sure if you can install command lines without xcode. I can not test as I already have Xcode on my system you can download command line tools here

Posted in Coding, OSX | Tagged , , , | Leave a comment

When mobile browsers don’t respect CSS3 media queries

If mobile browsers are not respecting your media queries and showing desktop instead of mobile site, add this meta tag before linking the style sheet.

<meta name="viewport" content="width=device-width">

Posted in Web Development | Tagged , , | Leave a comment

A thing is not high if one can reach it; it is not great if one can reason about it; it is not deep if one can see the bottom of it.

-Fountain Head

Posted in Quotes | Leave a comment

Trying cakePHP, lets see how it goes.

My growing list of direct AD sales was becoming hard to manage, dealing with direct AD sales was taking more time than it should actually take. It’s not streamlined. I lost AD revenue several times because I was too lazy to mail the advertisers about the renewal of their adspace.

I always wanted to automate the AD sales process, but I was busy with something or the other. Now that I got some free time to explore new stuff, I decided to take up this project.

Goals of the project

  • Maintain a list of advertisers and the AD space they bought.
  • Automatically send reminders to advertisers about renewals.
  • If they fail to renew, notify me, so that I can take down the AD.
  • A web interface where I can add details about the newly bought ads to the DB and make changes to previously bought ADS.
  • *Update the DB automatically when a payment is made through PayPal.
  • *Setup a AD server, which will let me control AD’s on all the sites without from a single location.

I’m going to implement this project using cakePHP, I hope cakePHP is the right choice.

 

Posted in CakePHP, PHP | Tagged , , , | Leave a comment

Subtracting two dimensional arrays in PHP

In the development a WordPress plugin I had to subtract two dimensional arrays. I tried array_diff() function, unfortunately it doesn’t seem to work for two dimensional arrays. Even if it worked, it wasn’t exactly the functionality I wanted.

Be warned, this isn’t exactly a alternate for array_diff(). For difference of two dimensional arrays you may try this (I dint try it)

I had these two arrays, which I had to subtract.

Array (
 [thumbnail] => Array ( [width] => 150 [height] => 150 [crop] => 1 )
 [medium] => Array ( [width] => 300 [height] => 300 [crop] => )
 [large] => Array ( [width] => 1024 [height] => 1024 [crop] => )
 [full-post-thumb] => Array ( [width] => 576 [height] => 150 [crop] => 1 )
 [popular-posts-home] => Array ( [width] => 210 [height] => 90 [crop] => 1 )
 [popular-posts-widget] => Array ( [width] => 32 [height] => 32 [crop] => 1 )
 [mag1] => Array ( [width] => 170 [height] => 0 [crop] => 1 )
 [mag2] => Array ( [width] => 284 [height] => 0 [crop] => 1 )
 [blog-thumb] => Array ( [width] => 135 [height] => 90 [crop] => 1 )
 [slider1] => Array ( [width] => 250 [height] => 130 [crop] => 1 )
 [slider2] => Array ( [width] => 576 [height] => 280 [crop] => 1 )
)

Array (
 [full-post-thumb] => Array ( [width] => 576 [height] => 150 [crop] => 1 )
 [popular-posts-home] => Array ( [width] => 210 [height] => 90 [crop] => 1 )
 [popular-posts-widget] => Array ( [width] => 32 [height] => 32 [crop] => 1 )
 [mag1] => Array ( [width] => 170 [height] => 0 [crop] => 1 )
 [mag2] => Array ( [width] => 284 [height] => 0 [crop] => 1 )
 [blog-thumb] => Array ( [width] => 135 [height] => 90 [crop] => 1 )
 [slider1] => Array ( [width] => 250 [height] => 130 [crop] => 1 )
 [slider2] => Array ( [width] => 576 [height] => 280 [crop] => 1 )
)

The result I wanted was this, but array_diff() returned null.

Array (
 [thumbnail] => Array ( [width] => 150 [height] => 150 [crop] => 1 )
 [medium] => Array ( [width] => 300 [height] => 300 [crop] => )
 [large] => Array ( [width] => 1024 [height] => 1024 [crop] => )
)

So, I used array_keys() function to get the keys of the second array, and ran a foreach loop on the value returned by array_keys, and unset the elements of first array


$key_names= array_keys ( $array2 );
foreach( $key_names as $key ){
unset($array2[$key]);
}
Posted in Coding, PHP | Tagged , , | Leave a comment

Compiling a list of resources and preaparing a plan for iOS app development

I tried web design, blogging, WordPress theme development, played with adsesne and lot of other stuff, every time half way through what I was doing I found some blog posts saying “Things you should know before doing  xxxxxx”, “common mistakes done by firs timers doing xxxx” . I always wished I found those posts before i did the mistakes said in those posts or before starting what I was doing.

This time I don’t want to say that to myself again. So, before I jump into the development, I’m gonna have a plan for how I’m gonna do it and do some research before I start doing anything.

Today I spent some time compiling a list of resources to get started with, undoubtedly Apple iOS DEV center seems to be the best place to get started, here are few other useful links

Getting Started

Resources

After going through the above resources, One thing common in all of them is “Learn Objective C”. I’m onto it, will keep you posted on how it goes.

Posted in iOS Development, M-1812241 | Leave a comment

Mission 1812241

The last five days have been pretty boring for me, been sleeping all day. No major accomplishments and work done. And, today is a very bad one for me, saw her online. I know what she did and I know she doesn’t deserve it,but still the site and thought of her disturbs me. I don’t know what this feeling is, but i want to get over it.

This mission is an attempt to get over her, the main objectives of this mission are

  • To develop an iOS application
  • Prepare for NID entrance.
  • Redesign of member profile pages on TechBU
  • Improve my vocabulary.

Deadline for this misison is April 3rd, that is 105 days from now. I will keep you posted on the progress and the resources i stumble across during this mission.

Posted in M-1812241 | Leave a comment