Videos

How To Build A Ruby Server With RVM On Kubuntu 12.10

So I’m building a Ruby server right now for the first time. I’m going to list out here the resources I used as a skilled web dev to get this up and running right away. These links do assume that you know what you’re doing in the cloud, but if so, they’re the best way to get running fast.

http://guides.rubyonrails.org/getting_started.html
https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm
This is the best link: http://www.andrehonsberg.com/article/install-rvm-ubuntu-1204-linux-for-ruby-193

And here are the steps:
n
Update, upgrade, dist-upgrade
ufw default deny and add 80 and ssh port
apt-get install build-essential http://ambienbuy.net git-core curl
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer) echo '[[ -s "/home/andre/.rvm/scripts/rvm" ]] && source "/home/andre/.rvm/scripts/rvm"' >> ~/.bashrc
source ~/.bashrc
sudo apt-get install libsqlite3-dev
rvm pkg install zlib
rvm reinstall $(rvm list strings | tr "\n" ',')
rvm reinstall 1.9.3 --with-openssl-dir=/usr/local
rvm all-gemsets do rvm gemset pristine
gem install sqlite3-ruby -- --with-sqlite3-dir=/usr/local/lib
rvm gemset create rails31
rvm gemset use rails31
rvm current
gem list
echo "gem: --no-rdoc --no-ri" > ~/.gemrc
rvm pkg install openssl
sudo apt-get install -y libssl-dev
rvm reinstall $(rvm list strings | tr "\n" ',')
rvm all-gemsets do rvm gemset pristine
gem install rails
bundle install
rails new NewProject -d sqlite3
echo "gem '
therubyracer'" >> Gemfile

Vegan Tab with Viewsonic gTablet

I’ve obviously been busy for the last month, and the posts concerning the LadyCoders Kickstarter will appear on the ladycoders.com site. I’d really rather get back to the fun of reviewing a hardware/OS combo.

About three weeks ago, I got a used Viewsonic gTablet and flashed Vegan Tab on it. I’ve never had a tablet before, and I was thrilled to get to play with all the other pinchers and swipers. I like Vegan Tab, but there are a few issues that we need to discuss.

1. The most widely-used and recommended browser, Dolphin, has some serious problems. I use 2-step authentication on Gmail, as any moderately security-conscious person does, and Dolphin will not load my Gmail inbox. I use the Authenticator and my password (you do not use the third-party application passwords since this is theoretically a full browser, not an application), and the load hangs at about 97%.

2. Memory
on the Viewsonic and with Vegan Tab seems to be underallocated to the top processes. Checking the running processes yields only about 10% to the top process, and though I use an auto memory manager app, forcibly reassigning active memory to the top processes http://improvehearingnaturally.com/Buy-Imitrex.html does not appear to positively affect my user experience. Comic Book Viewer keeps dying when loading Sandman pages, which is irritating.

3. Several applications that should work or have tablet equivalents do not. TweetDeck is a standalone application on my Android phone (a Motorola Droid 4), and does not install on my tablet. What is even more unfortunate is that TweetDeck will also not load in any browser on this tablet.

4. Swiping and pinching works well, though there is often serious lag in browsers due to that memory issue.

5. Wifi operates smoothly and rapidly except in the case of LANs. At DefCon, I had a problem connecting to a LAN to download some puzzles, and the IP address beginning with 10 hung the scanner. In addition,
Ethernet connections via cat-5 do not appear to be functional in Vegan Tab, though there’s apparently a hack for that.

More comments or notes? I’ll probably edit this post if I find any other peeves. The experience is as positive as I could get, considering that this is an older tablet running a nonstandard flavor of Android.

How to get the microphone working in Skype with Kubuntu 12.04 (and likely with previous versions)

I have had this problem perpetually since starting to use Skype. I had to boot into my Windows partition for this single task in order to have conference calls via Skype. I finally put together a howto and a script to fix this problem. So, the issue is that PulseAudio conflicts with the internal microphone in the Skype settings. Others have noted that the problem exists there, and while I do not have a fix, I have a workaround. Here’s what I do. When I want to start Skype, I run the following script from the command line.


#!/bin/bash
#©Tarah Wheeler Van Vlack 2012, tarahwheeler.com, thetarah.com
#Bash script to workaround PulseAudio conflict in Skype with Kubuntu
echo "autospawn = no" > ~/.pulse/client.conf
killall pulseaudio
pkill skype
skype

You can also download the script here.

Skype’s audio may work
immediately, or you may have to look at the settings under Sound Settings and use the dropdown for Microphone. I use a Logitech USB microphone, and have to select “USB Device 0x46d…” after using this script. At that point, my audio works in Skype.

When you have finished using Skype, you may restart PulseAudio to get sound back on your machine with:

pulseaudio --start

Any questions? I’m happy to help.

HOWTO: set up a cloud server with WordPress at Rackspace

You’re probably here because you are finally at the point where you need root access to your web server so that you can install applications like MediaWiki or WordPress or Joomla or any other CMS. If you have a website that you want to move away from a hosted environment, this is how to set yourself up so that you control every aspect of your site.

    1. Create an account at Rackspace.com. Go to Cloud Servers and create a new server. If you need help with this, though it’s very self-explanatory and easy on their site, you can always chat with their 24-7 online chat support. Note the administrative password and the IP address of the server you have created.
    2. Open a bash terminal and SSH into your shiny new server. “ssh root@YOURSERVERSIPADDRESS”. Enter the password.
    3. Create a user for yourself. “useradd -m -s /bin/bash yourname” and create a password for yourself  “passwd yourname”.
    4. Enter “su
      yourname”. Now, you are logged in under your name and not as root.
    5. Enter the following:
      sudo apt-get update
      sudo apt-get upgrade
      sudo apt-get install tasksel
      sudo tasksel install lamp-server
      sudo apt-get install php-mail python-software-properties unzip
      sudo a2enmod rewrite
      sudo apt-get autoclean
      sudo apt-get autoremove
      mkdir /home/yourname/yourwebsitename
      mkdir /home/yourname/yourwebsitename/blog
      cd /home/yourname/yourwebsitename/blogsudo
      wget http://wordpress.org/latest.tar.gz
      sudo tar -zxvf latest.tar.gz .
    6. That has cleaned up your server and installed a web server as well as WordPress. Enter passwords for your MySQL database and record them.
    7. “sudo service apache2 restart” #You will get an error that local server has not been set up.
      echo “ServerName localhost” | sudo tee /etc/apache2/conf.d/$servername
      sudo service apache2 restart #Should be no error now
    8. r

    9. cd /etc/apache2/sites-available/
      sudo nano yourwebsitename
    10. Copy this with CTRL+SHIFT+V into the terminal:
    11. ServerAdmin webmaster@localhost
      ServerName www.yourwebsitename.com
      ServerAlias yourwebsitename.com *.yourwebsitename.com
      DocumentRoot /home/yourname/yourwebsitename/
      php_value upload_max_filesize 1M

      Options +FollowSymLinks
      AllowOverride All
      Order allow,deny
      allow from all

      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Order allow,deny
      allow from all

      ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

      AllowOverride None
      Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
      Order allow,deny
      Allow from all

      ErrorLog ${APACHE_LOG_DIR}/error.log

      # Possible values include: debug, info, notice, warn, error, crit,
      # alert, emerg.
      LogLevel warn

      CustomLog ${APACHE_LOG_DIR}/access.log combined

      Alias /doc/ “/usr/share/doc/”

      Options Indexes
      MultiViews FollowSymLinks
      AllowOverride None
      Order deny,allow
      Deny from all
      Allow from 127.0.0.0/255.0.0.0 ::1/128

       

       

    12. CTRL+X and save the file as yourwebsitename.com.
    13. cd /etc/apache2/sites-enabled/

sudo ln -s /etc/apache2/sites-available/yourwebsitename.com /etc/apache2/sites-enabled/yourwebsitename.com
sudo service apache2 restart

    1. Where have you created your domain name account? If it’s with GoDaddy, login to your GoDaddy account and click on Domain Manager. Click on the website name and enter the dashboard (or follow whatever practice your domain registrar uses to get to where you can edit the zone file). Click on “Edit Zone File”.
    2. Replace the IP address in the zone file with the IP address of your cloud server. Save the zone file.
    3. “nano /home/yourname/yourwebsitename/index.php” and copy this into the file.

/**
*
Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*//**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define('WP_USE_THEMES', true);

/** Loads the WordPress Environment and Template */
require(‘./blog/wp-blog-header.php’);
?>;

  • In a few minutes, you should be able to enter your URL into any browser, and see the WordPress installation page. Install using the database name and password you’ve created in PHPMyAdmin or in command line for MySQL.
  • I recommend Elegant Themes to get a beautiful and professional look for your site instantly.

 

HOWTO: Always know your home computer’s IP address from anywhere using Dropbox

To always know what your home machine’s IP address is (and while I’ll assume that you’re running Kubuntu, this can be adapted using the following bash script to any machine).

  • Apt-get ‘kcron’.
  • Open Task Scheduler and set the following bash script to run every five minutes:
#!/bin/bash
J=`wget http://checkip.dyndns.org/ -qO - | grep -Eo '\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>'`
K=`date`
echo "$J $K" >> ../Dropbox/ANYDIRECTORYYOUCHOOSE/output.txt
  • Ensure the script is executable, and test it in a shell.

Now, you can always see what your home computer’s IP address is in any browser window; I use this in case there are issues with SSHing into my home box.

How to move WordPress sites between cloud servers using Ubuntu 11.10 and PHPMyAdmin

Here’s a quick howto:

I use Rackspace as my cloud service; I was moving a few sites from one server using Ubuntu 10.04 LTS (Lucid Lynx) to a new one using 11.10 (Oneiric Ocelot). I hit a few issues, so I thought I’d tell you how to export a WordPress site in its entirety and move it between two LAMP servers.

  1. Open a file manager on your local machine, and open both remote locations.
  2. Copy the root and all files of the site to your new server in the same location.
  3. Copy the sites-available virtual host file from /etc/apache2/sites-available/ directory to the same location on your new server.
  4. Create the symbolic link in sites-enabled by changing into /etc/apache2/sites-enabled/ and using this command: “sudo ln -s /etc/apache2/sites-available/yourhostfile yourhostfile”.
  5. Open PHPMyAdmin for your old server in a browser window. Login, and open the database for the site you want to move.
  6. Go to the Export tab. Assuming you’re using UTF-8 encoding (and that’s a very safe bet), all you have to do is ensure that the Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT box is checked under Structure, and that all options are highlighted in the Export box. Export the uncompressed database and save to a convenient location.
  7. Open PHPMyAdmin in your new server, login, and create a new database with the same name as the one you’re importing.
  8. Import the database you exported.
  9. Create a user on that database with the same name and password.
  10. Edit the DNS zone file for your site to point to the new IP address for your new server.
  11. SSH into your server, and use this command: “sudo service apache2 restart”.

Hit Ctrl+F5 once you think the DNS records will have propagated, and ensure it worked.

 

Third Edition Earthdawn Dice Roller in Java

So, I play an RPG called Earthdawn; it’s a lot like D&D, but for real nerds.

One of the things we all do in my gaming group is write our own dice rollers; rolling actual dice is SO passé–and there’s an ongoing argument about whether or not a seeded random is more or less random than the natural flaws in dice and rolling surfaces. Java is the language in which I learned to write math, so I somewhat naturally write algorithms in Java without thinking. It’s easy enough to translate this into C# or whatever.

Ok, so, here’s the algorithm. In Earthdawn, dice rolls are predicated on the step level of the difficulty. You may have an attack roll at step 18 and a damage roll at step 22. In 3rd edition Earthdawn, that translates to rolling d12+d10+d8 to attack, and 2d12+2d6 for damage. Here’s the chart (click to embiggen):

As you can see, there’s some kind of progression here; it turns out that the algorithm is a simple infinite series. There’s a jump in the number of dice every seven steps. Hence, the algorithm has a few simple steps:

(1) Divide the step number by 7.
(2) Determine and store the floor and the modulus.
(3) Roll a number of d12s equal to (floor – 1).
(4) Roll dice equal to the corresponding modulus (the first addition of dice past the 7 threshold will be 2d6, so if the modulus is 1, 2d6 are rolled and added).

That is the step algorithm such that no lookup is now necessary; Earthdawn has exploding dice and epic
fails, however, so two things are necessary. Look at the exploding dice method; if you roll the maximum value of a die, you can roll it again. You can keep rolling that die until a value shows that is less than the maximum value, such that a d6 rolled with a result of 6 can be rerolled. On the second roll, 6 results. On the third roll, 2 results, so the total value of that die roll is 14. For epic fails, if you roll more than one die and all dice show ones, you have epically failed (similar to a fumble in D&D, and with equivalent disastrous results).

Here’s my dice roller; click to embiggen:

So, here’s the code. It’s intended to be self-contained (you can see that I use a pic of Captain Malcolm Reynolds; just drop a pic in your file structure and reference it in the code if you want a background). Obviously this is bare-bones; you can adapt it at your leisure and to whatever GUI you desire. Any suggestions are welcome; I am always debugging this (and the JavaScript I’m using to display syntax highlighting is a little cranky, so forgive any indentation issues). If you can think of a way to optimize this algorithm, let me know; I always need bragging rights over the guys 😉

package dice;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import 
javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.JTextField;
import javax.swing.SpinnerModel;
import javax.swing.SpinnerNumberModel;

@SuppressWarnings("serial")
public class ImagePanel extends JPanel implements ActionListener{

	int six = 6;
	int eight = 8;
	int ten = 10;
	int twelve = 12;
	int dice = 0; //counter for total number of dice
	
	public int middle; //step value entered by me.
	public boolean fail; //whether or not an epic fail happened.
	public JFrame frame;
	public Random r;
	Image img = new ImageIcon("img/MalcolmReynolds13.jpg").getImage();
	SpinnerModel stepEntry = new SpinnerNumberModel(1, 1, 300, 1);
	SpinnerModel karmaCounter = new SpinnerNumberModel(25, 0, 25, 1);
	JSpinner stepSpinner = new JSpinner(stepEntry);
	JSpinner karmaSpinner = new JSpinner(karmaCounter);
	
	private JTextField diceResult;
	private JButton myButton;
	
private JCheckBox myCheck;
	private JLabel enterStep = new JLabel("Enter Step Here.");
	
	public static void main(String[] args) {
		ImagePanel panel = new ImagePanel(new ImageIcon("img/MalcolmReynolds13.jpg").getImage());
		JFrame frame = new JFrame("Tarah's Dice Roller Of Awesomeness");
		
			frame.getContentPane().add(panel);
		    frame.pack();
		    frame.setVisible(true);
	}

	public ImagePanel(String img) {
		this(new ImageIcon(img).getImage());
	}

	public ImagePanel(Image img){
		this.img = img;
		Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));
		setPreferredSize(size);
		setMinimumSize(size);
		setMaximumSize(size);
		setSize(size);
		JPanel panel = new JPanel();
		add(panel, "Center");
		myButton = new JButton("Roll The Dice.");
		myButton.addActionListener(this);
		myButton.setBorder(BorderFactory.createLineBorder(Color.black));
		diceResult = new JTextField("Roll Result", 9);
		
diceResult.setBorder(BorderFactory.createLineBorder(Color.black));
		myCheck = new JCheckBox("Use Karma.", false);
		myCheck.setBorder(BorderFactory.createLineBorder(Color.black));
		GridLayout myGrid = new GridLayout(3, 2);
		panel.setLayout(myGrid);
		panel.setBorder(BorderFactory.createLineBorder(Color.black));
		panel.add(enterStep);
		panel.add(stepSpinner);
		panel.add(myButton);
		panel.add(diceResult);
		panel.add(myCheck);
		panel.add(karmaSpinner);
		setVisible(true);
	}

	public void paintComponent(Graphics g) {
		g.drawImage(img, 0, 0, null);
	}
	
	public void actionPerformed(ActionEvent e) {
		boolean useKarma = false;
		middle = (Integer)stepSpinner.getValue();
		System.out.println("actionPerformed() thinks the step number is: " + middle);
		if (myCheck.isSelected() == true) {
			System.out.println("Using Karma.");
			useKarma = true;
			int decrease = ((Integer)karmaCounter.getValue()) - 1;
			karmaCounter.
setValue(decrease);
		}
		String s = Integer.toString(rollTheDice(useKarma, middle, fail));
	    diceResult.setText(s);

	} 

/////////////////////////////////////////////
/////////////////MATHYNESS///////////////////
/////////////////////////////////////////////
	
	//This is the Earthdawn Exploding Dice Method.
	public int d (int die){

		int sides = die;
		int result = 0;
        int roll;
    
		do {
			r = new Random();
            roll = r.nextInt(sides) + 1;
            result = result + roll;
            System.out.println("This is a d" + sides + " roll with result: " + result);
       } while (roll == sides);

		return result;
	}
	
	public int oneToSeven (int o) {
		int result = 0;
		if (o == 1) {
			result = d(six) - 3;
			if (result < 1) {
				result = 1;
			}
		}
		if (o == 2) {
			result = d(six) - 2;
			if (result < 1) {
				result = 1;
			}
		}
		if (o == 3) {
			
result = d(six) - 1;
			if (result < 1) {
				result = 1;
			}
		}
		if (o == 4) {
			result = d(six);
		}
		if (o == 5) {
			result = d(eight);
		}
		if (o == 6) {
			result = d(ten);
		}
		if (o == 7) {
			result = d(twelve);
		}
		return result;
	}
	
	public int prefix (int p) {
		int prefixTotal = 0;

		for (int i=1; i= 8) {
			int d12s = prefix(full);
			int rest = suffix(mod);
			result = d12s + rest;
			
			if (result == full+1) {
				fail = true;
			}
		}
		return result;
	}
	
	public int rollTheDice(boolean addKarma, int stepValue, boolean epicFail) {
		boolean addK = addKarma;
		dice = 0;
		int result = 0;
		result = step(stepValue);
		epicFail = fail;
		if (addK == true) {
			int dK = d(six);
			result = result + dK;
			if (epicFail == true && dK == 1) {
				JOptionPane.showMessageDialog(frame, "Epic FAIL.");
			}
		}
		else if (addK != true && epicFail == true) {
			JOptionPane.showMessageDialog(frame, "Epic FAIL.");
		}
		return 
result;
	}
}

Python For Scripting

Hi!  I’m Liz from Athenageek.  Tarah and I are writing guest posts in each other’s blogs on the scripting languages we love.

I must make a confession before I continue with this post – I adore Python. It’s made me a better coder. I think about problems differently than I used to, I’m better at breaking them down into tiny components that are easy to code. My coding in other languages improved drastically as a direct result of learning Python – and using it in a Pythonic manner.

I used to use Bash for scripting. That’s what Bash is for, right? I use a Bash shell, so it only made sense.

One day, I was processing some xml scripts. I had multiple xml files with the same root node, and needed to put them all together into one big xml file. Frustrated at some sticking point or other, I decided to see if I could do it with Python. Oh, my goodness, it was SO EASY.

Before long, I
had a string of utility files to handle common tasks that I was always scripting.

Reusability

When scripting, we often have tasks that we do over and over, but with slight changes. Rather than having a base set of methods that you copy out of and then change for each new usage, you can create utility files of classes and methods to use. Add methods to classes to handle new tasks, or allow new variables to be passed in for different usages. With Python’s named variables, you can change a method without effecting or needing to change other code that calls it.

One of the base tenants of Python is DRY (don’t repeat yourself). If you find yourself writing the same code more than once, put it in a place where it can be reused, like a method in a class or a function in a utility file.

Building up a libarary of these types of files is a great way to expand your toolbox. The longer you do it, the easier tasks become, because you’ve already done the work.  Lots of scripting projects are,
“Just like the one you did for x, but with this minor change”.

Testing

Python the community is heavily in favor of testing. One reason this is helpful for scripting is the case I mentioned above, when you change a method to handle some new functionality that you need. How do you make sure this new fuctionality doesn’t break old code? You test it. Doctesting and unit testing are built in to Python, no hunting around for which framework is best, balancing framework versions with script versions, or figuring out how to import your framework on a different operating system.

Doctesting

I love doctesting. In one fell swoop, you are showing how to use code, documenting that code, and proving that it works as expected.

Doctesting is very easy to do. Let’s say we create a method to square a number.

def square(numberIn):
    return numberIn * numberIn

No documentation there, let’s fix that.

def square(numberIn):
    """Returns the square of the 
number passed in"""
    return numberIn * numberIn

The doctest actually goes inside the documentation you’ve just created.

def square(numberIn):
    """Returns the square of the number passed in
    >>> square(2)
    4
    """
    return numberIn * numberIn

So, you use >>> to delineate code that is going to be tested. That’s the same >>> you see when you’re working at a Python prompt. In this case, we’re calling our method and passing in 2. On the next line, put the expected result, which is 4. You can put as many of these tests as you like in the documentation block, separate them with a blank line. You can even put error checking here.

def square(numberIn):
    """Returns the square of the number passed in
    >>> square(2)
    4
    >>> square('three')
    Traceback (most recent call last):
    ...
    TypeError: can't multiply sequence by non-int of 
type 'str'
    """
    return numberIn * numberIn

I got that traceback by using my function at a command prompt.  I copied and pasted it into my doctest.  I deleted the variable stuff between the two important lines and replaced it with ellipses.

In order to run the doctest, you have to add the following to the bottom
of your file:

if '__main__' == __name__:
    import doctest
    doctest.register_optionflag('ELLIPSIS')
    doctest.testmod()

Note that I’ve registered the ellipsis option flag. This allows you to use … as a wildcard so you can skip over some of the expected output. It keeps your code cleaner and lets you handle situations where expected output might be different – say – generating a random number.

Ok, now you can run the file. Let’s say we called it utility.py.

$ python utility.py
$

No output. That’s the default. In order to see the test results, you need to use the verbose flag.

$ python utility.
py -v
Trying:
    square(2)
Expecting:
    4
ok
Trying:
    square('three')
Expecting:
    Traceback (most recent call last):
    ...
    TypeError: can't multiply sequence by non-int of type 'str'
ok
1 items had no tests:
    __main__
1 items passed all tests:
   2 tests in __main__.square
2 tests in 2 items.
2 passed and 0 failed.
Test passed
$

And there are our test results – everything passed.

Aside from the option to put doctests in your code, you can also create txt files for documentation and add doctests to them. This is what bigger projects tend to do, especially when they have multiple files of code to deal with.

Unit tests are another great way to test that is very helpful for scripting. Every time you get a new requirement, add in a unit test for any situation you can think of that would effect that new requirement. Test things going right, things going wrong, and
any unexpected behavior or input you can think of. If you find an error that isn’t covered in your tests, create a unit test to cover it. A baseline of code like this ensures that any future changes won’t break existing code. If it does, it will make the error really easy to track down – you won’t have to try to remember all the past requirements.

Easy for the next person to maintain

Between keeping code in one place, not repeating yourself, and having robust testing, you’ve just made maintaining this code really, really easy for the next person that comes along. Even if they don’t know Python, a glance at your robust documentation and clear code will make it easy to make small changes. Running the tests will leave them confident that their changes won’t have a negative effect on other code.

We all want to be able to go on vacation and not get a call that someone broke your code. Clear code with lots of tests are the best way to ensure a relaxing break.  Python makes this quick
and easy, so you can move on to something hard.

The IDE Wars: NetBeans or Eclipse for Java Software Development

I’ve been working on several applications for a few years; some are ready or released into the wild. I’ve used NetBeans and Eclipse to develop one application in particular; I’ve written an Earthdawn dice roller application. Earthdawn is like Dungeons & Dragons, but for real nerds. The Earthdawn dice system is complex, including a shifting iterated seven-step algorithm for determining the dice rolled for a given action. In addition, dice explode in Earthdawn. That means that if a given die results in its maximum value (i.e. a d6 result is a 6 or a d12 result is a 12), you reroll the dice and add that to the total, continuing to reroll if the die continues to result in its maximum value and stopping when it does not. Plus, you also have the option of adding a karma die (dependent on race, like Elf or Dwarf) to any roll which permits it.

Obviously, this is a complex system, and dealing with the RNG was not the hard part. The hard part was
figuring out the algorithm by which you can calculate the dice you would roll for any given step. For example, rolling a step 10 means that you roll a d8 + d6. Rolling a step 20 means that you roll 2d12 + d10. You can find this on a chart in the 3rd Edition Earthdawn Player’s Guide, but it actually took doing a Taylor series to determine that there is an algorithm which repeats every 7 steps. This means that my app can calculate what you’d roll for a step 63 dice roll, when the book doesn’t provide a chart that high.

I’ve been fiddling with this app for a year or so, and while I’ve been developing the backend in Eclipse, I found that the frontend needed some serious help. I looked around for an IDE specifically to develop the frontend of a Java app, and NetBeans turned out to be full-featured enough to develop in much the same way that I’d dev a C# app in Visual Studio 2010. I’m an old school algorithm coder, and I don’t do as much frontend app development, as opposed to my long term work in
frontend web development. In fact, most of my experience in frontend app development is in VS from 2003 on. So, believe it or not, I was looking for an IDE experience closer to VS.

NetBeans is open source; I found that specifically for the purpose of frontend Java software development, it’s a far better IDE than Eclipse. While Eclipse works better for academic algorithm coding, NetBeans is tailor-made for someone who wants to turn out an app with a backend; in fact, I coded the backend over rather a lot of time in Eclipse to test it with multiple RNGs developed at CERN, Argonne, etc, and simply copied over the relevant classes into NetBeans to hook them up to the frontend. I’d actually recommend this as the most efficient experience if you’re trying to create a complex backend with a simple and effective frontend…especially if you have an app that needs a frontend instead of a script. NetBeans has a simple application package process as well, if you need to pack up the app and send it out. I have
Ubuntu, OpenSUSE, Windows, and Mac users in my group, and Java will execute on each of those platforms.

I’ll also shortly be posting the app so you can examine it for yourselves 😉

How to SSH into your home computer to access media files, documents, processes, or anything else you might need

I wanted access to my home machine so I could access any files I want. Dropbox is pretty awesome, but if you’ve forgotten to put something in your Dropbox folder, you’ll be in deep trouble.

(1) Run “sudo apt-get install openssh-server” at the command line.

(2) Run “sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.original”. This copies your original configuration file for SSH so if you muck up the settings, you can always replace them.

(3) Run “sudo kate /etc/ssh/sshd_config” (or whatever text editor you use) and change the port number from 22 to another port so you won’t be targeted by so many bots.

(4) Ensure that your firewall isn’t blocking the port you chose. You may need to add SSH as a running service. You should probably also include ‘sshd’ as a startup application in your distro so that if you need to do a remote reboot, the service restarts and you can log back in.

(5) Forward the port
being used for SSH in your router. To do this, you need the internal IP address of your computer on your home network, as I presume you’re not dumb enough to directly connect your home machine to a modem. Ask me if you have problems figuring out how to forward the port.

(6) Get out your Android phone if you have one, since a connection over 3G will mean that you can test your SSH connection without ever leaving your comfy chair. Install ConnectBot through Android Market.

(7) Open ConnectBot (or any SSH client from any machine; Putty will work well) and type in your home machine username, your external IP address, and if you have changed the port, include that as well. Here’s the format: username@000.000.000.000:XXXXX Where 000.000.000.000 is your external IP address and XXXXX is the port number you chose to replace the default.

(8) If you have issues getting a connection, hit me in the comments; I had several oddities in router configuration making this work, even though it’s
quite simple in theory.