Thursday, January 2, 2020

Install Terminus Font Ubuntu

Terminus font is easy to install in ubuntu command line. Just do this: sudo apt-get install xfonts-terminus console-terminus

Wednesday, January 1, 2020

How to setup Unifi Docker AWS Controller (instead of using a cloudkey)

Set Up Your EC2

* get an aws ec2 supporting docker
* open the ports as described in the docker manifest: https://hub.docker.com/r/linuxserver/unifi-controller
* factory your USG
* ssh into your usg ubnt@usg-lan-ip-addr
* factory your USG from command line if you are feeling doubtful that the above worked: you can skip above step if you can somehow get in sudo syswrapper.sh restore-default
* set-inform http://$EC2IP:8080/inform
* head to https://$EC2IP:8443 and log in and now you can adopt your USG-3
* repeat the set-inform on your other Unifi branded devices and they will populate in the EC2 controller

Bonus Points Upgrading your (Unifi Device)

* while your ssh connection is live on the device, google unifi upgrade and get the link to the proper firmware, currently it's here https://downloads.ui.com/unifi
* upgrade https://$FIRMWARE (where $FIRMWARE) is the url of the firmware

What if the IPADDRESS of my Controller Changed, like I forgot To Set A Elastic IP?

It's all good you can SSH into your local devices using probably the last IP address shown in your messed up controller. Note when the devices get adopted the ssh creds change from default to something like superadmin, and a hash found in the following screen, so grab the ssh creds like so:



They let you view the password in plain text, and ssh right in, redo the set-inform command with the new URL and you will be all set. Do it per each device.

Thursday, November 14, 2019

How to install youtube-dl on Windows (WSL)

Install Python2 and then curl install youtube-dl to the /usr/local/bin directory
* sudo apt install python -y
* sudo apt install mpv -y
* sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl && sudo chmod a+rx /usr/local/bin/youtube-dl
* youtube-dl all the things

Specific examples of how to use youtube-dl
* youtube-dl https://www.youtube.com/watch?v=KK5KTQGuXSQ --format ("bestvideo[width>=1920]"/bestvideo)+bestaudio/best --download-archive archive.txt --output %%(uploader)s/%%(upload_date)s.%%(title)s.%%(id)s.%%(ext)s --add-metadata --write-info-json --write-description --write-annotation --write-thumbnail --merge-output-format mkv --ignore-errors

You can use my Shell Script here too
#!/bin/sh
echo this you put $1
CORE='youtube-dl'
FIRST='${1}'
SECOND='-f bestvideo+bestaudio/best -i --prefer-ffmpeg --write-sub --all-subs --convert-subs srt --add-metadata --write-description --write-annotations --write-thumbnail -v'
echo this is second $SECOND

echo this is command: ${CORE} ${1} $SECOND
${CORE} ${1} $SECOND


#end

Command syntax is $ sh youtube-dl.sh https://full-youtube-link

Thursday, November 7, 2019

How to setup GNU Emacs on Windows 10

  • You want to C-h v (describe variable) user-init-file 
  • Put the path to your real init files in there eg, (load "c:/emacs/bin/init.el")
  • Source additional init files, eg, (load "c:/emacs/bin/_org.el"), (load "c:/emacs/bin/_erc.el")

Tuesday, November 5, 2019

How to Log Your Time in GNU Emacs

  • Create an .org mode file
  • C-u C-c .
    
to create your starting time
C-u C-c.
to create your ending time, make sure the two times are in succession with the
--
operator in between then, then you can evaluate the amount of time the task took with
C-c C-y
 
---
guidelines: https://orgmode.org/manual/Creating-timestamps.html 

Wednesday, July 26, 2017

How to setup a NodeJS app on Ubuntu

Untitled Document.md

Make All The Services

Ubuntu uses something called Upstart for services so you can either use services already on your box or make new ones. Your app uses nodejs so lets review how to install that and then make a service out of it:

Install NodeJS

This installs it to /usr/bin/nodejs:

sudo apt-get update
sudo apt-get install nodejs

Make the Web User and the web hosting directory

adduser www
mkdir /home/www/run
chown -R www:www /home/www/run && chmod -R 770 /home/www/run
mkdir -P /home/www/MY_APP/log
chown -R www:www /home/www/MY_APP && chmod -R 770 /home/www/MY_APP

Push All The Codes

Now that you are done writing your code, go ahead and push the code to:

/home/www/MY_APP/

Run this command again after to give the right permissions on your newly placed files:

chown -R www:www /home/www/MY_APP && chmod -R 770 /home/www/MY_APP

Your directory structure should look something like this because NodeJS:

node_modules
package.json
server.js
public/
routes/
view/

What we’re concerned with is the server.js file. That isNode.JS entry point to the world. In that file you will have something like the following symbolizing that your app runs on port 3000:


var app = express();

app.set('port', process.env.PORT || 3000);

Make the Upstart Service

Making a service is as easy as adding a .conf file to the /etc/init directory:

/etc/init/MY_APP.conf
description "MY_APP"
author "MY_NAME"


env NODE=/usr/bin/nodejs
env SCRIPT=/home/www/MY_APP/server.js
env LOG_FILE=/home/www/MY_APP/log/stdout.log
env PID_FILE=/home/www/run/MY_APP.pid
env USER=www


start on filesystem or runlevel [2345]
stop on shutdown


respawn
respawn limit 10 5


script
    exec start-stop-daemon --start --chuid $USER --make-pidfile --pidfile $PID_FILE --exec $NODE $SCRIPT >> $LOG_FILE 2>&1
end script


pre-start script
    touch $LOG_FILE
    chown root:$USER $LOG_FILE
    chmod 770 $LOG_FILE
    echo "[`date`] MY_APP starting" >> $LOG_FILE
end script


pre-stop script
    rm -f $PID_FILE
    echo "[`date`] MY_APP stopping" >> $LOG_FILE
end script

Check to make sure the new Service is ok:

 init-checkconf /etc/init/MY_APP.conf

Check the status of the new Service

service MY_APP status

Start the new Service

service MY_APP start
  1. Check the status of the new Service again
service MY_APP status

Why all this logging crap? Logs are important, when your NodeJS app starts behaving strangely you will want to know why on your production server so follow the paths of the log files, and verify they are there and correct.

I owe it to https://ubuverse.com/run-your-node-js-app-as-an-upstart-service/ who originally wrote a general version of the Upstart user creation and script

Aren’t Reverse Proxies Fun?

Your app is running but you have to hit port:3000 in order to view it, what do we do now?

This guide is how to setup Apache to handle your reverse proxy because Apache and because exposing NodeJS to port:80 is bad.

Enable proxies in apache

 sudo a2enmod proxy_http

Go to your /etc/apache2/sites-available/000-default.conf or whatever config file you are using to tell apache what to do:

<VirtualHost *:80>
       DocumentRoot /home/www/MY_APP
       ServerName www.awesome.com
       ServerAlias awesome.com

       ProxyRequests on
       ProxyPass / http://localhost:3000/
</VirtualHost>

Reload Apache

sudo service apache2 reload

Monday, April 17, 2017

How To Get MiniVMac Working on a PC (2017)


Follow the three below steps and you will get the bare essentials. 
  1. Download MiniVMac, the first one on this list is what you want, http://www.gryphel.com/c/minivmac/download.html
  2. Download a ROM as found here, https://sites.google.com/site/minivmacapplicationsv6/disk-images-and-roms
  3. Download a Diskette as found here, the first one on the list will do fine, https://sites.google.com/site/minivmacapplicationsv6/systems-os
Now let’s try to kick it up a notch. What we want to do here is load a diskette into the (already) running machine. What we can do here is follow the below instructions.
  1. Download PT-109 an old game but an awesome game. http://www.myabandonware.com/game/pt-109-ce#Mac
  2. Go onto Mini V Mac File Menu and select Open Disk Image...
  3. Point that to the game you downloaded and then it will show up on your Desktopdouble click it and go.