Witch one of these methods is better/safer to use? Simple MySql or MySql Class?

Witch one of these methods is better/safer to use? And what benefits i could get using one or other? I m really new to classes.

Simple mysqli:

connection.php

$  DBServer = "localhost"; $  DBPort = "3306"; $  DBUser = "root"; $  DBPass = ""; $  DBName = "test";  $  conn = new mysqli($  DBServer, $  DBUser, $  DBPass, $  DBName, $  DBPort); if ($  conn->connect_error) {     echo "Database connection failed: " . $  conn->connect_error, E_USER_ERROR; } mysqli_set_charset($  conn,"utf8"); 

index.php

include_once("connection.php");  $  l_name = mysqli_real_escape_string($  conn, $  _GET['l_name']);  $  query = mysqli_query($  conn, "SELECT * FROM test WHERE lname='".$  l_name."'"); while($  row = mysqli_fetch_array($  query)){     echo $  row['f_name'].' '.$  row['l_name'].'<br>'; } 

mysqli with class:

connection.php

class Connect {      var $  host = 'localhost';     var $  user = 'root';     var $  pass = '';     var $  db = 'test';     var $  con;      function connect() {         $  con = mysqli_connect($  this->host, $  this->user, $  this->pass, $  this->db);          if (!$  con) {             //die('Could not connect to database!');         } else {             $  this->con = $  con; //echo 'Connection established!';         }         mysqli_set_charset($  this->con,"utf8");          return $  this->con;      }      function close() {         mysqli_close($  con);     }  } 

index.php

include_once("connection.php");  $  con = new Connect(); $  con->connect();  $  l_name = mysqli_real_escape_string($  con->con, $  _GET['l_name']);  $  query = mysqli_query($  con->con, "SELECT * FROM test WHERE lname='".$  l_name."'"); while($  row = mysqli_fetch_array($  query)){     echo $  row['f_name'].' '.$  row['l_name'].'<br>'; } 

Thanks in advance!

Managing /data/system/netpolicy.xml: what do these policies mean?

Seems like it wasn’t clever of me to restore Data (policy/stats) with Titanium Backup. It has all that apps’ unique UIDs from my previous system (actually, the same phone, but wiped and flashed) and now I’m starting to think that the same apps now have new UIDs, so the settings may be completely wrong, except the system ones, right? If I remove all the policies from the file, should I expect it to repopulate with defaults? Is this file controlled by that system app which allows to enable/disable cellular/wlan access?

What do all that policies mean? In case of manual setting. They’re mostly 2048 and 3840, but there’re 2816, 1792 and 768 too.

The reason why I’ve started to worry about it: Play Store is having some problems with the connection. To be exact, when I download starts it runs with Download Manager (uid: 10010, com.android.probiders.downloads) and the manager keeps saying «reconnecting», meanwhile other apps have no problems with the internet access. 10010 has 768 policy + it whitelisted (<whitelist>...</whitelist>), but at the same time I see that another app has 768 policy and it’s some little game, I restricted it in internet access UI. However, it’s not a total connection failure: it can download a couple of megs, then speed drops to a few kbs and only then it starts to say «reconnecting».

Maybe (just maybe) it has nothing to do with netpolicy.xml and it’s something else causes the problem, but I don’t know what else tbh.

Syntax error on tokens, delete these tokens,any steps i did wrong

I was trying to read data from a file in my main program but it keep saying” Syntax error on tokens, delete these tokens”. Any steps i did wrong?

 public static void main(String[]args)throws FileNotFoundException{      File dataval=new File("valueofdata");      Scanner input=new Scanner(dataval);      PrintWriter output=new PrintWriter("array.txt");      int size=50;      double data;      double numbers[]=new double[size];      while(input.hasNextInt()){      data=input.nextDouble();        double avg;        double second[]=new double[16];        for(int i=0;i<size;i++){         numbers[i]= data;          output.println("here is the orignal array"+numbers[i]);}        avg=findAverage(numbers,size);        output.println("This is the average of the original array"+                       avg);        second=howFarAway(second,size,numbers,avg);        output.println("here is the new array"+second);        avg=findAverage(second,size);        output.println("the average of the new array"+avg);      }    input.close();    output.close();    }  } 

the file”valueofdata”: 3.2 9.2 -2.7 5.2 3.2 4.6 1.2 8.3 4.9 7.4 -6.6 2.4 8.0 3.7 1.2 3.9

Entity with custom field, how to get these field in template?

I have created a Slider entity with the drupal console, with the website interface I create some fields to this entity (field_image, field_title, field_subtitle), but I can’t manage to get these fields in my template.

I’m new to Drupal 8 and I don’t understand how to get these values, all the answer I saw on the web start with the node object but I don’t have a node object :/

So I created a block, in the build function I get all the Slider entity to show them in a carousel :

/**  * Slider homepage  *  * @Block(  *   id = "slider_block",  *   admin_label = @Translation("Slider (HP)"),  * )  */ class SliderBlock extends BlockBase {      /**      * {@inheritdoc}      */     public function build()     {         $  view_builder = \Drupal::entityTypeManager()->getViewBuilder('slider');          $  ids = \Drupal::entityQuery('slider')             ->condition('status', 1);         $  pids = $  ids->execute();         $  slides = Slider::loadMultiple($  pids);           $  build = [             '#theme' => 'carousel_slider',             '#slides' => $  view_builder->viewMultiple($  slides, 'full'),             '#attributes' => ['class' => ['owl-carousel-wrapper'], 'id' => 'owl-carousel-hp'],             '#attached' => [                 'library' => ['web_core/owl-carousel'],                 'drupalSettings' => [                     'owl-carousel-hp' => [                         'singleItem' => true,                     ]                 ],             ]         ];           return $  build;     }  } 

And what I want is to get the values of these fields in my template, this is the template for one slide, and I use this rendered markup in the carousel_slider template after.

<div class="slide">     <img src="{{ file_url(slide.field_image.entity.field_media_file.entity.fileuri) }}" >     <h2>{{ slide['slide']['#slider'] }}</h2> </div> 

I’ve tried some way to achieve this but I can’t manage to find how to access my values…

what difference between these video files might make youtube accept one and not the other?

what difference between these files might make youtube accept one and not the other?

Each is about 100KB or 150KB. Each of the two are one second long so are small easy to download and quick to test or fiddle with.

c_good.mp4 http://ge.tt/1ia9sWv2 (uploads)

c_bad.mp4 http://ge.tt/79FFvWv2 (does not upload)

The one that fails to upload, youtube says “The video has failed to process. Please make sure you are uploading a supported file type.”

E:\bigmoved2\editing\old\problem>mediainfo c_good.mp4 General Complete name                            : c_good.mp4 Format                                   : MPEG-4 Format profile                           : Base Media Codec ID                                 : isom File size                                : 143 KiB Duration                                 : 1s 3ms Overall bit rate mode                    : Variable Overall bit rate                         : 1 166 Kbps Writing application                      : Lavf58.3.100  Video ID                                       : 1 Format                                   : AVC Format/Info                              : Advanced Video Codec Format profile                           : Baseline@L3.1 Format settings, CABAC                   : No Format settings, ReFrames                : 1 frame Codec ID                                 : avc1 Codec ID/Info                            : Advanced Video Coding Duration                                 : 1s 2ms Bit rate                                 : 963 Kbps Width                                    : 854 pixels Height                                   : 480 pixels Display aspect ratio                     : 16:9 Frame rate mode                          : Constant Frame rate                               : 29.970 fps Color space                              : YUV Chroma subsampling                       : 4:2:0 Bit depth                                : 8 bits Scan type                                : Progressive Bits/(Pixel*Frame)                       : 0.078 Stream size                              : 118 KiB (82%)  Audio ID                                       : 2 Format                                   : AAC Format/Info                              : Advanced Audio Codec Format profile                           : LC Codec ID                                 : 40 Duration                                 : 1s 3ms Bit rate mode                            : Variable Bit rate                                 : 187 Kbps Maximum bit rate                         : 195 Kbps Channel count                            : 2 channels Channel positions                        : Front: L R Sampling rate                            : 48.0 KHz Compression mode                         : Lossy Stream size                              : 22.9 KiB (16%)    E:\bigmoved2\editing\old\problem>   E:\bigmoved2\editing\old\problem>mediainfo c_bad.mp4 General Complete name                            : c_bad.mp4 Format                                   : MPEG-4 Format profile                           : Base Media Codec ID                                 : isom File size                                : 97.7 KiB Duration                                 : 1s 22ms Overall bit rate mode                    : Variable Overall bit rate                         : 783 Kbps Writing application                      : Lavf58.3.100  Video ID                                       : 1 Format                                   : AVC Format/Info                              : Advanced Video Codec Format profile                           : High@L3.0 Format settings, CABAC                   : Yes Format settings, ReFrames                : 4 frames Codec ID                                 : avc1 Codec ID/Info                            : Advanced Video Coding Duration                                 : 1s 4ms Bit rate                                 : 651 Kbps Width                                    : 640 pixels Height                                   : 480 pixels Display aspect ratio                     : 4:3 Frame rate mode                          : Constant Frame rate                               : 29.900 fps Color space                              : YUV Chroma subsampling                       : 4:2:0 Bit depth                                : 8 bits Scan type                                : Progressive Bits/(Pixel*Frame)                       : 0.071 Stream size                              : 79.7 KiB (82%) Writing library                          : x264 core 152 r2851 ba24899 Encoding settings                        : cabac=1 / ref=3 / deblock=1:0:0 /   analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / is=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=6 /   lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / blu trained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 /   open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh 0 / rc=crf / mbtree=1 / crf=23.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40   / aq=1:1.00 Language                                 : English  Audio ID                                       : 2 Format                                   : AAC Format/Info                              : Advanced Audio Codec Format profile                           : LC Codec ID                                 : 40 Duration                                 : 1s 22ms Bit rate mode                            : Variable Bit rate                                 : 125 Kbps Maximum bit rate                         : 128 Kbps Channel count                            : 2 channels Channel positions                        : Front: L R Sampling rate                            : 48.0 KHz Compression mode                         : Lossy Delay relative to video                  : 67ms Stream size                              : 15.6 KiB (16%) Language                                 : English  E:\bigmoved2\editing\old\problem> 

This link may help https://support.google.com/youtube/answer/1722171 as it mentions recommended encoding settings. Though i’m not sure what difference is making or breaking it. Maybe if I was very good on ffmpeg I could know what to fiddle with to figure it out, but i’m not.

Malware these days [on hold]

I was just browsing the internet and looking for some informations for my diploma thesis which has a cool name ‘Malware these days’.

I’ve read a ton of info about this topic but I’m not really sure what to believe and what not. I’m not really experienced in this topic so I don’t know what the borders of malware are, what is the “hot” stuff these days, what are potentionals threads in the near future etc..

I have been checking youtube channels like Hak5, Seytonic, LiveOverflow but there is not a lot of info about malware. Sooo.. my questions are something like:

For the thesis – which books should I follow? Where can I get trusted info about todays malware which i can use in my work? Or anything else I can use in it? Ideas?

If u guys can give me a brief overview about “hot” stuff, that would be awesome.

Thank you. Much appreciated. (:

Do these rules for Critical Successes and Critical Failures seem Fair?

I’m thinking about implementing the following houserules at my table to try to bring back the concept of “Critical Successes” by piggybacking off the Advantage/Disadvantage system.

Critical Success

Whenever a creature makes a d20 roll with advantage, if both dice in the advantage roll result in a natural 20, then something especially good will happen as a consequence, determined at the DM’s discretion. For an attack roll, this might mean increased damage on the critical hit, or for a Saving Throw, it might mean avoiding all damage from a spell that normally only reduces to half.

Conversely, when a creature makes a d20 roll with disadvantage, if both dice in the disadvantage roll result in a natural 1, then something especially bad will happen as a consequence, determined at the DM’s discretion. For an attack roll, this might mean dropping their weapon or causing a self-inflicted injury. For a Saving Throw, it might mean suffering an additional effect contextual to the spell/source.

Although unlikely, if a “Critical Success” occurs in a scenario where success is normally impossible (like a creature with +3 to Charisma making a check with Advantage against a DC of 24), a “Critical Success” should not result in the check succeeding; but it should confer some kind of nominal benefit that reduces the penalty of failure or offers a different path forwards. Conversely, “Critical Failures” should not cause a check to fail if the total still matches the DC (like a +9 check with Disadvantage against a DC of 10) but should confer some nominal penalty to the result.

There’s a few things I’m trying to do with this rule:

  • I like the idea of “Critical Successes”/”Critical Failures” as a ludonarrative mechanism for especially unusual outcomes to gameplay situations,
  • But I don’t like the high frequency of these outcomes when using traditional “Critical Success on 20, Critical Failure on 1” rules
  • I also like the idea of Advantage giving a small chance of an especially good outcome occurring, with a reflective chance for Disadvantage for something especially bad occurring.

Has anyone attempted to use a rule like this in their games? If so, have players enjoyed this adjustment to the d20 rules? I worry that as-written the rule might be too insignificant to really affect gameplay, is that a potential issue? Should I flesh out the potential outcomes that can occur when following this rule?

How can i prove the following Equality? involving these infinite products

$ $ \prod_{n=2}^{\infty} (1-\frac{1}{n^3})= \frac{\cosh(\frac{\pi}{2}\sqrt3)}{3\pi} $ $

This can be found here (http://mathworld.wolfram.com/InfiniteProduct.html) Line 22

It is known that $ $ \cosh(z) = \prod_{n=1}^{\infty} \left(1+\frac{4z^2}{(2n-1)^2\pi^2}\right) $ $

via Weierstass Factorization Theorem

So my question is : if i allow z to be $ \frac{\pi}{2}\sqrt3$

how can i prove that $ $ \frac{1}{3\pi} \prod_{n=1}^{\infty}(1+\frac{3}{(2n-1)^2})= \prod_{n=2}^{\infty}(1-\frac{1}{n^3}) $ $

without going into some really crazy math. Is it even possible? I’ve been at it all night. Any help would be much appreciated. Thank you!

These latency number smell

I wanted to get some numbers to prove my reading that DynamoDB Key-Value storage has better read performance compare to relational DB (MySQL, PostgreSQL, Aurora). So I decided to compare READ Latencies of DynamoDB & AWS-Aurora (which is a/c to AWS website – “up to five times faster than standard MySQL databases and three times faster than standard PostgreSQL databases”)

Step1: Created a Table in Aurora with the following Schema and added 1.02 million records to that table.

Table gift_log (   gift_uuid               BINARY(16) NOT NULL,   user_uuid               BINARY(16) NOT NULL,   parent_uuid             BINARY(16),   operation_time          TIMESTAMP,   operation               VARCHAR(20) NOT NULL,   gift_type               VARCHAR(20) NOT NULL,   parent_type             VARCHAR(20),   relation_type           VARCHAR(20),   PRIMARY KEY (gift_uuid) ); 

Used Golang Client that uses MySQL driver for database/sql package to query table.

Step2; Created DynamoDB table with following Attributes. Added 1 million Items to the table. DID NOT use any sort key. All queries used Partition key.

 Table: GiftLog {     gift_uuid               Binary (Partition Key)     user_uuid               Binary     operation_time          Number,     operation               String,     gift_type               String,     parent_type             String } 

Used Golang Client that uses AWS Go-SDK to query DynamoDB table.

AURORA

startTime := time.Now().UnixNano()  rows, err := db.Query("SELECT * FROM gift_log WHERE gift_uuid=?", giftIDsToRead[i])  endTimt := time.Now().UnixNano() 

DynamoDB

queryInput := &dynamodb.QueryInput{         TableName: aws.String(tableName),         KeyConditions: map[string]*dynamodb.Condition{                         "GiftUUID": {                             ComparisonOperator: aws.String("EQ"),                             AttributeValueList: []*dynamodb.AttributeValue{                                 {                                     B: giftIDsToRead[i],                                 },                             },                         },         }, }  startTime := time.Now().UnixNano()  resp, err := svc.Query(queryInput)  endTime := time.Now().UnixNano() 

These numbers don’t seem right. Am I not comparing apples to apples?