Mockacino a lightweight ruby/sinatra API Mocking script

Hi Guys, so i’ve been working on a new app recently for a client of mine, currently there is no API… so in the meantime I decided to knock up a quick few lines of ruby to get a mocking api up and running… to explain this better, I need not do more than paste my README.md here.. Enjoy 🙂

Mockacino

A very simple and easy to use MOCK API server that serves static JSON written in ruby/sinatra.


NOTE: This is a super simple, super fragile MOCKING SERVER Intended so you can test routes and mock an API with static jso whilst you’re still building the real production API. DO NOT EVER use this in production… Seriously. It breaks a lot and will if you try… DONT. Absolutely 0 effort went into it, therefor 0 Warranty. Use if you dare.

DOCS:

Folder structure defines API calls…. return.json is what gets served.

site_root ->;
    [ http method ] ->; [ api call route ] ->; [ json response contents of call return.json ] 

e.g.

site_root ->;
    GET ->; users ->; return.json
    POST ->; users ->; create ->; return.json

If you have static assets you wanna reference in the json, plonk them in the ASSETS folder

e.g.

site_root ->; file.jpg

You can call http://yourhost:port/ASSETS/file.jpg

Here’s the directory structure of the sample project included here

mockacino.rb  
./site_root/ASSETS
./site_root/GET
./site_root/POST
./site_root/GET/sheep
./site_root/GET/sheep/create
./site_root/GET/sheep/return.json
./site_root/GET/sheep/create/return.json

Which supports calls like…

http://localhost:4567/sheep
http://localhost:4567/sheep/create

And gives responses from the static result.json file like…

{
    "sheep": [
        {
            "id": "1234",
            "name": "Dolly Two",
            "url": "http://mike.kz/sheep1234",
            "assets": {
                "small_image": "http://cloned.sheep.com/ASSETS/small.jpg",
                "large_image": "http://cloned.sheep.com/ASSETS/large.jpg"
            }
        }
    ]
}

Usage:

gem install sinatra
ruby mockacino.rb
 

Brisk a simple lightweight Networking Framework written in Swift


This is gonna be a short and sweet blog post… I’ve been working on a little pet project to practise and learn some Swift, so I thought, what do I use the most in projects these days… its networking. I’ve published on github.com my first attempt Brisk, its no where near complete and only has basic functionality right now, but if it becomes interesting i’ll pick up the effort and add more, until then, its a great educational exercise, you can check it out here and be sure to contribute back 🙂 it should work on both OS X and iOS and is MIT Licensed.

 

Ubuntu 13.04 on a Late 2012 Mac Mini

EDIT: Tonight i’ll be picking up one of my Mac Mini’s from the Datacenter to get Ubuntu 13.04 up and running! expect a full guide with drivers here shortly 🙂

So Ubuntu 13.04 LTS recently was released, It comes with the new 3.8.0-19 upstream of the Linux Kernel so I thought I’d check it out!

Although our patched 12.04 and 12.10 Ubuntu’s use version 3.124c of the tg3 NeXtreme drivers from Broadcom which have Mac Mini support… The version in Ubuntu 13.04 (3.128c) seems to have had this removed!

A simple run of modinfo tg3 | grep 1686 reveals sadly that support for detection of the Mac Mini Ethernet hardware seems to have been removed during 3.124 and 3.128 of the Broadcom tg3 drivers.

I’m likely to install 13.04 on a Mac Mini sometime soon so will update this post with a proper howto and any good news I encounter but I don’t think its good news…

lsmod | grep Ethernet returns
01:00.0 Ethernet controller: Broadcom Corporation Device 1686 (rev 01)

whilst modinfo tg3 | grep 1686 on our modified 12.04/12.10 machines using the NeXtreme driver from this blog returns:

alias:          pci:v000014E4d00001686sv*sd*bc*sc*i*

however on 13.04 returns nothing.

 

Manage your KVM Hypervisor Remotely on your iPhone / iPad

Recently I began experimenting with KVM virtualisation in the Linux Kernel. Its a great technology that if your CPU supports VT-x / AMDV offers almost (really, almost) bare metal level performance inside Virtual Machines. It works on most Linux flavours and has a couple of handy management tools such as virsh and virt-manager. However, one thing I thought was always lacking and annoying me was of course, the ability to manage my Hypervisor from my iPhone / iPad when on the move! Time for an experiment I thought; then out came “KVM Remote”

KVM Remote on the iPad and 3 Different Remote Hypervisors

Its universal so works on both the iPhone and iPad and is extremely bleeding edge right now, but works! and is incidentally the first App i’ve made that doesn’t have selfish fiscal intentions, so theres another great reason to download it from the AppStore now!

P.S. i’ll be updating it regularly adding more features as requests come in.

 

Custom IDN’s and TLD’s Using Punycode and BIND

I’ve been playing around with some IDN’s and TLD’s and DNS etc…. i’ve realised you can create IDN (punycode) subdomains to any existing domain, in addition, i’ve created my own TLD, and setup a DNS server that works for this purpose. If anyone would like an IDN or a custom TLD, get in touch!

From anywhere in the WWW:
http://армсторнг.el.cx

Set your DNS to: 77.79.11.26 in order to take advantage of the new ком TLD. (note: this is just a bit of fun, and is not official).
http://армсторнг.ком

 

NexentaStor AFP & iSCSI Xbench Benchmarks

UPDATED WITH BOTH iSCSI & AFP RESULTS

I’ve recently setup a ZFS raidz with 7 disks using NexentaStor, natively this doesn’t come with AFP, but I managed to get a package and get this all working (which i’ll demo in an upcoming tutorial), one thing i noticed however is that I could never find any benchmarks that tested the general use of a NAS… i.e. using CIFS or AFP over a network to another machine and testing performance. There are literally 0 AFP benchmarks for NexentaStor due to its non-native support. So here it is

Test Environment:

NAS: 7 SAMSUNG Spinspoint F3 2tb Hard drives connected via SATA & SATA-II, in a ZFS raidz running on NexentaStor 3
Network: 1000BaseT Gigabit LAN
Test Machine: MacMini with 1gb memory (disk tests are cached in memory for speed) running XBench to benchmark
… 

 

Bye Bye FreeNAS hello NexentaStor

Well, i’ve used FreeNAS for around 2 years+ now, and all has been good, however, in that time demand for large quantities of storage has now been joined by demand for high speed storage; Once I had replaced all of my drives with 2tb 7200rpm drives I realised that FreeNAS wasn’t giving me the performance on each drive that i’d like.

Welcome NexentaStor… a storage appliance natively supporting ZFS as its based on OpenSolaris! NexentaStor offers many of the same features of FreeNAS, however at a greater level of performance. This comes at a cost though, the free Community edition is limited to a some what large 18tb, whereas the paid version will cost you.

Also NexentaStor is a pure storage appliance, although it supports CIFS/iSCSI/NFS and the likes, it does not have all the bells and whistles of FreeNAS… but for me, there is no use having all these features if I can’t have the speed.

I’m installing NexentaStor now as we speak, after which I’ll be posting a review / tutorial on NexentaStor after i’ve got it up and running and configured to my liking 🙂 I hope you enjoy it!

 

Amazon Support Store

Hi everyone! I keep getting lots of emails from people asking where they can buy xyz to complete the tutorials and try out some of the things listed on CaptainGeek, well after I kept emailing people the same links i had a thought, why not setup an amazon affiliate store. Basically, i’ve setup a small amazon site with a small selection of products (only those used for the tutorials on this site + related ones), purchases and payments are handled by amazon, however a small percentage of the sale goes to helping fund the server this website is hosted on AT NO EXTRA COST TO YOU 🙂 so its a win win situation, please use the links whenever you can.

Our Amazon Store

 

Sharing iTunes Libraries over the Internet, Bypassing Bonjour Restrictions

Ever wanted to be able to access the shared libraries from your home… when you are away from home? I do, since I started to use FreeNAS with Firefly iTunes/DAAP media server this is exactly what i want… I’m often away from home, and always wanting to access my media library from within iTunes…

Bonjour (mDNS) is what the iTunes / Firefly DAAP server uses to advertise a “beacon” of your iTunes shared library to your local subnet (LAN), however this is restricted (due to industry pressure (RIAA)) to local area only, and not wide area (the Internet) as it once was… However its still easy to circumvent and work around this issue so you can listen to your shared libraries on the go!

This tutorial is aimed at Mac users, but the concept is possible on every OS using the appropriate tools…

Tools needed:

Once you have all of these it becomes easy, this is the general process of how it works … 

 

Multi-Homed Multi-Boxed ZFS Luns Using iSCSI

Recently i had a thought… Most of my machines are sitting redundant and have upto 4 drives in each… without unscrewing every single one of out of my rack… i want to utilise all of that space into one giant zpool using ZFS.

Imagine combining the drive space resources of 10 computers into 1 giant drive? see where i’m going with this now?

So my idea is to make the drives in each machine available to the “ZFS Master” (the solaris box running the ZFS pool) via iSCSI which is a sort of “offer your drives at a block level over ethernet” protocol… then add them all into a giant zpool… the advantages of this are:

  • Utilising all of my hardware
  • iSCSI can work over WAN so i could use boxes i have in other cities
  • Have each Lun “individual computer + drives” power up via WOL (wake on lan) initiated by the ZFS Master
  • Greater level of redundancy possible.
  • Backup “ZFS Master” possible
  • Everything connected via either Gigabit Ethernet or Fibre Channel.

So imagine.. a rack full of computers with hard drives in them… at the bottom is a more powerful computer running solaris which mounts the hdd’s of every single other computer and adds them into the zpool… then advertises this zpool over AFP / SMB to computers in my house…

Yet another way to make a α size tb system out of old free components that could possibly outperform a £20,000 solution! =) I’ll post all of the results of my testing after the break in a few days 🙂

P.S. This idea is without considering performance as that is something i can work out later 🙂 & thanks bda for your advice