At.js with froala issue

At.js is a Javascript library for having Github like mentions in an app. The library is here. It’s a very good library and simple to use however when I tried it, it didn’t work out of the box for froala editor. The problem is At.js surrounds the range with spans and since WebKit browsers insert spans, the editor accepts spans only if

data-fr-verified=”true”

is set to true. So to counter this, when initiating the function, a small tweak is required.

$(‘.froala-view’).atwho({
at: “@”,
editableAtwhoQueryAttrs: {“data-fr-verified”: true},

data:[‘Peter’, ‘Tom’, ‘Anne’]
})

This should get it working as it did for me.

 

Reference: Github issue

 

Hope  it helps

Postgres Error On Heroku

Recently, I ran into an error while deploying an application(redmine to be specific) on heroku.
I followed all steps listed on the wiki page, remove the required files from gitignore etc but when I did git push, I kept on getting the error:

Please configure your config/database.yml first
remote: rake aborted!
remote: URI::InvalidURIError: bad URI(is not URI?): ://user:pass@127.0.0.1/dbname

Since Heroku generates database.yml file itself, I had no clue what to do.
So in the gemfile, I deleted the following block:
# database_file = File.join(File.dirname(__FILE__), "config/database.yml")
# if File.exist?(database_file)
# database_config = YAML::load(ERB.new(IO.read(database_file)).result)
# adapters = database_config.values.map {|c| c['adapter']}.compact.uniq
# if adapters.any?
# adapters.each do |adapter|
# case adapter
# when 'mysql2'
# gem "mysql2", "~> 0.3.11", :platforms => [:mri, :mingw, :x64_mingw]
# gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
# when 'mysql'
# gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
# when /postgresql/
# gem "pg", "~> 0.17.1", :platforms => [:mri, :mingw, :x64_mingw]
# gem "activerecord-jdbcpostgresql-adapter", :platforms => :jruby
# when /sqlite3/
# gem "sqlite3", :platforms => [:mri, :mingw, :x64_mingw]
# gem "jdbc-sqlite3", "< 3.8", :platforms => :jruby
# gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
# when /sqlserver/
# gem "tiny_tds", "~> 0.6.2", :platforms => [:mri, :mingw, :x64_mingw]
# gem "activerecord-sqlserver-adapter", :platforms => [:mri, :mingw, :x64_mingw]
# else
# warn("Unknown database adapter `#{adapter}` found in config/database.yml, use Gemfile.local to load your own database gems")
# end
# end
# else
# warn("No adapter found in config/database.yml, please configure it first")
# end
# else
# warn("Please configure your config/database.yml first")
# end

and added

group :production do
# gems specifically for Heroku go here
gem "pg", ">= 0.11.0"
end

Also in config/environments/production.rb,I added the following line:

config.assets.initialize_on_precompile = false

Once I pushed, the above error went away but I got the following error:


Running: rake assets:precompile
remote: rake aborted!
remote: PG::ConnectionBad: could not connect to server: Connection refused
remote: Is the server running on host "127.0.0.1" and accepting

The problem here was I didn’t pre-provision my database before pushing to heroku.

So solve this, one can run the command:

heroku addons:create heroku-postgresql

So know about the issue, one can always use:

heroku config

Before running the command, heroku config, returned DATABASE_URL as blank and that was the issue.

Hope it helps !!

WiFi issues on Ubuntu 12.04

Hey ,

Recently installed ubuntu 12.04 on a fresh and clean system. While it works like a charm, a very irritating issue was that the inbuilt wireless card was not working. The ethernet connection using wire worked fine. Googled a lot and wasnt able to figure things out. Finally, backports saved my day. Here is the procedure I followed incase someone finds it useful.

 

Installing backports:

sudo apt-get install  linux-backports-modules-cw-3.8-precise-generic 

Some generic headers and libraries:

sudo apt-get install linux-headers-generic build-essential

Download this file and extract it at a location of your choice.
Navigate to the extracted directory using terminal and try:

make defconfig-ath9k
make
sudo make install

Reboot the system and ideally wireless should work!

Hope it helps.

Guake – Annoying feature of renaming tabs

I am a huge fan of guake terminal and after having used it for quite a while, I am literally addicted to it.

Recently, I encountered a very annoying feature which is when I rename a tab and perform any operation on that tab, the name I gave disappears and the absolute path is shown.

This was very painful because I am used to work with multiple tabs open and naming helps navigation.

After some googling, I found a solution which I present below.

Install gconf-editor.

sudo apt-get install gconf-editor

Start gcong-editor

gconf-editor

Browse to apps/general/guake/general.

On the right hand side, uncheck the “use_vte_titles” item and close it and restart guake.

All tabs would be named “Terminal” and renaming would preserve it.

The technical reason for doing this is the following piece of code:

def on_terminal_title_changed(self, vte, box):
    use_them = self.client.get_bool(KEY("/general/use_vte_titles"))
    if not use_them:
        return
    page = self.notebook.page_num(box)
    self.tabs.get_children()[page].set_label(vte.get_window_title())

As we can see ‘use_vte_titles' key prevents the autorenaming feature

Hope this helps and enjoy using guake.

Editing a form in nested_form gem

This is a very very naive and simple thing but I quite lost my time on this so I thought might be helpful.

Recently I was using the ‘nested_form’ gem by the great Ryan Bates (https://github.com/ryanb/nested_form). The form to create a new form works like a real gem without any effort.

Now, when I clicked on ‘edit’ link, it created some issues as the nested models didnt come.

I had a simple thing like each question has many answers. When I created a question, I added 5 answers to it but when I edited the question, no answers were visible.

The simple solution for this would be that the <% f.fields_for :answers do |an| %> line in your form would be without an equal to sign so just add it.

Thus, it looks like

<%= f.fields_for :answers do |an| %>

Thats all and it works like a charm!

Hope it helps.

Fixing Ubuntu GPG BADSIG error

Recently, I faced a error while updating my Ubuntu system.

When I ran “sudo apt-get update”,

it gave me the followinf error message:

 

W: GPG error: http://archive.canonical.com intrepid Release: The following signatures were invalid: BADSIG 40976EAF437D05B5 Ubuntu Archive Automatic Signing Key

 

The way I fixed it was:

 

$ sudo -i

# apt-get clean

# cd /var/lib/apt

# mv lists lists.old

# mkdir -p lists/partial

# apt-get clean

# apt-get update

 

Hope it helps. !!