Updates from April, 2012 Toggle Comment Threads | Keyboard Shortcuts

  • Shafiul Azam 12:51 am on April 30, 2012 Permalink | Reply
    Tags: collaboration, , merging   

    Collaborating using git: make merging less painful! 

    Hi, I’m Shafiul! Me along with Ibrahim & Sifat are working in a project which we maintain using git. We’ve decided to follow a simple protocol to merge our works effeciently in a painless way!

    All of us will work in our own branches (learn first about branching if you’re not familiar with it). At the end of the day, the one who finishes his work after the rest of the team, should merge all of our works!

    Say, after working all day long, I figured out Ibrahim was still working before I went to bed. So it became Ibrahim’s due responsibility to merge everyone’s work :)

    The first step is: create a new branch for you, where only you will work, and no one else will touch.

    Create a new Branch named “shafiul”:

    git branch shafiul

    To work in this branch, I need to check-out to work in this branch:

    git checkout shafiul

    While working, Commit any time:

    git add -A
    git commit -m "Message"

    When you’re done, push your commits to the server:

    git push origin shafiul:shafiul

    Note the command: It pushes your commits made in local “shafiul” branch to origin’s (server’s) “shafiul” branch.

    Like me, Ibrahim & Sifat has also crated their own branches named “ibrahim” & “sifat” and they’re working in their branches.


    Merging everybody’s work

    The one who will be merging has to do followings:
    First, download everyone’s commits from origin (server) to his local machine:

    git fetch origin shafiul:shafiul
    git fetch origin ibrahim:ibrahim
    git fetch origin sifat:sifat

    Now time to merge. Check-out to master branch. With this branch, we will merge all other branches.

    git checkout master

    Now merge all other branches with master:

    git merge shafiul
    git merge ibrahim
    git merge sifat

    Cool! master is now merged with everyones code (Congratulations if no conflicts has occurred. But don’t get panicked if conflicts occur, to learn how to resolve conflicts, see the end of this article) – now Push your local “master” to origin (server):

    git push origin master:master

    Everyone’s duty: Update your branches…

    The next day, before working, everyone should update their branches. First, everyone needs to pull updated “master” branch from origin (server) and merge it with your local copy of master branch:

    git checkout master
    git pull origin master:master

    Now your local copy of master branch is updated. Finally, checkout to your own branch and merge it with updated master:

    git checkout shafiul
    git merge master

     
  • Shafiul Azam 6:40 pm on February 15, 2012 Permalink | Reply
    Tags: android, code, source, sourcecode, the new boston, thenewboston   

    Source code of Android Tutorials from The New Boston 

    :)

    Get sources of tutorials of individual videos

    I’m  just learning android from the awesome tutorials made by Travis (available for FREE at here) and decided to code them in hand. Just pushing them to this repo if anyone needs them.

    One interesting point, I’ll make a commit after every tutorial! So you can browse the snapsot of each tutorial by selecting a commit from my Github

    Cool, huh? (The initial commit begins with Tutorial 10, though).

     
  • Shafiul Azam 1:10 pm on November 17, 2010 Permalink | Reply
    Tags: python equivalent for mysql_insert_id   

    Python MySQLdb equivalent for PHP’s mysql_insert_id() 

    What you’re looking for is lastrowid property of a cursor object.

    Code:

    import MySQLdb # MySQLdb module must be installed on the system
    connection = MySQLdb.connect(...) # Details skipped
    cursor = connection.cursor()
    query = "INSERT INTO ... " # put query here
    cursor.execute(query)
    print cursor.lastrowid # BINGO! This will print the id (auto-increment column) of the last inserted row
    # Other codes here
    

    Thanks to this article on the Internet

     
    • philihp 10:31 pm on February 12, 2012 Permalink | Reply

      I’m glad it was useful for someone :)

      • Shafiul Azam 11:46 pm on February 12, 2012 Permalink | Reply

        Haha…. lol :P

  • Shafiul Azam 10:06 pm on April 4, 2010 Permalink | Reply
    Tags: drupal enable php in blog post, drupal enable php in content, drupal how to enable php in blog, dupal how to enable php code, execute php in drupal blog, how to write php code in drupal blog, php code in drupal post, run php code in drupal posts   

    Drupal: Write & Execute PHP code in blog post/forum content entry 

    This is a short but efficient trick that I found after making some stupid search queries :( In Drupal 6 & higher, you can type & execute PHP codes in your blog posts/ other contents. To do so, First enable the PHP Filter module from your Adminstration > Modules section:

    (drupal-path/admin/build/modules)
    
    php filter module

    Enabling the PHP Filter module

    Next, you can configure who must have access to execute PHP in their content. To grant only trusted users this permission, go to the Input Formats section (available under Administer » Site configuration)

    (drupal-path/admin/settings/filters)

    Next, click on “configure” link next to the php code box.

    How to write php in your posts

    When creating a new blog/other entry, click on the “Input Format” just below the text editor. From the available options, select php code. See the screenshot below:

    php in drupal

    Hope this will be helpful!

     
  • Shafiul Azam 11:44 am on March 30, 2010 Permalink | Reply
    Tags: automatically shorten my web site link, easy method to use bit.ly, how to dynamically shorten my links, how to short any link of my site, how to shorten a dynamic link of my site, how to shorten my links by javascript, how to shorten my website easily, how to use bit.ly by ajax, how to use bit.ly by javascript, how to use bit.ly in my site   

    Auto Shorten dynamic URL by javascript 

    Live Demo

    Thinking of using bit.ly Url Shortening service in your site? You can use a simple javascript code in any page of your site, specially if it is a dynamic page. For example, look at a dynamic page of my online code compiling site:

    The link of a dynamic page is somewhat this: http://shafiul.progmaatic.com/hostcode/compiled.php?i=wRZWM&c=252&ext=11

    The link is too long. So, I automatically shortened the links, and gifted it to the viewers! ;)

    how to use bit.ly in your site

    How to use bit.ly service in your site

    First, you need an account on http://bit.ly. To create one, go to the site and register.

    Once you’ve registered, login and go to your Account page. There, you will find your API key.

    Now, we’ve all the resources. Let’s go to the code section

    The Code

    Between the <HEAD> and </HEAD> tag of your page, place the following code:

    	
  • <script type="text/javascript" charset="utf-8" src="http://bit.ly/javascript-api.js?version=latest&login=******&apiKey=*****************"></script>
  • Replace the first ***** by your bit.ly username and second ************** by your bit.ly API key!

    Now, place the following code anywhere of your page. It is nothing but a text-input field, where shortened link will be placed. You can use anything instead of a text area, perhaps a <div>tag to display the shortened link!

    <h3>Link to this page</h3><br>
    Use this link to tell others about this page! <input onclick = "this.select()" type = 'text' id = "qlink" style = "width:100%;">
    
    <br><br>
    
    

    Now, the final task. Place the following code just before </BODY> the tag of you page:

    <script>
    	// Bit.ly API
    	BitlyCB.shortenResponse = function(data) {
    			var sss = '';
    			var first_result;
    			// Results are keyed by longUrl, so we need to grab the first one.
    			for     (var r in data.results) {
    					first_result = data.results[r]; break;
    			}
    			sss = first_result["shortUrl"].toString();
    			document.getElementById("qlink").value = sss;
    	}
    	BitlyClient.shorten(window.location, 'BitlyCB.shortenResponse');
    </script>
    
    

    Yeah, you’re done! Now anyone entering the page with any query string, the link of the page with the query string will be automatically shortened :D

     
    • Ali 11:59 am on December 15, 2010 Permalink | Reply

      Nice Article,

      Is this only for one URL or we can use multiple, if we want multiple then do we have to code like this for each URL?

      Thanks

      • Shafiul Azam 7:15 pm on December 15, 2010 Permalink | Reply

        This works for multiple urls – the code automatically detects the page’s url and shortens it.

    • Shafiul Azam 1:41 pm on December 27, 2010 Permalink | Reply

      Code for the broke.

      
      
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel
Follow

Get every new post delivered to your Inbox.