Recent Updates Toggle Comment Threads | Keyboard Shortcuts

  • Jay Versluis 10:01 am on April 13, 2015 Permalink | Reply  
    Categories: Announcements, Linux ( 7 )

    LAMP Stack for Humans – now available on Amazon 

    Lampstack-SoftcoverMy book LAMP Stack for Humans is now available on Amazon. It this 284 page guide I’ll walk you through the process of turning an old laptop into an always-on server. You can use it to run web applications in the comfort of your own home or office – no “cloud” required.

    Together we will configure the entire server: you will learn how to install CentOS, Apache, PHP and MySQL (or MariaDB) and WordPress. I will show you how you can reach your server from other computers on the network and how to create regular backups.

    Perfect for the Linux newbie and those who want to get started with web applications without spending money “in the cloud” (in my opinion THE WORST expression for describing remote computers).

    If you’re an avid reader of this site and have always wished that some instructions would be presented in a more cohesive form rather than in snippets, then LAMP Stack for Humans is perfect for you.

     

    Grab your free sample today, or read the entire book for free via Kindle Unlimited!

     

     
    • Falkon 2:28 am on October 21, 2015 Permalink | Reply

      Hi Jay
      I have a question regarding WP adding a Landing page for an existing site, meaning to add a new page which only displays a big logo in the start and be able to make that logo a roleover logo, and then the click would navigate a user to the main ( index page) if you will. i am new to WP and PHP wise I am still learning so I would not know how to add an extra page as the index page and the first index page turns say into a home.html. How would you do that? I trying to learn PHP and WP to what I work with in HTML & CSS and front end designs.
      Beforehand allow me to thank you for you time, help and assistance,

      Best Regards
      Falkon

      • Jay Versluis 2:55 pm on October 21, 2015 Permalink | Reply

        Hi Falkon, that’s a VERY off-topic question for this post…

        WordPress does have a way to display a static page as front page, instead of the default blog posts. You can change it like this:

        • for the blog, create a new page with a title (no content is necessary)
        • head over to Settings – Reading
        • under Front Page Displays, select your pages
        • hit Save and refresh the front page

        As for the roll-over image: insert an image into your static front page, then link that image to wherever you want (you can do that with Add Media from the page creation dialogue).

        Hope this helps!

  • Jay Versluis 2:05 pm on January 16, 2016 Permalink | Reply
    Tags: Dolphin, Gamecube, Xbox Controller   

    Categories: Mac OS X ( 25 )

    How to connect your Xbox 360 Controller to Dolphin for Mac 

    DolphinI’ve been experimenting with the marvellous Dolphin Emulator recently. It’s an open source project that allows us to play Nintendo Gamecube and Wii games on modern hardware. Dolphin is available for Windows, OS X and Linux.

    I have a wireless Xbox 360 controller for Windows at my disposal, but the only Windows hardware I have is the first generation Surface Pro. While the controller connects without issues, the Surface sadly just isn’t fast enough to run Dolphin.

    My more powerful hardware is Mac based, and Dolphin runs great on my Mac Mini. But I had no idea how to connect my Xbox controller to it.

    Turns out it’s actually a breeze to setup: let me show you how it worked for me on OS X El Capitan.

    (More …)

     
  • Jay Versluis 5:16 pm on January 13, 2016 Permalink | Reply
    Tags: , ,   

    Categories: Commodore ( 24 )

    How to use direct block access commands in Commodore DOS 

    Commodore-Logo-PaddedWe can access each sector’s raw data on Commodore disk drives with direct block access commands. Supported drives include the 1541, 1571, the VICE emulator as well as the SD2IEC card reader (for the most part).

    Each single sided floppy contains 35 sectors, while a double sided 1571 formatted disk contains 70 sectors. Each track contains between 17 and 21 sectors depending on how far inside or outside they are. Each sector contains 255 bytes we can read or write.

    Sectors are the same as blocks: only the directory refers to them as “blocks” and shows us how many we have available.

    We’ll need to open two channels to our disk drives: a command channel and a data channel. Here’s how to do it:
    (More …)

     
  • Jay Versluis 9:17 am on January 2, 2016 Permalink | Reply
    Tags:   

    Categories: Commodore ( 24 )

    How to save data to your C128 RAM Expansion Unit (REU) 

    Commodore-Logo-PaddedWith a RAM Expansion Unit (REU), the Commodore 128 could address up to 512k of data. That was huge in the late eighties! All you needed was one of those REUs, plug it into your cartridge port, and so much more super fast memory was at your fingertips.

    But even with such a cartridge at hand, how do we actually make use of it from CBM BASIC 7.0? With three funky commands called STASH, FETCH and SWAP. Here’s how we can use them.

    The REUs cannot be addressed directly, like other memory in your computer. Instead, data has to be either copied from the C128 to the REU, or vice versa, or swapped out. All three commands take the same four parameters:

    • number of bytes to transfer
    • location in the C128 memory to start
    • REU bank (0-7, depending on the size of the REU)
    • location in the REU bank memory

    This sounds more cryptic than it actually is: the largest REU split 512k over 8 banks of 64k, so that the 8bit operating system could address it.

    So to store 200 bytes of C128 memory, starting at location 5000, saving it inside the REU’s bank 0, location 0, we can use the STASH command like so:

    STASH 200,3000,0,0
    

    To retrieve our data later and bring it back to the same C128 location as before, we can use FETCH with the same parameters:

    FETCH 200,3000,0,0
    

    Rather than copying, we can also exchange data in two places by literally swapping it over. Again the parameters are the same:

    SWAP 200,3000,0,0
    

    Enabling REUs in VICE

    Although I have a physical C128, I do not have a real REU. Maybe one day I’ll find one on eBay, but until then there’s an easy way to emulate an REU using VICE.

    To enable one, head over to Settings – Resource Inspector – Cartridges – REU. Pick the size you like, and even a hard disk location to make the contents of your REU survive restarts.

    Screen Shot 2016-01-02 at 09.08.35

    Screen Shot 2016-01-02 at 09.09.19

    Demo Listing

    Here’s a quick test that allows us to store an arbitrary message in memory, then stash or retrieve it from an attached REU.

    100 print "1 store message in internal memory"
    110 print "2 print message"
    120 print "3 stash message in reu"
    130 print "4 retrieve message from reu"
    140 print "5 clear internal memory"
    141 print "6 quit"
    150 input "your choice";m
    160 on m gosub 1010,1090,1210,1410,1310,2000
    170 run
    1000 :
    1010 rem input and save
    1020 input "what shall we store";a$
    1030 for i=1 to len(a$)
    1040 c$=mid$(a$,i,1)
    1050 poke 3000+i,asc(c$)
    1060 next
    1070 return
    1080 :
    1090 rem retrieve message
    1100 print:print "retrieving..."
    1110 for i=1 to 100
    1120 c=peek(3000+i)
    1130 b$=b$+chr$(c)
    1140 next
    1150 print b$
    1160 return
    1200 :
    1210 rem stash to reu
    1220 stash 200,3000,0,0
    1230 return
    1300 :
    1310 rem clear internal memory
    1320 for i=1 to 200
    1330 poke 3000+i,0
    1340 next
    1350 return
    1400 :
    1410 rem retrieve from reu
    1420 fetch 200,3000,0,0
    1430 return
    2000 :
    2010 rem the end
    2020 end
    

    We don’t see many BASIC listings these days anymore. Enjoy!

     
  • Jay Versluis 5:58 pm on December 27, 2015 Permalink | Reply
    Tags:   

    Categories: Commodore ( 24 )

    How to create relative data files on your Commodore 128 

    Commodore-Logo-PaddedThe CBM DOS can write “relative data” onto disk, based on individual records. The advantage is that all space is allocated once and then randomly accessed if and when it’s needed – much like the tracks on a CD.

    This approach is different from sequential files, which have to read or write the whole file in one go (Apple call this “reading and writing atomically”). So finding the 50th record in a sequential file can take some time, whereas retrieving record 50 from a relative file is just as fast as retrieving record 1 or record 157.

    Let’s see how we can deal with such relative files in CBM BASIC 7.0. This works with all physical disk drives (1541, 1571, etc) as well as the SD2IEC card reader – but not with your trusty old Datasette (for obvious reasons).

    This was revolutionary back in 1982!

    Creating Relative Files

    Here we create a new file with a REL extension using the DOPEN# keyword. When we do this for the first time, we need to tell the operating system how much data we’d like to allocate per record. Anything up to 255 bytes is fine. We’ll use 100 bytes in this example (the letter L followed by the length).

    10 dopen#1,"rel test",l100
    20 for i=1 to 100
    30 record#1,i
    40 a$="record"+str$(i)
    45 print "writing record ";i
    50 print#1,a$
    60 next
    70 close 1
    80 print "all done!"
    

    When we create a new file, CBM DOS doesn’t know how many records we’ll need, but it will create as many as necessary on the file. Here we create 100 entries using a for loop and write them to disk using the PRINT# statement.

    Notice that before saving a record, we must position the record pointer using RECORD#. That’s how our data is written to the correct position on disk. The whole loop will take a while to complete, but all space will be allocated on the disk as soon as we CLOSE the file.

    To add more records, we’ll simply position the record pointer to a later entry – even if one does not yet exist. CBM DOS will create the last record and all records leading up to it so they can be used later, up to a maximum of 65535 (space permitting obviously).

    Reading data from Relative Files

    Much like with sequential data, we can either use INPUT# or GET# to grab the data for an individual record. INPUT# reads everything until a CHR$(13) is found and works much faster, while GET# reads data one character at a time and is a lot slower.

    10 input"which record shall we retrieve";r$
    20 dopen#1,"rel test"
    30 record#1,val(r$)
    40 input#1,a$
    50 close 1
    60 print:print a$:print
    70 print"need another one? (y/n)"
    80 getkey k$:if k$="y" then goto 10:else end
    

    Here we ask the user which record we want to retrieve. Next we open our relative file using DOPEN#, position to the desired RECORD# and then read in its value using INPUT#. When we’re done we close the file and ask if the user wants to retrieve another record.

    While this type of data access is quick and convenient, it doesn’t help much unless you know which record is stored at which position. Think of an address book application: to find “Johnny Appleseed” can’t be done unless you sift through every single record until you find him.

    Commodore therefore suggest to use sequential files alongside relative files, in which things like a last name could be saved together with the record number. Likewise, another sequential file could hold all records for the first names, and appended accordingly when a new record is created, or replaced when updated.

     
  • Jay Versluis 5:36 pm on December 27, 2015 Permalink | Reply
    Tags:   

    Categories: Commodore ( 24 )

    How to create sequential files on your Commodore C128 

    Commodore-Logo-PaddedSequential files are files to which we can write arbitrary data and read it back later. We can even append data to the file later without having to re-write the whole file.

    This works with the Datasette (tape drive) as well as floppy drives. Here’s how to do it in CBM BASIC 7.0:

    Creating Sequential Files

    The C128 has a few special commands up its sleeve to aid us in this task. Here we create a new file using the DOPEN keyword and write 100 statements to it.

    10 dopen#1,"@seq test",w
    20 for i=1 to 100
    30 a$="record"+str$(i)
    40 print#1,a$
    50 print "writing ";a$
    60 next
    70 close 1
    

    We’re creating a new sequential file (SEQ extension rather than the usual PRG), using the w after the filename so that BASIC knows to create the file. The @ sign in front of the file name makes sure this file is overwritten every time we run the programme – omit it if you don’t want that functionality.

    Next we create a loop and generate a variable spelling RECORD 1, RECORD 2, etc. That’s your data. Each entry may be up to 127 characters in length (I believe) and is saved to the file by using the PRINT# keyword. Anything we could print to the screen, we can also print to a file.

    With each new PRINT# command, a carriage return is saved to disk. This can come in handy when we’re reading the data back in. If you need special characters to separate your data, feel free to use them.

    Appending data to Sequential Files

    If we need to add anything to the file (much like Linux would add to the end of a text file using the “greater than” symbol), we can use the APPEND# keyword:

    10 append#1,"seq test"
    20 for i=101 to 150
    30 a$="record"+str$(i)
    40 print#1,a$
    50 print "appending ";a$
    60 next
    70 close 1
    

    APPEND# opens the file for adding data and positions the pointer after the last entry in our file. We’ll do something very similar as above, creating records 101 to 150 and adding them to the file. Make sure to CLOSE the file so all data is saved to disk.

    Reading Sequential Data

    Much like PRINT# can be used to write data to disk, we can use INPUT# to read data back – almost equivalent to the INPUT keyword get get user input from a keyboard. The only difference is that out input comes from a different device:

    10 dopen#1,"seq test"
    20 for i=1 to 150
    30 input#1,a$
    40 print a$
    50 next
    60 close 1
    

    Here we open our file with DOPEN# and grab each entry in the file using the INPUT# keyword. This will automatically position the next INPUT# when a carriage return is received (CHR$(13)).

    This will work just fine as long as the original data does not contain any special characters, like a scary comma. If you need such characters, or if you want to ignore the carriage return, you can also use the GET# command to read one character at a time from disk. This is dramatically slower though.

    Notice that there’s no “end of file” marker as such: right now we need to know how many entries there are and read them accordingly. Reading beyond the data in our file will simply repeat the last record (on real devices) or crash your system (on VICE).

     
  • Jay Versluis 10:30 am on December 24, 2015 Permalink | Reply
    Tags:   

    Categories: Commodore ( 24 )

    How to switch the Commodore 1571 into 1541 mode and back 

    Commodore-Logo-PaddedThe Commodore 1571 floppy drive powers up in compatibility mode and behaves just like a 1541 drive – unless a C128 is connected and sends it a fast serial transfer.

    They did this because otherwise the drive wouldn’t be compatible with the C64 and Plus/4.

    The C128 speaks to its attached disk drive when we power it on, and that’s how a 1571 turns on its super fast magical properties. Holding down the Commodore key will boot into C64 mode, and the 1571 will in turn reset itself to 1541 emulation mode.

    Lucky for us, we can change this with a simple command, no matter what computer we’re using or which mode we’re currently in. This is done by first opening a command channel and then sending the 1571 the following switch command:

    // switch on 1571 mode
    OPEN 15,8,15,"U0>M1"
    CLOSE 15
    
    // switch on 1541 mode
    OPEN 15,8,15,"U0>M0"
    CLOSE 15
    

    This will let the 1571 behave like a 1571 even when attached to a C64 or Plus/4: format floppies on both sides and enjoy 1328 blocks without flipping disks. Sadly it won’t transfer data any faster because the attached computers just can’t handle it.

    Conversely, if we want to use a C128 and have our drive remain in 1541 mode for testing or compatibility, it works equally well.

    Rebooting your computer will reset this value. As far as I know, there is no way to test which mode the drive is in before issuing either of the above commands.

     
  • Jay Versluis 2:47 pm on December 12, 2015 Permalink | Reply
    Tags:   

    Categories: Mac OS X ( 25 )

    How to check the Fan Speed on your Mac 

    Sometimes you may want to know how fast your fans are spinning, more as a “number value” rather than a “noise value”. While you can hear when your Mac in front of you is working hard, it’s impossible to tell how fast those fans are spinning when you’re miles away from your Mac in a data centre.

    Thankfully there is an easy way to read out the fan speed with a small built-in utility we can access from the command line. Launch a terminal session and issue spindump as admin user:

    sudo spindump
    
    Password:
    Sampling all processes for 10 seconds with 10 milliseconds of run time between samples
    Sampling completed, processing symbols...
    Spindump analysis written to file /tmp/spindump.txt
    

    It’ll take a few seconds, at the end of which a file is produced that tells you a lot more than just the fan speed. To filter this info out, issue the following:

    cat /tmp/spindump.txt | grep "Fan speed"
    Fan speed:       3151 rpm (-317)
    

    And there you have it! Execute this command under low load, then try again under heavy load to see your low and high spin numbers to get an impression how how busy your Mac’s fans are.

    To remove that temporary file and avoid your hard disk from being clogged up, issue this when you’re done:

    sudo rm /tmp/spindump.txt
    

    This may not be the most elegant way to read out your fan speeds, but it works without installing additional utilities. The spindump command is computationally expensive, so don’t do it continuously – there are better tools for that (such as smcFanControl, or others – see the link below).

     
  • Jay Versluis 11:31 am on December 2, 2015 Permalink | Reply
    Tags:   

    Categories: Mac OS X ( 25 )

    How to disable System Integrity Protection on OS X El Capitan 

    System Integrity Protection was introduced in El Capitan to add another layer of security to OS X. The system prevents the root user from doing things that are potentially harmful. Apple did this because any app at any time may ask for the administrator password and execute commands with elevated permissions, which is a big security risk on single user systems.

    There are downsides to yet another layer of security, and much like Gate Keeper, System Integrity Protection brings us one step closer to a completely locked off system like iOS. I guess that’s the long term plan.

    Until then, and if you need it, you can disable System Integrity Protection. Here’s how to do it:

    • boot into the Recovery Partition (hold down CMD + R during boot)
    • this takes a little longer than usual
    • when the system is back, select Utilities – Terminal
    • now type “csrutil disable”
    • close Terminal and restart the system

    You can check at any time if this feature is on or off by typing

    csrutil status
    
    System Integrity Protection status: disabled.
    

    Enable it again during a Recovery session by typing “csrutil enable” and El Capitan is secured again.

    To see what else this command has to offer, type csrutil without parameters:

    csrutil
    
    usage: csrutil <command>
    Modify the System Integrity Protection configuration. All configuration changes apply to the entire machine.
    Available commands:
    
        clear
            Clear the existing configuration. Only available in Recovery OS.
        disable
            Disable the protection on the machine. Only available in Recovery OS.
        enable
            Enable the protection on the machine. Only available in Recovery OS.
        status
            Display the current configuration.
    
        netboot
            add <address>
                Insert a new IPv4 address in the list of allowed NetBoot sources.
            list
                Print the list of allowed NetBoot sources.
            remove <address>
                Remove an IPv4 address from the list of allowed NetBoot sources.
    
     
  • Jay Versluis 11:03 am on November 24, 2015 Permalink | Reply
    Tags:   

    Categories: Themes, WordPress ( 25 )

    How to turn plain URLs into clickable links in WordPress 

    The marvellous P2 Theme has an interesting feature: write out a plain link, and it magically becomes clickable without explicitly adding the a href tag.

    This may not be a big deal if you’re writing posts in the visual WordPress editor rather than HTML, but for those of us who like to write in HTML, it’s just one less thing to worry about.

    I was investigating this feature recently, and it turns out WordPress has a built-in function that can do this: they call it make_clickable(), and it works with URIs, FTP, Email addresses and anything starting with www. The function is really easy to use too: it only takes one parameter (a string), and returns the clickable HTML code.

    $clickableText = make_clickable($plainText);
    

    Let’s see how to use it in context, using the TwentyThirteen theme.

    (More …)

     
  • Jay Versluis 9:58 am on November 21, 2015 Permalink | Reply
    Tags: ,   

    Categories: WordPress ( 131 )

    How to display Jetpack stats per post in WordPress 

    Some websites employ this or similar technologies to show how many views a single post has had. I was wondering how they did that without starting to count stats that have already been counted for several years, either by Google or by Jetpack.

    Yesterday I came across this post by Topher about how to render Jetpack Stats: http://wpgr.org/2013/03/02/rendering-jetpack-stats/

    I decided to test this in TwentyThirteen, and it works a treat – here’s how to do it. The principle will of course work with any theme.

    (More …)

     
    • Jay Versluis 11:41 am on November 23, 2015 Permalink | Reply

      Notice that if you have over 500 posts, or your website has been around for longer than 3 years, Jetpack has a LOT of stats to fetch. If you experience a 500 Server Error, this is an indication of a Jetpack timeout – in which case, the above approach is probably not for you.

      Just thought I’d let you know.

c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel