Invalid CSS after “(min-width: “: expected expression (e.g.

Two possible reasons:

  • You might be @importing minified version of css assets like bootstrap.min.css
    • I did same and later solved using normal version css file
  • Search the suspect file if it has the content (min-width: and (max-width on the same line
    • see if there is any variable used
    • there might be px unit missing after the var
    • see if there is any possibility of var being nil
    • use @if condition to solve problem
    • eg:
@if  $min != null and $max != null{
  @media (min-width: $min + 'px') and (max-width: $max + 'px') {
    @content;
  }
}
Advertisements

Ruby on Rails | Setup MS-SQL server in Ubuntu 17.04

MSSQL Server Installation

Follow these instructions https://www.rootusers.com/how-to-install-microsoft-sql-server-on-ubuntu-linux/

Note: During installation it will ask you for password, put a strong password remember it or note it down.

Reset Server Admin(SA) password

If you, unfortunately, forgot the SA password then you can reset follow the commands

$ sudo systemctl stop mssql-server
$ sudo /opt/mssql/bin/mssql-conf setup

Testing

If you wish to test if Server is installed and ready to receive requests

sqlcmd -S localhost -U sa -P your_strong_password

Install FreeTDS binaries

$ apt-get wget
$ apt-get install build-essential
$ apt-get install libc6-dev

$ wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-1.00.21.tar.gz
$ tar -xzf freetds-1.00.21.tar.gz
$ cd freetds-1.00.21
$ ./configure --prefix=/usr/local --with-tdsver=7.3
$ make
$ make install

Install required gems

# SQL Server (2012 or higher required)
#
# Install the adapters and driver
#   gem install tiny_tds
#   gem install activerecord-sqlserver-adapter
#
# Ensure the activerecord adapter and db driver gems are defined in your Gemfile
#   gem 'tiny_tds'
#   gem 'activerecord-sqlserver-adapter'

If still, you cannot install the gem tiny_tds then try using sudo
$ sudo gem install tiny_tds -v '2.0.0'

Importing from Remote to Localhost db

Exporting from remote

bcp my_table_name out ~/my_table_name.txt -S yourdb.database.secure.windows.net -U yourusername -P 'YourStrongPassword123!!' -d mydbname -c -t ','

 

Import to Local

bcp my_table_name in ~/my_table_name.txt -S localhost -U sa -P 'PrashantBhusal1' -d my_local_db_name -c -t ',' -q

**Output When Successful**

Starting copy...

5 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.) Total : 16 Average : (312.5 rows per sec.)

Useful links

https://askubuntu.com/questions/870927/sqlcmd-not-available-after-installing-mssql-tools

https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-troubleshooting-guide

https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-troubleshooting-guide#connection

https://www.rootusers.com/how-to-install-microsoft-sql-server-on-ubuntu-linux/

https://github.com/rails-sqlserver/tiny_tds#install

Could not install Ruby 2.3.4 in Ubuntu 17.04 using RVM

I could not install Ruby 2.3.4 which I needed because Heroku does not support latest stable release like 2.4.0.  So my Gemfile has locked the version 2.3.4. Till now I have been manually commenting out that particular line from the Gemfile and skipping the change from Git-Commits.

Hack

I found a hack

  • install ruby 2.3 from apt-get
sudo apt-get install ruby2.3 ruby2.3-dev
  • find location of the ruby installed
which ruby2.3
# => /usr/bin/ruby2.3
  • Mount the ruby to RVM
rvm mount /usr/bin/ruby2.3 -n ruby-2.3.3

rvm list                                

rvm rubies

 * ext-ruby-2.3.3 [ x86_64 ]
   ruby-1.8.7-p371 [ x86_64 ]
   ruby-1.9.3-p551 [ x86_64 ]
=> ruby-2.4.0 [ x86_64 ]

A better option

Install Ruby from archived link

rvm mount -r https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.3.tar.bz2

Rails using Bootstrap templates in vendor

If you are considering using templates which you copied to vendor directory then things you need to keep in mind:-

  • Move all assets like Images, sounds, Fonts but not js or css to vendor/assets/ like
    • vendor/assets/fonts
  • Add this line in assets.rb
    • Rails.application.config.assets.precompile << /\.(?:svg|eot|woff|ttf)\z/
  • Make sure you are using `rails_12factor` gem in production
  • use image-url and font-url helpers
  • in scss files in @imports rule you do not use .css at last of the filename. It automatically calculates.
Nano editor Comment/Uncomment in GNU Nano editor using Alt+3 shortcut

GNU Nano editor adjust comment literal for PHP / C / C++

If you are a UNIX lover and fan of Nano text editor then while writing C / C++ code, you would like to put comments using Short-Cut key i.e. Alt+3. But the problem is, Nano puts the char # as comment literal instead of //. This happened because the default literal is # unless it is defined in configurations.

How to fix?

Continue reading