Restart the docker environment
docker-machine restart default
Refresh the docker environment settings
eval $(docker-machine env default)
Restart the docker environment
docker-machine restart default
Refresh the docker environment settings
eval $(docker-machine env default)
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.
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
bower install
npm install
I started working on an existing project that used “grunt-contrib-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.
Install ruby:
Using ruby you need to install gems
gem install sass
gem install compass
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.
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.
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’]
},
…
}
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’
]);
});
Open your .gitconfig file. You can find this file in your C:/Users/[your user] folder.
Open your .gitconfig file. You can find this file in your home ~/ folder.
You can type in the command line:
sudo nano ~/.gitconfig
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.
You can check your git settings in the command line by running the following:
git config -l
I have a daily battle with a proxy. Each day I think, “today this proxy will be tamed”. Only to have the proxy stop working and I have to start figuring it out from scratch.
Below is what I go through each time I experience problems with proxy connection.
Configure your windows environment to work through a proxy
One way is to update your environment variables.
Open a command console, and in it add these two settings:
set http_proxy=”http://proxyUsername:proxyPassword@proxyUrl:port”
set https_proxy=”’http://proxyUsername:proxyPassword@proxyUrl:port”
To view your system settings enter in your command console:
set
Using “set” is more like a “cache” setting, it will go away when you close the command console, or restart your computer. To set it permanently, either manually add it to your environment variables. Or use setx.
setx /M http_proxy “http://proxyUsername:proxyPassword@proxyUrl:port”
setx /M https_proxy “http://proxyUsername:proxyPassword@proxyUrl:port”
A note on the value ”http://proxyUsername:proxyPassword@proxyUrl:port”
This format can be:
Another note: ping will not work with a proxy. (Well for now I haven’t found a way for it to work yet.) From the research I have done to date, ping works at a different level to the proxy. So just a head’s up, if you use ping to test if your proxy settings now allow internet access, you will be going in circles.
What should work is if you use a tool like vagrant for example and you need to download a box.
If this doesn’t work, and you use a tool that needs internet acces through the command line and it still cannot connect to the internet. Make double-triple sure your proxy details are 100% correct. Make sure you are connected to the internet.
And try the below:
LAN Settings
Setting the proxy on the lan settings. I have found two ways of setting this, one way is through a web browser like Chrome. And the other is through the control panel.
Go to Settings.
Show advanced settings.
In the Network section click “Change proxy settings”.
In the window that opens up click on “LAN settings”.
Select “Use a proxy server for your LAN…”
Add the proxy address, add the proxy port.
If you have done all of the above and you still do not have internet acces through the proxy, you need to check if your proxy itself is not blocking the access.
This is still a work in progress, below is what I’ve figured out so far:
To set the system variables on linux:
export http_proxy=”http://proxyUsername:proxyPassword@proxyUrl:port”
export https_proxy=”http://proxyUsername:proxyPassword@proxyUrl:port”
The first task I was shown when following ansible tutorials was editing the hosts file. I ran into a few issues though, hence this post. The solutions I found that helped are documented below:
Install ansible
sudo apt-add-repository -y ppa:ansible/ansible
sudo apt-get update
sudo apt-get install -y ansible
Backups the hosts file
sudo mv /etc/ansible/hosts /etc/ansible/hosts.backup
Edit the hosts file.
sudo nano hosts
Add your environments and ip addresses, eg:
[local]
127.0.0.1
Get ssh working, and test it can connect to your listed servers
add-username-to-transactions
sudo apt-get install openssh-server
Then test it is working and started:
sudo service ssh start
Run the ansible ping command
ansible all -m ping
If you get these errors:
Error: Permission denied
Two solutions,
Run the following command with -k
ansible all -m ping -k
This will trigger the password request
OR
Force ask password through the ansible config file:
sudo nano /etc/ansible/ansible.cfg
uncomment:
ask_pass = True
This will also trigger the password request, but by default without needing the -k option.
Then insert your password. You should now get your pong result without the error.
The following is a last resort solution for a problematic database, I have yet to find a cleaner solution for this problem.
Delete the existing version of alembic, and start from scratch
source ~/venvs/env.Vodacom-QuoteService/bin/activate
Clear the alembic table
sqlite3 [yourdbfile]
> delete * from alembic_version;
Remove the migrations folder
rm -r migrations/
Initialize the database
python manage.py db init
Upgrade and migrate the database
python manage.py db upgrade
python manage.py db migrate
Restart the service that is using the table.
Might need to rerun these three steps if the database is still not working
python manage.py db upgrade
python manage.py db migrate
(restart your service)
Insert the below into the console
export VARIABLE_NAME = VARIABLE_VALUE
To remove the environment variable
unset VARIABLE_NAME
To view the environment variable:
env | grep -i VARIABLE_NAME
Note, for the env | grep -i command, the VARIABLE_NAME can also just be
part of the variable name, eg “proxy” and then any variables
containing that value will display. Eg http_proxy, and htts_proxy
will display if you insert env | grep -i “proxy”.
View the key:
cat ~/.ssh/id_rsa.pub
Copy and paste the key in here:
sudo nano ~/.ssh/authorized_keys