Linux command to restart network manager

I have been using Ubuntu a lot more, and I often need to switch between different network connections and go on and off of a network proxy. All that jumping around tends to affect my connectivity to the different networks. I find that the connecting part tends to hang and I cannot connect to a network anymore.

I found this handy command to help with that:

sudo service network-manager restart

After the network manager restarted on Ubuntu I was able to connect to a network with no delay.

Tips to get docker set up on Ubuntu

So I recently tried setting up docker on ubuntu and ran into a few hurdles, below is the checklist of what needed to be setup or installed on Ubuntu in order to run a docker project.

Make sure these are installed/Setup

docker
docker-compose
virtualbox
docker-machine

Setting up the docker-machine default ip

Then using docker machine you need to setup an IP to run in a web browser.

There is more thorough documentation on the docker website. The summary of what I found worked:

Run the following commands:

docker-machine create –driver virtualbox default
docker-machine env default
eval $(docker-machine env default)

Get the ip address of default

docker-machine ip default

That ip is what you will be using in your browser to view the docker files.

When you run your docker container:

docker-compose up

Then you will be provided with a port number. Eg 127.0.0.1:8000

Then you use the ip above and that port number.

See the other docker posts for solutions to some of the errors I ran into and fixed.

Setting up a new django project with Docker and getting gunicorn error “No module named…”

Just putting this here. I don’t understand docker fully yet. I have just managed to get it working for the first time. The solution I found for the “No module named…” error was to run the following command:

docker run -p 5000:5000 registry:latest

Configuring npm proxy details so that bower install work through a proxy

Trying to connect to npm while on a proxy?

When connected to a proxy and downloading bower depencies via the console/command line the following settings need to be set.

Update npm configs

npm config set proxy http://[username]:password]@[url]:[port]

npm config set https-proxy http://[username]:password]@[url]:[port]

Now you should be able to install dependencies through the proxy using npm

Example npm commands

bower install
npm install

 

Grunt task grunt-contrib-compass not working on windows

I started working on an existing project that used “grunt-contrib-compass”.

Grunt kept throwing the error, Warning: not found: compass

Running “concurrent:server” (concurrent) task
Warning: Running “compass:server” (compass) task
Warning: not found: compass Use –force to continue.

After going in circles with installing npm packages, uninstalling npm packages, I realised the problem was this library is dependent on Ruby.

The solution

Install ruby:

http://rubyinstaller.org/

Install gems

Using ruby you need to install gems

gem install sass
gem install compass

 

 

Adding less to an existing grunt project

Preparation for using less in your grunt file

Install the less grunt plugin

npm install grunt-contrib-less –save-dev

In your Grunfile.js you can add less as a step in your run process. You can also set Grunt up to watch changes to your less files and then convert any less to css.

Step 1. Convert less to css using a Grunt task.

Adding the less task:

less: {
style: {
options: {
compress: false
},
files: {
‘app/css/style.css’ : ‘app/less/style.less’
}
}
}

The filepaths will need to be updated to where your css files and your less files are kept.

Step 2. Watch for changes to less files, then run the less Grunt task.

In your watch add the less task below:

Don’t replace the whole watch block, just add the less: section.

watch: {
… existing code …

less: {
    files: [‘app/less/*’],
    options: {
        livereload: ‘<%= connect.options.livereload %>’
    },
    tasks: [‘less’]
},

… existing code …
}

The filepaths will need to be updated to where your less files are kept.

What the above does:

files: [‘app/less/*’] 

This tells Grunt that it must watch all files in app/less/…

livereload: ‘<%= connect.options.livereload %>’

This tells grunt that when a change is done, the browser should reload (after the task is run).

Also with <%= connect.options.livereload %> the naming needs to be correct. This needs to link up with your “connect” task in the Gruntfile. There should be connect code at the bottom that looks something like this:

connect: {

options: {
port: 9220,
hostname: ‘localhost’,
livereload: 35700
},

}

tasks: [‘less’]

This tells grunt that when the change is spotted by the watch, these tasks need to run. In this case we just one one task to run, the ‘less’ task that we added to the Grunfile.js.

Extra step: styles watch

Another watch that is important to add, is the styles watch. When less updates your css, a second watch needs to then update the css files you use. This is for example built into a yeoman generated app with the following code:

watch: {

styles: {
files: [‘<%= yeoman.app %>/styles/{,*/}*.css’],
tasks: [‘newer:copy:styles’, ‘autoprefixer’]
},

}

Step 3. Add less task to your build/serve task

When you run “grunt serve”, you want less to run as well, before your css gets copied over. Add the less task to your serve task list:

grunt.task.run([
… existing code…
‘less’,
… existing code …
]);

Full example of the serve task with the new ‘less’ task added:

grunt.registerTask(‘serve’, ‘Compile then start a connect web server’,         function (target) {
if (target === ‘dist’) {
return grunt.task.run([‘build’, ‘connect:dist:keepalive’]);
}
grunt.task.run([
‘clean:server’,
‘less’,
‘wiredep’,
‘concurrent:server’,
‘postcss:server’,
‘connect:livereload’,
‘watch’
]);
});

Configuring github to work through a proxy

Edit the .gitconfig file on Windows to work with a proxy

Open your .gitconfig file. You can find this file in your C:/Users/[your user] folder.

Edit the .gitconfig file on Ubuntu/Linux to work with a proxy

Open your .gitconfig file. You can find this file in your home ~/ folder.

You can type in the command line:

sudo nano ~/.gitconfig

Edit the .gitconfig file

Insert the following lines:

[http]
proxy = http://username:password@proxyurl:port
[https]
proxy = http://username:password@proxyurl:port
sslVerify = false

Username would be your proxy username.

Password would be your proxy password.

Proxyurl would be the proxy url.

Port would be the proxy port.

View your git settings

You can check your git settings in the command line by running the following:

git config -l