connection issues – Is there any ways to connect TV and laptop at the same time with one mobile phhone?

I need to debug (android app programming) with a Samsung Galaxy 20+.
The app is about displaying two different screens on dual screen. I want the mobile and the TV can show the built app right away after I build the project from laptop because I need to plug and unplug keep and forth to debug and also it’s also hard to debug because I can’t see the debug log properly.

So, Is there any Y shape C cable or is there any possible ways?

Samsung S20 Ultra Unlocked Hotspot limited to only 1 connection

My wife and I just switched to S20 Ultras from Pixel 3 & 4 XL. We had no problem with having multiple connections on either device. On the S20s under the Mobile Hotspot settings it says "Turn your phone into a Wi-Fi access point. Up to 1 other device will be able to use your phone’s mobile data or Wi-Fi connection to access the internet." Doing some research and talking to Samsung support there is supposed to be an option in "Configure Mobile Hotspot" to set the maximum number of connection. This option is not there for us. Is there another way of setting this hidden maximum number of connection setting? I tried a handful of 3rd party hotspot apps and none of them worked. I also tried a few hidden settings apps and I couldn’t find anything about setting the maximum connections.

Identifying a connection after SNAT

Hi I have a problem statement that I am trying to solve from quite a while now.

Problem Statement (This is a networking scenario):
Machine A and Machine B want to connect to Machine D, Machine C being a Load Balancer between them. At Machine D I want to determine which connection came from Machine A and which connection came from Machine B.

As the load balancer will use a single IP to SNAT all the connections coming from Machine A and Machine B.

Why I want to solve this ?
Consider that there is a Machine Z that is a malicious machine and it tries to connect to Machine D, I want to control all the incoming connections to this machine.

adb – Need Logs proof info about File Transfer copy/mv of my IMG files usb connection sowehow of hijacked rooted android

can you Help me get Logs or info about “File Access (copy/mv/pull) of my IMG files? happended through unallowed usb connection” by Syslog / etc from my unlocked / rooted, “debug allowed” Android SmartPhone someone took for some time, can anyone Help me out here please?
I need proof it’s important.

the suspect took my phone Android 5+ and ether used the TWRP MTP or adb connection via Linux Notebook (maybe cracked even just cracked the pin) to steal sensitive Private data like Whatsapp IMGs and other Business Data. Where can i find a** Log / Syslog or proof for the data to be “touched” etc** at a specific date like a Copy, Move, ADB Pull request or just the connection and establishion of an USB Data transfer connection etc. would be all i need to escalate.

hope you can help me, kind of serious situation here.

postgresql – How to prevent implicit casting from bytea to text during the current connection in postgres?

for example if there are non-ASCII bytes it cannot work smoothly

Why would you think so? bytea is coerced to either hex (default) or escape format when assigned to a text column. Non-ASCII characters are encoded automatically. Should work “smoothly” at all times – except that you don’t want to allow it.

How do I make (implicit) casts from bytea to text throw an exception only within the current connection?

… I can add a preceding SQL statement before every statement, that’s no problem.

Solution with custom cast

Currently (all versions incl. Postgres 13) the cast from bytea to text has no explicit entry in the system catalog pg_cast. It is provided by basic input/output functions of the respective types. This behavior can be overruled with an explicit entry, created with CREATE CAST.

You need to be the owner of the involved types, so this basically means you have to be superuser install it.

Create this casting function once per database:

CREATE FUNCTION public.text(bytea, int, bool) 
  RETURNS text
  LANGUAGE plpgsql STABLE STRICT PARALLEL SAFE AS
$func$
BEGIN
   IF $3 THEN           -- true if the cast is an explicit cast, false otherwise.
     -- no infinite loop because we do the cast manually
     -- honors current setting for bytea_output, hence function not IMMUTABLE
      RETURN textin(byteaout($1));
   ELSE
      RAISE EXCEPTION 'Assignment cast from bytea to text forbidden by custom cast rules in this database!';
      RETURN textin(byteaout($1));  -- we should *never* get here!
   END IF;
END
$func$;

To allow creating / dropping the special cast to unprivileged roles, add wrapper functions. Do this as superuser (or as dedicated daemon role):

CREATE FUNCTION public.f_create_cast_bytea2text() 
  RETURNS void
  LANGUAGE sql SECURITY DEFINER AS
'CREATE CAST (bytea AS text) WITH FUNCTION public.text(bytea, int, bool) AS ASSIGNMENT;';

CREATE FUNCTION public.f_drop_cast_bytea2text() 
  RETURNS void
  LANGUAGE sql SECURITY DEFINER AS
'DROP CAST IF EXISTS (bytea AS text);';

Now you can do what you asked for:

BEGIN;
SELECT public.f_create_cast_bytea2text();  -- optionally activate your casting rule

INSERT INTO tbl(txt_col)
VALUES ('00'::bytea::text, 'local bytea_output: hex');    -- explicit cast still works!

INSERT INTO tbl(txt_col)
VALUES ('00'::bytea); -- but assignment cast forbidden! -> ERROR

SELECT public.f_drop_cast_bytea2text();  -- deactivate your casting rule
END;

db<>fiddle here — second half does not execute due to missing privileges.

Extended test case

Test table:

CREATE TABLE test(id int, txt_col text, note text);
INSERT INTO test(id, txt_col, note) VALUES
  (-1, 'foo', 'plain text input')
, ( 0, '00'::bytea, 'default bytea_output: ' || current_setting('bytea_output'));

No exception raised:

BEGIN;
SELECT public.f_create_cast_bytea2text();

SET LOCAL bytea_output = 'hex';
INSERT INTO test(id, txt_col, note)
VALUES (1, '00'::bytea::text, 'local bytea_output: hex');    -- explicit cast still works

SET LOCAL bytea_output = 'escape';
INSERT INTO test(id, txt_col, note)
VALUES (2, '00'::bytea::text, 'local bytea_output: escape'); -- explicit cast still works

SELECT public.f_drop_cast_bytea2text();
END;

Also no exception:

BEGIN;
SELECT public.f_drop_cast_bytea2text();

SELECT '00'::bytea || text 'foo'; -- implicit cast still works

SELECT public.f_drop_cast_bytea2text();
END;

Exception raised:

BEGIN;
SELECT public.f_create_cast_bytea2text();

INSERT INTO test(id, txt_col, note)
VALUES (3, '00'::bytea, 'must fail!'); -- assignment cast forbidden!

SELECT public.f_drop_cast_bytea2text();
END;

network – Establish secure connection to localhost in Firefox

I have a Greenbone Security Assistant that has me connect to 127.0.0.1 port 9392, with the command:

sudo openvas-start
firefox http://localhost:9392

in Firefox. But before (and sometimes after) connecting, Firefox throws a lot of errors about insecure connection, and always highlights the better part of the URL in red. This also happens when connecting to localhost for, say, Autopsy. Is there any way I can establish a secure connection to localhost? Maybe from the terminal, in the firefox http://whateverURLforyourapp command?

c# – Is this code correctly using data connection for dapper

I am new to asp.net core 3.1 with no background of MVC i am just moving from webforms to ASP.Net core. i got below comments regarding my code, but this code is working fine for me, I am not sure how to improved it so that its bug free

** comments regarding buggy code received **

it’s actually a bit buggy. There’s no need to explicitly open or close
the connection (Dapper will open it), and using will dispose the
connection even in cases where finally won’t execute.

Another bug – catch(Exception ex){throw ex;} throws a new exception
with a different stack trace. It’s worse than no catch at all. To
rethrow the original exception after eg logging, use throw;, without
an exception object

I want to know how can i clean this code & write more optimized code based on below code, I would appreciate example with code

This is my code for API & other files

NewsController.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BookListRazor.Model;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Dapper;
using Microsoft.Data.SqlClient;
using System.Data;
using BookListRazor.Data;

namespace BookListRazor.Controllers
{
    // (Route("api/News"))
     //(Route("api/News/(action)"))
    (ApiController)
    public class NewsController : Controller
    {
        //for EF
        private readonly ApplicationDbContext _db;

        //For  Dapper
        private readonly SqlConnectionConfiguration _configuration;


        public NewsController(ApplicationDbContext db, SqlConnectionConfiguration configuration)
        {
            _db = db;
            _configuration = configuration;
        }
        
        //get all news 
        (HttpGet)
        (Route("api/news/GetAll"))
        public async Task<IActionResult> GetAll()
        {

            //fetch data using EF
            // return Json(new { data = await _db.News.OrderByDescending(x => x.NewsDate).ToListAsync() });

            //Fetch data using Dapper
            IEnumerable<News> newslist;
            using (var conn = new SqlConnection(_configuration.Value))
            {
                string query = "select * FROM News";

                conn.Open();
                try
                {
                    newslist = await conn.QueryAsync<News>(query, commandType: CommandType.Text);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    conn.Close();
                }

            }
            return Json(new { data = newslist });
        } 
        
    }
}

** News.cshtml **

<script>
    $(document).ready(function () {
    
     $.ajax({
                url: "api/news/getallnews/1",
                type: "GET",
                dataType: "json",
                success: function (response) {
                    var len = response.data.length;
                    var table = $("<table><tr><th>Details</th></tr>");
                    for (var i = 0; i < len; i++) {
                        //console.log("i "+i);
                        table.append("<tr><td>Title:</td><td>" + response.data(i).newsHeading + "</td></tr>");
                    }
                    table.append("</table>");
                    $("#news").html(table);
                }
            });

    });
</script>

** Update Code for Same function to rectify BUGS ****

//get all news 
(HttpGet)
(Route("api/news/GetAllData"))
public async Task<IActionResult> GetAllData()
{

    using (SqlConnection connection = new SqlConnection(_configuration.Value))
    {
        var param = new DynamicParameters();
        //  param.Add("@prodtype", prodtype);
        //return connection.QueryFirst(" select * FROM News");
        string query = "select * FROM News";
        IEnumerable<News> newslist;
        newslist = await connection.QueryAsync<News>(query, commandType: CommandType.Text);
        return Json(new { data = newslist });
    }

}

    

I want to know is this fine or this code can further be improved