Automating Android on Bash

#!/bin/bash

emulator -avd Nexus_7_API_27 &

# Wait for the emulator to fully start
echo "Waiting for emulator to start..."
boot_completed=false
while [ "$boot_completed" != "1" ]; do
  sleep 5
  boot_completed=$(adb -e shell getprop sys.boot_completed 2>/dev/null)
done

echo "Emulator is fully started."

# run activity on app
adb shell am start -n package/activity 

PERM RECOVERY ISO BOOT

Saved from https://forum.manjaro.org/t/usb-flash-disk-wont-format-read-only/142823/16
 Make some space on sdc and create a 10GB vfat partition and flag it with boot,esp and name the partition and file system “RECOVERY”.
 Mount it and install grub on it:

sudo mount --mkdir --label RECOVERY /mnt/recovery
sudo grub-install --target=x86_64-efi --recheck --removable --efi-directory=/mnt/recovery --boot-directory=/mnt/recovery/boot --verbose --force

Create an efi entry in your UEFI/BIOS:
sudo efibootmgr --create --disk /dev/sda --part 7 --label "Recovery" --loader '\EFI\BOOT\BOOTX64.

DataExpert.io Copy & Paste

`SHOW CREATE TABLE bootcamp.nba_game_details`

Display a statement that creates the table

Code to search JSON file and return the record if found

import json

# Specify the filename
filename = 'contacts.json'

# Function to search for a contact by name
def search_contact_by_name(contacts, name):
    for contact in contacts:
        if contact['name'].lower() == name.lower():
            return contact
    return None

# Read the JSON data from the file
try:
    with open(filename, 'r') as json_file:
        data = json.load(json_file)
except FileNotFoundError:
    print(f"The file {filename} does not exist.")
except json

JPA-Spring-Data

## JPA-Spring Tips and Tricks

### Rollback programatically
`TransactionAspectSupport.currentTransactionStatus().setRollbackOnly()`

Read JSON data from file

import json

# Specify the filename
filename = 'contact.json'

# Try to read the JSON data from the file
try:
    with open(filename, 'r') as json_file:
        data = json.load(json_file)
    print(data)
except FileNotFoundError:
    print(f"The file {filename} does not exist.")
except json.JSONDecodeError:
    print(f"Error decoding JSON from the file {filename}.")

Write data to file in JSON format

import json

# Define the data as a list of dictionaries
data = [
    {
        'name': 'John',
        'surname': 'Doe',
        'phone': '123-456-7890',
        'birthday': '1990-01-01',
        'notes': 'This is a sample note.'
    },
    {
        'name': 'Jane',
        'surname': 'Smith',
        'phone': '987-654-3210',
        'birthday': '1985-05-15',
        'notes': 'Another sample note.'
    }
]

# Specify the filename
filename = 'contacts.json'

# Write the li

MS Access DB SQL access

import pyodbc

# Define the path to your Access database
database_path = r'C:\path\to\your\database.accdb'

# Define the connection string
conn_str = (
    r'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};'
    r'DBQ=' + database_path + ';'
)

# Connect to the database
conn = pyodbc.connect(conn_str)

# Create a cursor from the connection
cursor = conn.cursor()

# Example query
query = 'SELECT * FROM YourTableName'

# Execute the query
cursor.execute(query)

# Fetch all

979. Distribute Coins in Binary Tree

You are given the root of a binary tree with n nodes where each node in the tree has node.val coins. There are n coins in total throughout the whole tree. In one move, we may choose two adjacent nodes and move one coin from one node to another. A move may be from parent to child, or from child to parent. Return the minimum number of moves required to make every node have exactly one coin.
/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @return {number}
 */
var distributeCoins = function(root) {
    let res = 0;

    // Define the DFS function
    const dfs = (node) => {
        if (node === null) return 0;
        let left = dfs(node.left);
        let r

IIS SQL Injection Request Filtering

IIS SQL Injection Request Filtering
<filteringRules>
    <filteringRule name="SQLInjection" scanQueryString="true">
        <appliesTo>
            <clear />
            <add fileExtension=".asp" />
            <add fileExtension=".aspx" />
        </appliesTo>
        <denyStrings>
            <clear />
            <add string="@@version" />
            <add string="sqlmap" />
            <add string="Connect()" />
            <add string="cast(" />
            <add string="char(" />
            <add string="bchar(" />
          

Tabs Conversion

find . -name "*.cs" -exec bash -c 'unexpand -t 4 --first-only "$0" > /tmp/totabbuff && mv /tmp/totabbuff "$0"' {} \;

Location Portal 3.0

An even more revised version of the Location Portal correcting some issues related to how the filters at top and filters on Country and City play together
<div class="container-widget-parent">

  <div class="container-widget">
    <div class="page-title-row">
    	<div class="page-title">Location Portal</div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div class="location-map-button"><input type="button" value="Location Map" ng-click="c.locationMap()"></div>
    </div>

    <!-- BEGIN FILTER SECTION -->

    <div class="container-filter-parent">
      <div class="container-filter">
        <div ng-repeat="filter in data.filters" class="filter-group">

Client callback in a webhook

user: SapioUser = context.user
client_callback: ClientCallback = DataMgmtServer.get_client_callback(user)

# Use the FormBuilder utility to quickly create a temporary data type with default layouts.
form_builder: FormBuilder = FormBuilder()

# Define a Boolean field
# The 2nd argument data_field_name is the key for this field in the dictionary returned by
# client_callback.show_form_entry_dialog
# The 3rd argument display_name is the message shown to the user besides the field itself
f

Export Certificates from Windows Cert-Store

- Export all certificates from Windows cert-store to a .pem file. - Show certifi cert location.öl - https://blog.totter.pw/posts/SSL-Issues-Databricks-Connect/
import ssl

context = ssl.create_default_context()
der_certs = context.get_ca_certs(binary_form=True)
pem_certs = [ssl.DER_cert_to_PEM_cert(der) for der in der_certs]

with open('wincacerts.pem', 'w') as outfile:
    for pem in pem_certs:
        outfile.write(pem + '\n')

Dockerfile PHP && Apache

FROM php:7.4-apache
COPY src/ /var/www/html/
EXPOSE 80

interaractive grid capture events sum

https://github.com/mgoricki/orclapex-ig-cheat-sheet https://docs.oracle.com/en/database/oracle/apex/23.2/aexjs/interactiveGridView.html https://docs.oracle.com/en/database/oracle/apex/23.2/aexjs/recordView.html#getActiveRecord https://docs.oracle.com/en/database/oracle/apex/23.2/aexjs/model.html#setValue
https://stackoverflow.com/questions/61670763/which-model-notifications-should-i-listen-to-in-order-to-calculate-the-sum-of-an

var igGrid$ = $("#employeesIG");

igGrid$.on("interactivegridviewmodelcreate", function(event, ui) {

  var model = ui.model;
  //  console.log('ui',ui);

    if (ui.viewId === "grid") {

        sid = model.subscribe( {

          onChange: function(type, change) {

            if (type === 'set' &&  change.field == 'BUDGET' ) {
                var record = model.getRec