How to make svn ignore file and folders on update and commit

When we work on Production and Development environment separately on subversion, many times we need to keep a file outside of the SVN versioning. Usually conf files come under this category.

A simple method of this is to navigate to the repositry and simply issue command so that svn ignore file in that folder.

 

[php]<br /> svn propset svn:ignore -F filename .<br /> [/php]

Don’t forget to include the last “.” it tells the svn client to set this property in the current folder you are working on.

For exluding multiple files of the same

Revert files to older svn version

A lot of times developers do one or other mistakes and you need to revert the files to older version. Which basically mean that you need to merge backwards with a older version of files. So let’s say if you want to go back from version 100 to 99, you’ve to


svn update
svn merge -r 100:99 .
svn commit -m "Rolling back to version 99"

Notice the . at end of svn merge command, this tells that current directory needs to be merged if you need a particular file to be merged you need to issue


svn merge -r 100:99 conf.php
svn commit -m "Rolling back conf.php to version 99"

Hope this helps someone.

Restricting folders for svn access

While working with several developers at the same time, you really need a method to make sure that each team doesn’t mess up with someone else module. Splitting directories of each user is a nice idea when your developers are not that diciplined or when you are running multiple sites of same repository.

I faced a similar problem when i wanted to restrict access to 2 of my developers from editing anything above directories i allocated. For this

Go to your conf directory this would be located inside your main configuration directory.

#cd conf

Fire up your favorite editor, mine is nano

#nano authz

And put a access control to directory

[/repo/project/folder]
usera = rw
userb = r

Say if you have multiple repositry in svn server, restrict access to a particular repositry by

[repo1:/repo/project/folder]
usera = rw
userb = r

I think this should help.

Google Plus API

Google is rolling out API very soon for developers to take a sneak peak and develop applications. In the meantime developers can sign up at https://services.google.com/fb/forms/plusdevelopers/ to get a early access onto the Google plus API.

Eventually, google plus is playing a invite only for brands and developers too after a successful stunt with social networking users all around the world. Brands can sign up here http://goo.gl/zq95C to be the first to get listed as business on Google+.

ERROR: While executing gem (Gem::RemoteSourceException) HTTP Response 302 fetching

While struggling with old gems and ruby installation on my macosx. I googled a lot for response and find no satisfactory answer.

The problem was simple, macosx 10.5 comes with ruby 1.8.1 and rails 1.2.6 which is now a depreciated version of ROR and not recommended to be used for production.

Now since gems have moved there base, every gem install command was throwing a 302 HTTP error.

$ sudo gem install rails
ERROR:  While executing gem ... (Gem::RemoteSourceException)
    HTTP Response 302 fetching http://gems.rubyforge.org/yaml

Even the most suggested resolution which is a gem update didn’t work.

gaurav-mishras-macbook:rubygems-1.8.5 gaurav$ sudo gem update --system
Updating RubyGems...
ERROR:  While executing gem ... (Gem::RemoteSourceException)
    HTTP Response 302 fetching http://gems.rubyforge.org/yaml

Then luckily a landed to a blog post which mentioned a similar problem and changing the source of the gem repositry worked like charm. Just add –source http://production.s3.rubygems.org

For example

gaurav-mishras-macbook:rubygems-1.8.5 gaurav$ sudo gem update --system --source http://production.s3.rubygems.org
Updating RubyGems...

2 regular expression code snippets a developer needs daily

Regular expression can be easily called the heart of data mining technology. For beginners it may look like a very hard thing to grasp, But actually it’s pretty simple and compact once it’s been learned.

I have listed some pretty basic regular expressions here , Which can help in mining nearly 70% of the text available on the web.

1) Validate username, consist of alpha-numeric (a-z, A-Z, 0-9), underscores, and has minimum 5 character and maximum 20 character. You could change the minimum character and maximum character to any number you like.

$username = "user_name12";
if (preg_match('/^[a-zd_]{5,20}$/i', $username)) {
    echo "Your username is ok.";
} else {
    echo "Wrong username format.";
}

2) Need to highlight repeating words in the text, This regex can become very handy.

$text = "This is a sample test written by Gaurav Mishra This is a sample test written by Gaurav Mishra This is a sample test written by Gaurav Mishra This is a sample test written by Gaurav Mishra This is a sample test written by Gaurav Mishra"; 
$text = preg_replace("/b(Gaurav)b/i", '<span style="background:#5fc9f6">1</span>', $text);
echo $text;

3)

2 most common php url functions for daily use

Seldom every php developer need some php url functions to work with , usually while parsing a web portal or finding the links url functions come very handy.

Here are URL based functionalities a developer may need .

1) Get the url of the portal:-


echo $_SERVER('HTTP_HOST');

2) Parse the url for extracting all components:-


$url_demo = 'http://user:pass@host/path?arg=val';

print_r(parse_url($url_demo));

Hope these handy code snippets would help you to save time for URL formatting in PHP.

Google Plus Circles

Update:- Google launched the google circle social network as Google plus. API is still awaited. Updates will be coming as the API gets launched.

Google is launching there new social networking service “Google Circles”, this is rumored to offer photo sharing, video sharing and updates. Which can be tightly linked to other social networks and circles. This news was broken by Read Write web today from #sxsw.

We wonder where buzz will fit into this and since this will be google product we are very excited to see what API details it will offer. We promise our readers to update with every bit of details, when there API announcement comes out.

Twitter bot tutorial

Twitter is heavily becoming a source of traffic and with there extremely powerful api , it’s very easy to automate stuff via Twitter bots.

Today i am going to show you a tutorial for very simple but yet very powerful bot which if used effectively can drive great traffic on sites. These bots simply search twitter stream for predefined keywords and tweet target messages to the tweeters. These bots can be set via cron to read stream every few minutes and make responses in real time.

For newbies and starters all Twitter API documentation can be found here , From here we are going to use Search API methods and Status Update REST api method for sending predefined tweets to the users.
Continue reading Twitter bot tutorial