August 2011
2 posts
1 tag
Backbonejs tutorials
http://andyet.net/blog/2010/oct/29/building-a-single-page-app-with-backbonejs-undersc/
Aug 21st
2 notes
1 tag
SQL Injection Pocket Reference
SQL Injection Cheat Sheet) 1.   MySQL a.   Default Databases b.   Comment Out Query c.   Testing Injection                                          i.    Strings                                         ii.    Numeric                                       iii.    In a login d.   Testing Version e.   MySQL-specific code f.    Database Credentials g.   Database Names h.   Tables &...
Aug 12th
3 notes
June 2011
5 posts
2 tags
PHP: Database Abstraction
interface DataBaseManager{ public function connect(); public function shutdown(); } class DatabaseCommon{ public function common_function_call(){ print "Function common to mySql and Oracle ..."; } } class mySql extends DatabaseCommon implements DataBaseManager{ public function connect(){ print "Connection mySql is establish ..."; } public function shutdown(){ print "Connection to...
Jun 28th
3 tags
PHP: Singleton
Some application resources are exclusive in that there is one and only one of this type of resource. For example, the connection to a database through the database handle is exclusive. You want to share the database handle in an application because it’s an overhead to keep opening and closing connections, particularly during a single page fetch. /* * Singleton */ Class DBconnection...
Jun 28th
15 notes
1 tag
jQuery: How to check if the javascript function...
To check if the javascript function is exist, we can check using typeof(). See example below: jQuery(document).ready(function() { if(typeof $(".change-password").fancybox == 'function') { $('.change-password').fancybox({ 'width' : '60%', 'height' : 400, 'transitionIn' : 'fade', 'autoScale' : false, 'transitionOut' : 'fade', 'scrolling' : 'no', 'type' : 'iframe', 'href'...
Jun 9th
2 tags
Fraction of Facebook source code (home.php)
include_once $_SERVER['PHP_ROOT'].'/html/init.php'; include_once $_SERVER['PHP_ROOT'].'/lib/home.php'; include_once $_SERVER['PHP_ROOT'].'/lib/requests.php'; include_once $_SERVER['PHP_ROOT'].'/lib/feed/newsfeed.php'; include_once $_SERVER['PHP_ROOT'].'/lib/poke.php'; include_once $_SERVER['PHP_ROOT'].'/lib/share.php'; include_once $_SERVER['PHP_ROOT'].'/html/init.php'; include_once...
Jun 2nd
2 notes
2 tags
How to install PHP5 and Apache on Ubuntu
How to install PHP5 and Apache on Ubuntu In your command shell, you will run the following commands: $ sudo apt-get install apache2 $ sudo apt-get install php5 $ sudo /etc/init.d/apache2 restart Thats all. In case, you encountered an error like this “Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName..” after restarting the Apache...
Jun 2nd
1 note
May 2011
6 posts
1 tag
Install memcached in ubuntu
Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering. Memcached is simple yet powerful. Its simple design promotes quick deployment, ease of development, and solves many problems facing large data caches. Its API is available for most popular languages. To install memcached type this...
May 18th
5 notes
3 tags
Installing and using memcache on ubuntu and debian
To install memcached, simply run the following command: sudo apt-get install memcached Once it’s installed, edit /etc/memcached.conf and change the line beginning ‘-m’ which is the amount of memory (in megabytes) to allocate to the server. You can also change the IP address that the server listens on  in the line beginning -l. Now restart the daemon by running /etc/init.d/memcached restart To...
May 12th
1 tag
Linux commands
#To check the running process: #netstat - Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships netstat -tap top - display top CPU processes vi (aka vim) tutorial, tips, tricks and useful commands Where grep came from (RE being Regular Expression): :g/RE/p #Delete lines 10 to 20 inclusive: :10,20d #or with marks a and...
May 12th
1 tag
Memcache vs Memcached
If you are confused between memcache and memcached: check the link below: http://serverfault.com/questions/63383/memcache-vs-memcached
May 11th
1 tag
Install PHP Memcache extension
Download the correct build here. The archive should contain php_memcache.dll. Extract the archive to your php extensions directory. On my system (i use XAMPP), this was C:\xampp\php\ext\ Edit php.ini, add this line to enable the extension: extension=php_memcache.dll Finally restart your server. To test your memcache installation run this piece of code in your machine: $memcache = new...
May 11th
6 notes
1 tag
Install memcached
Download the Memcached Win32 library here: http://code.jellycan.com/memcached. Just get the Win32 binary (direct link). Extract the downloaded archive file in a directory (e.g. c:\memcached). There should be a memcached.exe in there. Run a command prompt as an administrator. Some info on how to do that here. Install memcached as a service. Go to the memcached directory, type and...
May 11th
7 notes
April 2011
1 post
1 tag
Symfony: Short way in getting all users in widget
$this->setWidgets( array('sf_guard_user_id' => new sfWidgetFormDoctrineChoice(array('model' => 'sfGuardUser', 'add_empty' => true))) ); $this->setValidators( array('sf_guard_user_id' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => 'sfGuardUser', 'column' => 'id'))) ); Here we set the key as model with a value of sfGuardUser, it will return...
Apr 5th
8 notes
January 2011
1 post
1 tag
Symfony: Saving sfGuardUser and link it to User...
$guarduser = new sfGuardUser(); $guarduser->setUsername($username); $guarduser->setIsActive(1); $guarduser->setPassword($password); $guarduser->save(); $user = new User(); $user->sf_guard_user_id = $guarduser->id; $user->name = $name; $user->surname = $surname; $user->country_id = $country; $user->save();
Jan 16th
December 2010
1 post
1 tag
Symfony: Generate a URL
Two ways to generate a URL in your sf_Actions and don’t escape the & symbol 1. $this->rehearsalUrl = $this->getController()->genUrl("rehearsal/treepopup?studyunit_id={$this->studyunitId}&source_id={$this->source_id}&subject_id={$this->subject_id}"); 2. $subject_cached = $this->generateUrl('subject_cached', array('id' => $subject_id, 'user_id' =>...
Dec 7th
June 2010
1 post
1 tag
Symfony: Get current logged in User
3 different ways to get the current login user 1 $this->getUser()->getGuardUser()->getId(); 2 sfContext::getInstance()->getUser()->getGuardUser()->getId(); 3 $this->getContext()->getUser()->getAttribute('user_id','','sfGuardSecurityUser'); // To get current user id $user = sfContext::getInstance()->getUser(); $user = $user->getAttribute('User', null, 'User'); //...
Jun 1st
May 2010
1 post
Symfony / Doctrine – update a record using models
The Doctrine manual is really, really confusing in places. If you want to do something as simple as updating a record, the examples suggest that you use Doctrine_Query::create(). This doesn’t make a lot of sense, because we only want to manipulate the model, we shouldn’t have to even look at a query. Assuming you have the primary id of the record in question, you can do the following to...
May 26th
December 2009
1 post
PHP: self vs this
class Person { private $name; public function __construct($name) { $this->name = $name; } public function getName() { return $this->name; } public function getTitle() { return $this->getName()." the person"; } public function sayHello() { echo "Hello, I'm ".$this->getTitle()."<br>"; } public function sayGoodbye() { echo "Goodbye from...
Dec 1st
September 2009
1 post
“it works on my machine”
– World’s most famous Programmer excuse
Sep 13th
August 2009
1 post
Ruby on Rails Application Development
Ruby on Rails has grown enormously due to its following benefits: It follows Agile Software Development cycle It is consistent & simple; and supports Perl and Python. It uses the Model-View-Controller (MVC) architecture pattern to organize application programming. It provides scaffolding which can automatically construct some of the models needed for a basic website. Includes advanced...
Aug 16th
June 2009
1 post
A Rails/Django Comparison Abstract Ruby on Rails (“Rails”) is the dominant web programming framework for Ruby and, even outside the Ruby community, is considered the epitome of the latest generation of high-productivity, open source web development tools. Django is one of many competing web development frameworks for Python. It is notable, first, for being highly regarded amongst...
Jun 2nd
May 2009
1 post
welcome to my tumblrrROR
Meooww…welcome to my tumblrrROR.. -nerdy cat
May 24th