Am I using async C# correctly or how can I make correct use of async?

I wonder which of these version is the correct way of using async tasks. I want part of the code in the function to run parallel at the same time, and some methods to wait for the tasks to finish. It would be a lot of help to me if you also could provide me what I should do to improve my code.

Another problem is that this is an console application: I got a program.cs in the console project which use dependency injection to get the StartUp. The Startup is async void func and it calls on several tasks. My problem is that I can’t await and set the method bound to the timer.elasped to async task. . The method I bind to elapsed can’t bind to a async task method, but the method itself is calling on async tasks. Is this a bad thing or is it okay to leave it like this? Because the async tasks is tasks that runs in startup, before the startup call on the timer and initialize it, making the timer repeat the these async tasks functions. Version 1: public void startup() { var aTask = Task.Run(async () => { Console.WriteLine(Fetchstuff1″); var data3 = await GetStuff1(); });

        var bTask = Task.Run(async  () => {             Console.WriteLine("[Fetchstuff1stuff2");             var data1= await GetStuff2();         });          var cTask = Task.Run(async () => {             Console.WriteLine(Fetchstuff1stuff3");             var data2 = GetStuff3();         });           Task.WaitAll(aTask, bTask, cTask);          // DO STUFF AFTER ALL TASK OVER IS DONE         var categories = GetCategories();         var dt= CreateDatable();         Sendtodatabase();     }       public async Task<string> Dostuff1,2,3()     {         try         {              using (HttpResponseMessage result = await _httpClient.GetAsync(Adrdess))             using (HttpContent content = result.Content)             {                 result.EnsureSuccessStatusCode();                 string data = await content.ReadAsStringAsync();             }              return data;         }         catch (Exception ex)         {             Console.WriteLine("Error"         }     } 

Version 2:

public async Taskstartup()     {         await Task.WaitAll(lol());          // DO STUFF AFTER ALL TASK OVER IS DONE         var categories = GetCategories();         var dt= CreateDatable();         Sendtodatabase();     }      private async Task lol() {         await Task.Run(async () =>         {             Console.WriteLine(Fetchstuff1");             var data3 = await GetStuff1();             Console.WriteLine("[Fetchstuff1stuff2");             var data1= await GetStuff2();             Console.WriteLine(Fetchstuff1stuff3");             var data2 = GetStuff3();         });     }      public async Task<string> Dostuff1,2,3()     {         try         {              using (HttpResponseMessage result = await _httpClient.GetAsync(Adrdess))             using (HttpContent content = result.Content)             {                 result.EnsureSuccessStatusCode();                 string data = await content.ReadAsStringAsync();             }              return data;         }         catch (Exception ex)         {             Console.WriteLine("Error"         }     } 

version 3:

  public void startup()     {             Console.WriteLine(Fetchstuff1");             var task1= GetStuff1();             Console.WriteLine("[Fetchstuff1stuff2");             var task2 = GetStuff2();             Console.WriteLine(Fetchstuff1stuff3");             var task3= GetStuff3();          Task.WhenAll(task1, task2, task3);          List<String> data1 = await task1;         List<String> data2 = await task2;         List<String> data3 = await task3;             // DO STUFF AFTER ALL TASK OVER IS DONE             var categories = GetCategories();             var dt= CreateDatable();             Sendtodatabase();         }           public async Task<string> Dostuff1,2,3()         {             try             {                  using (HttpResponseMessage result = await _httpClient.GetAsync(Adrdess))                 using (HttpContent content = result.Content)                 {                     result.EnsureSuccessStatusCode();                     string data = await content.ReadAsStringAsync();                 }                  return data;             }             catch (Exception ex)             {                 Console.WriteLine("Error"             }         } 

What I want to do is to make a,b,c task run at same time, since they only retrieves some data. Then I want the method to wait until all the task has returned, before it continue the function and do stuff after all the tasks is done.

Is this done correctly or could I do it in a more clean way? Should I use Async Task Startup()? I removed it because I had no functions with await from warning. I then want all the last methods to run wait when it runs. because like sendtodatabase needs the dt from method executed before it.

In this situation my console application perform this: Main in Program.cs calls for startup method, startup call for datapoller method, datapoller call for handler method, and handler call for getstuff method. The method in the datapoller is an event, Timer.Elapsed += DataPollerOnElapsed; this can’t be set to async… Which is in the midle of the hierchy.

How can I solve this?

Correctly determine daylight-saving time in Central European Time?

The following constellation:
Our applications pass date&time around (in the most horrible way possible).
We want to simplify this. Instead of a culture-specific string like ‘31.12.2019’, we’re now passing an ecma-timestamp (the number of milliseconds between the point in time in UTC and 1970-01-01 00:00:00 UTC that is).

Now an additional complication.
Our pitiful application historically has saved all datetime values in the database as local time WITH DAYLIGHT-SAVING (central european summer or winter time, depending on the date ****aargh****) instead of UTC.

Now, central european summer time (CEST) is UTC+2, while central european winter time (CET) is UTC+1.

For the adjustment between summer and winter time, the following rules are applied:

  • the change from winter time to summer time is on the last sunday of March
    On the last Sunday morning of March, the clocks will be put forward from 02:00 to 03:00. (one ‘loses’ an hour)

  • the change from summer time to winter time is on the last sunday of October:
    On the last Sunday morning of October, the clocks will be put backward from 03:00 to 02:00 (one wins an hour).

As you might realize from looking at the definition, the change from summer to winter time presents a discontinuity range, in which a given local-time value can be both summer or winter time… (but not the change from winter to summer time)

Now, I have written the below functions to convert local/utc-time into an ECMA-timestamp, and you can specify if the input datetime is UTC or localtime.

I haven’t had the time to test it all too extensively, but I’d like to collect a second opinon on how to handle the times between 02 and 03 o’clock at the last Sunday of October…

  • Would you handle the conversion the same ? (appart from the fact that ideally, the conversion would be avoided / data changed to UTC)
  • Do you spot any error ?
  • Thoughts on what best to do between 02 and 03 …

Code:

PRINT 'Begin Executing "01_fn_dtLastSundayInMonth.sql"'   GO     IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[fn_dtLastSundayInMonth]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT')) BEGIN     EXECUTE(N'CREATE FUNCTION [dbo].[fn_dtLastSundayInMonth]() RETURNS int BEGIN RETURN 0 END ') END  GO     /* -- This is for testing SET DATEFIRST 3; -- Monday  WITH CTE AS (      SELECT 1 AS i, CAST('20190101' AS datetime) AS mydate       UNION ALL       SELECT i+1 AS i, DATEADD(month, 1, CTE.mydate) AS mydate      FROM CTE WHERE i < 100  )  SELECT -666 AS i, dbo.fn_dtLastSundayInMonth('17530101') AS lastSundayInMonth, dbo.fn_dtLastSundayInMonth('17530101') AS Control   UNION ALL   SELECT -666 AS i, dbo.fn_dtLastSundayInMonth('99991231') AS lastSundayInMonth, dbo.fn_dtLastSundayInMonth('99991231') AS Control   UNION ALL   SELECT       mydate      ,dbo.fn_dtLastSundayInMonth(mydate) AS lastSundayInMonth      ,dbo.fn_dtLastSundayInMonth(mydate) AS lastSundayInMonth      ,DATEADD(day,DATEDIFF(day,'19000107', DATEADD(MONTH, DATEDIFF(MONTH, 0, mydate, 30))/7*7,'19000107') AS Control  FROM CTE   */   -- ===================================================================== -- Author:        Stefan Steiger -- Create date:   01.03.2019 -- Last modified: 01.03.2019 -- Description:   Return Datum von letztem Sonntag im Monat  --                mit gleichem Jahr und Monat wie @in_DateTime -- ===================================================================== ALTER FUNCTION [dbo].[fn_dtLastSundayInMonth](@in_DateTime datetime ) RETURNS DateTime AS BEGIN     -- Abrunden des Eingabedatums auf 00:00:00 Uhr     DECLARE @dtReturnValue AS DateTime       -- 26.12.9999   SO     IF @in_DateTime >= CAST('99991201' AS datetime)          RETURN CAST('99991226' AS datetime);       -- @dtReturnValue is now last day of month      SET @dtReturnValue = DATEADD          (              DAY              ,-1             ,DATEADD             (                  MONTH                 ,1                 ,CAST(CAST(YEAR(@in_DateTime) AS varchar(4)) + RIGHT('00' + CAST(MONTH(@in_DateTime) AS varchar(2)), 2) + '01' AS datetime)              )         )     ;      -- SET DATEFIRST 1 -- Monday - Super easy !      -- SET DATEFIRST != 1 - PHUK THIS !      SET @dtReturnValue = DATEADD                         (                             day                             ,                              -                              (                                  (                                     -- DATEPART(WEEKDAY, @lastDayofMonth) -- with SET DATEFIRST 1                                      DATEPART(WEEKDAY, @dtReturnValue) + @@DATEFIRST - 2 % 7 + 1                                  )                                 %7                             )                             , @dtReturnValue     );      RETURN @dtReturnValue;  END   GO    GO    PRINT 'Done Executing "01_fn_dtLastSundayInMonth.sql"'    GO       PRINT 'Begin Executing "02_fn_dtIsCEST.sql"'   GO     IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[fn_dtIsCEST]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT')) BEGIN     EXECUTE(N'CREATE FUNCTION [dbo].[fn_dtIsCEST]() RETURNS int BEGIN RETURN 0 END ') END  GO      -- ===================================================================== -- Author:        Stefan Steiger -- Create date:   01.03.2019 -- Last modified: 01.03.2019 -- Description:   Ist @in_DateTime Mitteleuropäische Sommerzeit ?  -- ===================================================================== -- SELECT dbo.fn_dtIsCEST('2019-03-31T01:00:00'), dbo.fn_dtIsCEST('2019-03-31T04:00:00')  ALTER FUNCTION [dbo].[fn_dtIsCEST](@in_DateTime datetime ) RETURNS bit  AS BEGIN     DECLARE @dtReturnValue AS bit         -- https://www.linker.ch/eigenlink/sommerzeit_winterzeit.htm      -- the change from winter time to summer time is on the last sunday of March     -- the clocks will be put forward from 02:00 to 03:00. (one 'loses' an hour)      -- the change from summer time to winter time is on the last sunday of October:     -- the clocks will be put backward from 03:00 to 02:00 (one wins an hour).      DECLARE @beginSummerTime datetime      SET @beginSummerTime = dbo.fn_dtLastSundayInMonth(DATEADD(MONTH, 2, DATEADD(YEAR, YEAR(@in_DateTime)-1900, 0)) )       SET @beginSummerTime = DATEADD(HOUR, 2, @beginSummerTime)       DECLARE @beginWinterTime datetime      SET @beginWinterTime = dbo.fn_dtLastSundayInMonth(DATEADD(MONTH, 9, DATEADD(YEAR, YEAR(@in_DateTime)-1900, 0)) )        SET @beginWinterTime = DATEADD(HOUR, 2, @beginWinterTime)       SET @dtReturnValue = 0;      IF @in_DateTime >= @beginSummerTime AND @in_DateTime < @beginWinterTime      BEGIN          SET @dtReturnValue = 1;     END       RETURN @dtReturnValue; END   GO    GO    PRINT 'Done Executing "02_fn_dtIsCEST.sql"'    GO       PRINT 'Begin Executing "03_fn_dtToEcmaTimeStamp.sql"'   GO     IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[fn_dtToEcmaTimeStamp]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT')) BEGIN     EXECUTE(N'CREATE FUNCTION [dbo].[fn_dtToEcmaTimeStamp]() RETURNS int BEGIN RETURN 0 END ') END  GO      -- ===================================================================== -- Author:        Stefan Steiger -- Create date:   01.03.2019 -- Last modified: 01.03.2019 -- Description:   Ist @in_DateTime Mitteleuropäische Sommerzeit ?  -- ===================================================================== -- SELECT dbo.fn_dtToEcmaTimeStamp('2019-03-31T01:00:00', 1), dbo.fn_dtToEcmaTimeStamp('2019-03-31T04:00:00', 1)  ALTER FUNCTION [dbo].[fn_dtToEcmaTimeStamp](@in_DateTime datetime, @in_convert_to_utc bit) RETURNS bigint  AS BEGIN     DECLARE @dtReturnValue AS bigint          IF @in_convert_to_utc = 1      BEGIN         SET @in_DateTime =          CASE WHEN dbo.fn_dtIsCEST(@in_DateTime) = 1              THEN DATEADD(HOUR, -2, @in_DateTime)              ELSE DATEADD(HOUR, -1, @in_DateTime)          END;     END       SET @dtReturnValue =          CAST         (             DATEDIFF             (                 HOUR                 ,CAST('19700101' AS datetime)                 ,@in_DateTime              )             AS bigint         ) *60*60*1000         +          DATEDIFF         (              MILLISECOND              ,CAST(FLOOR(CAST(@in_DateTime AS float)) AS datetime)              ,@in_DateTime          ) % (60*60*1000)     ;      RETURN @dtReturnValue; END   GO    GO    PRINT 'Done Executing "03_fn_dtToEcmaTimeStamp.sql"'    GO       PRINT 'Begin Executing "04_fn_dtFromEcmaTimeStamp.sql"'   GO     IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[fn_dtFromEcmaTimeStamp]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT')) BEGIN     EXECUTE(N'CREATE FUNCTION [dbo].[fn_dtFromEcmaTimeStamp]() RETURNS int BEGIN RETURN 0 END ') END  GO     -- ===================================================================== -- Author:        Stefan Steiger -- Create date:   01.03.2019 -- Last modified: 01.03.2019 -- Description:   Ist @in_DateTime Mitteleuropäische Sommerzeit ?  -- ===================================================================== -- SELECT dbo.fn_dtFromEcmaTimeStamp('1551437088122', 1), dbo.fn_dtFromEcmaTimeStamp('1554069600000', 1)  ALTER FUNCTION [dbo].[fn_dtFromEcmaTimeStamp](@in_timestamp bigint, @in_convert_to_localtime bit) RETURNS datetime  AS BEGIN     DECLARE @dtReturnValue AS datetime           DECLARE @hours int      SET @hours = @in_timestamp /(1000*60*60);      DECLARE @milliseconds int      SET @milliseconds = @in_timestamp - (@in_timestamp /(1000*60*60))*(1000*60*60);       SET @dtReturnValue = DATEADD                          (                             MILLISECOND, @milliseconds,                              DATEADD(hour, @hours, CAST('19700101' AS datetime))                          )        IF @in_convert_to_localtime = 1      BEGIN         SET @dtReturnValue = DATEADD(HOUR, 1, @dtReturnValue)          SET @dtReturnValue =                                  CASE WHEN dbo.fn_dtIsCEST(@dtReturnValue) = 1                                      THEN DATEADD(HOUR, 1, @dtReturnValue)                                      ELSE @dtReturnValue                                  END;     END       RETURN @dtReturnValue; END   GO    GO    PRINT 'Done Executing "04_fn_dtFromEcmaTimeStamp.sql"'    GO  

How to Correctly Apply Gamma To Machine Vision Camera

I am using a machine vision camera that, according to the manufacturer, produces linear pixels. As a result, I need to apply a gamma correction to the image before I can view the result. However, after applying any gamma correction to the image, the colors appear washed out.

Before any gamma correction:

Example Of Raw Output

After applying a 2.2 gamma:

Example Port 2.2 Gamma Application

Overall, the brightness in the image looks substantially better. However, the colors in the color checker appear very desaturated. Is color desaturation a natural consequence of applying a gamma, and if so what can be done to compensate for that effect?

Am I understanding how to calculate a mule’s pulling capacity correctly? (beast of burden ability)

The PHB offers a few bits of information scattered across the chapters, and though I’ve read answers like this, I’d like to make sure I’m understanding how to account for a mule’s “beast of burden” ability correctly.

First, a mule is defined as:

Medium beast, unaligned

Armor Class 10 Hit Points 11 (2d8 + 2) Speed 40 ft.

STR 14 (+2) DEX 10 (+0) CON 13 (+1) INT 2 (-4) WIS 10 (+0) CHA 5 (-3)

Senses Passive Perception 10 Languages — Challenge 1/8 (25 XP)

Beast of Burden. The mule is considered to be a Large animal for the purpose of determining its carrying capacity.

Sure-Footed. The mule has advantage on Strength and Dexterity saving throws made against effects that would knock it prone.

Actions Hooves. Melee Weapon Attack: +2 to hit, reach 5 ft., one target. Hit: 4 (1d4 + 2) bludgeoning damage.

As for knowing their pulling capacity, Chapter 7 says:

Carrying Capacity. Your carrying capacity is your Strength score multiplied by 15. This is the weight (in pounds) that you can carry, which is high enough that most characters don’t usually have to worry about it.

Push, Drag, or Lift. You can push, drag, or lift a weight in pounds up to twice your carrying capacity (or 30 times your Strength score). While pushing or dragging weight in excess of your carrying capacity, your speed drops to 5 feet.

Size and Strength. Larger creatures can bear more weight, whereas Tiny creatures can carry less. For each size category above Medium, double the creature’s carrying capacity and the amount it can push, drag, or lift. For a Tiny creature, halve these weights.

And finally, to see how that is affected by the vehicle they are pulling, Mount and Vehicle states:

An animal pulling a carriage, cart, chariot, sled, or wagon can move weight up to five times its base carrying capacity, including the weight of the vehicle. If multiple animals pull the same vehicle, they can add their carrying capacity together.

So if I am understanding how to put that together, the carrying capacity of a mule is:

((Carrying Capacity x Beast of Burden ability) x vehicle mount calculation) – weight of vehicle

(((Strength 14 x 15) x 2) x 5) – 200lbs (cart) or 400lbs (wagon)

((210 x 2) x 5) -200lbs or 400lbs

(420lbs x 5) -200lbs or 400lbs

2’100lbs – 200lbs or 400lbs

So a mule carrying a cart can carry 1’900lbs or a 1’700lbs for a wagon (like Minman and Salteris said in the linked question)

Or, is a vehicle considered “pulling an object” and thus has to have an additional calculation:

(((Carrying capacity x beast of burden) x Pulling) x vehicle) – weight of vehicle

((420lbs x 2) x5) – vehicle weight

(840lbs x 5) – vehicle weight

Thus a mule can carry 4’000lbs in a cart and 3’800lbs in a wagon, but has a 5-foot speed drop Side Question: If this is the case, does the effect negate if two mules are pulling the wagon?

Though I believe it’s the first, I’d like to make sure.

Google Analytics doesn’t track events, everything else is correctly tracked

I’ve set Analytics for my new landing page. Everything works correctly( real-time data as well) except for Events tracking.

Actually, this is the first time I’m working with Analytics Events tracking, it looked so easy to set up at the beginning but now I’m lost.

I’ve searched for tons of information on the internet and followed many different instructions but I still can’t get it to work.

This is how my set up looks like:

Inside my header:

  <!-- Global site tag (gtag.js) - Google Analytics -->   <script async src="https://www.googletagmanager.com/gtag/js?id=*mytrackingid*">   </script>   <script>      window.dataLayer = window.dataLayer || [];      function gtag(){dataLayer.push(arguments);}      gtag('js', new Date());       gtag('config', '*mytrackingid*');   </script> 

onCall handler:

"gtag('event', 'Test1', {'event_category': 'Test2''});" 

I’ve tried using “ga()” as well with no results.

I’m really stuck here.

PS: I have no filters on my Analytics view.

Update grub menu entries to correctly point to old OS installations

I have recently added an SSD to my system. I have installed Windows and Ubuntu on this new SSD. I want to keep an earlier installed Ubuntu.

SSD0 - New Ubuntu 18.04 (works) [1]      - New windows 10 (works) [2] HDD0 - Ubuntu 18.04 (old) [3] HDD1 - Windows 10 (old) [4] 

I have tried running update-grub when on [1]. This resulted in the grub menu having additional entries for [3] and [4]. When I choose one of these two however, I get the following error:

error: no such device: B6C5-4C11. error: disk 'hd3,gpt2' not found. 

If I try booting from HDD0, I get my old grub menu where I am able to boot into [3] and [4] but not [1] and [2].

What I am trying to accomplish is: be able to go into [1], [2], [3] and [4] from one grub menu after booting to SSD0.

Here is a Sketch

a sketch of the disk/OS layout

Auto brightness not working correctly on Macbook Pro 13″ 2015

I have problem with set up auto brightness. Everything was fine until I didn’t pushed brightness button on keyboard. Now system report says that auto brightness settings are not working but in Preferences everything is set up correctly. Of course, my auto brightness settings are working fine. But why system report says that it is not?

I have also tried to reset SMC NVRAM and PRAM but it is not working.

enter image description here enter image description here

Correctly locate the desired field from cut operation

I have such processes running

me   26175  1.7  2.5 1483984 100148 tty2   Sl+  12:49   0:04 /snap/electronic-wechat/7/dist/electronic-wechat-linux-x64/electronic-wechat me   26237  0.0  0.7 311516 29176 tty2     S+   12:49   0:00 /snap/electronic-wechat/7/dist/electronic-wechat-linux-x64/electronic-wechat --type=zygote --no-sandbox me   26276  0.2  2.0 550496 81800 tty2     Sl+  12:49   0:00 /snap/electronic-wechat/7/dist/electronic-wechat-linux-x64/electronic-wechat --type=gpu-process --channel=26175.0.1924433599 --mojo-application-channel-token=3E65B226573BBE452FCCE4212BC242ED --no-sandbox --window-depth=24 --x11-visual-id=33 --supports-dual-gpus=false --gpu-driver-bug-workarounds=5,18,56 --gpu-vendor-id=0x0000 --gpu-device-id=0x0000 --gpu-driver-vendor --gpu-driver-version --gpu-driver-date --v8-natives-passed-by-fd --v8-snapshot-passed-by-fd me   26284  0.2  3.8 1085556 150812 tty2   Sl+  12:49   0:00 /snap/electronic-wechat/7/dist/electronic-wechat-linux-x64/electronic-wechat --type=renderer --no-sandbox --primordial-pipe-token=85EEA61A3C800C4096858B6AE571B4EB --lang=en-US --node-integration=true --enable-pinch --num-raster-threads=2 --content-image-texture-target=3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553 --video-image-texture-target=3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553 --disable-accelerated-video-decode --mojo-channel-token=F13ADFBA9E2E351C09B10692D10BCFBE --mojo-application-channel-token=85EEA61A3C800C4096858B6AE571B4EB --channel=26175.1.78915562 --v8-natives-passed-by-fd --v8-snapshot-passed-by-fd 

I desire to get column pid using cut rather than advanced tools as gwak

 ps -aux | grep wechat | sed "s/$  USER/me/g" | cut -f 2 | head -n 4  me   26175  1.2  2.5 1483984 100220 tty2   Sl+  12:49   0:05 /snap/electronic-wechat/7/dist/electronic-wechat-linux-x64/electronic-wechat me   26237  0.0  0.7 311516 29176 tty2     S+   12:49   0:00 /snap/electronic-wechat/7/dist/electronic-wechat-linux-x64/electronic-wechat --type=zygote --no-sandbox me   26276  0.1  2.0 550496 81800 tty2     Sl+  12:49   0:00 /snap/electronic-wechat/7/dist/electronic-wechat-linux-x64/electronic-wechat --type=gpu-process --channel=26175.0.1924433599 --mojo-application-channel-token=3E65B226573BBE452FCCE4212BC242ED --no-sandbox --window-depth=24 --x11-visual-id=33 --supports-dual-gpus=false --gpu-driver-bug-workarounds=5,18,56 --gpu-vendor-id=0x0000 --gpu-device-id=0x0000 --gpu-driver-vendor --gpu-driver-version --gpu-driver-date --v8-natives-passed-by-fd --v8-snapshot-passed-by-fd me   26284  0.1  3.8 1085556 150812 tty2   Sl+  12:49   0:00 /snap/electronic-wechat/7/dist/electronic-wechat-linux-x64/electronic-wechat --type=renderer --no-sandbox --primordial-pipe-token=85EEA61A3C800C4096858B6AE571B4EB --lang=en-US --node-integration=true --enable-pinch --num-raster-threads=2 --content-image-texture-target=3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553 --video-image-texture-target=3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553 --disable-accelerated-video-decode --mojo-channel-token=F13ADFBA9E2E351C09B10692D10BCFBE --mojo-application-channel-token=85EEA61A3C800C4096858B6AE571B4EB --channel=26175.1.78915562 --v8-natives-passed-by-fd --v8-snapshot-passed-by-fd 

It conclude that the outputs are not delimited by tabs, then tried space

me@host:~$   ps -aux | grep wechat | sed "s/$  USER/me/g" | cut -d ' ' -f 2 | head -n 4      me@host:~$    

But get bulks of spaces, and the pid is mysteriously locate in field 4

me@host:~$   ps -aux | grep wechat | sed "s/$  USER/me/g" | cut -d ' ' -f 4 | head -n 4  26175 26237 26276 26284 me@host~$    

I am very confused here, how could I decide which filed not by error-testing?

Php 7.2.15 doesn’t load correctly

I have been having problems with Apache2 loading php. First it printed raw code to the screen. Then I ran sudo apt-get install php libapache2-mod-php and sudo a2enmod mpm_prefork && sudo a2enmod php7.0. The 2nd command appeared to be unneeded but the 1st moved the issue forward slightly.

Running this test file in the browser (from /var/www/html):

// http://localhost/test.php <? phpinfo(); 

shows this:

1024) //{ // $  bandwidth = round($  bandwidth / 1024 , 2);  // $  bandwidth .= " MB"; //} //else //{ // $  bandwidth .= " KB";  //} // //switch (@$  _GET['download']) { //case 'resume_speed':  //case 'noresume_speed': //case 'resume': //case 'noresume':  // $  object->set_byfile($  FILENAME); // if ($  _GET['download'] ==  'noresume' || $  _GET['download'] == 'noresume_speed')  $  object->use_resume = false; // if ($  _GET['download'] ==  'resume_speed' || $  _GET['download'] == 'noresume_speed' )  $  object->speed = 100; // $  object->download(); //break;  //case 'data': //case 'dataresume': // $  data = implode('' ,  file($  FILENAME)); // $  object->set_bydata($  data); // if  ($  _SERVER['download'] != 'dataresume') $  object->use_resume =  false; // $  object->filename = basename($  FILENAME);  // $  object->download(); //break; //case 'auth':  // $  object->set_byfile($  FILENAME); // $  object->use_auth =  true; // $  object->handler['auth'] = "test_auth"; // $  object- >download(); //break; //case 'url': // $  object- >set_byurl('https://www.php.net/get/php_manual_chm.zip/from/cr. php.net/mirror'); // $  object->download(); //break; //} // //if  ($  object->bandwidth > 0) //{ // error_reporting(E_NONE); // $  b  = intval(implode('',file('bandwidth.txt'))) + $  object- >bandwidth; // $  f = fopen('bandwidth.txt','wb'); //  fwrite($  f,$  b); // fclose($  f); // exit; //} // //function  test_auth($  user,$  pass) { //test authentication function // if  ($  user == 'user' && $  pass == 'pass') return true; // return false; //} // //?> --> 

Black text on white background. No formating.

Going to the root of a wordpress directory (with an index.php file) shows this (black text white background):

<?php /**  * Front to the WordPress application. This file doesn't do anything, but loads  * wp-blog-header.php which does and tells WordPress to load the theme.  *  * @package WordPress  */  /**  * Tells WordPress to load the WordPress theme and output it.  *  * @var bool  */ define( 'WP_USE_THEMES', true );  /** Loads the WordPress Environment and Template */ require( dirname( __FILE__ ) . '/wp-blog-header.php' ); 

Anyone know the issue?

owner@G700:/var/www/wptest1$   apache2 -v Server version: Apache/2.4.29 (Ubuntu) Server built:   2018-10-10T18:59:25  owner@G700:/var/www/wptest1$   php -v PHP 7.2.15-0ubuntu0.18.04.1 (cli) (built: Feb  8 2019 14:54:22) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies     with Zend OPcache v7.2.15-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies 

I’m on Lubuntu 18.04

Snort sfportscan preprocessor not logging port scans correctly

I am trying to get the sfportscan preprocessor to log SYN port probing but it does not appear to be operating correctly.

I have a .pcap file with portscan traffic which can be seen in wireshark using the filter:

( tcp.flags.syn == 1 && tcp.flags.ack == 0 ):

portscan wireshark

The config file has been tested as valid using:

snort -c C:\snort\etc\snort.conf -T 

I have removed all other preprocessors and enabled the stream5 and sfportscan preprocessors as the minimum requirement in the snort documentation.

My preprocessor configuration in snort.conf is as follows:

# Target-Based stateful inspection/stream reassembly.  For more inforation, see README.stream5 preprocessor stream5_global: track_tcp yes, \    track_udp yes, \    track_icmp yes  #Portscan detection.  For more information, see README.sfportscan preprocessor sfportscan: proto { all } \         scan_type  { all } \         sense_level { high } \         logfile { portscan }  

When checking the log for the sfportscan preprocessor i do not get the expected results showing port scan traffic from 172.16.0.114 , instead the log file looks like this:

Time: 12/31-19:30:18.075254  event_id: 1 172.16.16.197 -> 208.111.168.7 (portscan) TCP Filtered Portsweep Priority Count: 0 Connection Count: 30 IP Count: 15 Scanned IP Range: 8.18.95.169:209.85.225.165 Port/Proto Count: 1 Port/Proto Range: 80:80  Time: 12/31-19:30:29.705276  event_id: 2 172.16.16.136 -> 168.143.161.20 (portscan) TCP Filtered Portsweep Priority Count: 0 Connection Count: 30 IP Count: 3 Scanned IP Range: 66.35.45.201:168.143.161.20 Port/Proto Count: 1 Port/Proto Range: 80:80 

Which shows the majority of portscan traffic not being detected by the preprocessor. I am under the assumption that even with local.rules file left blank, snort should still be alerting on portscan traffic if sfportscan preprocessor is activated.

I have searched the web and only found very few posts of other people experiencing a similar problem but no resolution. With minimal documentation and discussion for sfportscan & snort, this has been difficult to figure out.

Any ideas?

Thanks