Instant upload images to imgur from android

Python needs to be embraced for it's capacity to gel with android so well and make things easier with simple and fun scripts.

After installing G+ android app, /me was curious about instant upload of images that the app provides, so decided to make a simple script to emulate the same, but as imgur is one my favs, used the same.

Instant upload images to imgur is a simple script that does :

<

ul>

  • Invoke camera to take a picture.
  • Upload the picture to imgur.
  • SMS the link to the img.
  • Copies the link to the cilpboard.
  • Figlr ASCII art on fly

    Figlr is a simple fun tool to generate FIGlet text. Those are normally used to make ASCII art banners.

    It makes use of Figlet-JS which is a JavaScript implementation of a FIGdriver and is also available as a Node module and a jQuery plugin.

    The code :
    The code is a simple javascript trick, to listen on the paste and keyup events from a text area and populate a pre tag with the FIGlet text.

    <

    pre style='color:#000000;background:#ffffff;'>$(function(){

    Programmatically delete SMS in android using python

    Deleting SMS text has been on of issues with default SMS clients of Andriod OS. Issue 5669 talks a lot about it.

    The most common alternative is to use different SMS clients, that allows bulk delete.

    But using some simple python script, deleting SMS from inbox is just a click away, provided one has SL4A installed on the device.

    Simple python script to delete SMS from inbox in Android devices :

    Yoda talks to XMPP, Twitter and Identi.ca

    This is more a tribute to Master Yoda rather than coding!

    The idea was to use a simple python script to update my gmail, tiwtter and identi.ca with a random saying from Master YODA from Star Wars!

    Yoda for me is not a mere character for a movie, but he is a philosopher, motivator and indeed the renowned Jedi master.

    Python modules needed :

    Some extra steps for twitter
    For oauth all one needs to do is create an twitter APP with Access level to be read and write in our case.

    After creating note down the : consumer_key, consumer_secret, access_token_key, access_token_secret.

    All is well now, GET SOURCE modify the creds and enjoy!

    Yes the yoda_says list can read read from a file, better read randomly with linecache, but just wanted to have a single file for the easy of it.

    You feel there are more quotes to added? Suggest them! ^_^

    Wikipedia search summary API

    After Random images from wikipedia I made another simple API to get the summary for a search term using PHP.

    It's a JSONP API that queries the DNS of wikipedia to fetch the TXT records, which also includes a short URL to the complete corresponding Wikipedia entry. As cross-domain requests are possible with this API, one can easily integrate it to search boxes or widgets.

    Monkey code :

    Random images from wikipedia

    After Random images from xkcd as wallpaper it was time for some more fun, this time did a simple script to get Random images from

    Get json ip service

    Getting client IP address is one common thing most of the web developers do, but getting the same with JavaScript is not possible as there is no notion of hosts or ip-addresses in the standard library.

    True, there are many such services that provide IP in JSON format, but is it not better to trust yourself ;) ?

    Just for the fun of it, made a simple service using PHP that would return the clients IP address in JSON and the same can be used in a client side scripting language like Jquery.

    The php code :

    Compressing files with python, perl, ruby and php

    Compressing files

    is one of the most common tasks any programmer would have done. The below is a simple comparison of compression paradigms of selected programming languages i have really liked!

    This post is much influenced by :

    SMS from android using python

    Sending an SMS programmatically using python in an android easier than any other programming language

    All one needs to have is Scripting layer installed in the mobile device.
    Use the QR code below to get the apk and install the required and then install the python interpreter.

    The below is the simple script to send random Chuck Norris jokes:

    My Google Interview > /dev/null

    It all started couple of months back, on a fine sunny morning i read a mail with a subject Career Opportunities @ Google at first thought it was a spam mail, but then to my astonishment and delightment it wasn’t... then the mail read :

    Hi Hemanth,

    I'm writing to introduce myself and inquire about your interest in confidentially exploring opportunities with Google. Please let me know if you have a few minutes to discuss.

    I support a team called the Google.com/Site Reliability Engineering and we are currently looking for different types of engineers to help support some of the current and upcoming exciting projects.
    Ideally we are seeking technical generalists with fluency in coding/scripting, fundamental knowledge in systems administration, network administration and strong analytical and troubleshooting skills.

    This team is hiring in San Francisco, Santa Monica, Pittsburgh, Kirkland, Seattle, Lenoir NC, Las Vegas, New York as well as Dublin, London, Zurich, Munich, Sydney. If this does not sound like the best fit for you, there are several other teams hiring as well.

    In the event that you're happily employed, but know of any engineers of your quality who may be on the market, please don't hesitate to pass along my contact information.

    Thank you in advance for your consideration! I look forward to your reply.

    I could not believe my eyes! That i had received a mail from GOOGLE! To be frank, I had not applied to Google in any of their portals and was extremely excited and replied to the mail saying,I was interested and had attached my resume with the mail (Not that Google wanted my resume, as they would know be better than me ;) )

    I got a quick response for my mail saying :

    Hi Hemanth,

    Thank you for your interest in Google! I support a team called the Google.com/Site Reliability Engineering and we are currently looking for different types of engineer to help support some of the current and upcoming exciting projects.

    What I have in mind for you is a unique hybrid position. As a Google.com engineer, you wear many different hats and and are expected to be a jack-of-all-trades. It calls for solid knowledge in Unix/Linux Systems, Scripting/Coding and Networking and/or Databases. We put the best and brightest on this mission-critical team to solve large scale, highly complex problems related to Google's customer-facing sites and internal services.

    I'd love to have a brief conversation to gauge your interest and tell you more about the team. If you could provide me with a few time slots that would work for your schedule over the next few business days, I will confirm one with you.

    So all excited Hemanth, gave few time slots and dates where he would be free and would be easy to talk. ( Talking to one about yourself is the toughest thing to do! NO?).

    CALL 0
    So the clock ticked 22:45 hrs i was about to sleep, but wanted to surf some reddit, my cell rung time was exactly 23:00hrs! As soon as i noticed it was an international call ( Call was from California ) plugged in my head phone and said hello, I heard a charming voice a lady from the Google recruitment team,
    she got to know more about me and explained me about how working at Google would be and what they are expecting from a candidate.

    CALL 1
    This was about what i had learnt so far and what would be covered in the up coming interviews. Was requested to prepare on basic of whatever i had studied in my bachelors as a computer science grad.

    CALL 2
    Around 23:15hrs about a week after CALL 1, This call had question that would gauge me and suggest me the right stream in Google that would suite my true nature. Call was all about the basic of Computer programming, Networking, GNU/Linux and indeed algorithms.
    Sorry can't disclose the questions, after this round I got a mail saying that i had cleared this round and need to get ready for other rounds.

    CALL 3
    Before the CALL 3 really happened, I had to give list of time slots with in a given range, that was like 23:30 to 04:00 hrs [IST] yes time seemed bit odd, but that is how they like it and more over the Engineer who was supposed to talk my interview was in US, so had no other options. It's hard to focus at odd hours especially when you had a long day at work, but that is not the whole point, if there is real love in technology time must not matter!

    This call was very interesting, it also included Computer programming, Networking, GNU/Linux and a shared Google document where i had to code on a given problem [ Can't share more details here too! ]

    Call ended with me saying, "I could not be at my best, really don't know why! May the odd time or over excitement", other end the Google engineer said, i can understand no issue, if any more questions please contact the recruitment team.

    So Call 3 was it i knew i had screwed up, could have done much better! After few more days got a mail that my resume will be in there repo if there are more jobs that are apt for me they will get back.

    Even though i knew the answers to all of them, was not able to delivery it in the right manner and with the same level of confidence, which i would have done with any other company!

    RETROSPECTION

    I'm must say that disappointment is indeed echoing in me, but must be happy as Google Getting 1300 Resumes A Day chose me, from one of the open source sites where i had done my contributions! Indeed has boosted my confidence!

    Lesson Learnt

    <

    ul>

  • 1. KEEP IT COOL : When excited the amount of mistakes you make is comparatively more, especially when it comes to problem solving!
  • 2. No matter if it's "GOOGLE"stature, they will ask question to which are simple but yet tricky, so If step 1 is applied this stage will be easy to know.
  • 3. It's not about getting every answer right at one shot, they look into how you solve stuff and what is your stand on what you have already said!
  • 4. Don't over prepare! Yes stuff your head with too much of data is not needed, be confident on whatever you know and keep it cool!
  • 5. Don't over think! Yes this where it matters the most, try to find the simplest solution, don't start thinking if it's right or if it's the best complexity! Most of the things one g33ky dev would have come across and solved the questions which they ask, it's all about how you perform at that time, is all that matters
  • With this i thank Google for giving me such a great opportunity! No matter what reasons i may list now, the past is past and lost is lost.

    In life, we need to face failures to realize the taste of success…they are like injections; they pain but it's a good pain!! So if it does not end well, then there is more to come!

    Selective directory index from htacess

    Apache Module mod_dir provides "trailing slash" redirects and serving directory index files. "The DirectoryIndex directive sets the list of resources to look for, when the client requests an index of the directory by specifying a / at the end of the directory name. Local-url is the (%-encoded) URL of a document on the server relative to the requested directory; it is usually the name of a file in the directory. Several URLs may be given, in which case the server will return the first one that it finds. If none of the resources exist and the Indexes option is set, the server will generate its own listing of the directory."

    How to have different index to sever from the same directory?

    Downloading files : A Comparative study

    The idea :

    A simple case study of downloading files in perl, ruby, python and php.

    The algorithm :

    Assumption : The input for these scripts are obtained from a simple cgi form.

    • 0. Hit an URL which in turn responds with a list of URLs ( Like RealMedia Metafiles )
    • 1. Download the contents of each URL that the is returned from the master.
    • 2. Zip all the downloaded files and exit.

    Downloading files in perl :

    GNU MediaGoblin

    What is GNU MediaGoblin?
    Initially, a place to store all your photos and artwork, more better than (Flickr, DeviantArt, SmugMug, Picasa, etc). Later, a place for all sorts of media, such as video, music, etc hosting.

    P.S: This will mostly be usable system by September 2011.

    Getting the code :
    Dependencies : apt-get install mongodb git-core python python-dev python-lxml

    Running bootstrap and buildout

    Clone the repository: git clone http://git.gitorious.org/mediagoblin/mediagoblin.git

    Keyless auto login SSH script

    keys less login has been easy always with ssh keygen and copy-id, but just a small bash loop will help auto login on disconnections. Key-less auto login SSH simple script, but helped me to make one of my team mates switch to GNU/Linux.

    Simple script :

    <

    pre style='color:#000000;background:#ffffff;'># Read the hostname and username for SSH login.

    Server-Side JavaScript with Node.js

    node.js => evented I/O for v8 javascript

    <

    p>Installing node.js on a Debian machine :

    <

    pre style='color:#000000;background:#f1f0f0;'>sudo apt-get install g++ curl libssl-dev apache2-utils git-core git clone http://github.com/joyent/node.git cd node

    Stealing Google Logos using Yahoo API

    Many love browsing through Google Logos, so do some of my friends, was planning to make a simple page with infinite scroll with all the Google Doodles so far.

    The idea
    To programmatically fetch all Google logos so far and display it with infinite scroll, also to keep the page in sync with Google logo list.

    The plan
    Using Yahoo! YQL to select the required section from the Google logo page and display the images suitably. As YQL also returns a JSON, displaying the required images was not a big issue.

    The key ingredients : Yahoo! YQL + Jquery

    The color clock

    I came across the thecolourclock wanted to check out the source sadly it was build in flash
    so tired to make one with some HTML and JS. Check out thecolorclock. [See time in colors :)] The idea is to represent time as a hexadecimal color value.

    Check out the code [Indeed view source ;) ] or :

    Get the git clone or view the raw from <a href="https://github.com/hemanth/futhark/blob/master/colorclock.html">colorclock</a>

    Multi lingual xmpp translate bot

    Multi lingual translate bot code in ruby after the xmpp ruby chat-bot this bot is coding in ruby with the help of to_lang ruby gem.

    Demo of the bot :

    Will be adding more flags for the easy of use soon!

    How the bot works?
    It makes use of Google translate API the response that will be returned by the server will be a JSON

    Python objects to JSON string

    Python provides a easy way to handle JSON, by importing the**  json  **module, one can easily encode a list of dicts or a dict of dicts so on, but there is a easy trick to generate a JSON or even a nested JSON string from an object of a class.

    `json.dumps(obj[, skipkeys[, ensure_ascii[, check_circular[, allow_nan[, cls[, indent[, separators[, encoding[, default[, **kw]]]]]]]]]])`=> Serialize obj to a JSON formatted str

    Getting the redirected URL

    Many time one needs to get the redirected URL, the reasons might be many but the logic remains the same. HTTP request response is what it's all about, say if an URL has a redirection, one can find the redirected URL in the RAW headers of the response, the location would be the HTTP/1.1 307 Temporary Redirected URL.


    REQUEST-RESPONSE

    Google i'm feeling lucky in python and ruby

    With the xmpp and irc bots : l33ty.l33t and l33ty so far i'm having fun coding them, of all the methods in them i liked the goog method, which returns the first URI from the list of URI's returned from the Google web search API, that is the linear implementation of IMFL search.

    First up is python:

    XMPP ruby chat bot

    After Python-IRC-bot my interest was in making a gmail bot, that lead me to make a simple bot very much like the previous irc bot, its called rgbot.

    To add the bot to your contact : add l33ty.l33t[at]gmail[dot]com

    About rgbot
    XMPP Gmail Bot in rb ; rb+gmail+bot => rgbot. rgbot is an XMPP bot build with ruby, that runs on gmail and can do things like :

    * l33t translation

    Python IRC bot

    It started with the intention of making a simple IRC l33t translate bot after the l33t translation API.

    l33ty is an IRC bot build with python with the help of twisted modules and uses "Reactor pattern". l33ty can do few many things like :

    * l33t translation
    * Google I'm feeling lucky search
    * Karma system
    * XCKD random images
    * Flipping a coin, throwing the dice

    Preparing your system

    L33t translator

    Here I introduce a dynamic 733+ translator an on the fly translator similar to Google translate.

    Where i can see the translator in action?
    You can here in the demo page [[ not much of an eyecandy ]]

    What is l33t?
    "Leet, also known as eleet or leetspeak, is an alternative alphabet for the English language that is used primarily on the Internet. It uses various combinations of ASCII characters to replace Latinate letters. For example, leet spellings of the word leet include 1337 and l33t; eleet may be spelled 31337 or 3l33t." [[ wikipedia ]]

    Edit dot rc files and auto source

    Dot rc files are not supported by all the shell, but on those which it's supported we often edit ~/."$SHELL"rc files and source them or exec the shell. I made a small python app using which one can select the login shell from the list of shells installed in the current system.

    Copying shared library dependencies

    I call it cpld a simple utility for copying shared library dependencies to a given folder

    Time zone conversions

    "Time is constant, we come and go", but the beauty of earth is so, that time varies with space.

    I made a simple BASH script to convert between different time zones, as i badly needed one such app, that would give me time in my terminal.

    Curious case of combining pdfs

    We have all combined a pdfs in the past, and it all seems easy until you come across a situation like this!

    Limpid a simple app for p2pu

    Limpid is a simple gtk application coded in python, as there was a requirement for the course named Scripting-101 which i'm mentoring on Mozilla P2PU. The app has a window with a split screen, where in the first part of the split is a simple webbased IRC and the other part is a virtual GNU/Linux terminal.

    It all start with a simple idea, i got of embedding a vt in a terminal, later on it turned out to be a stand alone all, with a browser and a terminal in it! Absoluteness of pygtk, even the same can be achinved with QT4, there are few many massive apps, out there, but this one is a minimal app to meet the requirements.

    Setup Diaspora on Ubuntu

    Diaspora => The privacy aware, personally controlled, do-it-all, open source social network.

    Was seeing lot of people facing issues to in set up, including me at the beginning, so i thought to make a setup script for ubuntu os,which can be cloned from my repo [[ Mentioned below ]].

    I have tested it to the max i could, still it might not be fool proof, do try and let me know if you find any bugs.