How to cleanly write SQL get functions in PHP with params?

I’m working on a PHP application where we have helper functions to run our SQL queries on our MariaDB database. The queries are formatted as strings and then we call a helper function select, update, etc. I have a getUsers function that originally took no parameters and returned a list of all of the users in the application. Now, if I want a list of users of a certain type, is it better that I create an entirely new function getUsersOfType, or should I add a parameter to the function getUsers(type = true) and conditionally query based on that? Which way follows SOLID principles the best while keeping the code slim?

python – How to write this 7-nested loop in a better way while keeping (or improving) performance?

I’m doing a challenge online, the problem is to find all happy numbers from 1 up to 1.000.000.0.

In a part of my code , I have to sum all of the digits to the power of two for numbers from 0 to 1.000.000.0 then I have to find if the sum is inside a given set of integers and if this is true put this number inside a list . At the end I wrote this messy solution to complete this task :

for a in range(10):
    l = a*a
    for b in range(10):
        l += b*b
        for c in range(10):
            l += c*c
            for d in range(10):
                l +=d*d
                for e in range(10):
                    l += e*e
                    for f in range(10):
                        l += f*f
                        for g in range(10):
                            l += g*g
                            if l in set : list.append(a*1000000+b*100000+c*10000+d*1000+e*100+f*10+g) 
                            l -= g*g
                            if g == 9 : 
                                l -= f*f
                                if f == 9 :
                                    l -= e*e
                                    if e == 9 :
                                        l -= d*d
                                        if d == 9 :
                                            l-= c*c
                                            if c == 9 :
                                                l-= b*b
                                                if b == 9 :
                                                    l-= a*a

But even if It’s good enough in terms of performance it is also very bad written.

I tried this but it’s slower :

from itertools import product
for a,b,c,d,e,f,g in product(range(10),repeat=7):
    k = a*a + b*b + c*c + d*d + e*e + f*f + g*g
    if k in set : list.append(a*1000000+b*100000+c*10000+d*1000+e*100+f*10+g)

I don’t find a way to mantain ( or improve ) efficiency and at the same time writing it in a better way. How could it be achieved?

What if one application couldn’t write incoming voice?

I tried a call recorder, but only my voice was recorded, not those on the other side.
Does it mean that my phone doesn’t support something or should I try to find an application that may work?

boot – Getting attempt to read or write outside of disk “hd0” after install

After installing 20.04 I keep getting the error message attempt to read or write outside of disk “hd0” Entering rescue mode…

I have done a lot of reading on this and have tried all of the given solutions and none of them have worked. I have even loaded the Ubuntu LiveCd and run the Boot Rescue program and I still get the error.

The machine is a Dell R710 with a H700 Raid Controller with six 3TB HDDs in a Raid 50 configuration and I’m using all but ~500MB.

I also know that this is an Ubuntu install issue as I can load Windows 10 and have absolutely no errors. I have also tried installing 14.xx and I get the same error.

What am I missing???

Postgresql: Write Binary File on Disk using ( Large Object )

I am trying to write a binary file (dll) to a disk using postgresql (large objects)

first I encoded the dll file using base64

cat file.dll | base64 -w 0
TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAA......

Then I used python code to automate the process, since the large object take only 2048 byte on each page ( first page with UPDATE Query) and then all pages take INSERT

file = "TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAA......"

def insert_file(url, loid):
    log("(+) write the file of length %d into LO..." % len(file))
    for i in range(0,int(round(len(file)/2048))):
        file_chunk = udf(i*2048:(i+1)*2048)
        if i == 0:
              sql = "UPDATE PG_LARGEOBJECT SET data=decode('%s', 'base64') where loid=%d and pageno=%d" % (file_chunk, loid, i)
        else:
              sql = "INSERT INTO PG_LARGEOBJECT (loid, pageno, data) VALUES (%d, %d, decode('%s', 'base64'))" % (loid, i, file_chunk)

Finlay, Exporting the dll to filesystem

def export_file(url, loid):
    log("(+) Exporting UDF library to filesystem...")
    sql = "select lo_export(%d, 'C:\Users\Lab\file.dll')" % loid

However, The file has been written on the Disk, but it’s corrupted .. I am not sure where is the problem. but I feel it’s in the encoding it self, Do I need to escape some characters that should not use with postgresql ?

Write 500 Words Article with Copyscape Premium Proof for $15

Write 500 Words Article [ with Copyscape Premium Proof ]

We are team of 20 article writers with fluent English.

We can handle any topic of articles, including but not limited:

  • Affiliate Marketing
  • Blogging
  • Business
  • Celebrity
  • Diet
  • DIY
  • Education
  • Family
  • Fashion
  • Finance
  • Fitness
  • Food
  • Health
  • Internet Marketing
  • Investment
  • Lifestyle
  • Marketing
  • Parenting
  • Pet
  • Photography
  • Quiting
  • Self Help
  • Sports
  • Technology
  • Travel
  • Weight Loss

What made our gig special is we guarantee all articles we produce will be Copyscape Premium passed.We will provide the proof in screenshot.

.

SUPolicy to allow custom service to read and write from Internal Storage

I’m setting up custom service with custom sepolicy using this as a base:
How to fix SELinux "avc: denied" errors when launching DNSCrypt as init.d script?

My issue is that I want config and log files to be read and written (respectively) from the internal storage /sdcard aka /storage/self/primary

What are my options?

mac – I want to write a script to open a fixed URL + whats in the clipboard. Ex: Open Safari to Url+clipboard contents “https://site.com/clipboard contents”

Will this applescript work?

Tell Application "Safari" to open location
"http://www.site.com/"
end tell

Tell Process "Safari"
   Keystroke "l" using command down

Tell application "System Events" to key code
124 using command down

Tell Process "Safari"
   Keystroke "v" using command down
   Keystroke return
end tell

How to take values from a file, apply an equation to those values, and write them to file in c

How do I take values from a file, apply an equation to those values, and write them to file in c
It seems simple, what I’ve tried just writes the same number as many times as I have samples. I would like to write a file with the new values.

   printf("Enter the number of sample values in the file minus 1.n");  //11025
   scanf("%d",&n);

   printf("using %d sample values.n",n);

    //  fseek(filein, "%lg", SEEK_SET);
   for ( c = 0 ; c <= n ; c++ )//     // Convert a reading (which goes from 0 - 65536) to a value (-1 - 1):
                                      // float voltage = sensor * (1 / 65536.0);
   {
      fseek(filein, n, SEEK_SET);
      fscanf(filein, "%lg", var);

      sum = var * (maxy / 65536.0);
//todo?

//todo?
   fprintf(fileout,"%lgn",sum);
   }
   getchar();
fclose(filein);
fclose(fileout);
   return 0;
}



return 0;
} ```

sql – How to write inner join using posts_clauses?

Can someone please show me how I can achieve the same result with this SQL:

SELECT *
FROM wp_2_posts
INNER JOIN wp_2_icl_translations
ON wp_2_icl_translations.element_id = wp_2_posts.id
AND wp_2_icl_translations.language_code = 'en'
WHERE wp_2_posts.post_type = 'properties';

Using posts_clauses ? In other words I’d like a posts_clauses filter to perform the same query as the one shown above in SQL.

I am trying to query posts that are only in English.