GU Eduroam trouble solved

Connecting to Eduroam (at the University of Gothenburg) was tricky this time. The main problem was ensuring the CA Certificate was installed. Clicking the certificate link on the instructions page at Medarbetarportalen gave a message saying This certificate is already installed as a certificate authority. Yet, when configuring the WiFi connection, there was no option to choose that certificate (or any other certificate, for that matter). The trick turned out to be first saving the file, and then opening it.

You don’t have to bother with the crazy Eduroam CAT app.

So:

  1. Visit the Installationsguide Eduroam page.
  2. On Google Chrome, long-tap the certificate link at the bottom of the page and select Download link.
  3. Or, if you use another browser, save the file on a computer and transfer it to your phone 🤷‍♀️
  4. Install the certificate by either opening it through the file browser, or using Settings > Wi-Fi > Advanced > View more > Install network certificates.
  5. Finally, configure the network connection:
    EAP method: PEAP
    Phase 2 authentication: MSCHAPV2
    CA certificate: (whatever name you gave it, should be an option between Select certificate and Don’t validate)
    Identity: x…@gu.se or gus…@gu.se

This was with Android 8.0.0 on a Samsung Galaxy J3. Your mileage may vary. Good luck 🤞

Fix SSH backspace coming out as “^?”

When using SSH at FS Data, pressing backspace in Vim were coming out as ^? so editing files was a hassle. (I am on a Linux workstation btw.) mistyped

I found a solution in the Vim documentation, via a Stack Overflow post. I just opened ~/.vimrc and added the following:

:if &term == "xterm-256color"
:  set t_kb=CTRL-V<BS>
:endif

Here, xterm-256color is whatever came out when I ran :echo &term inside Vim. CTRL-V<BS> is not those literal characters, but the key combination Ctrl+V followed by Backspace. It comes out on the screen as ^?, like in the screenshot below.vimbs

Duplicated id="x" in WP Meta Boxes

I am building a very minimalistic calendar plugin for WP (an idea that doesn’t seem to turn out very well so far), and I got a cryptic JS error when adding JQuery datepicker saying “a is undefined”. I debugged this for a good two or three hours, until today I tried replacing the minified datepicker.js file with source code.

The error turned out to be caused by the same HTML id being assigned to a meta box div as well as to a custom field.

function transparentcalendar_add_meta_boxes() {
    add_meta_box( 'transparentcalendar-time', __( 'Calendar', 'transparentcalendar' ), 'transparentcalendar_meta_box_time', 'post' );
}

function transparentcalendar_meta_box_time( $post ) {
    $time_current = transparentcalendar_post_get_time( $post->ID );

    echo '<div class="form-field">
        <label for="transparentcalendar-time">' . __('Time', 'transparentcalendar') . '</label>
         <input id="transparentcalendar-time" name="transparentcalendar_time" type="text" size="20" value="' . $time_current . '" class="datepicker">';
}

I have learned these two simple things:

    • Get a HTML validator browser plugin, thus I might have noticed the duplicated id earlier
    • Use a dev version of WP when developing, as it uses non-minified JS

Customer-specified price in Drupal 7 Commerce

Today, I spent several hours messing about with the Rules UI and googling Commerce docs and forums, trying to figure out how to provide a field where the customer can freely choose the price of a donation-style product. In the end, I found pointers to a method which turns out to work pretty well.

My use case

Donation as a Drupal 7 Commerce product. Donation amount can be chosen freely, above a fixed minimum. The customer/donor receives a reward (but that is not actually relevant here).

Howto

This is how I did it:

  1. Install Commerce Customizable Products
  2. Add price field
    1. Add a line item type at admin/commerce/config/line-items. It is created with a bunch of default fields, which you cannot change.
    2. Add a field of the Price type (TODO: Figure out how to set a minimum)
  3. Make it visible
    1. At the field display settings of your product display content type (something like admin/structure/types/manage/product-display/display), edit the settings for the product reference field. Change Add to Cart line item type to your new line item type. Click Update and Save.
  4. Make it count
    1. Add a new rule at admin/config/workflow/rules. Choose the event Calculating the sell price of a product.
    2. Add an Entity has field condition with commerce-line-item for Entity and your price field for Field.
    3. Add a Set the unit price to a specific amount action with commerce-line-item for Line item and something like commerce-line-item:field-donation-price:amount for Amount.