MyVideoGameList.com v6.0.0

I've been working hard to roll out the next version of my video game website, MyVideoGameList.com and today I finally pushed it out to the live site. I had some trouble with the Bootstrap date picker scripts, but I finally got them working. I was pretty much dreading working on the site because I know so very little Javascript. I probably could have rolled out the site about a month ago if I wasn't being such a big baby about this small piece of the site.

Anyways, here's some screenshots!

Destiny - Game Profile

This is what the game profile page looks like. I also got the Recently Completed By and Recently Favorited By blocks working a lot better. The rows and columns of the userpics display much better now.

jimmy's Profile

morgan's Profile

These are a couple examples of how user profiles look now. As you can see we now support a cover picture.

There's still a lot more we want to do we user profiles and the site. Items that I would love to get working this coming year would be:

  • Allow users to select and show the consoles they own on their profile
  • Show break downs of the types of genres and consoles users play on
  • Have some sort of friend feed
  • Allow users to setup and manage gaming groups
  • Possibly setup some sort of private messaging system
  • Review all the code again and make sure it's clean and tidy

Overall though I am definitely much happier with the site now. The only other thing we definitely need to be working on it getting all the games requested by users into the database. I think we have some 3500 pending requests at this point.

JSBin

JSBin - Self Hosted

I've just started using this powerful tool. It also happens that it can be self-hosted which I am huge advocate for in any web software. I generally use it to tinker around with HTML and CSS as I'm not that good with Javascript but I could definitely see it being useful when I learn more about that language.

Now I just need to keep looking for a self-hosted solution that allows for real-time collaborative code sharing. And not a full on IDE, just something with nice syntax highlighting for multiple languages that lets me work on code in real time with a friend or co-worker.

My JSBin Instance.

Installing StackEdit

StackEdit Self-Hosted

I recently brought on a new team member for one of my many projects. We had an immediate need for documentation collaboration. My first idea was to use Hackpad or Etherpad, but we were going to be working a lot with Markdown, so I Google'd around a bit and came across StackEdit!

As with most of our tools we use, I prefer self-hosted solutions more often then not. Thankfully StackEdit fit that bill.

My StackEdit system is a 4 virtual-core, 6GBs of RAM with CentOS 6.x VPS.

Install Prerequisites

yum -y install nano gcc gcc-c++ git

Install Node, Gulp & Bower

StackEdit runs off Node so we'll need to get that installed along with a few other npm packages.

cd /usr/src
wget http://nodejs.org/dist/v0.10.30/node-v0.10.30.tar.gz
tar zxvf node-v0.10.30.tar.gz 
cd node-v0.10.30
./configure
make
make install

Next Gulp:

npm install --global gulp

And finally Bower:

npm install -g bower

The StackEdit Source Code

This one is pretty quick and easy!

cd /opt/
git clone https://github.com/benweet/stackedit.git

Now we need to install some of it's dependencies.

npm install
bower install --allow-root

Of note, if you're not running these commands as root you may omit the --allow-root from the Bower command.

CouchDB - For Lazy Couch Potatoes!

Alright! So StackEdit will work now, however if you want to allow the synchronizing and sharing of files between people, you'll want to either setup Google Drive, Dropbox or CouchDB. I didn't have the time to setup Google Drive or Dropbox so I went to CouchDB. In fact anyone who uses StackEdit or your StackEdit instance can setup CouchDB to use with StackEdit.

I really recommend reading this documentation on how to setup CouchDB, but I'll give a brief overview here.

First go to SmileUpps. They offer free CouchDB hosting. Sign yourself up for an account. Then you'll want to setup a domain for your project.

Next you'll want to go into the CouchDB configuration to set a few items up.

CouchDB - SmileUpps

Click on the Configuration option from the right sidebar. You should see a new page with a table of configuration options. Scroll to the bottom and click on the 'Add a New Section' link and a little dialog box pops up. Enter in 'httpd' to the first field, 'enable_cors' to the second field and 'true' to the third field. Don't use the quotes of course though. Hit the Create button.

Couch DB CORS

Again, go to 'Add a New Section' and enter in 'cors' for the first field, 'origins' for the second field and 'http://localhost, https://yourdomain.com' for the third field.

Now back on your server you'll want to run the following commands:

curl -X PUT https://yourinstance.smileupps.com/documents
curl -O https://raw.githubusercontent.com/benweet/stackedit/master/couchdb/setup.js
node setup.js https://yourinstance.smileupps.com/documents

That should be all you need to get CouchDB going. I also recommend going to your StackEdit instance and update the CouchDB URL. Go to Menu > Settings > Advanced -- and set the CouchDB URL.

Finish Up!

Your StackEdit instance should be ready to roll. You can configure other items in the `` file.

One thing I had an issue was when sharing documents was that it kept using the stacked.io domain which would likely cause some confusion. So in order to remedy this I had to edit the ./public/res-min/main.js file in 2 places. The first is line 13692:

var l = "http://mydomain.com/" + "editor#!" + e.param(a);

and line 13703:

var l = "http://mydomain.com/" + "viewer#!" + e.param(a);

I restarted the application and all was well!

Notes

  1. My instance currently is not connected with any of the third party apps like Dropbox, Google Drive or Google Analysts. I do not believe it would be terribly difficult to set these items up but I just didn't have a time or a real need.
  2. This is one of the first self hosted apps which I haven't had to proxy with Nginx. That's nice!
  3. I am not sure if the app should be running as root or a less privileged account.
  4. I also removed the donation links and alert boxes since I had no real use for them on my internal site.
  5. I also removed the link to Classeur since I had no real use for that being there.
  6. I also noticed it looks like you can deploy your StackEdit instance to Heroku or Docker, but didn't give those a shot. Maybe someday!

StackEdit Self-Hosted

Resources

Reddit Self-Hosted

Reddit

I previously wrote about installing my own instance of Reddit but I haven't done a lot with. This post is really just to share a couple things I have been trying to work on to make the Reddit instance usable.

I've mostly just been working to try to get my instance to suck in text and link posts from the real reddit.com, however I know very little about Python so I currently am only able to fetch some posts, but I am not sure how I get them into my instance as a specific user. Here's my script so far:

#!/usr/bin/python

import praw
import logging

logging.captureWarnings(True)

r = praw.Reddit(user_agent="Ubuntu:reddit.local:v0.1 (by /u/jimmybreddit)")
subreddit=r.get_subreddit('Equestrian')

for submission in subreddit.get_new(limit=10):
    print "---------------------------------"
    print submission.title
    if submission.is_self == True
        print submission.selftext
    else
        print submission.url
    print "---------------------------------"

I am going to keep working on it, and hopefully one day I can get my Reddit instance to pull in posts as a bot. 😄

Update - November 18, 2015: I've been working on my Reddit API script and this is what I've come up with:

#!/usr/bin/python

import praw
import logging
import time
import calendar

logging.captureWarnings(True)

fh = open("/home/username/Scripts/announcements.date", "r")
previous = fh.read()

r = praw.Reddit(user_agent='Ubuntu:reddit.local:v0.1 (by /u/username)', site_name='reddit')
subreddit=r.get_subreddit('announcements')

for submission in subreddit.get_new(limit=50):
    if int(submission.created) > int(previous):
        if submission.is_self == True:
            rl = praw.Reddit(user_agent='Ubuntu:reddit.local:v0.1 (by /u/username)', site_name='local_dev')
            rl.login(username="$USERNAME", password="$PASSWORD")
            rl.submit('announcements', submission.title, text=submission.selftext)
            print "Submitting Text: " + submission.title
        if submission.is_self == False:
            rl = praw.Reddit(user_agent='Ubuntu:reddit.local:v0.1 (by /u/username)', site_name='local_dev')
            rl.login(username="$USERNAME", password="$PASSWORD")
            check = r.request_json("http://reddit.local/api/info/.json", params={"url": submission.url})
            if check == '':
                rl.submit('announcements', submission.title, url=submission.url)
                print "Submitting Link: " + submission.title

timenow = calendar.timegm(time.gmtime())
timenow = int(timenow) + 25200

fh = open("/home/username/Scripts/announcements.date","w")
fh.write(str(timenow))
fh.close()

So what this script does is connects with reddit.com and pulls the last 50 new submissions from a specific subreddit. It relies on a seprate file which stores the date of the last check and should only submit new submissions since that date. The date is stored in a Unix timestamp value. It also checks if the submission is a text post or link. If a link it checks the local installation to ensure the link hasn't been submitted to the subreddit before.

Now, I still had some issues with this, where submissions coming in from reddit.com where posted in the future. I have no idea how that happened. Due to this, it resulted in duplicate posts to my local installation, but beyond this the script worked well.

Also of note, this script uses no authentication to reddit.com and username and password authentication to the local installation. Obviously not ideal. It should be using OAuth2, but I didn't have time or patience to wrap my head around that.

Installing Hackpad

Hackpad

I started using the hosted version of Hacked about a year ago, however, ever since they got bought out by Dropbox I haven't been using them as much. I don't believe it was the buy-out that triggered it, but most likely another alternative solution that I used instead.

Back in April of 2015 the Hackpad team announced they would be releasing the source code to Hackpad so one could host it on their own server. I was absolutely enthralled. However, once the buy-out happened, it took quite a while for them to actually release the source. Finally though it happened!

It should be noted that it looks like Hackpad is actually just a prettied up version of Etherpad with a few extra features.

Installing Hackpad is actually pretty easy, especially if you're familiar with installing self-hosted applications and have some system administration experience.

I setup a VPS to run my Hackpad install on. It has 4 virtual-cores, 6GBs of RAM and a 60GB hard disk. I also installed CentOS 6.7 64bit as my operating system.

Install Java JDK

Once you've got your system setup, you'll want to snag a copy of Java JDK:

cd /usr/src
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz"
tar zxvf jdk-7u79-linux-x64.tar.gz

This will download the Java software and then uncompress it. Next you'll need to install it.

cp -Rva jdk1.7.0_79/ /opt/
cd /opt/
cd jdk1.7.0_79/
alternatives --install /usr/bin/java java /opt/jdk1.7.0_60/bin/java 2
alternatives --config java
export JAVA_HOME=/opt/jdk1.7.0_79
export JRE_HOME=/opt/jdk1.7.0_79/jre
export PATH=$PATH:/opt/jdk1.7.0_79/bin:/opt/jdk1.7.0_79/jre/bin

Install Git

Next we'll install Git.

yum -y install git

Get the Hackpad Source Code

Now it's time to get the source code for Hackpad!

cd /opt
git clone https://github.com/dropbox/hackpad.git

Install Nginx

Now let's go back over to /usr/src and snag Nginx.

cd /usr/src
wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
rpm -ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm
yum install nginx

Next, go into /etc/nginx/conf.d and create a hackpad.conf file.

cd /etc/nginx/conf.d
nano hackpad.conf

Place the following into the hackpad.conf file:

# Upstream configuration
upstream hackpad_upstream {  
     server 0.0.0.0:9000;
     keepalive 64;
 }

# Public
server {  
    listen 80;
    server_name ~^(.+)$; # domain of my site

   location / {
        proxy_http_version 1.1;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header   X-NginX-Proxy    true;
        proxy_set_header   Host             $http_host;
        proxy_set_header   Upgrade          $http_upgrade;
        proxy_redirect     off;
        proxy_pass         http://hackpad_upstream;
    }
}

Now make sure to enable Nginx on system start:

chkconfig nginx on

Install MySQL

Time to get MySQL installed. Use these commands to install MySQL 5.5.x.

yum -y install mysql-server
yum -y install mysql-client
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
rpm -q mysql mysql-server
yum install mysql.`uname -i` yum-plugin-replace
yum replace mysql --replace-with mysql55w
service mysqld start
/usr/bin/mysql_secure_installation

The last command will be a bit interactive and you'll be asked a few questions about root passwords and removing test data and such.

I also recommend setting MySQL to start on boot:

chkconfig mysqld on

Next bring up Nginx:

/etc/init.d/nginx restart

Install Scala

Now we need Scala!

cd /usr/src
wget http://www.scala-lang.org/files/archive/scala-2.11.7.tgz
tar xvf scala-2.11.7.tgz
cp -Rva scala-2.11.7/ /usr/lib/
ln -s /usr/lib/scala-2.11.7/ /usr/lib/scala
export PATH=$PATH:/usr/lib/scala/bin

Configuring Hackpad - Part I

Now we need to do a little bit of tweaking to the Hackpad files to get it to run properly in our CentOS environment.

cd /opt/hackpad/
nano bin/exports.sh

The following it what I need to change my exports.sh file to get it working in a CentOS 6.x environment:

# These lines assume you installed Scala via Homebrew.
export SCALA_HOME="/usr/lib/scala"
export SCALA="$SCALA_HOME/bin/scala"
export SCALA_LIBRARY_JAR="$SCALA_HOME/lib/scala-library.jar"

export JAVA_HOME="/opt/jdk1.7.0_79"
export JAVA="/opt/jdk1.7.0_79/bin/java"

Setting Up MySQL

The next part may be possible to do a different way, but I just wanted to get my Hackpad instance up and running quickly. First edit the following file:

nano contrib/scripts/setup-mysql-db.sh

Update the MySQL username and password, I just used the root MySQL user and password. That should be all you need to edit here. Now run this command:

contrib/scripts/setup-mysql-db.sh

This should populate MySQL with the necessary items to run Hackpad. Once that is done, I removed the credentials from the file.

Configuring Hackpad - Part II

I recommend creating a new MySQL user to use for your Hackpad. Google is great if you need some help creating a MySQL user and giving it access to the newly created hackpad database.

Next we'll want to create a configuration file for our Hackpad instance.

cp etherpad/etc/etherpad.localdev-default.properties etherpad/etc/etherpad.local.properties
nano etherpad/etc/etherpad.local.properties

If you followed my above recommendation on creating a new MySQL user, you'll want to edit the following in the configuration file:

etherpad.SQL_PASSWORD =
etherpad.SQL_USERNAME =

I also recommend editing the following as well:

topdomains =
customBrandingName =
customEmailAddress =
customEmailImapPassword =
supportEmailAddress =
etherpad.canonicalDomain =
smtpServer =
smtpUser =
smtpPass =

Save and you should be all set.

Build the App

Run this command which should build the app.

bin/build.sh 

Run the App

Now run this command which should start up the app. Upon first start it may take a minute so don't worry!

bin/run.sh

If all is well should be able to visit http://hackpad.yourdomain.com or whatever URL you've set it up within Nginx.

You can now create yourself an account via the web page interface of Hackpad. If you've setup the SMTP details you should have gotten an account verification email. If not, you'll need to go into the database to grab your token out of the email_signup table. Then visit a URL like this:

http://hackpad.yourdomain.com/ep/account/validate-email?email=YOUR_EMAIL&token=TOKEN

This will activate your account and you can start using Hackpad!

Notes

  1. I am not sure my MySQL installation notes are 100% right. I am thinking you may not need to do the yum install mysql-server and yum install mysql-client first. You may be able to just fetch the MySQL 5.5 repository and install that right off the bat. I just didn't have time to test this out.
  2. The SMTP stuff didn't work right even though I had filled out the SMTP details in the configuration file. I just got some giant Java error whenever the system tried sending an email. Having a second thought about this, it may be because I didn't install anything like Exim or Postfix, so that may be worth checking.
  3. Inserting images does not appear to be working. I assume images are uploaded to Amazon S3 but I can't seem to figure that out for sure. I didn't try using the URL of an image instead to use images in my documents but I assume that might actually work.

Hackpad

Resources

Installing Your Own Habitica Instance

My Habitica Instance - http://habitica.linuxbox.ninja

I subscribe to /r/selfhosted and they have a link to another fantasic page which lists tons of software you can host on your own system. From there I found Habitica which is:

Habitica is a free habit building and productivity app that treats your real life like a game. With in-game rewards and punishments to motivate you and a strong social network to inspire you, Habitica can help you achieve your goals to become healthy, hard-working, and happy.

I provisioned myself a new VPS with the following specs:

  • 80GB Disk Space
  • 4GBs RAM
  • 4-cores for CPU
  • Ubuntu 15.04

Now Habitica has some installation instructions which can be found here, but I found that I did some Googling around since I hit a couple snags while installing. So before we jump into getting Habitica installed there's some pre-requisites that need to be installed first.

I had some issues running npm install so I had to adjust my DCACHESIZE in the containers OpenVZ configuration. I used the following value(s):

DCACHESIZE="2109840:2147483647"

Of note, once I made this change, I restarted the container and confirmed I could then run npm install without issue.

MongoDB

Habitica utilizes MongoDB for storing data. I utilize this guide here for getting it installed into my Ubuntu 15.04 environment. You should be able to utilize the following steps to get it installed if on Ubuntu 15.04 (assuming you're running the commands as root:

  1. Install the MongoDB repository key:
    apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
  2. Now add the MongoDB repository to the system:
    echo "deb http://repo.mongodb.org/apt/debian wheezy/mongodb-org/3.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
  3. Now run apt-get update
  4. Now install MongoDB!
    apt-get install mongodb-org
  5. You can now run the following to ensure MOngoDB is up and running:
    sudo systemctl status mongod

NodeJS & NPM

Next we'll want to get NodeJS and npm installed. This should be pretty easy.

apt-get install python-software-properties
apt-add-repository ppa:chris-lea/node.js
apt-get install nodejs
apt-get install npm
apt-get install nodejs-legacy

Git - Cloning HabitRPG/habitrpg

Now we want to get the Habitca code to run. First you'll want to create your own fork of the Habitica code. This can easily be done from the GitHub interface. You can find the Habitica repository here.

Once you have your own fork, you can run the following:

git clone https://github.com/YourUsername/habitrpg.git
git remote add upstream https://github.com/HabitRPG/habitrpg.git

You can then run git remote -v and you should see output similar to this:

origin  https://github.com/YourUsername/habitrpg.git (fetch)
origin  https://github.com/YourUsername/habitrpg.git (push)
upstream    https://github.com/HabitRPG/habitrpg.git (fetch)
upstream    https://github.com/HabitRPG/habitrpg.git (push)

Of note, I put my Habitica code into /opt/ so it all lives in /opt/habitrpg.

Configuring and Running Habitica

We're almost there, just a few more steps. I found that you need to install the following package in Ubuntu to when running npm install.

apt-get install libkrb5-dev

Next run these commands to install some packages:

npm install -g gulp grunt-cli bower
bower install --allow-root
npm install

This should install everything that Habitica needs to run. Next you'll want to copy over the example configuration file:

cp config.json.example config.json

If you don't plan on using email then nothing needs to be done with the file. However if you plan on needing email to work you'll want to edit at least the ADMIN_EMAIL, SMTP_USER, SMTP_PASS and SMTP_SERVICE values.

Once that is done you should be ready to start up Habitica!

npm start

It may take a minute to start up, but when it does you should be able to visit http://localhost:3000.

Bonus Items - Nginx & Mailgun

Alright, so if you're like me and you've install Habitica on a remote VPS, obviously accessing http://localhost:3000 isn't going to work. This is were Nginx comes in and I use it as a proxy so I can access my Habitica instance at http://habitica.linuxbox.ninja instead. First you'll want to install Nginx:

apt-get install nginx

Next, you'll want to create a Nginx configuration file for Habitica:

cd /etc/nginx/site-available
nano habitica

Now you'll want to put the following into your habitica file:

# Upstream configuration
upstream shout_upstream {  
     server 0.0.0.0:3000;
     keepalive 64;
 }

# Public
server {  
    listen 80;
    server_name yourdomain.com; # domain of my site

   location / {
        proxy_http_version 1.1;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header   X-NginX-Proxy    true;
        proxy_set_header   Host             $http_host;
        proxy_set_header   Upgrade          $http_upgrade;
        proxy_redirect     off;
        proxy_pass         http://shout_upstream;
    }
}

Next, run this comamnd:

cd /etc/nginx/sites-enabled
ln -s /etc/nginx/sites-available/habitica .
/etc/init.d/nginx restart

Now you should be able to access your Habitica instance at your own domain!

If you'd like to use email with your Habitica instance you can set it up with a wide variety of services. I needed to use email to reset my password so I had to get it setup and running. You will need to open the config.json file in your favorite text editor and locate the following lines:

"SMTP_USER":"SMTP_USERNAME",
"SMTP_PASS":"SMTP_PASSWORD",
"SMTP_SERVICE":"mailgun",
"SMTP_HOST":"smtp.mailgun.org",
"SMTP_PORT": 587,
"SMTP_TLS": true,

I used Mailgun to handle email for my Habitica instance, but there's quite a wide variety of popular email services this can work with. I also tested Gmail and confirmed that works fine as well.

One of the really nice things about Habitica is that when you save this file, the server will reload itself automatically and use any new configurations.

Summary

I am still learning about how Habitica works, how the MongoDB schema is setup as well as about MongoDB commands as well. It's fun and I think Habitica will be a fun way to keep track of tasks I need to be doing. Anyone is welcome to sign up for an account on the server as well!

Resources

Minecraft: Story Mode - Episode 1 & 2

Minecraft Story Mode

Ever since seeing the trailing for Minecraft: Story Mode I've been pretty excited about the game. It just came out a couple weeks ago and I've had the chance to play through Episode 1 and 2 so far.

I don't intended to write a full and completely in-depth review in this post, but I wanted to give some thoughts I had.

The game itself is a lot of fun, and I really enjoy the story even if it's nothing new. The game for me it's been a nice break between the FPS shooters I've been normally playing. The characters are fun and funny in their own unique ways, even Ruben the pig has his own personality.

One thing which is turning me off from the game is that when I think of Minecraft and the Minecraft universe is that it's all about exploring and going off the beaten path to make your own. This game is very linear and allows for very little if any exploration. It's too bad because the design of the world is beautiful and vibrant and being someone who is curious, it's get frustrating at times when you're forced to go in a single direction throughout the game. I know that's to be expected and this isn't the Minecraft we normally think of, but it would be so nice to be able to just go off and explore the worlds and levels further then what's allowed.

Overall, I do enjoy the game, I just need to stop thinking that it's an exploration game like the normal Minecraft game and that it truely is 'Story Mode'. I am looking forward to Episode 3 😄 🎮

Hosting Your Own Ghostbin in 2019

I used a basic VM to get this going. You can likely do it with less. It has 2GBs of RAM, 80GBs of disk space and 2x 2.4GHz CPU cores. It was actually pretty easy to install, actually quite a bit easier then I remember.

Installing GhostBin
  1. Install your operating system. I used Ubuntu 18.04 Server.

  2. Install Go:

    cd /usr/local
    wget https://dl.google.com/go/go1.12.8.linux-amd64.tar.gz
    tar -C /usr/local -xzf go1.12.8.linux-amd64.tar.gz

    Add to the bottom of your /etc/profile file with:

    export PATH=$PATH:/usr/local/go/bin

    You can either also run that at your command prompt or logout and log back in.

  3. Install Mercurial and Python Pygments:

    apt install mercurial python-pygments
  4. Install ansi2html:

    apt install python-pip
    pip install ansi2html
  5. Install Git:

    cd /usr/local/src
    apt install autoconf libssl-dev zlib1g-dev libcurl4-openssl-dev tcl-dev gettext
    wget https://github.com/git/git/archive/v2.22.1.tar.gz
    tar zxvf v2.22.1.tar.gz
    cd git-2.22.1/
    make configure
    ./configure --prefix=/usr
    make -j2
    make install
  6. I recommend creating a new user to run your GhostBin code under:

    adduser ghostbin
  7. You should also set a password on the new user account using passwd ghostbin.

  8. Login as your new user account and add the following to your ~/.bashrc file:

    export GOPATH=$HOME/go
  9. Save and exit the file and run source ~/.bashrc.

  10. Next obtain the source code for GhostBin (login as your new user first):

    mkdir -p ~/go/src
    cd $HOME/go/src
    mkdir github.com
    cd github.com
    git clone https://github.com/DHowett/spectre.git
    cd spectre/
  11. At this point your full path should be something like - /home/ghostbin/go/src/github.com/ghostbin.

  12. Run go get.

  13. Run go build.

  14. Run which pygmentize. It should return /usr/bin/pygmentize. If not, no problem, just copy the path.

  15. You'll also want to run which ansi2html which should return /usr/local/bin/ansi2html. Again, if it doesn't no big deal, just copy the path.

  16. Now exit the languages.yml file and update the path for pygmentize which should be on line 6. Also update the path for ansi2html which should be on line 23. Save and exit. Here's my languages.yml up to line 25 to give you an example:

    formatters:
      default:
        name: default
        func: commandFormatter
        args:
        - /usr/bin/pygmentize
        - "-f"
        - html
        - "-l"
        - "%LANG%"
        - "-O"
        - "nowrap=True,encoding=utf-8"
      text:
        name: text
        func: plainText
      markdown:
        name: markdown
        func: markdown
      ansi:
        name: ansi
        func: commandFormatter
        args:
        - /usr/local/bin/ansi2html
        - "--naked"
      iphonesyslog:
  17. Next we'll need to build a CSS file which will give color to the pastes:

    pygmentize -f html -S $STYLE > public/css/theme-pygments.css

    You can choose from several styles/color themes:

    - monokai
    - manni
    - rrt
    - perldoc
    - borland
    - colorful
    - default
    - murphy
    - vs
    - trac
    - tango
    - fruity
    - autumn
    - bw
    - emacs
    - vim
    - pastie
    - friendly
    - native

    I used monokai:

    pygmentize -f html -S monokai > public/css/theme-pygments.css
  18. If all went well all that is left to do is to start the service:

    ./spectre
  19. Here's an screenshot of my install:
    GhostBin

  20. I would also recommend running the binary with the --help flag:

    $ ./spectre --help
    Usage of ./spectre:
      -addr string
            bind address and port (default "0.0.0.0:8080")
      -alsologtostderr
            log to standard error as well as files
      -log_backtrace_at value
            when logging hits line file:N, emit a stack trace
      -log_dir string
            If non-empty, write log files in this directory
      -logtostderr
            log to standard error instead of files
      -rebuild
            rebuild all templates for each request
      -root string
            path to generated file storage (default "./")
      -stderrthreshold value
            logs at or above this threshold go to stderr
      -v value
            log level for V logs
      -vmodule value
            comma-separated list of pattern=N settings for file-filtered logging

    This allows you to see flags you can run with the binary. I run mine as such:

    ./spectre -logtostderr

    This will just log the errors to the screen.

Setting Up GhostBin w/ Nginx
  1. Install Nginx:

    apt install nginx
  2. Create a Nginx configuration file for GhostBin:

    nano /etc/nginx/sites-available/ghostbin.conf
    # Upstream configuration
    upstream ghostbin_upstream {  
         server 0.0.0.0:8080;
         keepalive 64;
    }
    
    # Public
    server {  
        listen 80;
        server_name ghostbin.YOURDOMAIN.com; # domain of my site
    
        location / {
            proxy_http_version 1.1;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
            proxy_set_header   X-NginX-Proxy    true;
            proxy_set_header   Host             $http_host;
            proxy_set_header   Upgrade          $http_upgrade;
            proxy_redirect     off;
            proxy_pass         http://ghostbin_upstream;
        }
    }

    You'll obviously want to update the server_name bit. Save and exit the file.

  3. Next we need to make a symlink so Nginx knows to load the configuration:

    cd ../site-enabled
    ln -s ../sites-available/ghostbin.conf .
  4. Restart the Nginx service:

    systemctl restart nginx

    Your GhostBin site should now be available at http://ghostbin.YOURDOMAIN.com!

Other Notes
  • Whenever I start up the binary I see:

    E0815 21:19:58.915843   19895 main.go:773] Expirator Error: open expiry.gob: no such file or directory

    This doesn't appear to be an issue and I haven't had any issues with using GhostBin thus far. There seems to be some code in main.go referencing it. It looks related to the expiration of the paste, but I don't know GoLang so I can't be sure.

    pasteExpirator = gotimeout.NewExpirator(filepath.Join(arguments.root, "expiry.gob"), &ExpiringPasteStore{pasteStore})
  • It looks like the GhostBin repository has been renamed to 'spectre'. It looks like this was done to "de-brand" it for people who want to run it themselves and separate it from GhostBin.com where I believe the developer run their own copy. See this commit.

  • You should definitely set up your install with Let's Encrypt for SSL.

Xserve + OS X Yosemite 10.10.5

1A2F2wqi.png

Xserve + OS X Yosemite 10.10.5

This year I aquired a 2006 Xserve for relatively cheap. Unfortunately I hadn't realized that in order to bring it up to date in terms of putting a later version of OS X on it I would need a new graphics card that was supported by the later versions of OS X.

Just this last week I also managed to get my hands on a 2009 MacPro which came with two NVIDIA GT 120 video cards. I pulled one and placed it into the Xserve. After a few hours of hacking apart the OS X installer, I finally had OS X 10.10.5 running on it!

Requirements

  • 8GB+ USB Flash Drive
  • Copy of OS X Yosemite installer app
  • 2GBs of RAM on destination Mac
  • Flat Package Editor
  • Pacifist

Creating Modified OS X Yosemite Installer

  1. Open Disk Utility and format your flash key. Ensure to set the Scheme as GUID and format as OS X Extended (Journaled) / HFS+.
  2. Download the OS X Yosemite installer from the App Store.
  3. Once the installer has finished downloading it, I recommend making a copy of it. I placed my copy into ~/Downloads/tmp/. Right click on the copy you've made, and select, Show Package Contents. Go to /Contents/Resources/SharedSupport and open the .dmg file.
  4. You will now need to show hidden files which can easily be done with a Terminal command: defaults write com.apple.Finder AppleShowAllFiles YES && killall -9 Finder
  5. Now navigate to the .dmg file you've just mounted. Locate the BaseSystem.dmg file. This part may be a bit tricky depending on the system you're working on. I did this on OS X El Capitan where the Disk Utility app got quite the overhaul. Previous to this you were able to just drag an image file into the sidebar however in El Capitan it seems to be a bit of a different process. I first went to Images >> Scan Image for Restore and selected the BaseSystem.dmg. Once the scanning is done, then click on the partion (not the root device) and go again to Image from the menu bar but this time choose the Restore option. Select the BaseSystem.dmg file. I believe it took about 5-10 minutes to complete.
  6. Once the restore is done, go back over the .dmg you originally mounted and and copy the Packages folder. Paste this folder into your flash key to the directory, /System/Installation/. This will take a bit longer as it's about 5.5GBs in size. It took about 30-45 minutes when I did this.
  7. You will now need to start editing some of the installer files. It's very important these files do not get corrupted or edited incorrectly. You must be very careful to ensure you're replacing the right things else your installer won't work. You may want to create copies of the files you're editing before you do so, just in case something goes wrong.
  8. First you'll need to obtain your Mac's Board-ID value. If you have OS X already running on the Mac you're wanting to upgrade you should be able to use an app, IORegistryExplorer.app, which can provide this ID to you. If you don't, there's a fantastic list of IDs here. Once you have your ID, go to your flash key and open the following file in a text editor (I recommend Atom), /System/Installation/Packages/InstallableMachines.plist. Go to the last ID and replace it with your own. I have my .plist file here if you want to reference or even use it. It's been modified for the Xserve 1,1 model.
  9. Next you'll want to open and edit /System/Library/CoreServices/PlatformSupport.plist. You can reference or use mine, it is pre-edited for the Xserve 1,1 model. You'll want to again put in the board ID as well as the model.
  10. On your flash drive, make a copy of the following file, /System/Installation/Packages/OSInstall.mpkg. I put mine into ~/Downloads/tmp/. Open your copy of the OSInstall.mpkg in the Flat Package Editor. Extract the Distribution file and open it in your text editor. Locate the var platformSupportValues=[" ... "]; section and add your board ID value here. You can see my edited file here. Save and then replace the original file inside the OSInstall.mpkg. You'll want to delete the original from the .mpkg file and the insert your edited file. Save the OSInstall.mpkg file and replace it into the flash drive at /System/Installation/Packages/.
  11. Again, go to the .dmg you originally mounted and copy the BaseSystem.dmg and BaseSystem.chunklist and paste them into the root of your flash drive.
  12. Using Pacifist open the following file from the original .dmg that was mounted - Packages >> Essentials.pkg. Once this is opened up navigate to /System/Library/Kernels and extract the kernel file.
  13. Go to your flash key, and navigate to /System/Library. Create a new directory in here called, Kernels. Take your extracted kernel file and place it into this new directory.
  14. This step is somewhat optional, but very important if your system has 32-bit EFI. You will need to download a modified boot.efi file. I used the one here, and it seemed to have no issues. You'll want to copy this boot.efi into the following two locations on your flash drive, /System/Library/CoreServices/ and /usr/standalone/i386/.
  15. At this point your installer should be all ready to rock and roll. Moment of trust, you'll attach it to your Mac and boot from it. You can hold the Alt key to get to a list of bootable drives connected to the Mac if it doesnt automatically boot from it.
  16. Hopefully your install has gone without a hitch. Once you've installed and rebooted into OS X Yosemite, I highly recommend installing the PikeYoseFix script. This will allow you to install any OS updates without issue. Normally during an OS update some files will get replaced which can prevent the system from booting.

Resources

Well this is definitely awesome. 👍