ejes consulting

Techincal Consulting Design and Automation

Archive for the ‘Neat Stuff/Good Ideas’ Category

Mac OS X Swap File Optimization

leave a comment »

So I like OS X.  It’s a UNIX desktop done well, it’s well designed, beautiful and easy to use.

With all I love about OS X, there are things that I absolutely HATE.  They could, for example, use the Unix Filesystem Hierarchy (https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard) but this article is more about how there is no easy way to modify your swap file and it’s usage.

I understand the desire to keep these kinds of settings under the covers from users who may be in experienced or not know exactly what they’re doing, but they could make it a little simpler to get your hands on.

Nevertheless, it’s not impossible.  During my research, I came upon this guys site (http://osxdaily.com/2010/10/08/mac-virtual-memory-swap/) and with this info (read it, it’s short) you can re-mount your swap files on a new filesystem.

In OS X, swap files are stored at /private/var/vm, so that’s where we’ll concentrate our filesystem changes.

First things first, though, we have to disable the swap files.  Thankfully, this can be done from the command prompt, but before you do disable virtual memory, you should not be running any applications.  If possible disable all network services, and close all programs before releasing all virtual memory, if you leave programs, (especially swapped, unfocused or background ones) open, you may have problems, otherwise consider yourself warned.

Disable “Dynamic Pager” (swap):

Mac-Mini:~ root# launchctl unload -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist

After this command is done, you can safely delete everything in the /private/var/vm/ directory.

Mac-Mini:~ root# rm /private/var/vm/*

Then simply mount your new filesystem.  Mine is “msdos”, I figured that having less overhead would make it slightly quicker.   Though a security remember: these files would be readable by perhaps the wrong people, and could be used for malicious reasons or for information gathering purposes (ex. http://www.linuxjournal.com/content/doing-reverse-hex-dump).

Mac-Mini:~ root# mount -t msdos /dev/disk1s1 /private/var/vm

Then you can re-enable dynamic pager (swap, virtual memory), don’t forget the “-wF” the F probably means “force”:

Mac-Mini:~ root# launchctl load -wF /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist

There you have it, your swap file will grow on this partition.

Please remember that you have to be root to run these, if you are unable to become root, please consult the manual pages for “sudo” on OS X.

Written by ejes

December 28, 2013 at 10:58 pm

pSearch Source!!

leave a comment »

So I had some trouble getting my source put onto wordpress.  I can understand their point, they don’t want to share .zip, .tar or any other archive container formats.

In the intrest of brevity, I decided to just use a free file host.  I chose medifire, it was top on google when I checked.


There is where you can find the historical archives of my search development.  I did my best to ensure that it could be compiled on Windows (32-bit XP via, MinGW) or Linux (ubuntu 64-bit server), sometimes OpenBSD. You’ll likely need sqlite (http://www.sqlite.org/) and libcurl (http://curl.haxx.se/), you’ll probably need pcre libraries as well (http://www.pcre.org/).  If you try to compile something that looks like it should work, let me know and I’ll see if there’s any libraries that I might be missing, or at least I can let you know if it SHOULD compile.

All the above source is released under the original BSD Licence.

Copyright (c) 2010-, Evan Stawnyczy (ejes consulting) ejes@torfree.net
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
   must display the following acknowledgement:
   This product includes software developed by ejes consulting.
4. Neither the names ejes consulting, Evan Stawnyczy nor the
   names of its addional contributors may be used to endorse or promote
   products derived from this software without specific prior written


As of right now, I’m working on a complete rewrite.

This rewrite I’m hoping will serve as good working reference code.  It will be clear, easy to understand and most likely SLOW.  I am now using ODBC instead of limiting users to sqlite.  This also will hopefully allow enterprises to adopt use without too much trouble.  I decided to scrap the web-server aspect – hopefully someone will want to bundle search and web-server for home use.  Especially with the wide adoption of ipv6 a single workstation could easily share information with others all indexed through a private search network.  At the very least someone should write an nginx (http://nginx.org/), lighttpd (http://www.lighttpd.net/) and apache (http://www.apache.org/) module that indexes static and cached content and publishes the search results.

That leads me to trying to build this as an ip-agnostic application. I want it to run in both an ipv4 and ipv6 network. Of course this has it’s own challenges as well.  I’m trying to maintain ANSI compliance where I possibly can so that it can be easily portable, and mostly so that it can run on windows or unix without too much trouble.

Written by ejes

November 11, 2011 at 2:54 pm

pSearch – a peer to peer, distributed search engine

leave a comment »


So I haven’t been posting very much for the last while, and this is mainly because I’ve been very busy.

I always have several projects on the go, and I don’t have enough time to devote to all of these things at once, so usually the least interesting project gets placed on the back burner.

That is what happened to this blog.

Now I’ve spent a great deal of time on this, and have produced some very good design documents as well as a bunch of source code.  So… Without further ado

This is my distributed, peer-to-peer search engine.

Attached to this post you’ll find a couple of architecture documents, a pdf with a visual diagram of how this engine is suppose to work, and another pdf with a long winded, half written description of why and how I expect this conceptually to run.

I’m not a writer, and am mostly a technical person, however, I am actively updating and modifying this project so expect updates as it goes.

The first document is the “pSearch – Document

In this document I attempt to explain the strategy, and reasons for this project and what  I hope that it will accomplish.   This document is incomplete, but I encourage you to read it anyway.

The second document is the “pSearch – Drawing

In this document I have detailed the major aspects of the distributed search.  Hopefully it’s easy to follow, I don’t expect this diagram to change very much.

And I have a LOT of source code that I still have to organize – much of it will be posted here and some of it is too embarrassing.


So, without drudging into my documentation in too much detail (I posted them above, feel free) a simplified “how does this work” seems appropriate.

Each peer will accept connections  from the internet.  Each search request is forwarded to other peers as defined in it’s database.

While this happens, it also uses a second task to search it’s own internal database.  On a private home machine this internal crawler has a small collection of sites and keywords based on several configurable data collection points (such as your browser cache, or installed programs) which would automatically include a lot of data that would be specific to you.   A public internet site would index their own pages (this isn’t mandatory, but preferred).

After that, it’s a simple case of matching the keyword and publishing the results to the connected client.

Peers who respond quickly, and with a lot of results are flagged as “experts” when it comes to this set of terms.  This way, when you search for a similar set of terms again, the “expert” peers will be consulted first.

This way, common search terms will be responded to by clients who have a lot of information on these terms.  For example a site that indexes movies (like imdb) would respond with a lot of results for movie titles and information about films, but probably have very little to respond when a query has some specific request about cars.

Expect more as I develop more.  I encourage anyone to read and comment about my designs.

Written by ejes

November 7, 2011 at 11:43 am

Javascript Obfuscation to the MAX!!!

with one comment

I was stumbling around the internet today and found this:


Yep, perfectly legal Javascript, Care to hazzard a guess as it’s function?


^ go here to find out more… It’s fantastic :)

Written by ejes

February 1, 2011 at 2:47 pm

Amazing One Line Script

leave a comment »

I was stumbling around on the internet this morning and I found this awesome site… (http://www.centerkey.com/tree/)

This guy posted an amazing one line script that will graphically show your directory tree with a simple one line command:

ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'

and that’s all!!! It works great!

Written by ejes

March 17, 2010 at 11:42 am

MAME cabinet, on Debian (Part 1)

with 6 comments

Okay, so generally you know I’ve been up to no good (contracts) when I haevn’t posted in some time. It’s true, I’ve been working pretty hard lately.

So last night I sat while watching the olympics it made me think of Hyper Olympic, the name of the console that I got for my Mame Cabinet.

I decided to finally install an OS on the machine I’ve devoted to my arcade console. Since this is just first step, I don’t have pictures for you yet – but I will – rest assured.

So I started with a clean debian netinst cd for Debian 5.0 (Lenny).

I started by installing the “Advanced install“.  I want my stystem to be as slim as possible, so I want to control as many options as I can while installing.

After the usual language, keybaord layout and detection of the CDROM and installation media the fun started.

I set my hostname to “Hyperolympic”; the name of the game my cabnet came from.  Later on I hope that it will default to “hyper olympic” as a screensaver – but right now, it’s just the host name.

I also configured it to allow me to contiue working on it from SSH (which allowed me to watch the USA team whoop Canada’s Hocky team), from there I configured it to use the time.nrc.ca atomic clock for ntp, and start to parition the disks up.

The drive I have in it is an old 30Gb hard disk, the ROMS I’ll store on my NAS so It only really needs to hold temporary data and so the drive doesn’t need to be very large.  I used an old 2Gb USB Thumbdrive as a “swap” partition.  Very simple partition scheme, the 30GB drive is a the root (/) paritition, the entire USB Thumb Drive is swap.

Install the base system, and cheer on the Canadians.  I created a user called “interface” who will be the “interface” user, I disabled root here as well and do all interactive root sessions by using “sudo -i” from my interface user.  I’ve seen a few tutorials that start the mame arade as root, but I disagree with this practise. 

Finally it asked for some “task specific” kinds of installation options.  I chose “Standard System Only” (or similar), I have no need for apache, dns, or an xwindows desktop environment.

Install grub (not grub2) and ta-da.   A bootable debian.

Next, I logged in as interface, sudo -i to root, and edited my /etc/apt/sources.list.  I found this neat place (http://apt.ludomatic.fr/?hl=en#repo) who has mame sdl, precomplied for debain.  Following their instructions I added the following lines to my sources.list:

deb http://apt.ludomatic.fr lenny non-free
deb-src http://apt.ludomatic.fr lenny non-free

Then using a quick command (they also show) I get their security keys:

wget http://apt.ludomatic.fr/ludomatic.key.asc -O - | apt-key add -

I run apt-get update to ensure there are no errors (there weren’t).

Now I have to enable the framebuffer.  There’s not a whole lot if info about this – but it turns out it’s pretty easy.  I added the “vga=791 video=nvidiafb” to my boot.1st file and rebooted.  Obviously this is for nvidia cards, if you don’t know your card you can use the “video=vesafb” instead, or you can use your own… there’s plenty and you can find them all in:

“/lib/modules/”uname -r`/kernel/drivers/video/”

You also should edit your /etc/modules to include your framebuffer drive too.  I also installed “splashy” which allows me to choose themes and “boot up screens”

apt-get install splashy splashy-themes

Once all of that is complete I now install GCC and build utilities so that I can build the “advanced menu” system.

apt-get install gcc g++ binutils make

Then in my /usr/local/src directory I download the advance menu sources:

wget http://prdownloads.sourceforge.net/advancemame/advancemenu-2.5.0.tar.gz?download
tar -vxzf advancemenu*.tar.gz
cd advancemenu-2.5.0
./configure && make install

Now, SDL Mame.

apt-get install sdlmame

Next I edit my /boot/grub/menu.1st and change the “timeout   5” line to “timeout 3” to speed up boot, I also changed the /etc/init.d/rc script the line that reads “CONCURRENCY=none” to “CONCURRENCY=shell

. . . and Reboot!

Ta-DA :)  A bootable system, not much is going on – you can start messing with the advance menu system, which I’ll cover next time :)

to be continued…

Written by ejes

February 23, 2010 at 11:00 am

Video Capture Card Driver Woes

leave a comment »

So lately I’ve been working on copying my old VHS movies to digital format so that my NAS can serve them up to my XBMC.

In my stumbles around the internet I found this really great project.

It seems to include EVERY older Video Capture Card for Windows drivers all into 1 beautiful fast and easy to install package.

Since I don’t use windows, I don’t really have much to do with it, but it’s good for those of you who do.

Take a look

Written by ejes

November 4, 2009 at 3:29 pm

Back from the Dead – Fixing Drives in Linux

with 2 comments

So as you all know I lost my NAS due to some disk errors. 

Sadly, it was actually my flash adapter card (http://www.dealextreme.com/details.dx/sku.711) failed and this caused my FreeNAS to fail.

After much debugging – since this solid state drive seemed like a power supply failing: power turns off a couple seconds after being turned on, turning it on sometimes would do nothing until you unplugged the power supply then plug it back in.  (http://hubpages.com/hub/How-to-Tell-When-Computer-Power-Supply-Is-Failing)

Anyway, after figuring it out, I put in an old unlocked X Box hard disk (15 Gb) and that’s now my boot drive.  I used the newest version of FreeNAS which allows for a “full install” on a hard disk. (simply boot it up, and use the console menu to install)

Now that I’ve got my FreeNAS server up again, I still have a broken 500Gb drive to fix.

I took the 500Gb drive out and put it in my Ubuntu Linux lab server.  I usually use this machine for any experiments that I’m doing and for virtual machines.

Canada computers and a few others have some pretty good deals on 1Tb drives right now.   (I got mine for $90.00. http://www.canadacomputers.com/index.php?do=ShowProduct&cmd=pd&pid=024109&cid=HDD.443.877)  So this is a good time to upgrade my drive.

I put it into my lab server, and dd’ed the drive to make a complete copy onto my new 1Tb drive. 

Now I have a whole bitwise copy of my drive, now the fun part.

I don’t know UFS as well as I know FAT or EXT, so I was hoping to find a utility to help me with the restoration of this drive.

A quick google found me a utility called “testdisk”, (http://www.cgsecurity.org/wiki/TestDisk) and since I have a bitwise copy of my drive, I thought let’s give it a try.

Ran it,  it took literally 1 hour to analyze the drive.  It was so slow that I almost gave up.  However, beer and a night of Simpsons let me relax and let it do its work.

I wish I’d taken screen shots for you, but I was thrilled to find out that it actually worked. 

It recognized the UFS filesystem, GFI partition and all.  It rewrote the partition table, and dropped me to a command prompt.

I installed “ufsutils” with apt-get install, and ran fsck.ufs on it.  fsck did it usual “i found xxx fix?” and the drive was repaired.

I copied the data from the old 500Gb to the new 1Tb, and installed the new 1Tb drive into my FreeNAS server, added the drive, and ta-da it worked.

Back in business.

Now, the new version of FreeNAS has some neat new features that I discovered, the least of which is “/etc/rc.d/transmission blocklist-update” – which makes my old tutorial redundant, and I’ll write an update about that sometime soon :)

This week I’m going to reconfigure it – and I’ll probably write a little tutorial for you all who are interested.

In the meantime, I got my NAS back – and my movies.

Written by ejes

October 5, 2009 at 11:06 am

Revisit Royale Noir

leave a comment »

I know I’ve failed to post for the last little while.  But with good reason, my FreeNAS server crashed (destroying the drive) which I intend to post about once I’ve fixed it, I have also been writing a few pieces of software for my clients, and 1 for the open source community (again, I will post this once I have something more “polished” for general consumption)

But, since i’ve been looking at the same page of posts for the last couple of weeks i thought i owe it to you to write something… anything, just to keep you (and me) on our toes.

Since this is something of a revisit but I think it’s quite catching and really a nice personal touch that many of us can use to make our windows boxes just a little more unique.

It’s called “Royale Noir”, a secret hidden XP theme that is only available using a special “luna.msstyles” visual settings file by Microsoft.

Installation is a snap, you just download the royale_noir.zip file that I literally stole from the old “istartedsomething” post (see: http://www.istartedsomething.com/uploads/royale_noir.zip) unzip it into a “royale noir” subdirectory in your “%WINDIR%\resources\themes\” folder, double click on the “luna.msstyles” file and select “Noir” from the colour scheme.


 Royal Noir Display Properties

Royal Noir Display Properties

If you want to see the original post: http://www.istartedsomething.com/20061029/royale-noir/

Written by ejes

September 29, 2009 at 2:18 pm

Burn a CDROM to a friend?

leave a comment »

Ever wanted to send your friend a cdrom, but didn’t want to send an iso or whatever?  this is for you!


Written by ejes

September 15, 2009 at 2:42 pm