Deprecated: Function jetpack_form_register_pattern is deprecated since version jetpack-13.4! Use Automattic\Jetpack\Forms\ContactForm\Util::register_pattern instead. in /var/www/html/wp-includes/functions.php on line 6078 Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-includes/functions.php:6078) in /var/www/html/wp-includes/feed-rss2.php on line 8 Software – D Khaz https://khaz.me Things that I spend my time on... Fri, 06 Aug 2021 03:48:33 +0000 en-US hourly 1 https://khaz.me/wp-content/uploads/2018/05/DK_logo_square___100x100.png Software – D Khaz https://khaz.me 32 32 147286311 “There was an error connecting to the Apple ID server” in MacOS password reset https://khaz.me/there-was-an-error-connecting-to-the-apple-id-server-in-macos-password-reset/ Fri, 06 Aug 2021 03:40:55 +0000 https://khaz.me/?p=500

While trying to reset my SO’s password, I was getting this error. This was after trying to log in on the main boot and rebooting into password recovery mode. I tried several wifi networks and tethering to my phone to no avail. I then rebooted and went into a guest mode which reboots the OS into a Safari-only state and wasn’t able to connect to any sites. This was a hint.

Next, I Reset NVRAM and then rebooted with Command + R. Don’t select any of the recovery options and instead select Network Tools (or something like that) under Utilities. I rejoined my wifi network and was able to successfully ping apple servers (apple.com).

Then, I went back to Utilities and opened the terminal. I had a hunch the date on this machine was off as it had been without power in a closet for a while. Using the date command I was able to confirm this as it told me it was April. To fix this, type ntpdate -u time.apple.com and hit enter. Now you have accurate time.

Finally, in terminal you type resetpassword and hit enter. This will bring up the Apple reset password dialog box. Select the first option, log in with your Apple ID, and it should now work with any errors.

Hopefully, this saves you a few minutes and some heartburn. Donations to my coffee fund are appreciated!

]]>
500
Configuring DuckDNS dynamic DNS on the Ubiquiti USG https://khaz.me/configuring-duckdns-dynamic-dns-on-the-ubiquiti-usg/ Wed, 10 Jun 2020 17:42:45 +0000 https://khaz.me/?p=350 I have a remote USG deployed at a relative’s house and need to have a way to access the UniFi Security Gateway’s WAN IP if the ISP changes it.

Steps to implement

  1. Create a user account on www.duckdns.org. This will generate a new user token. Save this as you will need it later and don’t share this.
  2. Create a subdomain on www.duckdns.org
  3. Go to your UniFi controller and set up a config.gateway.json file, instructions here.
  4.  Add the below configuration to this file. Replace SUBDOMAIN with just the subdomain of your duckdns site and replace TOKEN from your account token.
  5. Go to your UniFi Controller and reprovision your USG. Your dynamic DNS should now be working
{
  "service": {
    "dns": {
      "dynamic": {
        "interface": {
          "eth0": {
            "service": {
              "dyndns": {
                "host-name": [
                  "SUBDOMAIN"
                ],
                "login": "nouser",
                "password": "TOKEN",
                "server": "www.duckdns.org"
              }
            },
            "web": "dyndns"
          }
        }
      }
    }
  }
}

Check to make sure it works

To check and confirm the USG is updating the DNS correctly, you can SSH into the USG and run show dns dynamic status.

show dns dynamic status
interface    : eth0
ip address   : 123.123.123.123
host-name    : SUBDOMAIN
last update  : Wed Jun 10 12:08:20 2020
update-status: good

You can also force an update by running update dns dynamic interface eth0

]]>
350
An easier way to download your AliExpress order history https://khaz.me/an-easier-way-to-download-your-aliexpress-order-history/ Fri, 01 May 2020 10:21:38 +0000 https://khaz.me/?p=297 While there are some benefits to using AliExpress, ease of use of the website is definitely not one of them.  I was looking for a way to download my order history, it’s useful for many reasons to know what you’ve ordered.  However, AE doesn’t give you any way of doing this.  It appears I wasn’t alone as there are many that have worked on this and continue to need it.

Below is a tampermonkey script to parse the data from your AliExpress order history page and copy it to your clipboard as CSV.  It also pulls in the tracking number and status and displays it on the page.  I tried to get the tracking to copy into CSV, but I have no idea what I’m doing.

The high-level process to get this working:

  1. Install Tapermonkey extension in Chrome
  2. Create a new script with the code below or click here to do it automagically
  3. Goto your AliExpress order history page
  4. This script will create two additional buttons:
    • One to copy all of the order data
    • And another to copy the header
  5. Now just paste the header into your favorite spreadsheet as the first row and follow by the data itself.

Tampermonkey script

// ==UserScript==
// @name         Ali Express Order Downloader
// @namespace    https://gist.github.com/
// @version      0.3
// @description  Retrieve Aliexpress order information and export as CSV via clipboard
// @author       You
// @match        https://trade.aliexpress.com/orderList.htm*
// @grant        unsafeWindow
// @grant        GM_xmlhttpRequest
// @grant        GM_setClipboard
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @require      https://code.jquery.com/jquery-latest.js
// @require      https://www.17track.net/externalcall.js
// ==/UserScript==

// Original order data script: https://gist.github.com/Bolukan/16146e6e9c3c7e05a8a23f8b2f8a1dc4
// Original order tracking script: https://gist.github.com/rafal83/6dea29d07743a8a7bab091e31e3c9782

// I couldnt get the tracking number and status to extract to the tables. 

function parseDate(txt)
{
    // 012345678901234567
    // 10:31 May. 21 2019
    // var d = new Date(year, month (0-11), day, hours, minutes, seconds, milliseconds);
    return new Date(txt.slice(14,18),("Jan.Feb.Mar.Apr.May.Jun.Jul.Aug.Sep.Oct.Nov.Dec.".indexOf(txt.slice(6,10)))/4, txt.slice(11,13), txt.slice(0,2), txt.slice(3,5),0,0);
}

var listTrack = new Array();
var totalTrack = 0;
var dt = 0;

getTrackingNumber = function(data){
    //console.log(data);
    console.log(listTrack.length+'/'+totalTrack);
    var orderId = data.cainiaoUrl.split('=')[1];
    var trackId = data.tracking[0].mailNo;
    var oneUrl = 'https://www.17track.net/fr/track?nums='+trackId;
    var status = data.tracking[0].keyDesc;
    listTrack.push(trackId);
    if(data.tracking[0].traceList) {
        dt = new Date(data.tracking[0].traceList[0].eventTime);
        status += '<br/>'+dt.toLocaleString()+'<br/>'+data.tracking[0].traceList[0].desc;
    }
    jQuery('.button-logisticsTracking[orderid='+orderId+']')
        .before('<td class="tracking_number" style="background-color: red;color: white;font-weight: bold;padding:0px">'+data.tracking[0].mailNo+'</td>')
        .before('<span class="tracking_status" style="color: black;font-weight: bold;font-size: 13px;">'+status+'</span>');
};

(function() {
    'use strict';

    function getAllTrackingNumber() {
        console.log("Search orders");
        listTrack.length=0;
        totalTrack = jQuery('.button-logisticsTracking').length;
        if(totalTrack > 0) {
            console.log("Total "+totalTrack);
            jQuery('.button-logisticsTracking').each(function() {
                var orderId = jQuery(this).attr('orderid');
                jQuery.ajax({
                    url:document.location.protocol+'//ilogisticsaddress.aliexpress.com/ajax_logistics_track.htm?orderId='+orderId+'&callback=getTrackingNumber',
                    dataType:'jsonp'
                });
            });
        }
    }
    getAllTrackingNumber();
})();

var orders = [];
var items = [];
var reqs = [];
var options = { weekday: undefined, year: 'numeric',
                month: '2-digit', day: '2-digit',
                hour: '2-digit', minute: '2-digit'};
$(".order-item-wraper").each((ind, eo)=>{
  var hasTracking = $(eo).find(".button-logisticsTracking ").length > 0;
  let order = {
    order_id:     $(eo).find(".order-info .first-row .info-body ").text().trim(),
    order_time:   parseDate($(eo).find(".order-info .second-row .info-body").text().trim()).toLocaleDateString('nl-NL', options),
    order_amount: $(eo).find(".order-amount .amount-num").text().trim(),
    order_status: $(eo).find(".order-status .f-left").text().trim(),
    store_name:   $(eo).find(".store-info .first-row .info-body").text().trim(),
    store_url:    $(eo).find(".store-info .second-row a:first()").attr('href'),
    order_tr_num: $(eo).find(".order-action .tracking_number").text().trim(),
    order_tr_stat: $(eo).find(".order-body .order-action .tracking_status").text().trim(),
    product_action: $(eo).find(".product-action span:first()").text().trim(),
    hasTracking:  hasTracking,
  }
  orders.push(order);
//  console.log("Tracking number: " + order.order_tr_num );
//  console.log("Tracking status: " + order.product_action );

  var products = [];
  var inum = 0;
  $(eo).find(".order-body").each((i,eb)=>{
    $(eb).find(".product-sets").each((i,ep)=>{
      let product = {
        order_product_num: ++inum,
        product_id:        $(ep).find(".product-title .baobei-name").attr('productId'),
        product_title:     $(ep).find(".product-title .baobei-name").attr('title'),
        product_url:       $(ep).find(".product-title .baobei-name").attr('href'),
        product_pic_url:   $(ep).find(".product-left img").attr('src'),
        product_snapshot:  $(ep).find(".product-snapshot .baobei-name").attr('href'),
        product_count:     $(ep).find(".product-amount span:nth-child(2)").text().trim().slice(1), // remove parcer for different currency
        product_price:     $(ep).find(".product-amount span:first()").text().trim(),
        product_skuid:     $(ep).find(".product-property span:first() span:first()").attr('id'),
        product_property:  $(ep).find(".product-property span:first() span:first()").text().trim(),
        //product_action:    $(ep).find(".product-action span:first()").text().trim(),
        order:             order,
      };
//      console.log($(ep).find(".product-action span:first()").text().trim());
      products.push(product); // local all products
      items.push(product); // global all products
     //   console.log(item);
    });
 //  console.log(products);
  });
/*
  let order = {
    id: $(el).find(".order-info .first-row .info-body ").text().trim(),
    status: $(el).find(".order-status .f-left").text().trim(),
        orderPrice: $(el).find(".amount-num").text().trim(),
        productPriceAndAmount: $(el).find(".product-right .product-amount").text().trim().replace(/(?:\s\s)/g, ""),
        productsNames: products.map((it)=> it.title).join(", "),
	    orderDate: $(el).find(".order-info .second-row .info-body").text().trim(),
	    sellerName: $(el).find(".store-info .first-row .info-body").text().trim(),
        hasTracking: hasTracking,
        products: products,
    };
*/
/*
  if (hasTracking){
    var req = new Promise((resolve, reject) => {
      GM_xmlhttpRequest({
        method: "GET",
        url: "https://ilogisticsaddress.aliexpress.com/ajax_logistics_track.htm?orderId=" + order.id + "&callback=test",
        onload:(data)=>{
          order.tracking = eval(data.responseText).tracking;
          order.trackingNumber = order.tracking.map(it=>it.mailNo).join(", ");
          resolve(order);
          orders.push(order);
        },
        onerror: () => reject(400)
      });
    });
    reqs.push(req);
  } else{
    orders.push(order);
  }
*/
});
//console.log(JSON.stringify(orders));

$.when.apply(null, reqs).done(function(){
  //   console.log(orders);
  // console.log(orders.length);
});
//<button id="search-btn" class="ui-button ui-button-primary search-btn" type="button">Search</button>

$('#mybutton').one('click', function(){
  var r=$('<input/>').attr({
    type:  "button",
    id:    "field",
    value: 'LOAD CSV'
  });
  $("body").append(r);
});

$('<button/>', {
  text: "Copy Orders CSV",
  id: 'csvBtn',
  click: function () {
    $("#csvBtn").text("Loading...");
    Promise.all(reqs).then(o =>{
      var s = "";
      items.forEach(e=> {
        s += e.order.order_id + "\t";
        s += e.order.order_time + "\t";
        s += ((e.order_product_num==1) ? e.order.order_amount : "") + "\t";
        s += e.order.order_status + "\t";
        s += e.order.hasTracking + "\t";
//        s += e.order.order_tr_num + "\t";
//        s += e.order.order_tr_stat + "\t";
        s += e.order_product_num + "\t";
        s += "\"" + e.product_title + "\"\t";
        s += "\"" + e.product_property + "\"\t";
        s += e.product_count + "\t";
        s += e.product_price + "\t";
        s += e.order.product_action + "\t";
        s += e.product_id + "\t";
        s += ((typeof(e.product_skuid)=='undefined') ? "" : "\"" + e.product_skuid + "\"") + "\t";
        s += e.order.store_name + "\t";
        s += "https:" + e.order.store_url + "\t";
        s += "https:" + e.product_url + "\t";
        s += "\"" + e.product_pic_url + "\"\t";
        s += "https:" + e.product_snapshot + "\t";
        s += "https://trade.aliexpress.com/order_detail.htm?orderId=" + e.order.order_id + "\t";
        s += "\n";

      });
      //console.log(s);
      GM_setClipboard (s);
      $("#csvBtn").text("Orders on clipboard");
    });
  }
}).appendTo("#appeal-alert");

$('<button/>', {
  text: "Copy HEADER",
  id: 'headerBtn',
  click: function () {
    $("#headerBtn").text("Copied!");
    Promise.all(reqs).then(o =>{
      var h = "";
        {
        h += "Order Number" + "\t";
        h += "Order Date" + "\t";
        h += "Total Order Amount" + "\t";
        h += "Order Status" + "\t";
        h += "Tracking Available" + "\t";
//        h += "Tracking Number" + "\t";
//        h += "Tracking Status" + "\t";
        h += "Item Number of Order" + "\t";
        h += "Item Title" + "\t";
        h += "Item Selections" + "\t";
        h += "Item QTY" + "\t";
        h += "Item Price" + "\t";
        h += "Item Actions" + "\t";
        h += "Item Number" + "\t";
        h += "SKU" + "\t";
        h += "Store Name" + "\t";
        h += "Store URL" + "\t";
        h += "Item URL" + "\t";
        h += "Item Picture URL" + "\t";
        h += "Item Snapshot URL" + "\t";
        h += "Order Detail URL" + "\t";
        };
      GM_setClipboard (h);
      $("#headerBtn").text("Header copied");
    });
  }
}).appendTo("#appeal-alert");

]]>
297
Turning off your Touch Bar Macbook Pro screen without closing the lid https://khaz.me/turning-off-your-macbook-pro-screen-without-closing-the-lid/ Fri, 24 Apr 2020 04:06:10 +0000 https://khaz.me/?p=275

I’ve had a Touch Bar Macbook Pro for three years.  It’s generally been running fine, but as of late, it’s starting to make more fan noise than necessary.   With my previous 2014 unit, I would operate in clams hell mode.  I’m not sure if that the official name, but I did this by putting a magnet around the frame.  This fooled the OS into thinking the lid is closed so it would disable the built-in display eliminating the graphics overhead.  I had tried this years ago after I upgraded to the newer model, but it didn’t work.  I spent some time googling back then and didn’t find the solution.  Then again this week, the fans spun up and I said to my self enough and that I’ll figure this out.   After all, how hard can this be?  Famous last words.

I thought I’d have a quick and dirty solution for this in a few minutes…famous last words.  I started off by googling again to see if there was a solution since my original searches but it was a waste of time.  I’ve watched a handful of Louis Rossmann videos over the years and remembered that I should be able to track down some schematics online.  After finding the schematics, I was able to locate the name of the hall sensor for determining the lid position.  On the schematics, its called out as J5250.  At this point, I figured out why I couldn’t get it to work with my previous “slide a magnet around the perimeter until the screen turned off” tactic.  The newer design uses two hall effect sensors to prevent false positives.

Now I knew what the chip was called, just not where it was located.  So I had to find the board view files for the main logic board.  Then they wouldn’t open in Eagle, so I found Open Board View which opened the file without issues.  Finally, this showed me where the sensors are located.  I did some testing to confirm the location of these sensors to trigger the console mode.  Unfortunately, there is something magnetic near the sensors that pulls the magnets away so they don’t stay in place.  So I continued down the path of unnecessary overbuilt solution.

So I went into Fusion and designed a mount to hold the 6mm round neodymium magnets in place.  I had to split the part in two as it’s too big for a single print and then hit the print button.

And here it is, in all its simple glory:

     

And here it is in action in the real world:

This design makes it easy to place in the right spot and turn off the screen in one easy move.  Here are the files if you want to print your own:

 

 

Documents that I used for reference:

  • My machine: MacBook Pro w/ Touchbar 15.4″ 3.1GHz Core i7 (A1707, MPTU2LL/A, MacBookPro14,3) [source]
  • My logic board: Apple PN: 661-07829 / Manufacturer PN: 820-00928 [source]
  • Schematic for APPLE MACBOOK PRO 15 A1707 X363G MLB [source]
  • Board View File for Logic Board [source]
  • Open Board View for viewing the PCB [source]
]]>
275
Moving ScanSnap Receipts Database to a new Mac https://khaz.me/moving-scansnap-receipts-database-to-a-new-mac/ https://khaz.me/moving-scansnap-receipts-database-to-a-new-mac/#comments Sat, 11 Aug 2018 17:35:28 +0000 https://khaz.me/?p=134 I recently moved to a new MacBook. Part of the transition required moving my Fujitsu ScanSnap ix500 ScanSnap Receipts over to the new machine. While the scanner is an incredible piece of hardware that lives up to typical Japanese over engineered standards, the software is a complete dumpster fire.  The only options provided for exporting the data is to either get the CSV data of your receipts or as images/PDFs.  No option to just move your database with receipt data and images to another machine.

So here’s a simple way to move your files over.

Grab the Receipt DB.ssrdb database file from the old machine. Install ScanSnap Receipts on the new machine.  Place your database file into the same folder on the new machine, overwriting the empty database.

~/Library/Application Support/PFU/ScanSnap Receipt/Receipt DB.ssrdb

 

I ran into a problem where after doing this I was getting “Internal Error (-34)” errors while viewing receipts and the images were not showing up.  I did some digging around.  Right-clicking on the ssrdb > Show Package Contents.  Navigate down to the folder containing the images.

~/Library/Application Support/PFU/ScanSnap Receipt/Receipt DB.ssrdb/ssrimg/body

What I found was that all of my images had file extensions of either .jpg or .tif but the software did not need them.  I used two bash scripts to rename these files to remove the extensions:

for i in *.jpg
do
mv -- "$i" "${i%.jpg}"
done

 

for i in *.tif
do
mv -- "$i" "${i%.tif}"
done

 

This fixed my problem and the receipts were showing up as expected.  I’m not sure why the extensions were added. It might have been because I used Google Drive to transfer the files.

]]>
https://khaz.me/moving-scansnap-receipts-database-to-a-new-mac/feed/ 4 134