fogbound.net




Fri, 19 Jun 2015

Failed Javascript Experiment

— SjG @ 5:47 pm

I was thinking about textures that are traditionally called Islamic or Moorish tilings.

One simple pattern is built by placing circles on a staggered grid, placing points around their circumferences, and then connecting points to neighboring circles in a pre-defined pattern. Here’s one example:

basic-detail

I was thinking – hey, what if I vary the radius of those circles from row to row?

Three hours of clumsy Javascripting later, I found the answer:

pattern(click on image to see detail)

Unfortunately, it often takes hours of coding to learn that an idea’s not much good.

You can play with some of the variables yourself, or (horrors) look at the source code to see how it works.

Updated:
I couldn’t leave well enough alone, and have added a few features. And I’m getting slightly more interesting stuff now.
pattern2(click on image to see detail)


Tue, 16 Jun 2015

Localized images in Silverstripe with Fluent

— SjG @ 10:50 am

Say you’re building a web site using Silverstripe. And say you need to localize it, and you opted to use the fluent add-on. You have a nice normal page set up, along with a slick user-selected side image. But now, just to finish this hypothetical, say you not only need text on the page to be localized, but you need the image to be localizable too (e.g., a different image depending on someone’s country or language).

Here’s what I ended up doing, and what seems to work for Silverstripe 3.1.

My page model looks like this:


class Page extends SiteTree {
   private static $db = array();
   private static $has_one = array(
      'SideImage'=>'Image'
   );

   public function getCMSFields() {
      $this->beforeUpdateCMSFields(function($fields) {
         $fields->addFieldToTab('Root.Images', UploadField::create('SideImage','Image for Right Panel'));
      });
      return parent::getCMSFields();
    }

The page template has a simple image inclusion:


< % if $SideImage %>
   $SideImage.setWidth(310)
< % end_if %>

In my _config/config.php, I then added


Page:
  extensions:
    - 'FluentFilteredExtension'
  translate:
    - 'SideImageID'
    - 'SideImage'

Run http://www.yoursite.com/dev/build

Now your Page admin will have an Images tab where you can set the Side Image. If you set the Side Image while in the default locale, that image will show for all locales. But if you use the locale menu item to select a different locale, you can override the Side Image for the page.

Slick!


Fri, 5 Jun 2015

pfSense Can’t See the Outside World

— SjG @ 11:00 am

We had a static IP address change on a network that had been in operation for about six years. Since we have gradually been migrating services off to third-party hosting, we no longer need a block of local static IP addresses. To save some ca$h, we are down to one static IP — but that necessitated getting a new IP.

At midnight, the change occurred.

I went into the pfSense admin, got rid of all my 1-to-1 NAT mappings, virtual IPs, and all the firewall rules that protected the no-longer-extant servers. And I couldn’t see the outside world.

I couldn’t even ping the gateway.

Plugging a Mac into the same cable, however, and setting the network parameters, and I had immediate glorious interweb access everywhere.

It was perplexing. The pfSense firewall was configured exactly the same as the Mac. Why u no work firewall?

After a bunch of nonsense, I found the problem. I’d set the WAN interface to our new IP address, and specified it as a single IPv4. I thought I was setting the netmask correctly for a single IP:

IPv4 WAN Address: xxx.xxx.xxx.xxx/32

It turns out, I needed to reduce that netmask. That /32 means *all* of the address is the network submask.

For a single IP address, I used /24 (leaving the entire last byte as my address), although /31 should probably work and would lock it to the specific address.
Edit: The key is the netmask has to leave the gateway in the same subnet as your IP. Doh! You can see I don’t do this kind of stuff enough to know what I[‘m talking about.


Tue, 2 Dec 2014

Compiling Kannel 1.4.4 under Centos 7.0

— SjG @ 4:28 pm

This took me while to get to work. If you follow these steps in order, it should work nicely.


# yum install mariadb-devel
# yum install libxml2-devel
# yum install bison
# yum install byacc
# cd /usr/local/src
# wget http://kannel.org/download/1.4.4/gateway-1.4.4.tar.gz
# tar xzvf gateway-1.4.4.tar.gz
# cd gateway-1.4.4
# ./configure --prefix=/usr/local/kannel --with-mysql --with-mysql-dir=/usr/include/mysql --disable-wap
# make

There are a few tricks here. First, just having libxml2 installed is not enough. You need the libxml development headers, etc. Should be obvious, but tricked me. Next, if you run ./configure before you have some of the dependencies installed (e.g., Bison), you will have modified source files that will still fail even after you install the dependency. Thus it’s important to install all that stuff before you run ./configure.

This stuff isn’t really that hard, but it can be time consuming to track down why it’s not working.


Sat, 25 Oct 2014

Simple Budgeting Spreadsheet

— SjG @ 7:21 pm

Sometimes, simple is best.

Here’s a simple Open Office spreadsheet to help visualize what your “Daily Nut” is when it comes to expenses and income. It makes it easy to visualize how much that daily coffee and doughnut cost you over the course of a year, or shows you how much more discretionary spending you can engage in before causing yourself serious trouble. Then again, if you have discretionary spending money, I’d advise putting half into savings or investments, and giving the other half to charity. But that’s just me.

ScreenShot

Get the spreadsheet over on GitHub:
https://github.com/libelle/the-daily-nut