Category Archives: Uncategorized

Pulling in Facebook Posts


		

Adding django via pipenv

Pip environments with python and django have evolved over the years, but once constant has remained: virtual environments to run the code and packages in. The latest consensus is to use pipenv to keep things separated. Let’s see how.

First, I’ll assume that you already have python 3.7 installed. If you need help, check out this other post I wrote: https://markcerv.com/2019/03/adding-python-3-7-to-ubuntu-18-x/

Next:

sudo apt install python-pip
sudo pip install pipenv

pipenv --python 3.7 install django

In order to use pipenv, you will need to cd to the directory where you want to put your code, and then:

cd  somename
pipenv --python 3.7 install django django-cors-headers \
         djangorestframework pytz
# a bunch of things will happen, including that a virtualenv
# will get get created like:
# ~/.local/share/virtualenvs/somename-oYSXMPkF

# to actually fire up the environment
pipenv shell

Next, you’ll need to setup a minimum of files to get django going. :

django-admin startproject test2

cd test2

python manage.py migrate     #will setup the needed database stuff
python manage.py createsuperuser    # lets you make a u/p for login

./manage.py  runserver  0.0.0.0:8000

You can now jump over to a browser, and visit http://127.0.0.1:8000/admin/ and sign in to your app. It’s pretty boring right now, but you can fix that.

Adding python 3.7 to ubuntu 18.x

If you quickly want to get the latest version of Python installed on Ubuntu and get future updates automatically, then you can install it from the below third-party PPA repository…

To do that, run the commands below to add the PPA.

First install Ubuntu software properties package if it’s not already installed on your system..

sudo apt update
sudo apt install software-properties-common

After that run the commands to add the PPA..

 sudo add-apt-repository ppa:deadsnakes/ppa 

Finally, run the commands below to install Python 3.7

sudo apt update
sudo apt install python3.7

That’s it!


Brother HL3140CW Printer – Reset ‘out of toner’ message

How to reset the fake “out of toner message” and instantly make the printer work again:

1. Open the top lid of the printer and leave it open.
2. Press and hold the “Secure” and “X Cancel” buttons at the same time.
3. Use the arrow keys to select the cartridge model you would like to reset and press “OK”.
4. Press the UP arrow to reset the cartridge.

Once reset is selected you will see “ACCEPTED” on the screen.

Reset them all by scrolling through the various colors on the menu.

5. Close the top lid. It will make a bunch of noise for a minute or so, then it will print like new again.

Now the printer thinks you installed brand new toner cartridges, and you will get double or more the amount of printed pages from the same old “out” toner. When you notice the quality of the printouts degrading, THEN its time to replace the toner. Not before. While you are waiting for your new toner to arrive, take the old one out and shake it- prints will look new again for a short period of time. Buy toner when you are out, not when the machine tries to tell you what to do.

Moving over VirtualBox/Vagrant the hard way

There is a right way to move/copy over a VirtualBox to a new computer/colleague/etc.

And then there is the hard way.  What is the hard way?  The hard way is when you need to manually copy over .vbx and .box files and edit .xml files. 

Step 1 – Copy files over from the old drive.

Copy over the directory that contains the .vagrant folder. The way I have my environment it’s “c:\home\blah”.  I do by having 2 windows explorer windows open, and dragging and right-clicking on the destination folder, then clicking “Copy here” or “TerraCopy here.”

Take note of the value of c:\home\blah\.vagrant\machines\default\virtualboxes\id

067c8f42-0e93-4825-a02a-8ecf3a6586d3

Next, copy over the c:\Users\YOURNAME\VirtualBox VMs\xxx folder that corresponds/correlates to your Vagrant box.

Then, double click on the .vbox file in the directory you just copied over. This should automatically import it into VirtualBox.

Finally, open up c:\Users\YOURNAME\.VirtualBox\VirtualBox.xml and check that the uuid matches.

      <MachineEntry uuid="{aaaaaaa-bbbb-cccc-dddd-eeeeeeeeee}" src="C:/Users/YOURNAME/VirtualBox VMs/xxx/xxx.vbox"/>
    </MachineRegistry

Fire up your cmd prompt, switch to the c:\home\xxx\ directory and

vagrant up

Celebrate!