となりのトトロ

Source.



ハウルの動く城

Source.



千と千尋の神隠し



「山賊の娘ローニャ」 予告動画

Studio Ghibli going to be doing some TV now! 😄



Travel Advice Calendar: Tokyo



Shibuya, Tokyo, Japan 4K (Ultra HD) - 渋谷/東京



Creating a Disk Image of a Hard Drive

This one is really useful if you want to take a quick backup of an entire hard drive. 💻

root@server.server.com:~# dd if=/dev/sda of=/backup/hdadisk.img

Of course make sure you input the correct if and of values where if is the source drive and of is the output file. 👍 Enjoy!



Reading and Writing to an HFS+ Disk in Linux

This past week I had to take a backup of one of my servers, but the only drive I had laying around with HFS+ formatted (Mac OSX). After fiddling around in Knoppix and going through a bunch of Google search results, I think I finally found the right combination of tools and commands to get the HFS+ formatted drive to show up under Knoppix as both read and write.

First, you'll want to make sure you get hfsprogs installed. As mentioned, I was in a Knoppix live environment, so using the following command worked for me:

root@Microknoppix:/# apt-get install hfsprogs

Now with this utility installed you should be able to mount your drive:

root@Microknoppix:/# mkdir /mnt/drive
root@Microknoppix:/# mount -t hfsplus -o force,rw /dev/sdXY /media/mntpoint
root@Microknoppix:/# cd /mnt/drive

Now it may also be possible to use this command if you previously tried mounting the drive without having hfsprogs installed. Without hfsprogs it can likely still mount the drive but it will be mounted as read-only.

root@Microknoppix:/# mkdir /mnt/drive
root@Microknoppix:/# mount -t hfsplus -o remount,force,rw /mount/point
root@Microknoppix:/# cd /mnt/drive

In any event, your HFS+ drive should now be mounted as read and write! 👍

Resources:



New Super Mario Bros. U



Installing Your Own Reddit Server

Reddit is apparently a pretty popular website. So how about having your own Reddit website?! Not only can you create your own subreddits but you can be the administrator of the whole entire thing. Cool!!

Head on over to the reddit GitHub page and visit this wiki page in particular. You mostly just need to follow the directions provided here, however there's a couple extra things I would like to add in.

Firstly, it's really important you follow their direction on the Linux distribution to use, Ubuntu 12.04. I'll go ahead and give another shoutout to my favorite DigitalOcean since they're so easy to get setup and running.

Once you've gotten your Ubuntu instance going login as the root user. Next install screen and less. These aren't necessary but I find that they're useful tools. It's possible they may already been installed.

root@reddit:~# apt-get install screen less

Next add a new user account. This account is where Reddit will be installed too.

root@reddit:~# adduser reddit

You'll likely get prompted to input a password and possible some extra information about the user. I usually just input the new password and hit Enter for the remaining questions (such as first name, last name, etc...).

Now let's add that user to the sudoers file.

root@reddit:~# nano /etc/sudoers

Now, this may not be 100% sure or the 100% proper way to do this as this basically provides your user complete root access but it will ensure that Reddit installs itself correctly. That said, add this line to the above file.

reddit ALL=(ALL) ALL

Save your changes. Now grab a copy of the Ubuntu Reddit installer script and set execute permissions on it. You'll want to do this as the reddit user (assuming your non-root account is named reddit - mine is).

reddit@reddit:~$ wget https://raw.github.com/reddit/reddit/master/install-reddit.sh
reddit@reddit:~$ chmod +x install-reddit.sh

Now, as recommended by the official wiki article, you may want to review and check through the script. If you feel so inclined:

reddit@reddit:~$ less install-reddit.sh

Alright, hopefully that was a fun read. Let's install it! 😄 Fortunately this is probably the most easy part, assuming nothing errors out.

reddit@reddit:~$ REDDIT_DOMAIN=yourdomain.com ./install-reddit.sh

The install shouldn't take very long, I believe it took 10 minutes at most on my little VPS instance. If all ended well, you'll see some nice output about what URL to use to visit your instance as well as some information on how you can populate your Reddit install with some demo data.

All done! 👍

Resources:



「Junk Head 1」 FULL English

This guy and his video are really amazing.



Install GitBucket w/ Nginx

I previously wrote an article to get GitBucket working with Heroku which was awesome for testing purposes, however if you actually plan on using GitBucket, you probably want an environment that saves your data and users! Fear not, it's easier then I thought. Follow this guide to get GitBucket working in a production-like environment.

Install Your Server

I used CentOS 6 x86_64 for my server. I just got it running in a VPS environment. You can use DigitalOcean, it's nice and cheap and super easy to use.

Install Java

Next you'll want to make sure Java is installed. This is quite simple as well.

cd /opt/
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/7u60-b19/jdk-7u60-linux-i586.tar.gz"

This will download Java for you. Next let's unpack the archive.

tar zxvf jdk-7u60-linux-i586.tar.gz

Next, we'll use Alternatives to get Java installed to your system.

cd /opt/jdk1.7.0_60/
alternatives --install /usr/bin/java java /opt/jdk1.7.0_60/bin/java 2
alternatives --config java

You should get the output of something like:

There is 1 program that provides 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           /opt/jdk1.7.0_60/bin/java

Just hit the 'Enter' key at the prompt and it'll proceed with your installation. If all went well Java should be installed:

[root@git jdk1.7.0_60]# java -version
java version "1.7.0_60"

You'll also want to setup some environment variables:

export JAVA_HOME=/opt/jdk1.7.0_60
export JRE_HOME=/opt/jdk1.7.0_60/jre
export PATH=$PATH:/opt/jdk1.7.0_60/bin:/opt/jdk1.7.0_60/jre/bin

That completes the installation of Java onto your system.

Install GitBucket

Next grab a copy of the latest release of GitBucket. The version as of writing was 2.0.

cd /opt
mkdir gitbucket
cd gitbucket/
wget https://github.com/takezoe/gitbucket/releases/download/2.0/gitbucket.war

That's pretty much all we'll do with it for now. We'll come back to the war file in a bit.

Install Nginx

Since I prefer to not have :8080 in my URLs and I like Nginx, I'll install it as a front-end proxy to GitBucket. It's really easy!

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

If all went well you should see something like:

Installing : nginx-1.6.0-1.el6.ngx.x86_64                                                                                                                                                                   1/1 
----------------------------------------------------------------------

Thanks for using nginx!

Please find the official documentation for nginx here:
* http://nginx.org/en/docs/

Commercial subscriptions for nginx are available on:
* http://nginx.com/products/

----------------------------------------------------------------------
  Verifying  : nginx-1.6.0-1.el6.ngx.x86_64                                                                                                                                                                   1/1 

Installed:
  nginx.x86_64 0:1.6.0-1.el6.ngx                                                                                                                                                                                  

Complete!

Now, we'll need to add a configuration file for your GitBucket install. Navigate to the /etc/nginx/conf.d folder and create a file named gitbucket.conf:

nano gitbucket.conf

Simple! Now add the following into the file:

server {
        listen   80; # The default is 80 but this here if you want to change it.
        server_name gitbucket.example.com;

  location / {
    proxy_pass              http://localhost:8080;
    proxy_set_header        Host $host;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_connect_timeout   150;
    proxy_send_timeout      100;
    proxy_read_timeout      100;
    proxy_buffers           4 32k;
    client_max_body_size    500m; # Big number is we can post big commits.
    client_body_buffer_size 128k;

  }
}

Remember to change the server_name setting to your URL. In my case I did:

server_name gitneko.com;

Also, you may want to set Nginx to start up on boot.

chkconfig nginx on

Running GitBucket

You're on the final stretch! Open a new screen (you may need to install screen if it's not installed already).

screen
cd /opt/gitbucket
java -jar gitbucket.war

This will start up GitBucket. Once it's started up hit Ctrl+A, Ctrl+D to get out of screen. Now we're going to start up Nginx.

/etc/init.d/nginx restart

Don't worry if you see something like:

[root@git conf.d]# /etc/init.d/nginx restart
Stopping nginx:                                            [FAILED]
Starting nginx:                                            [  OK  ]

It only failed to stop because it wasn't running. You could even just start instead of restart...

At this point you should be able to visit http://yourdomain.com and you'll see your GitBucket instance running! Done and done!

Updating GitBucket

Thankfully the developers of GitBucket have made it extremely easy to upgrade GitBucket. You simply need to download the new .war file and replace your current one with it. I then recommend restarting Nginx as well for good measure.

Resources



Pixel Totoro!

Source.



How To Install Dreamwidth

Ever since 2007 or so I've been running and managing Scribbld.com. Since then we've been using the LiveJournal open source code to run the site. In the beginning the code was managed by a group of really great people and developers, however during the past 10 years or so LiveJournal has swapped hands far more then I can count. Even in the beginning the code wasn't all that easy to manage or upgrade, so much so that I believe I only updated the code-base once. It was nothing short of a nightmare.

After much thought and deliberation I've decided to switch my LiveJournal-based site over to using the Dreamwidth-based code. Dreamwidth utilized the LiveJournal code a few years back and has forked it and done some really awesome stuff with it. Most (if not all) of it remains to be BML/Perl which I really dislike but at least it's continually being updated and is managed at GitHub which I really enjoy using.

For those wishing to run Dreamwidth (or rather a Dreamwidth clone if you may) this guide should help a lot of you to get going. This guide is heavily based on the one Dreamwidth has provided however it includes a few new things.

Firstly you'll need your own server with which you have root access too. I used Ubuntu 14.04 x86_64 without any issues. It has about 160GBs of disk space and 4GBs of RAM. Remember, Perl likes to eat all your memory, so having lots of RAM is going to help a lot.

Update Your System

I started off with a fresh Ubuntu 14.04 install, a clean, blank slate. However, it's also important to make sure your system software is up to date. Simple.

apt-get update
apt-get upgrade

If you'd like to have man pages on your system (may already be installed):

apt-get install man

Next you'll need a bunch more software to run Dreamwidth.

Installing Necessary Packages

apt-get install git-core subversion apache2-mpm-prefork \
  libapache2-mod-perl2 libapache2-mod-apreq2 libapache2-request-perl \
  mysql-server wget unzip links vim libclass-autouse-perl \
  libdatetime-perl libcache-memcached-perl libhash-multivalue-perl \
  libgd-gd2-perl libhtml-template-perl libwww-perl libmime-lite-perl \
  libnet-dns-perl liburi-perl libxml-simple-perl libclass-accessor-perl \
  libclass-data-inheritable-perl libclass-trigger-perl libcrypt-dh-perl \
  libmath-bigint-gmp-perl liburi-fetch-perl libgd-graph-perl \
  libgnupg-interface-perl libmail-gnupg-perl perlmagick \
  libproc-processtable-perl libsoap-lite-perl librpc-xml-perl \
  libstring-crc32-perl libtext-vcard-perl libxml-atom-perl libxml-rss-perl \
  libimage-size-perl libunicode-maputf8-perl libgtop2-dev build-essential \
  libnet-openid-consumer-perl libnet-openid-server-perl libyaml-perl \
  libcaptcha-recaptcha-perl libdbd-sqlite3-perl libtest-simple-perl \
  libtemplate-perl libterm-readkey-perl \
  gcc libtest-most-perl libgearman-client-perl \
  libbusiness-creditcard-perl liblwpx-paranoidagent-perl \
  libtheschwartz-perl libfile-type-perl libjson-perl

Their instructions also included libtest-simpleunit-perl but I found this package was not necessary and haven't come across any issues without having installed it. This will download about 110MBs of data and then install it to your system. During this time you may be asked to setup MySQL, however it's very simple, and should only ask a couple questions such as setting up the root password for MySQL.

Set Apache to Use MPM Pre-fork

If you've used the above one-liner it should install the Prefork module for Apache, however it may not configure it to use it. By default my copy of Apache was set to use MPM Event. Easy enough to change though.

a2dismod mpm_event
a2enmod mpm_prefork

Install Extra Perl Modules

Next you'll need to install a few more Perl modules the Dreamwidth code will need to run. Each line below is a single command. To save you from having to run the first one twice, you should run these commands first:

locale-gen en_US en_US.UTF-8
dpkg-reconfigure locales

This just configures language locales on the system, which the Perl modules appear to require before being installed.

cpan Bundle::CPAN   # this will guide you through setting up CPAN
cpan GTop  
cpan Digest::SHA1
cpan Unicode::CheckUTF8
cpan MogileFS::Client   # this is necessary even if you don't use MogileFS
cpan TheSchwartz::Worker::SendEmail
cpan TheSchwartz::Worker::PubSubHubbubPublish
cpan Digest::SHA256
cpan Text::Markdown
cpan Image::ExifTool

Install Postfix

Next install Postfix and configure it. The configuration is relatively easy to go through. I won't get into how to configure it, there's Google for that.

apt-get install postfix

Set Timezone to UTC

For whatever reason Dreamwidth requires the timezone to UTC.

dpkg-reconfigure tzdata

Setup a 'dw' User Account

Add the account to the system:

adduser dw

Next add the user to the sudo group:

usermod -a -G sudo dw

Get the Dreamwidth Code!

These next few commands will have you run them as the dw user account.

su - dw
export LJHOME=/home/dw/dw
echo $LJHOME

The final command above should return /home/dw/dw.

Next you'll need to get yourself a free GitHub account. Once that is done fork the follow repositories:

Here's a quick overview of how the repositories will work together:

  • dw-free is the main repository and goes into $LJHOME
  • other repositories will go into $LJHOME/ext
  • personal config files go into $LJHOME/ext/local
  • All code from dw-free ($LJHOME) and the additional repos under $LJHOME/ext are automatically live when you start your server. There's no need to run any additional syncing steps anymore.

Setup dw-free

# clone a copy of the repository onto your machine
cd ~/
git clone https://USERNAME@github.com/USERNAME/dw-free.git $LJHOME
cd $LJHOME

# and let's make it aware of the dreamwidth repository so we can grab updates later
git remote add dreamwidth https://github.com/dreamwidth/dw-free
git fetch dreamwidth
# we also want to sync up with the main branches
git branch --set-upstream develop dreamwidth/develop 
git branch --set-upstream master dreamwidth/master

You'll want to replace the USERNAME bits with your GitHub username. This will make your repository an authenticated version that can push changes back to Github, as opposed to only being able to pull them.

I am leaving out the setup the dw-nonfree code since I did not use that repository, however you can refer to their guide for more information on how to set it up.

Database Setup

MySQL should already be installed, setup and running at this point. Next you'll need to create a couple databases. First get logged into MySQL.

mysql -u root -p

Next you'll run a couple commands to actually setup the database(s):

create database dw;
grant all on dw.* to 'dw'@'localhost' identified by 'SomePassword';

Next you'll add a database for TheSchwartz.

create database dw_schwartz;
grant all on dw_schwartz.* to 'dw'@'localhost' identified by 'SomePassword';

You can then quit out of MySQL.

Setting Up The Configuration Files

The next part may be the most time consuming part. You'll need to edit your configuration files. There are three really important configuration files for the whole install, so it's good to learn which configuration values are store in each file.

## copy over your config files, and tell them to take priority
## over config files in any of the repos
cd $LJHOME
mkdir -p ext/local/etc
echo "highest"  > ext/local/.dir_scope
cp doc/config-local.pl.txt ext/local/etc/config-local.pl
nano ext/local/etc/config-local.pl

Note that the $IS_DEV_SERVER flag is set to 1 in the template given. Be sure to set this to 0 for a production site, as there are big security issues involved with leaving the flag set to 1.

Next, you need to change your local variables in the config-private.pl file. This is where your passwords are configured, as well as many of the variables which define your domain. You will want to change at least your $DOMAIN and the %DBINFO structure.

cd $LJHOME
cp doc/config-private.pl.txt ext/local/etc/config-private.pl
chmod go-rwx ext/local/etc/config-private.pl
nano ext/local/etc/config-private.pl

Note that there are two DBINFO blocks; make sure to get them both.

Run checkconfig.pl

Once you've updated your configurations you'll want to run a check script which looks over your install to make sure any necessary packages and software have been installed. I believe the first time I ran this one or two packages came up missing. Fortunately the script let's you know which packages are missing and even provides necessary commands to get them installed.

cd $LJHOME
bin/checkconfig.pl --no=ljconfig

Populate the database

Now let's get some structure and initial data into the database.

$LJHOME/bin/upgrading/update-db.pl -r --innodb
$LJHOME/bin/upgrading/update-db.pl -r --innodb # at least for now we have to run this twice
$LJHOME/bin/upgrading/update-db.pl -r --cluster=all --innodb
$LJHOME/bin/upgrading/update-db.pl -p

Next, you'll populate the dw_schwartz database:

mysql -u dw -p dw_schwartz < /usr/share/doc/libtheschwartz-perl/schema.sql

Create a system user account

Now, we'll create a initial system account. This lets you login as the system user and generate invite codes and set privileges to other user accounts.

$LJHOME/bin/upgrading/make_system.pl

Load Translation Strings

Next, you'll run a tool to load in translations strings.

$LJHOME/bin/upgrading/texttool.pl load

Configure Apache

You will need configure Apache next. You'll want to do this as the root user account. Put the following into /etc/apache2/sites-available/stage.conf:

User dw
Group dw
UseCanonicalName off

StartServers 1
MaxSpareServers 2
MinSpareServers 1
   
DocumentRoot /home/dw/dw/htdocs
   
PerlSetEnv  LJHOME /home/dw/dw
PerlPassEnv LJHOME
   
PerlRequire  /home/dw/dw/cgi-bin/modperl.pl

Now you'll want to disable the default site, and enable this new site:

a2dissite default
a2ensite stage

Go ahead and restart Apache. Hopefully you'll get no errors.

/etc/init.d/apache2 restart

Extra Notes

It appears for some reason the default language is set to en_DW in the $LJHOME/etc/config.pl. Change:

@LANGS = qw( en_DW );

to

@LANGS = qw( en );

There also appears to be an issue with some of the code utilizing remote_ip instead of client_ip. It's possible this is due to the code being older and being developed for older versions of Apache then what I have installed. Fortunately it's easy to fix. You'll need to edit a bit of code here. On line 173 of /home/dw/dw/cgi-bin/DW/Request/Apache2.pm:

# returns the ip address of the connected person
sub get_remote_ip {
    my DW::Request::Apache2 $self = $_[0];
    return $self->{r}->connection->remote_ip;
}

to

# returns the ip address of the connected person
sub get_remote_ip {
    my DW::Request::Apache2 $self = $_[0];
    return $self->{r}->connection->client_ip;
}

Next in /home/dw/dw/cgi-bin/Apache/BML.pm on line 1919 change:

sub get_remote_ip
{
    my $apache_r = BML::get_request();
    return $apache_r->connection()->remote_ip;
}

to

sub get_remote_ip
{
    my $apache_r = BML::get_request();
    return $apache_r->connection()->client_ip;
}

Getting the Shopping Cart Working

If you'd like to get the basic shopping cart working, you'll first want to setup API keys for PayPal. Just login to your PayPal account, go to Tools and then under Manage your business click on API Access. Go through the setup process there. Once finished you'll end up with an API username, password and signature. Note, that some menu options or page locations may be different within PayPal when you read this. You'll copy those into the $LJHOME/ext/local/etc/config-private.pl file. Now open up the $LJHOME/ext/local/etc/config-local.pl file and locate %SHOP. You can edit this to your liking (setting pricing and such). It should look something like this when you're done:

# shop/pricing configuration
    %SHOP = (
        # key => [ $USD, months, account type, cost in points ],
        prem6  => [  20,  6, 'premium', 200 ],
        prem12 => [  40, 12, 'premium', 400 ],
        paid1  => [   3,  1, 'paid', 30    ],
        paid2  => [   5,  2, 'paid', 50    ],
        paid6  => [  13,  6, 'paid', 130   ],
        paid12 => [  25, 12, 'paid', 250   ],
        seed   => [ 200, 99, 'seed', 2000   ],
        points => [],     # if present, sell points
        vgifts => [],     # if present, sell virtual gifts
        rename => [ 15, undef, undef, 150 ],
    );

Getting YouTube API

If you'd like to utilize YouTube/embeds on your site, first edit the $LJHOME/ext/local/etc/config-local.pl and edit this:

# additional domain from which to serve the iframes for embedded content
# for security reasons, we strongly recommend that this not be on your $DOMAIN
$EMBED_MODULE_DOMAIN = "embed.your-domain.com";

I have two domains, so I just put the URL on the secondary domain.

Next, you'll need to get an API access key to YouTube. For this I ended up Googling 'YouTube API key'. Basically you just need to go here and register your site and choose the YouTube Data API. Copy over your key(s) into the $LJHOME/ext/local/etc/config-private.pl file and you should be all set.

Adding Privs

As a rule of thumb I don't use the system account. I setup my own account and add any necessary privileges onto the account which I may need. The ones I used are as follows. To add these to my personal account, I do this from the system account $URL/admin/priv/. Here's what I add. They're mostly privileges which let me manage the FAQs and help requests.

faqadd *
faqcat
faqedit *
payments
siteadmin
supportchangesummary
supportclose
supporthelp
supportmakeinternal
supportmovetouch
supportread
supportviewinternal
supportviewscreened
supportviewstocks
suspend
sysban
vgifts *

Setting Up Workers

For your website to be fully functional you'll want to configure some workers to handle various jobs around your website. I mostly just went off the wiki page for this.

Other Recommended Reading

So there you have it, that's how you can setup your own Dreamwidth-based website!



JohnnyExpress

This is one of the most fantastic things I've seen in a while.



Jimmy B.

Technical Analyst Supervisor at cPanel. Equestrian. Snowboarder. Gamer. Web Developer. I love my German Shepherd!
🐴🎮🍃

Search



Instagram

Twitter