Sunday, December 17, 2017

Rails vs Padrino or others

Starting writing in Ruby after touching all other languages is like finding manna as the life saver. Talking about Ruby, the one web framework that comes to mind is Rails. I will not talk about Padrino or others until a while. Let me try to put the reasons on why you should use rails

1. Large community base - building or adding features and bug fixes continuously gives it capability to have the latest web technologies be it like front end technology like sass, bootstrap and all.

2. ‎Automatated generators - almost every MVC part generation is automated, be it creating controllers, adding or updating models, creating views with ERB (try haml too) adding tests, rake tasks and much more, all from the command line. I recommend using Linux ( Manjaro ) with rbenv to manage ruby environments and of course VIM editor with tmux for ide like multitasking. I prefer solarized light theme for them 😀

3. ‎Rails console - gives the easy shell to check your variables, url params, perform database CRUD operation methods, session values, "string".classname to get inherited classes or modules and all

4. Github and Heroku deploy - Using one branch for each task and merging them to master once done is the way to go. Lastly the deployment is as easy as single command 'git push heroku' which pushes the master branch to Heroku. Heroku generates an url for your application. Also it supports postgres for now, so watch out for it when starting to build your app.

That's it, this is what it should take for you to get going with your loved programming language on the best automated web framework.

Roughly you would be adding the routes in the config/routes file. It's controller will be an ApplicationController class in app/controllers/name with methods or actions like index, create, show, delete or similar. Finally the render for views is in app/views/name as .ERB file for each controller (class) created. These can be further broken down using partials using underscores like _footer.erb or _ header.erb . One can further use HAML instead of ERB for minimal writing. Of course you can use SASS or SCSS and coffee script for JS.

I recommend reading or referring Michael Hartl's Rails book, it's a pretty good book for a first time web developer. The recommend chapters are static pages ....

If you read till now, I am pretty sure you will stick to rails for a while. Now let me talk about its competition. One I think of is Padrino which is built on top of Sinatra mini web framework.

Sinatra doesn't have a routes but instead have their routes defined in the controller class itself. Padrino has a lot of work in progress parts but shows off the light weight benefits.

Padrino imports lot of rails generator concepts for creating controllers, tests, models, views and all. The blog tutorial on its site uses sequel which I didn't want to start learning as I just learnt Activerecord which uses such easy methods like User.find_by_name("Ragavendra") to retrieve say user records and say .save , . create and .delete to fulfill CRUD.

 I assume Activerecord was created by the Rails team. There are a tonne more libraries contributed by the rails team to the Ruby community as gems or even to its core. Rails is what more or less made Ruby popular. Lot other modern web frameworks have inherited Ruby gem concepts as well for easier web development.

Spree is an ecommerce built on top of rails. Hanami seems easier and imports a lot of rails like commands, it has a lot of nitty gritty which feels like working on HTML for some reason. I am pretty sure you will want to fall back to rails like me if you walk through all the other web frameworks. The best part is the sane eco system it has to offer.

The tests part is one which I wouldn't recommend and DHH thinks the same too, it takes to much time and stresses real bad. Better to have a separate team write integration tests than those painful TDD or unit tests.

Wednesday, July 12, 2017

Are you technically apt - Software developer

You don't have to be technically apt to be able to achieve business needs or requirements. Often in interviews people try to test your coding knowledge to the point of knowing the perfect syntax. What would happen if you actually made coding mistakes when coding on a machine, you would actually see some interpreter or compiler warnings or errors. Now can't you fix this code now. Do interviewers question this? Actually Google is just a click away to precisely help to fix issues if in case we did not understand how to fix it. Are interviewers thinking that you are a compiler or an interpreter 😀 . A knowledgeable coder is one who can pick the best method or approach for a problem rather than one who knows everything like a poem and is not good in knowing the best solution. I often find that interviewers are trying to find the later ones for their teams. Did you just read poem, yes that's correct. I was one of the worst in memorizing poems in my class and that's why I moved to  Science. I always think Science is learning based on understanding. So should the other IT people be too, if not I am afraid of its future. I am ready to take a bet on it. Having almost learnt so many programming languages I have to admit that most was possible because the boss gave me an opportunity to do it rather than question me before giving it. Yes I had some very good considerate bosses in my career. In turn I did what was expected and won accolades too like the best performer award in the government project. I always never want to work for anyone who can't praise your success or even understand it and so should anyone. Eventually people will judge you based on rumors and it has never worked in your favor.


Saturday, November 19, 2016

Orange PI Plus 2 with Arch Linux Minimal



ArchLinux_Minimal.img                            Arch Linux basic image (without Desktop GUI)

Download ArchLinux_Minimal.img from https://drive.google.com/drive/folders/0B1hyW7T0dqn6fndnZTRhRm5BaW4zVDVyTGlGMWJES3Z1eXVDQzI5R1lnV21oRHFsWnVwSEU


Installation on SD Card


  • Download any of the available images (xz archive) from Mega or GoogleDrive
  • Download scriptbin_kernel.tar.gz, it contains the latest kernel (uImage) and script.bin
  • Unpack the archive.
  • Write the xxx.img file (disk image) to your SD Card
  • on Linux use dd command ( sudo dd if=image_name.img of=/dev/sdX bs=1M oflag=direct )
  • on Windows use disk image writing software such as Win32 Disk Imager
  • After writing the image, mount SD Card FAT partition (BOOT)
  • Copy uImage_OPI-2 or uImage_OPI-PLUS (depending on your board type) to uImage (for OPI-PC use uImage_OPI-2)
  • Copy one of the script.bin.OPI-XXXX (depending on your board type and desired monitor resolution) to script.bin
  • use uImage_OPI-XX and script.bin.OPI-XXXX from scriptbin_kernel.tar.gz if it is newer (probably it is).
  • Boot your Orange PI board from SD Card


Installation on internal EMMC


  • Install the image on SD Card as described above
  • Boot your Orange PI board from SD Card
  • Run:
    1. sudo install_to_emmc
    Copy the Code

  • Power off the board.
  • Remove SD Card
  • Power on, the board will boot from EMMC

1) First connect to internet via the LAN cable
2) try `sudo pacman -Syu` to fetch the updated installation urls. Hit NO when asked to install update packages.
3) Now do `sudo pacman -S parted dosfstools` to install the partitioning pr the disk packages
4) Now you can do `sudo install_to_emmc` .... have fun ....


Setting up WiFi


wifi-menu -o

# netctl start profile 
then it can be enabled using:
# netctl enable profile
This will create and enable a systemd service that will start when the computer boots. Changes to the profile file will not propagate to the service file automatically. After such changes, it is necessary to reenable the profile:
# netctl reenable profile


If you see network profile aleady up, do
ip link wlan0 down

then do
netctl start wireless-wpa

Wednesday, August 17, 2016

Innovations in demand or needed badly

1) Flood survival kit - Like below, need a kit to help survive floods

2) Building/ apartment on fire escape kit -- http://www.dailymail.co.uk/sciencetech/article-3192161/SkySaver-backpack-lets-ABSEIL-multi-storey-buildings-escape-fires.html#v-4410962511001

Todo - Shortly need to create a post on change.org to pledge governments to provide these/ similar kits to the residents as it can come handy during the disaster.

3) Tornado survival kit - Like above, need a kit to help survive tornado

4) Tsunami survival kit - Like above, need a kit to help survive tsunamis

5) Earthquake survival kit - Like above, need a kit to help survive earthquakes

6) Frost bite survival kit - Like above, need a kit to help survive frost bites

7) War survival kit - Like above, need a kit to help survive wars

Sunday, August 7, 2016

BC Stop Sign

Types of STOP signs and rules to follow.

*Basic rule for any STOP sign is to stop in a STOP sign before the white line for 3 seconds (the rule) and move if there is no pedestrian crossing in front of you and accordingly depending on the type of the sign as mentioned below.

1) Two way or one way STOP sign
is one where you and the driver from the opposite side would be facing. Follow the *basic rule like said above and then say

a) Turning Right
If you plan to turn right and if there is a vehicle already if waiting in the opposite direction, then he has the preference to go first. In case he's blocked by traffic then, you get the preference to proceed. Make sure that there is no traffic coming from the left side in the lane* you want to turn or you think you can merge (comes with experience). You do this which is known as left shoulder check. Then slowly move with turn and merge into the lane provided you didn't see any objects by doing the right shoulder check too. If there is curb before the intersection you should have stopped before the curb and slowly move to merge to make right turn.

b) Turning Left
If you plan to turn left (tougher one) , again the vehicle already if waiting in the opposite direction, has the preference to go first. If you are first, then make sure first there is no traffic from left by left shoulder check. Then check no traffic again from right by right shoulder check. Now slowly move your vehicle if all is clear and turn into the immediate 1st lane after the turn nd slowly spped up to the speed limits (usually 50 Kmph)

2)  Three way or four way STOP sign
This one is a lot easier and safer one then the two or the one way STOP sign, provided all in the intersection are following the rules.
Irrespective of turning left or right, the basic idea is that all the vehicles come to a STOP and follow the *basic rule. The vehicle which came first gets to go first in whichever direction provided the intersection is clear. If two or more of them came almost at the same time, then person in the left has to let the person in the right make the turn. This can however be confusing for a new or experienced drivers too. So the best bet is to slowly start moving your vehicle and stop immediately if anyone else jumped the gun to avoid the crash.

DISCLAIMER: PLEASE NOTE THAT ALL THE INFORMATION PROVIDED HERE IS FOR LEARNING PURPOSE ONLY WITH TIPS AND IDEAS BUT SHOULD ANYWAY CONSULT WITH THE LOCAL LAWS TO CONFIRM THE SAME.

Monday, July 11, 2016

Drupal 7 Views field customization

Lets say you have a drupal 7 installation with Views enabled. Now you have a view for a products page or a block. Lets say you are not happy with the the fonts, the position or any front end related to the field. How do you overcome this situation. One way is to theme the particular field.

1) In the view, for the field go to the style settings,
a. select customize field HTML
b. select the HTML element like say 'DIV' in this case. Lookup for each and what they mean.
c. select create a CSS class and give it a name say, 'product_title'
d. Finally hit apply. We are done with the ui side of the setup.

2) Now, lets try to customize the field class we defined above for class name 'product_title'
a. You can either pass the full CSS path like below to be specific or the actual element itself making it like more global like.
b. Open you CSS which could be your_theme/css/style.css and add like below.
div.product_title,
.product_title {
align_text: center,
font-size: 1.145em
}


Thursday, April 28, 2016

Orange Pi Plus 2 LAN setup


Update the below file
`sudo nano /etc/network/interfaces`

to look like below
`auto eth0 
iface eth0 inet dhcp`

Then finally do like below
`sudo /etc/init.d/networking restart`

To manually update your ip, do like below
`ifconfig eth0 192.168.1.5 netmask 255.255.255.0 up`

 I connected my pi to a Mac book pro via LAN. The Mac book was set to share its internet connection. Make sure the thunderbird is green on the Network setings.

Then you can do like below to install xfce desktop

`sudo install_xfce_desktop`

Browser background color or monitor brightness

Have you been in a situation where you are almost sitting the whole day in front of your browser and going through a document and find that ...