Skip to content

Useful Code Snippets

Rob Ruana edited this page Aug 21, 2018 · 16 revisions

Make Any '<form>' an ajax-form

Add the following

<script>
$("#formID").ajaxForm(function(message){
    toastr.info(message);
    setTimeout(function(){
        location.reload(true);
    }, 1500);
});
</script>

Bower/Grunt install

Run the following

sudo apt-get install npm
cd ~/uber/sideboard/plugins/uber
sudo npm install -g bower
npm install grunt # Possibly unnecessary?
sudo npm install -g grunt-cli
sudo ln -s /usr/bin/nodejs /usr/bin/node
bower install
npm install grunt-bower-concat # Fails on Windows, see note below
grunt

The Apply Node command

When upgrading Reggie the Registration system you can use the following sh file

uber/puppet/apply_node.sh localhost

Once completed use sep reset_uber_db to drop all the database tables

Turn off the Uber Daemon

Are you getting an error stating that Port 8282 is not free on 0.0.0.0? SSH into your vagrant instance and use the command sudo supervisorctl stop all

Developing Static Content

Ubersystem uses multiple layers of caching for static content. In order for changes you make in your development deployment to show up in your browser, you may have to clear the cache at each layer.

Clearing NGINX Cache

As root/sudo:

find /var/cache/nginx/**/* -type f | xargs rm --

Clearing CherryPy Cache

If you're using supervisor to run uber_daemon, as root/sudo:

supervisorctl restart uber_daemon

If you're running from the command line, first CTRL-C to kill the server, then restart it with:

run_server

Clearing Browser Cache

The final place where static assets might be cached is in your browser. If your changes still aren't showing up after clearing NGINX cache and clearing CherryPy cache, try clearing your browser cache.

Completely Wipe Out Database

DROP SCHEMA public CASCADE;
CREATE SCHEMA IF NOT EXISTS public AUTHORIZATION rams_db;
GRANT ALL ON SCHEMA public TO public;
GRANT ALL ON SCHEMA public TO rams_db;

I have an error, what's going on?!

Check the logs located at /var/log/uber-app.log