Block and shorten URLs EARN MONEY – URL shorteners with CPA – Other ways to earn money

Lock.ist is a URL shortening service in combination with content blocking. The sales model of this network is CPA. So you won't be paid for clicks and impressions. Users need to take action such as: B. install software or fill out a simple form.

How do I start with Lock.ist?

If you shorten the link with Lock.ist, it will be locked automatically. The visitor has to do a simple task to unlock the link. You will receive a commission of $ 0.10 to $ 10 for each task.

payment

You will be paid within 2 working days once you have reached the minimum payment. The payment option is only Bitcoin. The minimum payout is $ 20.

Referral program

The publishers can earn extra money by referring others to this network. The commission rate is 10% for life.

Best properties

-This network accepts members worldwide.

– You do not need a website or blog to use this service.

-Tools (website widget, browser button and API)

– General system

-The members always receive a timely payment.

-Dedicated support

For tips and ideas: https://lock.ist/pages/tips-ideas

Ref Link: https://lock.ist/ref/MomMoney12

Shortcut: https://lock.ist/

mysql – Shorten retrieval of time tracking data for queries

I have a code that does the following:

  • Get data from the HrAttLogs table
  • Input data from the HrAttLogs Table for HrAttLogsFormatted table

I would like to know if the query below that I will provide can be improved. In terms of Performance and speed.

SELECT 
    FingerId, 
    ShiftId, 
    DateIn, 
    DateOut, 
    ScanIn, 
    ScanOut, 
    WorkhourIn, 
    WorkhourOut, 
    TIME_IN, 
    TIME_OUT
FROM
    (
    SELECT
        i.FingerId,
        i.ShiftId,
        i.Date AS 'DateIn',
        o.Date AS 'DateOut',
        i.Time AS 'ScanIn',
        CASE WHEN o.Time != i.Time THEN o.Time END AS 'ScanOut',
        CASE
            WHEN i.Time < i.ShiftIn_2 THEN i.WorkhourIn_1
            WHEN i.Time < i.ShiftIn_3 THEN i.WorkhourIn_2
            WHEN i.Time > i.ShiftIn_1 THEN i.WorkhourIn_3
    END AS WorkhourIn,
        /* Added check for Date too.. the last checking is for any overlapping Date */
        CASE WHEN i.Status = 'Rolling' THEN
                CASE
                    WHEN i.DateOut = i.Date AND i.Time > i.ShiftOut_1 THEN i.WorkhourOut_2
                    WHEN i.DateOut = i.Date AND i.Time > i.ShiftOut_2 THEN i.WorkhourOut_3
                    WHEN i.DateOut = i.Date AND i.Time > i.ShiftOut_3 THEN i.WorkhourOut_1
                    WHEN i.DateOut > i.Date THEN i.WorkhourOut_3
                END
        ELSE
            CASE WHEN i.ShiftId != 'Rolling' THEN 
                    CASE WHEN i.DateOut = i.Date AND o.Time > i.ShiftOut_2 THEN i.WorkhourOut_3
                    ELSE i.WorkhourOut_2
                    END
                    WHEN i.DateOut = i.Date AND o.Time > i.ShiftOut_3 THEN i.WorkhourOut_1
            END
        END AS WorkhourOut,
        CASE
            WHEN i.Time < i.ShiftIn_2 THEN TIMEDIFF(i.Time, i.WorkhourIn_1)
            WHEN i.Time < i.ShiftIn_3 THEN TIMEDIFF(i.Time, i.WorkhourIn_2)
            WHEN i.Time > i.ShiftIn_1 THEN TIMEDIFF(i.Time, i.WorkhourIn_3)
        END AS 'TIME_IN',
        CASE WHEN o.Time != i.Time THEN 
            CASE WHEN i.Status = 'Rolling' THEN
                CASE WHEN o.Time > i.ShiftOut_3 THEN 
                    CASE WHEN o.Time > i.ShiftOut_1 THEN 
                        CASE WHEN o.Time > i.ShiftOut_2 THEN TIMEDIFF(o.Time, i.WorkhourOut_2)
                        ELSE TIMEDIFF(o.Time, i.WorkhourOut_1)
                        END
                    ELSE TIMEDIFF(o.Time, i.WorkhourOut_1)
                    END 
                ELSE TIMEDIFF(o.Time, i.WorkhourOut_3)
                END
            ELSE
                CASE WHEN i.Status != 'Rolling' THEN
                    CASE WHEN o.Time > i.ShiftOut_1 THEN
                        CASE WHEN o.Time > i.ShiftOut_2 THEN TIMEDIFF(o.Time, i.WorkhourOut_1)
                        ELSE TIMEDIFF(o.Time, i.WorkhourOut_2)
                        END
                    END
                END
            END
        END AS 'TIME_OUT',
        i.ShiftIn_1,
        i.ShiftIn_2,
        i.ShiftIn_3,
        i.ShiftOut_1,
        i.ShiftOut_2,
        i.ShiftOut_3,
        i.WorkhourIn_2,
        i.WorkhourIn_3,
        i.WorkhourOut_2,
        i.WorkhourOut_3,
        i.Status
    FROM
        ( /* INSERT here */
                SELECT 
                    i.FingerId,
                    fs.ShiftId,
                CASE WHEN i.Status = 0 THEN
                    MIN(i.Date)
                END AS 'Date',
--         MIN(i.Date) AS 'Date',
                /* Added CASE expression to deal with overlapping attendance Date */
                CASE WHEN i.Status = 0 AND MIN(i.Time) >= '19:00:00' 
                     THEN DATE(DATE_ADD(i.Date, INTERVAL + 1 DAY)) 
                ELSE 
                    DATE(DATE_ADD(i.Date, INTERVAL + s.DayOut DAY)) 
                END AS 'DateOut', 
                    CASE WHEN i.Status = 0 THEN
                        i.Time
                    END AS 'Time',
--           MIN(i.Time) AS 'Time',
                    i.Status,
          s.ShiftIn_1,
          s.ShiftIn_2,
          s.ShiftIn_3,
          s.ShiftOut_1,
          s.ShiftOut_2,
          s.ShiftOut_3,
          s.WorkhourIn_1,
          s.WorkhourIn_2,
          s.WorkhourIn_3,
          s.WorkhourOut_1,
          s.WorkhourOut_2,
          s.WorkhourOut_3
        FROM HrAttLogs AS i
        INNER JOIN HrEmployee AS fs ON fs.FingerId = i.FingerId
        INNER JOIN HrEmployeeShift AS s ON s.Id = fs.ShiftId
        WHERE 
            i.Time >= s.ShiftIn_1
            AND i.Date >= '2020-04-07'
            AND i.Date <= '2020-04-09' 
            AND i.MachineIp = '10.20.20.73'
        GROUP BY
                        i.Id,
            i.FingerId, 
            i.Date 
        ) AS i
        LEFT JOIN (
            SELECT
                o.FingerId,
                CASE WHEN o.Status = 1 THEN
                    MAX(o.Date)
                END AS 'Date',
                CASE WHEN o.Status = 1 THEN
                    MAX(o.Time)
                END AS 'Time',
                o.Status
            FROM
                HrAttLogs AS o
            WHERE
                o.Date >= '2020-04-07'
                AND o.Date <= '2020-04-09'
                AND o.MachineIp = '10.20.20.73'
            GROUP BY
                o.Id,
                o.FingerId,
                o.Date
            ORDER BY
                Date ASC,
                Status ASC
        ) AS o ON i.FingerId = o.FingerId 
        AND o.Date = i.DateOut 
        AND o.Time >= '00:00:00'
    ) AS q
WHERE
    FingerId = 61
    AND FingerId IS NOT NULL
    AND ShiftId IS NOT NULL
    AND DateIn IS NOT NULL
    AND DateOut IS NOT NULL
    AND ScanIn  IS NOT NULL
    AND WorkhourIn IS NOT NULL
    AND WorkhourOut IS NOT NULL
    AND TIME_IN IS NOT NULL
    AND TIME_OUT IS NOT NULL
ORDER BY
    q.FingerId ASC,
    DateIn ASC

I'll save it here for more details

Rooting – debunk: triggering KNOX will shorten the battery life?

I have heard various people in XDA report that rooting a Samsung S8 (or something similar – S8 +, S7, S7 Edge, S6, S5, S9, etc.) will permanently lose 30% of your battery life.

Is that true? I think the myth is based on reports that KNOX Used 30% of the battery life in some phones and removing it will increase Battery life up 30%, but I have no way to prevent it.

I've had the experience that a damaged Samsung phone will lose a lot of its battery life. Maybe Knox stumbles?

Geometry – How many arcs do I have to cut if I shorten a chord?

I have the option to buy a quonset hut. It's a good deal. A quonset hut is a metal building and consists of half a cylinder. The interior is created by placing the opening side of the half cylinder down. Since it has a radius of 15 ″, the total width at the base is 30 ″. BUT I only have a 29 & # 39; 6 "foundation! My question: Given the intended (lower) chord of 30 & # 39; how much arc length needs to be cut to a (lower) chord of 29 & # 39; 6" to create?

c – Is there a way to simplify or shorten this chain of conditions in this version comparison code?

I wonder if there is a way to meaningfully shorten the chain of conditions used here to compare two versions. struct VERSIONCODE represents a version number of the form major.minor.revision and CompareVersions returns EQUAL if they are the same; LHS_NEWER if vLHS is newer and RHS_NEWER if vRHS is newer.

typedef enum
{
    EQUAL = 0,
    LHS_NEWER,
    RHS_NEWER
} ECOMPARISON;

// Specifically not named "VERSION" to avoid conflicting with common names from third-party libraries etc.
typedef struct
{
    int nMajor;
    int nMinor;
    int nRev;
} VERSIONCODE;

ECOMPARISON CompareVersions(VERSIONCODE vLHS, VERSIONCODE vRHS)
{
    if (vLHS.nMajor > vRHS.nMajor)
    {
        return LHS_NEWER;
    }
    else if (vLHS.nMajor < vRHS.nMajor)
    {
        return RHS_NEWER;
    }
    else// if (vLHS.nMajor == vRHS.nMajor)
    {
        if (vLHS.nMinor > vRHS.nMinor)
        {
            return LHS_NEWER;
        }
        else if (vLHS.nMinor < vRHS.nMinor)
        {
            return RHS_NEWER;
        }
        else// if (vLHS.nMinor == vRHS.nMinor)
        {
            if (vLHS.nRev > vRHS.nRev)
            {
                return LHS_NEWER;
            }
            else if (vLHS.nRev < vRHS.nRev)
            {
                return RHS_NEWER;
            }
            else// if(vLHS.nRev == vRHS.nRev)
            {
                return EQUAL;
            }
        }
    }
}

How can you shorten this C code to check the checksum?

This is a function that checks whether the checksum is correct. It works fine, but the code is terrible. I tried looping in a loop but it didn't work. card() is a character with 12 characters, which together represent a hexadecimal number. The checksum is OK if XOR is the sixth pair for the first five pairs. So I get pairs of card(), change it to number and check checksum.

bool checksum(char card())
{
int a=0;
char character0(2);
char character1(2);
char character2(2);
char character3(2);
char character4(2);
char character5(2);
long n0,n1,n2,n3,n4,n5;
char card_number;

    for(int i=0;i<2;i++)
    {
        for(a=0;a<2;a++)
        {
        character0(a)=card(i);
        }
    }
    for(int i=2;i<4;i++)
    {
        for(a=0;a<2;a++)
        {
            character1(a)=card(i);
        }
    }
    for(int i=4;i<6;i++)
    {
        for(a=0;a<2;a++)
        {
            character2(a)=card(i);
        }
    }
    for(int i=6;i<8;i++)
    {
        for(a=0;a<2;a++)
        {
            character3(a)=card(i);
        }
    }
    for(int i=8;i<10;i++)
    {
        for(a=0;a<2;a++)
        {
            character4(a)=card(i);
        }
    }
    for(int i=10;i<12;i++)
    {
        for(a=0;a<2;a++)
        {
            character5(a)=card(i);
        }
    }
    n0 = strtol(character0, NULL, 16);
    n1 = strtol(character1, NULL, 16);
    n2 = strtol(character2, NULL, 16);
    n3 = strtol(character3, NULL, 16);
    n4 = strtol(character4, NULL, 16);
    n5 = strtol(character5, NULL, 16);


if(n0^n1^n2^n3^n4==n5)  return true; 
else return false;


}

For example, the input is "1E00EDEecueF3", so 1E ^ 00 ^ ED ^ E5 ^ E5 should be F3.

And something is wrong with this code, I see it now because

if(n0^n1^n2^n3^n4==n5)  return true; 
else return false;

works fine, however

if((n0^n1^n2^n3^n4)==n5))   return true; 
else return false;

doesn't work at all.

Payskip.org – Shorten URLs and make money

[IMG]

Payskip.org is a completely free tool that allows you to create short links that are not only free but also paid for!

We offer high CPM rates as standard, but especially for our loyal users.
Check our publisher prices here: https://payskip.org/payout-rates

Ad prices: https://payskip.org/advertising-rates
If you think your traffic deserves higher CPM rates, you can contact us to request an increase or a fixed CPM …

Payskip.org – Shorten URLs and make money

Excel VBA to shorten the runtime with functions other than .find

My code here goes through my folder and my files inside the folder and uses them.find and copy the strings into a new Excel sheet and then with all the data in the new sheet, I will use .Find(What:=) In order to find the strings within the new worksheet and then either divide or use the right, left, mean, and sometimes replace functions, 68 files take a run of 1 minute and 30 seconds with that code, and I need help to make it more efficient and faster coding, please advise me! Even better, if you can provide a small code!

Option Explicit

Sub GenerateData()

    Application.ScreenUpdating = False

    Dim wks As Worksheet
    Dim wkb As Workbook
    Set wkb = ActiveWorkbook
    Set wks = wkb.Worksheets.Add(After:=wkb.Worksheets(wkb.Worksheets.Count), Type:=xlWorksheet)

    ' Add headers data
    With wks
        .Range("A1:K1") = Array("Test", "Temp", "Type", "Start", "FileName", "No", "End", _
        "Month", "Smart", "Errors", "ErrorCellAddress")
    End With

    ' Early Binding - Add "Microsoft Scripting Runtime" Reference
        Dim FSO As New Scripting.FileSystemObject
    ' Set FolderPath
        Dim FolderPath As String
            FolderPath = "c:UsersDesktopTryout"
    ' Set Folder FSO
        Dim Folder As Scripting.Folder
            Set Folder = FSO.GetFolder(FolderPath)

    ' Loop thru each file
        Dim File As Scripting.File
        Dim a As Range, b As Range, c As Range, d As Range, e As Range, f As Range, g As Range, h As Range, l As Range
            For Each File In Folder.Files

            Dim wkbData As Workbook
                Set wkbData = Workbooks.Open(File.Path)

            Dim wksData As Worksheet
                ActiveSheet.Name = "Control"
                Set wksData = wkbData.Worksheets("Control") ' -> Assume this file has only 1 worksheet

        'Format of the data
            Dim BlankRow As Long
                BlankRow = wks.Range("A" & wks.Rows.Count).End(xlUp).Row + 1

        ' Write filename in col E,F,G
            wks.Cells(BlankRow, 5).Value = File.Name
            wks.Cells(BlankRow, 6).Value = File.Name
            wks.Cells(BlankRow, 7).Value = File.Name

        'Find Testtest
            Set a = wksData.Columns("A:A").Find("  testtest         : ", LookIn:=xlValues)
        If Not a Is Nothing Then
            wks.Cells(BlankRow, 1).Value = a.Value
        End If

        'Find Temp
            Set b = wksData.Columns("A:A").Find("  testflyy         : ", LookIn:=xlValues)
        If Not b Is Nothing Then
            wks.Cells(BlankRow, 2).Value = b.Value
        End If

        'Find Type
            Set d = wksData.Columns("A:A").Find("  testflyy         : ", LookIn:=xlValues)
        If Not d Is Nothing Then
            wks.Cells(BlankRow, 3).Value = d.Value
        End If

        'Find start
            Set l = wksData.Columns("A:A").Find("  Started at: ", LookIn:=xlValues)
        If Not l Is Nothing Then
            wks.Cells(BlankRow, 4).Value = l.Value
        End If

        'Find Smart
            Set c = wksData.Columns("A:A").Find("SmartABC ", LookIn:=xlValues)
        If Not c Is Nothing Then
            wks.Cells(BlankRow, 9).Value = c.Value
        Else
            Set f = wksData.Columns("A:A").Find("SmarABCD Version ", LookIn:=xlValues)
        If Not f Is Nothing Then
            wks.Cells(BlankRow, 9).Value = f.Value
        Else
            Set g = wksData.Columns("A:A").Find("smarabcd_efg revision", LookIn:=xlValues)
        If Not g Is Nothing Then
            wks.Cells(BlankRow, 9).Value = g.Value
        End If
        End If
        End If

        'Find Errors
            Set e = wksData.Columns("A:A").Find("ERROR: ABC", LookIn:=xlValues)
        If Not e Is Nothing Then
            wks.Cells(BlankRow, 10).Value = e.Value
            wks.Cells(BlankRow, 11).Value = e.Address
        Else
            Set h = wksData.Columns("A:A").Find("ERROR: EFG", LookIn:=xlValues)
        If Not h Is Nothing Then
            wks.Cells(BlankRow, 10).Value = h.Value
        End If
        End If


        ' Trim and tidy up Data

    'Trim Testtest RowA(1)
    wks.Cells(BlankRow, 1).Replace What:="testtest         : ", Replacement:="", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False

    'Trim StartTime RowD(4)
    wks.Cells(BlankRow, 4).Replace What:="  Started at: ", Replacement:="", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False

    'Trim Temp RowB(2)
        Dim strSearchB As String, strSearchC As String
        Dim bCell As Range, cCell As Range
        Dim s2 As String, s3 As String
            strSearchB = "  testflow         : B"
            strSearchC = "  testflow         : M"

    Set bCell = wks.Cells(BlankRow, 2).Find(What:=strSearchB, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False)

    If Not bCell Is Nothing Then
        s2 = Split(bCell.Value, ":")(1)
        s2 = Mid(s2, 1, 3)
        bCell.Value = s2
    Else

    Set cCell = wks.Cells(BlankRow, 2).Find(What:=strSearchC, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False)

    If Not cCell Is Nothing Then
        s3 = Split(cCell.Value, ":")(1)
        s3 = Mid(s3, 10, 2)
        cCell.Value = s3
    End If
    End If

    'Trim Type RowC(3)
        Dim strSearchD As String, strSearchE As String
        Dim dCell As Range, eCell As Range
        Dim s4 As String, s5 As String
            strSearchD = "  testflow         : B"
            strSearchE = "  testflow         : M1947"

    Set dCell = wks.Cells(BlankRow, 3).Find(What:=strSearchD, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False)

    If Not dCell Is Nothing Then
        s4 = Split(dCell.Value, "_", 3)(2)
        s4 = Mid(s4, 1, 3)
        dCell.Value = s4
    Else

    Set eCell = wks.Cells(BlankRow, 3).Find(What:=strSearchE, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False)

    If Not eCell Is Nothing Then
        eCell.Value = "123"
    End If
    End If

    'Trim No RowF(6)
        Dim strSearchF As String
        Dim fCell As Range
        Dim s6 As String
            strSearchF = "homebeestrash_archivetreser"

    Set fCell = wks.Cells(BlankRow, 6).Find(What:=strSearchF, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False)

    If Not fCell Is Nothing Then
        s6 = Split(fCell.Value, "treser")(1)
        s6 = Mid(s6, 1, 2)
        fCell.Value = s6
    End If

    'Trim EndDate RowG(7)
        Dim strSearchG As String
        Dim gCell As Range
        Dim s7 As String
            strSearchG = "homebeestrash_archivetreser"

    Set gCell = wks.Cells(BlankRow, 7).Find(What:=strSearchG, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False)

    If Not gCell Is Nothing Then
        s7 = Split(gCell.Value, "reports")(1) 
        s7 = Split(s7, "Report")(0) 
        s7 = Left(s7, 8) & " " & Right(s7, 6) 
        'Month Row H(8)
        wks.Cells(BlankRow, 8).Value = WorksheetFunction.Transpose(Left(s7, 4) & "-" & Mid(s7, 5, 2) & "-" & Mid(s7, 7, 2)) 
        gCell.Value = s7
    End If
        wks.Cells(BlankRow, 8).NumberFormat = "($-en-US)mmmm d, yyyy;@" 'Set Date format

    'Trim Smart
        Dim strSearchST As String
        Dim stCell As Range
        Dim s8 As String
            strSearchST = "This is "

    Set stCell = wks.Cells(BlankRow, 9).Find(What:=strSearchST, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False)

    If Not stCell Is Nothing Then
        s8 = Split(stCell.Value, "This is ")(1)
        s8 = Mid(s8, 1, 29)
        stCell.Value = s8
    End If

    wkbData.Close False
    Next File

    'Add AutoFilter
    Dim StartDate As Long, EndDate As Long

    With wks.Cells(BlankRow, 8)
        StartDate = DateSerial(Year(.Value), Month(.Value), 1)
        EndDate = DateSerial(Year(.Value), Month(.Value) + 1, 0)
    End With

    wks.Cells(BlankRow, 8).AutoFilter Field:=5, Criteria1:=">=" & StartDate, Operator:=xlAnd, Criteria2:="<=" & EndDate
    If ActiveSheet.FilterMode Then ActiveSheet.ShowAllData

End Sub
```

Calculus and analysis – [NOOB]How can I shorten the time to integrate this feature?

I try the function & # 39; Cumul1 & # 39; by defining other relevant functions. The problem is that the computation literally takes an eternity of time because the relevant functions consist of both special functions and a series of terms. This is not optimal for my goal, & # 39; Cumul1 & # 39; by maximizing the integration range. I tried to find the solution, and received some hints, eg. For example, using NIntegrate, but most of them are not applicable to my case because my integration code contains variables in integer boundaries. So I want to ask … How can I shorten this integration?

fc = 40*10^3
fs = 80*10^3
t1 = 3.9*10^-3
t0 = 6.9*10^-3
nr = Round(0.00204361*fc)
n1 = Round(t1*fc)
n0 = Round(t0*fc)
u0 = 0
u1 = 0.37*10^-9
Prob0(x_) = 1/2 (1 + Erf((x - u0)/s))
Prob1(x_) = 1/2 (1 + Erf((x - u1)/s))
N1(x_) = E^((1 - x)/n1)/(n1 (1 - E^(2 - nr/n1)))
N0(x_) = E^((1 - x)/n0)/n0
S(n_, x_) = (n/nr Prob1(x) + (nr - n)/nr Prob0(x))^nr
Cumul1(x_) = Integrate(N1(t) (Integrate(N0 (n) S(n, x), {n, 1, nr - t}) + Integrate(N0(n) S(n, x), {n, nr - t, Infinity})), {t, 1, nr - 1})

Partitioning – To shorten a disk image file of unused space without damaging the GPT partition table (end pointer)

Lots of information about creating a disk image, shrinking the root partition (bionic), and then truncating the image to remove the part that became free space. Like https://softwarebakery.com//shrinking-images-on-linux

So there are basically three steps. Use resize2fs to shrink a file system on a partition, and then shrink the partition as well. Then finally remove the unused space in the image file.

It's the third part I'm having a problem with. Each time I try to create or trim an image, all partitions of the image are removed as if the GPT partition table in the image file had been moved to the Trash.

Here is the original picture

GPT fdisk (gdisk) version 1.0.3

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk rock64-base.img: 30310400 sectors, 14.5 GiB
Sector size (logical): 512 bytes
Disk identifier (GUID): 159DCEDE-DBEA-4657-96D9-2CE178A96B7E
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 30310366
Partitions will be aligned on 64-sector boundaries
Total free space is 30 sectors (15.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              64            8063   3.9 MiB     8300  loader1
   2            8064            8191   64.0 KiB    8300  reserved1
   3            8192           16383   4.0 MiB     8300  reserved2
   4           16384           24575   4.0 MiB     8300  loader2
   5           24576           32767   4.0 MiB     8300  atf
   6           32768          262143   112.0 MiB   0700  boot
   7          262144        30310366   14.3 GiB    8300  root

Then after the first two steps

Found valid GPT with protective MBR; using GPT.
Disk test.img: 30310400 sectors, 14.5 GiB
Sector size (logical): 512 bytes
Disk identifier (GUID): 159DCEDE-DBEA-4657-96D9-2CE178A96B7E
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 30310366
Partitions will be aligned on 64-sector boundaries
Total free space is 23555002 sectors (11.2 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              64            8063   3.9 MiB     8300  loader1
   2            8064            8191   64.0 KiB    8300  reserved1
   3            8192           16383   4.0 MiB     8300  reserved2
   4           16384           24575   4.0 MiB     8300  loader2
   5           24576           32767   4.0 MiB     8300  atf
   6           32768          262143   112.0 MiB   0700  boot
   7          262144         6755394   3.1 GiB     8300  primary

You can see that the root file system partition has been reduced to 3.1G

I can load the picture well. I can put it back on an SD card and boot my device. Steps 1 and 2 are okay.

Enter image description here

NOW…

when I finish the process, I do a
`truncate –size = $ ((6755394 + 1) * 512) & # 39; test.img & # 39;

and

GPT fdisk (gdisk) version 1.0.3

Warning! Disk size is smaller than the main header indicates! Loading
secondary header from the last sector of the disk! You should use 'v' to
verify disk integrity, and perhaps options on the experts' menu to repair
the disk.
Caution: invalid backup GPT header, but valid main header; regenerating
backup header from main header.

Warning! Error 25 reading partition table for CRC check!
Warning! One or more CRCs don't match. You should repair the disk!

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: damaged

****************************************************************************
Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk
verification and recovery are STRONGLY recommended.
****************************************************************************
Disk test2.img: 6755395 sectors, 3.2 GiB
Sector size (logical): 512 bytes
Disk identifier (GUID): 159DCEDE-DBEA-4657-96D9-2CE178A96B7E
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 30310366
Partitions will be aligned on 64-sector boundaries
Total free space is 23555002 sectors (11.2 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              64            8063   3.9 MiB     8300  loader1
   2            8064            8191   64.0 KiB    8300  reserved1
   3            8192           16383   4.0 MiB     8300  reserved2
   4           16384           24575   4.0 MiB     8300  loader2
   5           24576           32767   4.0 MiB     8300  atf
   6           32768          262143   112.0 MiB   0700  boot
   7          262144         6755394   3.1 GiB     8300  primary

Enter image description here

Obviously cut off (or dd for that matter) does not play well with GPT.
If you run gdisk on this file, it confirms that gpt has been moved to the Trash

When I run gdisk on the truncated file, a GPT error is reported.

So obviously I miss something here. If the end of the volume file changes, the GPT appears to be corrupted or needs to be repaired (mismatched). Although it is ok at the end of step 2, I played around with gdisk and could not fix it. Also, I wanted a solution that I could do with a script, and it does not work with this GPT.

Since it is a GPT, I have to use something other than "Truncate" or "DD" or I have to "fix" the GPT manually after truncation.

Here's what Gdisk reviews

Caution: The CRC for the backup partition table is invalid. This table may
be corrupt. This program will automatically create a new backup partition
table when you save your partitions.

Problem: The secondary header's self-pointer indicates that it doesn't reside
at the end of the disk. If you've added a disk to a RAID array, use the 'e'
option on the experts' menu to adjust the secondary header's and partition
table's locations.

Problem: Disk is too small to hold all the data!
(Disk size is 6755395 sectors, needs to be 30310400 sectors.)
The 'e' option on the experts' menu may fix this problem.

Problem: GPT claims the disk is larger than it is! (Claimed last usable
sector is 30310366, but backup header is at
30310399 and disk size is 6755395 sectors.
The 'e' option on the experts' menu will probably fix this problem

Partition(s) in the protective MBR are too big for the disk! Creating a
fresh protective or hybrid MBR is recommended.