Friday, May 17, 2013

IRSSI: nick already in use error after a disconnect or network issue

This error pretty much annoyed the shit out of me where a temporary disconnect resulted in this error for a few minutes on freenode and irssi used to try using a different nick.

This can be solved by not authenticating using
/msg NickServ password mypass
 If SASL is used for authentication, Freenode servers knows beforehand what my nick is and doesn't complain about this error. The how-to guide for it can be seen here:  http://freenode.net/sasl/sasl-irssi.shtml

This is one of those issues for which I was lazy enough to not search about it.



Sunday, March 17, 2013

Move a filtered thread that skips INBOX to INBOX in Gmail if you reply to a message there

If there is a a mailing list which is filtered and doesn't pass my INBOX, even if I reply to a thread in it, it'll still goto the filter and skip in INBOX. Well, this is perfectly defined behaviour but due to this, I sometimes missed mails.

So, to get threads to INBOX which are actually filtered if you reply to any mail in that thread, you can use this script.
function move_to_inbox(threads) {
   Logger.log(threads.length);
   for each (thread in threads) {
       if (thread.isInInbox() != 'true') { 
           thread.moveToInbox();
       }
   }

}

function myFunction() {
    //Remove starred if you don't want it
    move_to_inbox(GmailApp.search('is:unread (in:sent OR is:starred)', 0, 10));
}

Goto http://script.google.com and copy the above script there. Then, setup triggers (Resources->All Your Triggers) to execute myFunction() every minute.

OR

save the script in your google account by visiting this link.

Make sure that triggers are set to work correctly.


Friday, March 1, 2013

Puppet: Override/change resource attributes defined in included class or inherited node

There can be instances where you would want to change a resource which has come from included class. If there is no way for you to *not* include, there is a way.

Resource collectors can be used to search and re-open the resource and edit it.

The code below will result in elasticsearch service as stopped in a node.
#In a node or class somewhere
service { 'elasticsearch':
  ensure => running,
}

#Sometime later in the code, for ex, in a node that inherits above node (also valid for classes)
Service <| title == 'elasticsearch' |> { ensure => stopped }
No multiple resource definition error or anything. :)

Sunday, February 24, 2013

Up-to-date guide for running Django (using django-nonrel) on Google App Engine (2013)

  • First install Google App Engine using AUR . If you don't use Arch by now, it's about time :P. Anyways, use your package manager to install GAE.
    This will install Google App Engine in  /opt/google-appengine-python/ directory. The project that we're gonna clone wants google-appengine to be present in /usr/local/google_appengine
    sudo ln -s /opt/google-appengine-python /usr/local/google_appengine
    
  • Get our shit ready.
  • $cd django_on_gae;            #Our Project 'super' directory
    $git clone https://github.com/django-nonrel/django-nonrel
    $git clone https://github.com/django-nonrel/djangoappengine
    $git clone https://github.com/django-nonrel/djangotoolbox
    $hg clone https://bitbucket.org/twanschik/django-autoload
    $git clone https://github.com/django-nonrel/django-dbindexer
    $git clone https://github.com/django-nonrel/django-testapp #This is our test app
    
    
    Copy the relevant folders to the project directory.
    $cd django-testapp
    $cp -rv ../django-nonrel/django .
    $cp -rv ../djangotoolbox/djangotoolbox .
    $cp -rv ../django-autoload/autoload .
    $cp -rv ../django-dbindexer/dbindexer .
    $cp -rv ../djangoappengine .
    
  • Create a app on http://appengine.google.com/. When you are done, you'll get a page saying: 
    The application will use hello-world-shadyabhi as an identifier. This identifier belongs in your application's configuration as well. Note that this identifier cannot be changed. Learn more
    
    Open app.yaml fil and edit the application: accordingly.
  •  Finally, 
    $./manage.py createsuperuser
    WARNING  2013-02-24 05:05:42,848 dev_appserver.py:3578] The datastore file stub is deprecated, and
    will stop being the default in a future release.
    Append the --use_sqlite flag to use the new SQLite stub.
    
    You can port your existing data using the --port_sqlite_data flag or
    purge your previous test data with --clear_datastore.
    
    WARNING  2013-02-24 05:05:42,848 datastore_file_stub.py:528] Could not read datastore data from /home/shadyabhi/github/django_on_gae/django-testapp/.gaedata/datastore
    WARNING  2013-02-24 05:05:42,850 simple_search_stub.py:975] Could not read search indexes from /tmp/dev_appserver.searchindexes
    Username (Leave blank to use 'shadyabhi'): root
    E-mail address: myemail@gmail.com
    Password: 
    Password (again): 
    Superuser created successfully.
    
    $./manage.py syncdb
    WARNING  2013-02-24 05:06:27,198 dev_appserver.py:3578] The datastore file stub is deprecated, and
    will stop being the default in a future release.
    Append the --use_sqlite flag to use the new SQLite stub.
    
    You can port your existing data using the --port_sqlite_data flag or
    purge your previous test data with --clear_datastore.
    
    WARNING  2013-02-24 05:06:27,200 simple_search_stub.py:975] Could not read search indexes from /tmp/dev_appserver.searchindexes
    Creating tables ...
    Installing custom SQL ...
    Installing indexes ...
    No fixtures found.
    
    $./manage.py runserver #And everything should work
    


  • For password-less deploys: 
    /usr/bin/appcfg.py --oauth2 update ./
    
    A new tab will open and that'll require you to click allow access.  
  • From now on, if you do any changes, you can deploy the app by executing the above command again, ie: 
    /usr/bin/appcfg.py --oauth2 update ./ 
    That's it for now.

    Tuesday, January 29, 2013

    Disable rate-limiting in rsyslog v5

    If you are here, you might be getting error messages like
    imuxsock begins to drop messages from pid 29233 due to rate-limiting 
    
    in your /var/log/messages. rsyslog v7 has this disabled by default but rsyslog v5 has this enabled.

    To disable it, add
    $SystemLogRateLimitInterval 0
    $SystemLogRateLimitBurst 0
    
    to your /etc/rsyslog.conf.