uniq -f (ignore first n fields – or with rev last n fields)

#find web access log files in backups – only take one from each date – put them together in date order in one file

#!/bin/bash
FOO=`find /backups/*/a/var/log/nginx -name "access.log*" -ls|cut -b 60-|sort -k 1 -k 2 -k 3|rev|uniq -f 1|rev|awk '{ print $4 }'`
for file in `ls -rt $FOO`; do
gzip -cd $file|grep website.com >> /var/tmp/joined.access.log
done

lineageOS 20.0 TheMuppets blueline roomservice.xml

.repo/local_manifests/roomservice.xml

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
  <project path="device/google/blueline" remote="github" name="LineageOS/android
_device_google_blueline" revision="lineage-20" />
  <project path="device/google/crosshatch" remote="github" name="LineageOS/andro
id_device_google_crosshatch" revision="lineage-20" />
  <project path="kernel/google/msm-4.9" remote="github" name="LineageOS/android_
kernel_google_msm-4.9" revision="lineage-20" />
  <project path="packages/apps/ElmyraService" remote="github" name="LineageOS/an
droid_packages_apps_ElmyraService" revision="lineage-20.0" />
  <project name="TheMuppets/proprietary_vendor_google_blueline" path="vendor/goo
gle/blueline" remote="github" revision="lineage-20" />
  <remote name="gitlab" fetch="https://gitlab.com" />
  <project name="the-muppets/proprietary_vendor_firmware" path="vendor/firmware"
 remote="gitlab" revision="lineage-20" depth="1" />
</manifest>

dynamic/live search box with php, javascript, mysql

I went through a bunch of iterations with this a couple years ago and didn’t get it working.

This is the second one I tried recently and was able to get what I wanted for hyperlinked results.

https://www.codingcage.com/2016/12/autocomplete-search-with-href-link-php.html

code blobs for posterity:

database:

--
-- Database: `codingcage`
--

-- --------------------------------------------------------

--
-- Table structure for table `tbl_posts`
--

CREATE TABLE IF NOT EXISTS `tbl_posts` (
  `postID` int(11) NOT NULL AUTO_INCREMENT,
  `postTitle` varchar(255) NOT NULL,
  `postUrl` varchar(255) NOT NULL,
  PRIMARY KEY (`postID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;

--
-- Dumping data for table `tbl_posts`
--

INSERT INTO `tbl_posts` (`postID`, `postTitle`, `postUrl`) VALUES
(1, 'Simple jQuery Add, Update, Delete with PHP and MySQL', 'http://goo.gl/IL6NTr'),
(2, '15 Free Bootstrap Admin Themes Demo and Download', 'http://goo.gl/1dBwEy'),
(3, 'Easy Ajax Image Upload with jQuery, PHP', 'http://goo.gl/jXZ6LY'),
(4, 'How to Send HTML Format eMails in PHP using PHPMailer', 'http://goo.gl/kQrzJP'),
(5, 'Ajax Bootstrap Signup Form with jQuery PHP and MySQL', 'http://goo.gl/yxKrha'),
(6, 'Submit PHP Form without Page Refresh using jQuery, Ajax', 'http://goo.gl/14vlBe'),
(7, 'How to Convert MySQL Rows into JSON Format in PHP', 'http://goo.gl/qgOiwB'),
(8, 'Designing Bootstrap Signup Form with jQuery Validation', 'http://goo.gl/nECERc'),
(9, 'Upload, Insert, Update, Delete an Image using PHP MySQL', 'http://goo.gl/HRJrDD'),
(10, 'Login Registration with Email Verification, Forgot Password using PHP', 'http://goo.gl/O9FKN1');

php:

<?php
 
 $DBhost = "localhost";
 $DBuser = "root";
 $DBpass = "";
 $DBname = "codingcage";
 
 try {
  $DBcon = new PDO("mysql:host=$DBhost;dbname=$DBname",$DBuser,$DBpass);
 } catch(PDOException $ex){
  die($ex->getMessage());
 }
$keyword = trim($_REQUEST['term']); // this is user input

 $sugg_json = array();    // this is for displaying json data as a autosearch suggestion
 $json_row = array();     // this is for stroring mysql results in json string
 

 $keyword = preg_replace('/\s+/', ' ', $keyword); // it will replace multiple spaces from the input.

 $query = 'SELECT postID, postTitle, postUrl FROM tbl_posts WHERE postTitle LIKE :term'; // select query
 
 $stmt = $DBcon->prepare( $query );
 $stmt->execute(array(':term'=>"%$keyword%"));
 
 if ( $stmt->rowCount()>0 ) {
  
  while($recResult = $stmt->fetch(PDO::FETCH_ASSOC)) {
      $json_row["id"] = $recResult['postUrl'];
      $json_row["value"] = $recResult['postTitle'];
      $json_row["label"] = $recResult['postTitle'];
      array_push($sugg_json, $json_row);
  }
  
 } else {
     $json_row["id"] = "#";
     $json_row["value"] = "";
     $json_row["label"] = "Nothing Found!";
     array_push($sugg_json, $json_row);
 }
 
 $jsonOutput = json_encode($sugg_json, JSON_UNESCAPED_SLASHES); 
 print $jsonOutput;

html:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0, maximum-scale=2.0">
<title>AutoComplete Example in PHP MySQL</title>
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="http://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
</head>

<body>

 <div class="container">
    
     <div class="page-header">
        <h3 style="color:#00a2d1; font-size:30px; font-family: Impact, Charcoal, sans-serif; text-align: center;">AutoComplete Search with Href Link in PHP MySQL</h3>
        </div>
         
        <div class="row">
        
         <div class="col-lg-12 text-center">
          
         <div class="col-lg-offset-2">
             <form>
             <div class="form-group">
             <div class="input-group">
             <input id="txtSearch" class="form-control input-lg" type="text" placeholder="Search for PHP, MySQL, Ajax and jQuery" />
             <div class="input-group-addon"><i class="glyphicon glyphicon-search"></i></div>
             </div>
             </div>
             </form>  
             </div> 
                
            </div>
        
        </div>
        
    </div>

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>

<script>
$(document).ready(function(){
 
 $('#txtSearch').autocomplete({
     source: "post_search.php",
     minLength: 2,
     select: function(event, ui) {
         var url = ui.item.id;
         if (url != '#') {
             location.href = url
         }
     },
     open: function(event, ui) {
         $(".ui-autocomplete").css("z-index", 1000)
     }
 })
 
}); 
</script>

</body>
</html>

This site was the first one that I got working – but I wasn’t happy with using it for hyperlinked results.

https://codeforgeek.com/ajax-search-box-php-mysql/

code blobs for posterity:

 

WARNING: sanitize your input and prevent code injection attacks

html file:

<html>
  <head>
    <title>Ajax Search Box using PHP and MySQL</title>
    <scriptsrc="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">        </script>
     <script src="typeahead.min.js"></script>
  </head>
  <body>
   <inputtype="text" name="typeahead">
  </body>


  <script>
    $(document).ready(function(){
      $('input.typeahead').typeahead({
        name: 'typeahead',
        remote:'search.php?key=%QUERY',
        limit : 10
      });
    });
  </script>
</html>
search.php:
<?php
    $key=$_GET['key'];
    $array = array();
    $con=mysqli_connect("localhost","root","","demos");
    $query=mysqli_query($con, "select * from cfg_demos where title LIKE '%{$key}%'");
    while($row=mysqli_fetch_assoc($query))
    {
      $array[] = $row['title'];
    }
    echo json_encode($array);
    mysqli_close($con);
?>

nominatim php-intl error message Class Transliterator not found code 0

ubuntu package management decided I didn’t need the current version of php-intl which was running in apache so nominatim fell on it’s face with this error message

“error”
“message” => Class “Transliterator” not found
“code” => 0))

I found the current version of php running in apache with this (put it in a file under the webserver and point a browser at it

<?php
phpinfo();

and then install the relevant version of php-intl

control of domain(s) associated with nextcloud snap

associate domain names with your nextcloud snap

$ nextcloud.occ config:system:set trusted_domains 1 \
--value=nextcloud.foo.bar
$ nextcloud.occ config:system:set trusted_domains 2 \
--value=192.168.1.11

and then get new certs from letsencrypt

$ nextcloud.enable-https lets-encrypt

from:
https://medium.com/@dbclin/administrating-nextcloud-as-a-snap-4eb43ca6d095

android games without ads or in-app-purchases

solitaire

https://play.google.com/store/apps/details?id=com.IskoGames.SolitaireCardGames&hl=en&gl=us $0

https://play.google.com/store/apps/details?id=com.brasskeysoftware.yukongold&hl=en&gl=us $1.99

tetris

https://play.google.com/store/apps/details?id=com.voriacorporation.tetris&hl=en&gl=us $0

https://play.google.com/store/apps/details?id=woodblock.puzzle.brick.tetris&hl=en&gl=us $0

Also some games on f-droid like 2048

copy of https://arkienet.com/2018/01/google-fi-dialer-codes/ for posterity

Google Fi Dialer Codes

Here are a list of dialer codes that can be used with Google Fi.  These codes shouldn’t be used unless you are aware that they may impact the way your Fi phone switches between carriers.

 

Carrier Selection

The following options are only available for “Designed for Fi” phones. They will not work on the iPhone or “Compatible with Fi” phones because they are T-Mobile only.  See which class of phone you have here.

ALPHA CODE DIALER CODE DESCRIPTION
FI AUTO *#*#342886#*#* Set carrier selection to automatic.
FI NEXT *#*#346398#*#* Select Next Carrier
FI SPR *#*#34777#*#* Select Sprint for 2 hours
FI TMO *#*#34866#*#* Select T-Mobile 2 hours
FI USC *#*#34872#*#* Select US Cellular 2 hours
FI SIMON *#*#3474666#*#* Select Three (UK only)

Service Codes

ALPHA CODE DIALER CODE DESCRIPTION
FIXME *#*#34963#*#* Force reactivation
FI INFO *#*#344636#*#* Get information about the current network.
INFO *#*#4636#*#* Get general phone information.
DEBUG *#*#33284#*#* Phone Debug Options
PRL *#*#775#*#* Force download of Preferred Roaming List (Sprint)
PRL *228 Force download of Preferred Roaming List (US Cellular)
FI ROAM *#*#347626#*#* Turn on International Roaming
SWITCH
SIM
*#*#794824746#*#* Switch to / from eSim.

install lineageOS on blueline (pixel 3)

copy of https://lineageosroms.com/blueline/ for posterity

Install LineageOS on blueline

Basic requirements

  1. Make sure your computer has adb and fastboot. Setup instructions can be found here.
  2. Enable USB debugging on your device.

Unlocking the bootloader

  1. Enable OEM unlock in the Developer options under device Settings, if present.
  2. Connect the device to your PC via USB.
  3. On the computer, open a command prompt (on Windows) or terminal (on Linux or macOS) window, and type:
    adb reboot bootloader
    

    You can also boot into fastboot mode via a key combination:

    • With the device powered off, hold Volume Down + Power.
  4. Once the device is in fastboot mode, verify your PC finds it by typing:
    fastboot devices
    
  5. Now type the following command to unlock the bootloader:
    fastboot flashing unlock
    
  6. If the device doesn’t automatically reboot, reboot it. It should now be unlocked.
  7. Since the device resets completely, you will need to re-enable USB debugging to continue.

Temporarily booting a custom recovery using fastboot

  1. Download a custom recovery – you can download Lineage Recovery. Simply download the latest recovery file, named something like lineage-17.1-20201116-recovery-blueline.img.
  2. Connect your device to your PC via USB.
  3. On the computer, open a command prompt (on Windows) or terminal (on Linux or macOS) window, and type:
    adb reboot bootloader
    

    You can also boot into fastboot mode via a key combination:

    • With the device powered off, hold Volume Down + Power.
  4. Once the device is in fastboot mode, verify your PC finds it by typing:
    fastboot devices
    
  5. Temporarily flash a recovery on your device by typing:
    fastboot flash boot <recovery_filename>.img
    
  6. With the device powered off, hold Volume Down + Power.

Installing LineageOS from recovery

  1. Download the LineageOS installation package that you would like to install or build the package yourself.
    • Optionally, download additional application packages such as Google Apps (use the arm64 architecture).
  2. If you are not in recovery, reboot into recovery:
    • With the device powered off, hold Volume Down + Power.
  3. Now tap Factory Reset, then Format data / factory reset and continue with the formatting process. This will remove encryption and delete all files stored in the internal storage, as well as format your cache partition (if you have one).
  4. Return to the main menu.
  5. Sideload the LineageOS .zip package:
    • On the device, select “Apply Update”, then “Apply from ADB” to begin sideload.
    • On the host machine, sideload the package using: adb sideload filename.zip
  6. (Optionally): If you want to install any additional add-ons, click Advanced, then Reboot to Recovery, then when your device reboots, click Apply Update, then Apply from ADB, then adb sideload filename.zip those packages in sequence.
  7. Once you have installed everything successfully, click the back arrow in the top left of the screen, then “Reboot system now”.

Update to a newer build of the same LineageOS version on blueline

Updating your device

Using the LineageOS Updater app

  1. Open Settings, navigate to “System”, then “Updater”.
  2. Click the Refresh Icon in the top right corner.
  3. Choose which update you’d like and press “Download”.
  4. When the download completes, click “Install”. Once the update process has finished, the device will display a “Reboot” button, you may need to go into the Updater menu in Settings, “System” to see it. This will reboot you into the updated system.

From your PC via the push_update script (Linux/macOS only)

  1. Make sure your computer has working adb. Setup instructions can be found here.
  2. Enable USB debugging on your device. Additionally, open Settings, then “System”, then “Developer Options”, and then either check “Rooted Debugging” (LineageOS 17.1 or above) or select “Root Access Options”, then “ADB Only”.
  3. Run adb root
  4. Run wget
    https://raw.githubusercontent.com/LineageOS/android_packages_apps_Updater/lineage-16.0/push-update.sh
    && chmod +x push-update.sh
  5. Run: ./push-update.sh /path/to/zip
  6. Open Settings, navigate to “System”, then “Updater”. click “Install”. Once the update process has finished, the device will display a “Reboot” button, you may need to go into the Updater menu in Settings, “System” to see it. This will reboot you into the updated system.

backup/install android app from adb

search elsewhere for how to enable developer mode, and how to enable usb debugging.

#then find the fullname of the app

$adb shell 'pm list packages' |grep i foo
package:com.bar.android.foo

#Then find the path to the app

$ adb shell pm path com.bar.android.foo
package:/data/app/com.bar.android.foo-asdfasdfasdfasdfasdfas==/base.apk

# then download the app

$ adb pull /data/app/com.bar.android.foo-asdfasdfasdfasdfasdfas==/base.apk

#then later or on another device restore the app

$ adb install -r base.apk