error
Most of us have seen this dreaded error page when developing on rails.Launching up irb or rails console wastes a lot of time and brain cycles.
Having said that I came across this neat gem called ‘web-console’.This gem is really handy ,it launches rails console right there is the browser along with the current context.
Installing it is pretty simple Add it to your Gemfile and you are up and running.Make sure you have the version mentioned below or something higher.

gem 'web-console', '2.0.0.beta2'

 

web-console



The current project I am working with required me to have maps to work offline.The gist of the app was it would connect to a hardware device running a server.Since most common use case for the app was at remote location, having offline maps was essential.

After some quick googling I came across mapBox,it is a startup which works on creating open source mapping tools for developers.

Getting back to the meat of this post,
To get the maps to work on mapbox i have to create maptiles which is a combination of sql statements which is required by map box to generate maps.
The most essential tool for creating the maps was homebrew.

I then had to install postgres which was pretty easy with homebrew.

brew install postgresql
initdb /usr/local/var/postgres -E utf8
postgres -D /usr/local/var/postgres
createuser -d -P postgres

The previous commands install postgres ,setups up initial databases,creates a new user called postgres and starts the database.

Since the default install of postgres doesn’t understand gis(Geographic Information System) data we had to install postgis (extension for postgres).Brew comes back to scene making it trivially easy to install.

brew install postgis

Next we create a database on postgres to save the map data.

psql -U postgres 
CREATE DATABASE osm;
c osm;
create extension postgis;
dt

If you don’t see any table means that the extension has not been loaded correctly.To fix it you might have run the following

psql osm < /usr/local/Cellar/postgresql/9.3.5/share/postgresql/extension/postgis--2.1.3.sql

 Note the postgresql & potgis version number depends on the version you have installed;

Next you can download compressed binary map data from http://metro.teczno.com/ or the updated https://mapzen.com/metro-extracts/.
Download the pbf file of the particular location.

Once you have downloaded the file you will also require osm2pgsql which converts the binary pbf file to sql statements

osm2pgsql -c -G -d test -S /usr/local/share/osm2pgsql/default.style dubai-abu-dhabi.osm.pbf

Note: replace test with name of the database you created on postgres.Also change dubai-abu-dhabi.osm.pbf to the file you just downloaded

The next steps would let will create world map (just outline no details/layers)

wget https://github.com/mapbox/osm-bright/zipball/master
wget http://data.openstreetmapdata.com/simplified-land-polygons-complete-3857.zip
wget http://data.openstreetmapdata.com/land-polygons-split-3857.zip

Once you have downloaded these files extract the osm-bright zip first.Then extract the other two files.

Copy the extracted file to the shp directory.
Then edit the configure.py file in the mapbox-osm-bright folder
Edit the config[“postgis”] usually along line 21-25
Also edit the map.py file.Change defaultconfig[“postgis”] to our environment.(Usually at line 81-86)

Before you run that download tilemill and run it.

Once you are done with that.Run the python script make.py
This will create a project file for the tilemill app.
The project name is called osm-bright open it and select export to maptile to create one.
You now have an offline map file which will work with mapbox.

 

 



Two nights ago I accidentally bricked my router by flashing the original firmware over openWRT firmware on the MR3020.

WARNING:If you want to flash the original firmware remove the boot part from the firmware.

After quick google, I came across this page.It was had all of the instructions i needed to fix my bricked router. Unfortunately it required some extra hardware especially a usb to serial convertor, soldering iron and some headers.It had been more than 1 year that i soldered anything(Last time being in college).I had the necessary resistors leftover from my arduino project.

I took apart the router and found out the necessary pins for the header.Now it was time to solder.Moreover the openWRT website also had the pin layout with the necessary details of the pins.

 

 

1 2 3 4
TX RX GND VCC

 

All I had to do was connect the 10K resistor from the TX pin to the VCC pin.The connection to the usb device was also simple.
RX -> TX
TX -> RX
GRND -> GRND

MR3020

IMG_0778

IMG_0779

Time to flash the firmware.I had to run a tftpd server on my machine and a serial connection to the device.I tried running the device at 56000 bits.It didnt work all gibberish on the screen.After the reading the instructions again.I had to set the bit rate to about 115200.Once that was done.The text was legible.Once the autobooting text came up on the screen I had to type tpl(Note sure why but that was some sort of ‘open sesame’ for the bootloader developers).Then i ran the following commands.

hornet> setenv ipaddr 192.168.1.1
hornet> setenv serverip 192.168.1.2
hornet> tftpboot 0x80000000 openwrt-ar71xx-generic-tl-mr3020-v1-squashfs-factory.bin
eth1 link down
dup 1 speed 100
Using eth0 device
TFTP from server 192.168.1.2; our IP address is 192.168.1.1
Filename 'openwrt-ar71xx-generic-tl-mr3020-v1-squashfs-factory.bin'.
Load address: 0x80000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ######################################################
done
Bytes transferred = 3932160 (3c0000 hex)
hornet> erase 0x9f020000 +0x3c0000

First 0x2 last 0x3d sector size 0x10000                                                                                                        61
Erased 60 sectors
hornet> cp.b 0x80000000 0x9f020000 0x3c0000
Copy to Flash... write addr: 9f020000

done
hornet> bootm 9f020000

 

Once this was done the router was back from the dead ready for some more tweaking.



Toro is simple PHP Router that has beautiful & minimalistic syntax.Its just 125 lines of php.

Building a rest client is as pretty simple.All one has to do is require the library and set up the routes.You may ask me whats the difference between Toro and other routing framework.To that I will say there are many.First the code is so simple and clean(a daunting when using PHP).The API it provides are simple and straight forward as well with minimal setup requirements.It also includes pre & post hooks.

To setup a basic route one has to do the following