text:
Q: Notepad++ Remove two or more spaces I need to remove occurrences of two or more spaces in a row in my dataset using regex with find and replace in Notepad++. I am aware that ([\s]+)([\s]+) would probably do the job, however it would also remove tabs and I only want to remove two or more consecutive occurrences of spaces.
Any help would be greatly appreciated, thank you!

A: Replace \s{2,} with nothing, using the Regular Expression search mode.


text:
Q: ASP.NET MVC Entity Framework application is using wrong SQL connection string I have an ASP.NET MVC5 web application that was originally created using VS2013 and uses Entity Framework 6 Code First, with data migrations. It has been working fine (in production) for almost a year and has been re-deployed numerous times, from Visual Studio, using Web Deploy.
Today, I opened the solution in VS2015 and redeployed a known working version of the codebase to production without any problems. However, after deployment, the production website suffered from the problems described in this article, which I solved by applying author's the recommended fixes.
After applying these fixes, I now have a new problem: an exception that suggests that the application is trying to access the database using the wrong connection string:

Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed.

Within the details of the exception page, the cause of the problem is clarified:

The connection string specifies a local Sql Server Express instance using a database location within the application's App_Data directory.

I'm puzzled by this because the application has a dedicated SQL Server instance that is accessed using a regular connection string. I've checked the Web.config generated by Web Deploy and it seems to be intact. It contains a named connection string that correctly references the production SQL Server instance, and the code (which hasn't changed) correctly instantiates an Entity Framework ApplicationContext using the named connection string.
Does anyone have any idea why this application now expects to create its own SQL Server instance or what I can do to debug this problem?
Many thanks for your suggestions,
Tim

A: A few things you can try before making the web deploy:

*

*Check if the project that contains the connection string declaration (web.config) is setted as the 'startup project'.

*Rebuild the solution in release mode.

*In the Publish Web wizard, in Settings, expand File Publishing Options and check 'Remove additional files at destination' and 'Exclude files from App_Data folder'

redpajama_set_name: RedPajamaStackExchange


text:
Q: Why does having a custom name for apk leads to an error when changing target device to one with a different Android version? The issue I have is that if I try to run my app on different devices that have different Android version I have to clean every time before changing Android versions. If I don't clean, I get the following error:
Zip file '/long path to app/app/build/outputs/app/apk/my_app_name-my_variant_name-verionName.apk' already contains entry 'some file.dex', cannot overwrite

After having this error for a long time I finally found the piece of code that is causing the problem when Android Studio Arctic Fox started telling me exactly which file had the conflict.
The gradle code that causes the problem is this:
android.applicationVariants.all { variant ->
                variant.outputs.all { output ->
                    outputFileName = new File(path + "my_app_name-${variant.name}-${variant.versionName}.apk")
                }
            }

One solution I've found that saves me a clean is to delete the build/outputs/app directory.
So is there some way to accomplish the same thing without having this issue?

A: This isn't exactly an answer as to why it happens. As someone pointed out, it might have to do with Android Studio trying to build apks per architecture, however the solution I found here https://stackoverflow.com/a/28992851/704836 does not make different apks per architecture, so I don't know why this fixes it but it does.
Basically I removed the code from the original post:
android.applicationVariants.all { variant ->
                variant.outputs.all { output ->
                    outputFileName = new File(path + "my_app_name-${variant.name}-${variant.versionName}.apk")
                }
            }

And replaced it with:
setProperty("archivesBaseName", "MyApp-$versionName")

And that was enough to solve the issue. I can not switch phone targets and it works just fine. The new apk that is generated is called MyApp-version-variant.apk


text:
Q: ArcGIS, update features envelopes without "Repair geometry" I am developing a toolbar for ArcMap with .NET ArcObjects and I made an option to round vertices coordinates to meters (no decimals). So I change X and Y of each vertex on each feature. The problem is that if I do a Check Geometry after, I get bad envelope on all features. I guess that it's because the envelope doesn't update itself after changing the vertices.
Is there a way to update envelopes without using Repair Geometry?
I don't want to use it because it does a lot more than just updating envelopes.
Here is the code I am using
lIGeometryCollection = layerFeature.Shape
For idx_geometrie As Integer = 0 To lIGeometryCollection.GeometryCount - 1
    Dim pointCollection As IPointCollection = lIGeometryCollection.Geometry(idx_geometrie)
    For idx_point As Integer = pointCollection.PointCount - 1 To 0 Step -1
        Dim lPoint As IPoint = New ESRI.ArcGIS.Geometry.Point
        lPoint.PutCoords(
            Math.Round(pointCollection.Point(idx_point).X / ResolutionXY, 0, MidpointRounding.AwayFromZero) * ResolutionXY,
            Math.Round(pointCollection.Point(idx_point).Y / ResolutionXY, 0, MidpointRounding.AwayFromZero) * ResolutionXY)
        pointCollection.UpdatePoint(idx_point, lPoint)
        System.Runtime.InteropServices.Marshal.ReleaseComObject(lPoint)
    Next
Next
layerFeature.Store()

A: Don't know if this will help but is good practise:
The remarks section of IPointCollection states -

For efficiency UpdatePoint does not check if the spatial reference of
  the input point is equal to the spatial reference of the
  PointCollection. Please make sure that the spatial reference of the
  input point is equal to the spatial reference of the PointCollection
  before you pass the point in.

As you are creating new point objects and then setting the XY based on the truncated XY values, you are overwriting points in IPointCollection with points that don't have any spatial reference. You can set the spatialreference of points before you update.
Also look into IGeometryCollection.GeometriesChanged.
Finally I have found ITopologicalOperator.Simplify can fix geometry problems.


text:
Q: karma parallel executing test cases twice I am upgrading my angular from 4 to version 7. I had karma-parallel to run the tdd and it was working as expected with Angular 4. Now after upgrading to 7 the same tests are running twice before stop executing.
My karma.conf.js is as below,
const path = require('path');
module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: [ 'parallel', 'jasmine', '@angular-devkit/build-angular'],
    plugins: [
      require('karma-parallel'),
      require('karma-jasmine'),
      require('karma-spec-reporter'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('@angular-devkit/build-angular/plugins/karma')
    ],
    parallelOptions: {
      executors: 3, // For Jenkins enterprise, stick to 6 executors. For local laptop, change to 3-5
      shardStrategy: 'round-robin'
    },
    client: {
      jasmine: {
        random: false
      },
      clearContext: false
    },
    coverageIstanbulReporter: {
      reports: ['html', 'json', 'text-summary'],
      dir: path.join(__dirname, 'coverage'),
      fixWebpackSourcePaths: true
    },
    reporters: ['spec', 'kjhtml'],
    specReporter: {
         maxLogLines: 5,
         suppressErrorSummary: true,
         suppressFailed: false,
         suppressPassed: false,
         suppressSkipped: true,
         showSpecTiming: true,
         failFast: false
      },
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['ChromeHeadlessNoSandbox'],
    customLaunchers: {
        ChromeHeadlessNoSandbox: {
            base: 'ChromeHeadless',
            flags: [
                '--no-sandbox', // required to run without privileges in docker
                '--user-data-dir=/tmp/chrome-test-profile',
                '--disable-web-security',
                '--no-proxy=http://0.0.0.0:9876/'
            ]
        }
    },
    singleRun: true,
    concurrency: Infinity,
    captureTimeout: 180000,
    browserDisconnectTimeout: 90000,
    browserNoActivityTimeout: 180000
  });
};

The command used to run the test cases is as below,
node --max_old_space_size=4096 node_modules/@angular/cli/bin/ng test --watch=false --code-coverage --source-map=false

Please advice.

A: When you run ng test it will run the tests for all projects.
For instance, if you have these two projects in your angular.json:

*

*hello-world (with 10 tests)

*utilities (with 100 tests)

then when you run ng test it will run tests for both hello-world and utilities.
However if you are using Karma with watch files or auto-watch enabled, it will stop at the first project so you will only see 10 tests run (or 100 tests depending on the order of the projects). Then when you Ctrl+C and exit the Karma process, it will continue to the next project, compile it and run the tests. So you will have two test runs.
What to do?

*

*If you have multiple Angular applications but are deploying one to production you should use ng test <app> with the project name that you are deploying.

*If you have an Angular application and a library you will want to test the application and the library: ng test <app> && ng test <library>

*If you want to run the full test suite, just do ng test and don't forget to change Karma to run a single test run and not to auto-watch for changed files!

*Update the karma.conf.js for each project to ensure it has the correct settings (no watching, single run, correct browsers to use)

A: So I have found the issue. In angular.json file i have 2 projects both have the test block configured and that was causing it to run twice. Removing the last project test block resolved it. Not sure how Angular 4 was running the TDD only once while with the same configuration Angular 7 run it twice.


text:
Q: Stop browser.downloads.download force-encoding file names I'm developing a browser addon and I'm debugging it in Firefox 56.
There seems to be a bug in browser.downloads.download which causes files downloaded like this:
browser.downloads.download({url:'https://foo.bar/example - foobar.mp3'})

to be named like this:
example%20-%20foobar.mp3

Is that expected behavior? When I manually enter the url and press enter to download it or when I create a link with that url and click it, this does not happen. I already tried using decodeURI() on the url before calling the download function, but it is still adding the encoding.
Why is this happening and how can I prevent this from happening?


text:
Q: I am getting thread1:SIGNAL sigbart in output this is my code, PLease help me ! im using xcode.. i want to generate a sequence for a polynomial and the terms are xor'ed and made a feedback to the first input bit since it is 8 bit it is done 2^8-1 times.Alternate code will also be helpful Thanks in advance
#include "32bit.h"
#include<iostream>

using namespace std;
int main()
{
    bool input[8];
    int n;
    bool out=0;
    cout<<"Enter the no of terms ";
    cin>>n;
    int temp1[n];
    int gen=0;
    bool store[255];
    cout<<"Input power of x in increasing order, Omit x^0";

    for(int i=0;i<n;i++)
        cin>>temp1[i];
    cout<<"Enter key to generate ";
    cin>>gen;
    for(int m=0;m<255;m++)
    {
        store[m]=input[gen];
        bool temp2[n];
        int var=0;
        for(int j=0;j<n;j++)
        {

            var=temp1[j];
            temp2[j]=input[var];
        }
        int c=0;
        for(int k=0;k<n;k++)
        {
            if(temp2[k]%2==1)
                c++;

        }
        if(c%2==1)
            out=1;
        else
            out=0;
        for(int l=0;l<8;l++)
            input[l+1]=input[l];
        input[0]=out;
    }
    for(int p=0;p<255;p++)
        cout<<store[p];
}

A: There is an out of bounds array access here:
    for(int l=0;l<8;l++)
        input[l+1]=input[l];

since input is only of size 8 and you are trying to write to input[8] (i.e. the non-existent 9th element) on the last iteration of this loop. I'm guessing it should probably be:
    for(int l=0;l<7;l++)
        input[l+1]=input[l];


text:
Q: Remove DataSnapshot From Firebase setValue() My Firebase database storage format like this.
{
    key=3553: 3223,
    value={
        -KZMFwmCYKevESD6qtjD={
            text=Hello I am,
            timestamp=[
                .sv: timestamp
            ],
            imageUrl=,
            senderId=yDapbI755tOD72ivfsdferOv1RIHMnAe03
        }
    }
}

but at the time of set value to store in firebase database i am doing like this.
String Temp = "{timestamp: [.sv: timestamp], imageUrl: , senderId: " + Utils.SET_HEADER_ID + ", text: " + strMessage + "}";
System.out.println("===== Temp String : " + Temp);

String key = mFirebaseDatabaseReference.child("threads/3333:3333").push().getKey();
mFirebaseDatabaseReference.child("threads/3333:3333").child(key).setValue(Temp);

As I wrote above code I added a data in Firebase database. But it will automatically include DataSnapshot JsonObject at top my insert database format like this, which is wrong.
DataSnapshot{
    key=3333: 3333,
    value={
        -KZPfTKJhaCC4RkIj45P={
            timestamp: [
                .sv: timestamp
            ],
            imageUrl: ,
            senderId: yDapbI755tOD72ivOv1RIHMnAe03,
            text: hiiiiiiiii
        }
    }
}

How can I remove this DataSnapshot from insert format of Firebase?

A: You cannot pass a raw JSON value to Firebase. You'll instead have to build the data structure in your code:
Map<String,String> map = new HashMap<String,String>();
map.put("timestamp", Firebase.Database.ServerValue.TIMESTAMP);
map.put("imageUrl", "an actual image URL, which is missing from your question");
map.put("senderId", Utils.SET_HEADER_ID);
map.put("text", strMessage);

mFirebaseDatabaseReference.child("threads/3333:3333").child(key).setValue(map);

Alternatively you can use a library such as Jackson to convert the JSON intro the required nested map structure. See for example Nested Json to Map using Jackson.


text:
Q: Any 'design pattern' of c++ enable_if and SFINAE? I did quite some searches on Internet and I found some examples of enable_if in different contexts.
However, pretty much all of the examples I found are 'dummy' examples, which can be done easily through inheritance and other OO approaches.
I am wondering what's the real world application of enable_if, the one that is difficult to be implemented in OO.
Or in other words, in what kind of application enable_if could be most useful/elegant?
Can anyone provide an example here?
I can understand c++ std library uses a lot of enable_if, but I have no intension to write a std library.
I am currently working on fleet management software. I am wondering if there is any kind of 'pattern' for using enable_if in software design.
For example, enable_if can be used to 'differentiate' return type:
template<typename T>
std::enable_if_t<std::is_integral<T>::value> f(T t){
    //integral version
}

template<typename T>
std::enable_if_t<std::is_floating_point<T>::value> f(T t){
    //floating point version
}

Thanks a lot


text:
Q: Does Baneful Bunker cause regular Poison or Toxic Poison? I've been reading up on some of the new Pokemon and I noticed that Toxapex gets a Protect-like move called Baneful Bunker:

Baneful Bunker protects the user from damage. In addition, any opponent making direct contact on that turn is poisoned.

Does Baneful Bunker cause regular poison status, or Toxic Poison status? (The latter having the increased-damage-per-turn effect of course).

A: Now that I have the move, I can confirm that Baneful Banker inflicts regular poison, not toxic poison.


text:
Q: Good Web Server/Servlet Container for Clojure Web Apps? I am looking for a good production web server/servlet container for my compojure web appliction. What are the pros and cons of using Jetty or Tomcat or other server for a Clojure web app using compojure? Is there any good documentation for using a web server with Clojure for production, or tools?
I would prefer a web server that is flexible, easy to configure and has good documentation on how to configure and use it.

A: I think there is not yet a pure Clojure Webserver, but I heard that people at Apache were working on something like that. On the meanwhile I have some links I found useful myself.
A commentary on Apache + Jetty: http://briancarper.net/blog/510/deploying-clojure-websites
Take a look at this for implementing your own webserver via servlets: Clojure web application - where do I start?

A: If you don't already have your own infrastructure to run on, you might consider Heroku, which supports Clojure. See their tutorial Getting Started With Clojure on Heroku/Cedar. It's free to start and very easy to scale.

A: Chas Emerick has a rather old blog post + slides on doing continous integration on webapps right (Heroku, Pallet, War-file or whatever nescessary to NOT roll your own solution).


text:
Q: Powershell replacing 2nd item in cron schedule? Am sure I'm way off here & there's probably an easier way to do this, but I have to change some cron text schedules & change the hour in which they run..
The cron itself is in a text file so I was thinking of using powershell to get the content, update it & save it..  but I'm not very good with regex etc with this. -I've cobbled something together from internet sources, but something is still slightly missing....
I can do all the grabbing of the file content & writing etc, it's just the slightly more advanced replacement of the 2nd variable that's an issue....
Here's my code:
$testText = "cron(0 20 * * ? *)"
$pattern = '(\().+?(\))'
$new1 = [regex]::Matches($testText, $pattern).Value
"new1 $new1"
$new2 = $($new1 -replace '\s+', ' ').split()
"new2 $new2"
$new3 = $new2[1]-1 #Set back an hour
#$new3 = $new2[1] -replace $new2[1],"22" #Specify Hour
"new3 $new3"
$new4 = $testText -Replace($new2,$new3)
"new4 $new4"

This results in this output - where annoyingly the first bit is knocked off..
new1 (0 20 * * ? *)
new2 (0 20 * * ? *)
new3 19
new4 cron(19* * ? *)

I've split this using spaces as the 1st item after the parenthesis can be 1 or 2 digits & after the 2nd set of chars(the hour) these can also be different.. i.e. cron(30 06 ? * MON-FRI *)
Any help would be appreciated... - it's been a long day & my brain is very tired!!

A: $testText = "cron(0 20 * * ? *)"

$cron = $testText.split(' ').split('(').split(')')

'cron(' +
$cron[1] + ' ' +
(([datetime]::Today).AddHours($cron[2] -1).Hour) + ' ' +
$cron[3] + ' ' +
$cron[4] + ' ' +
$cron[5] + ' ' +
$cron[6] +
')'

or perhaps a little easier
$testText = "cron(0 20 * * ? *)"

$cron = $testText.split(' ').split('(').split(')')
$cron[2] = ([datetime]::Today).AddHours($cron[2]-1).Hour
'cron(' + ($cron -join ' ') + ')'


text:
Q: How to get file path of the script that's executing? I hope I have explained this makes sense...
Basically I want to run a python file which will edit itself and delete itself (don't ask) but to delete itself I need the python file to locate its file path (I know I could manually put the file path in but that means the file would have to stay in the same folder). Does anyone know any code I could use so that the program can copy its file path?
Below is the code I am using so that the program can delete itself as you can see I need the file path but I do not know how to copy it within the program.
import os
os.remove(r"filepath")

A: Use __file__.
Test 1:
cat > /tmp/foo.py << EOF
print(__file__)
EOF

python /tmp/foo.py
# output: /tmp/foo.py

Test 2:
cat > /tmp/foo.py << EOF
import os

print(f'deleting self ({__file__})')
os.unlink(__file__)
print('Done.')
EOF

python /tmp/foo.py
# output:
deleting self (/tmp/foo.py)
Done.

# second try
python /tmp/foo.py
# python: can't open file '/tmp/foo.py': [Errno 2] No such file or directory


text:
Q: Allow multiple instances of Handbrake Is it possible to run multiple instances of Handbrake on Windows 7 (video encoding application)?
I have a 32 thread system and I think it would be more efficient to encode 2-3 movies at the same time. (Handbrake does not use all 16 cores at the moment)


text:
Q: Optical Mouse as encoder Recently I discovered the beauty of the optical mouse as an incremental position encoder.
An optical mouse usually contains one component in which a camera is linked to an image processor linked to an USB interface. The resolution depends on the camera resolution. On the internet it is easy to find back the datasheets of this type of components describing also how to read/write with them.
My problem I first need to solve is how to make sure that an encoder mouse is not seen by the laptop/pc as a pointing device without disabling the USB port to which it is connected. I need to use 2 encoders so that means that 3 usb ports need to be used on my PC (running Windows XP), one for the mouse as pointing device and two for a mouse as encoder.
A second question is how to read/write instructions/data from/to the encoder mouse over an USB port? Could someone send me a link to a tutorial/example in C++?
Thanks very much in advance,
Stefan

A: The USB mouse microcontroller is probably hardcoded to send USB frames identifying itself as a HID device. In that case there's little hope you can succeed in preventing Windows to use it as a mouse. After all this IS a mouse.
If you are in DIY, you could try to hack the mouse board by unsoldering component/wires and directly control the encoders with your arduino. This way, the Arduino could read the data from the encoder and send it to the PC using its own USB serial port.
See an example there:
http://www.martijnthe.nl/2009/07/interfacing-an-optical-mouse-sensor-to-your-arduino/
For more info on HID device: http://en.wikipedia.org/wiki/USB_human_interface_device_class
Excerpt:
"There are two levels of APIs related to USB HID: the USB level and the operating system level. At the USB level, there is a protocol for devices to announce their capabilities and the operating system to parse the data it gets. The operating system then offers a higher-level view to applications, which do not need to include support for individual devices but for classes of devices. This abstraction layer allows a game to work with any USB controller, for example, even ones created after the game."

A: Take a look at the Raw Input API to see if you can pick up on the events that way and block Windows from acting on them.


text:
Q: How to integrate cdn of bootstrap using webpack only in production mode Hi i am using htmlwebpackextract plugin.here is my config code
new HtmlWebpackExternalsPlugin(
            {
            externals: [
                {
                    module: 'jquery',
                    entry:'https://unpkg.com/jquery@3.2.1/dist/jquery.min.js',
                    global: 'jQuery'
                },
                {
                    module: 'bootstrap',
                    entry: {
                        path: 'https://unpkg.com/bootstrap@4.0.0/dist/css/bootstrap.min.css',
                        type: 'css'
                    },
                    append: true,
                }
            ],
            enabled:isProd,
            }

        )

It gives some error as cannot read property 'var'of null.In index.js require('bootstrap') is there


text:
Q: What does the following jQuery code mean? I am new to jQuery. What does the following code mean? Especially the first part.
$(".locale-en-us", $iframe).append($('script').attr('type', "text/javascript").attr('src', "https://mytestbox/testsite/test.js"));

A: it is going to add script tag to your element having class locale-en-us which is present in $iframe element
    <div class="locale-en-us">
        <script src="https://mytestbox/testsite/test.js" type="text/javascript"></script>
    </div>

A: The above code will find the element with class name "locale-en-us" and then Add an Iframe element.
In Iframe element add the script with set type="text/javascript" and src="https://mytestbox/testsite/test.js".

A: I think the first part means:
select the elements whose class is 'locale-en-us' from the jQuery variety 'iframe'.
The rest codes can be understood easily:
add js file!


text:
Q: JS - How to get and calculate the current date Sorry, but what is the fastest way to display the current date?
 2014-01-18 Saturday 12:30

with this function or how do it the right way?
 var d=new Date();
 var t=d.getTime();

A: Try
var d = new Date();
var dd = d.getDate();
var mm = d.getMonth()+1; //January is 0!
var yy = d.getFullYear();

var weekday=new Array(7);
weekday[0]="Sunday";
weekday[1]="Monday";
weekday[2]="Tuesday";
weekday[3]="Wednesday";
weekday[4]="Thursday";
weekday[5]="Friday";
weekday[6]="Saturday";

var day=weekday[d.getDay()];

var h = d.getHours();
    var m = d.getMinutes();

alert(yy+"-"+mm+"-"+dd+" "+day+" "+h+":"+m)

DEMO

A: If you don't mind the format, you can do it in one line:
''+new Date()

You only need to use a Date object as a string, in order to implicitly call its .toString() method, which

returns a String value. The contents of the String are
  implementation-dependent, but are intended to represent the Date in
  the current time zone in a convenient, human-readable form.

A: var d =  new Date();
alert(d.toString());

A: new Date().toGMTString()

It's something similar to what you are looking for
If you want complicate the output you can get element by element and format yourself the date (or you can use Globalize.js)


text:
Q: Eddy currents of a thin wire vs. a large plate? In many examples such as this:

I noticed that most cases where Eddy currents are of focus, or have a considerable effect, would be with examples having a large conductive area perpendicular to the magnetic field, such of a plate or a disc etc...
If I compare it to wires very thin(regardless of length) there aren't any Eddy currents? I fail to understand the difference with this set-up:

Are there Eddy currents to this case as well?

A: This video is the best illustration of the effect that I have seen because it introduces a third type of pendulum as well as the normal plane metal sheet (1) and the metal sheet in the form of a comb (2).  It is a sheet with slots in it (3).

The plane metal sheet is your first example and the metal sheet in the form of a comb is your second example.  The third sheet is the intermediate type.
When a conductor passes at right angles to a magnetic field, an emf is induced - Faraday's Law.  This happens in each of the sheets because of the force produced by the magnetic field on the moving mobile charge carriers in the metal plates.
If there is a conducting path, currents are induced whose magnitude depend on the magnitude of the induced emf and the resistance of the conducting path.
The induced current tries to oppose the motion producing it - Lenz's Law.
The larger the current the greater the opposition.
In the demonstration the opposition is greatest for sheet 1 and least for sheet 2.
I think that the diagrams speak for themselves in showing why it is the induced (eddy) currents are much bigger in sheet 1 than sheet 2 and so much bigger than in sheet 3.  It is the resistance of the conducting paths which changes due to the different sheet geometries.
Note that the emf induced in sheet 1 is less than that induced in sheet 2 and yet because the resistance of the conducting paths in sheet 1 are so much less than in sheet 2 the induced (eddy) currents (opposition to motion) are so much larger.


text:
Q: How can I import the images of the configurable product in simple product? I need to send my products for Amazon but I created simple products through configurable products. So simple products are no images.
How can I assign the images of configurable products to simple products to send them the Amazon?

A: First, backup your database in case I'm wrong.
Let's say that $configurableProductId is the configurable product id.
Now you can run this script for a configurable product.
//load the configurable product - not a very fast way to do it, but you need a load to fetch all the images
$confProduct = Mage::getModel('catalog/product')->load($configurableProductId);
//get the images
$gallery = $product->getData('media_gallery');
//get the instance for the media_gallery attribute
$mediaGalleryAttribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'media_gallery');
//get access to a model that handles the image association to products
$resource = Mage::getResourceSingleton('catalog/product_attribute_backend_media');
if (isset($gallery['images'])) {
    //get all simple child products ids
    $simpleProductIds = $conProduct->getTypeInstance()->getUsedProductIds();
    //for each simple product
    foreach ($simpleProductIds as $productId) {
        //for eahc image from the main product
        foreach ($gallery['images'] as $image) {
            //build an array with imag settings
            $data = array();
            $data['entity_id']      = $parentId;
            $data['attribute_id']   = $mediaGalleryAttribute->getId();
            $data['value']          = $image['file'];
            //save the image and get the id
            $lastId = $resource->insertGallery($data);
            //set the label and position for the new images
            $data = array();
            $data['value_id'] = $lastId;
            $data['label']    = $image['label'];
            $data['position'] = (int) $image['position'];
            $data['disabled'] = (int) $image['disabled'];
            $data['store_id'] = (int) $product->getStoreId();
            //finish the job
            $resource->insertGalleryValueInStore($data);
        }
    }
}

If you need to get all the configurable products ids you can do this:
$productsIds = Mage::getModel('catalog/product')->getCollection()
    ->addAttributeToFilter('type_id', 'configurable')
    ->getAllIds();

A: Marius's solution is great but it needs further modification to Magento backend media class which has a method _removeDuplicates() to remove duplicate entries from catalog_product_entity_media_gallery.
When catalog loads on frontend it triggers Mage_Catalog_Model_Resource_Product_Attribute_Backend_Media::loadGallery
() and Mage_Catalog_Model_Resource_Product_Attribute_Backend_Media::loadGallerySet
that implements _removeDuplicates(). This method will initially remove duplicate image entries from catalog_product_entity_media_gallery table resulting in images being lost for both configurable and associated products.
To resolve this we need to uncomment _removeDuplicates() method. Best way is to create new plugin that will override Mage_Catalog_Model_Resource_Product_Attribute_Backend_Media.

*

*Create file M2e_Plugin.xml in the following directory
In app/etc/modules/M2e_Plugin.xml put the following content:
<?xml version="1.0"?>
<config>
    <modules>
        <M2e_Plugin>
            <active>true</active>
            <codePool>local</codePool>
        </M2e_Plugin>
    </modules>
</config>

*Create file config.xml and its new directory in
app/code/local/M2e/Plugin/etc/config.xml
Put the following content:
<?xml version="1.0"?>
<config>
    <modules>
        <M2e_Plugin>
            <version>0.1.0</version>
        </M2e_Plugin>
    </modules>
    <global>
        <models>
            <catalog_resource>
                <rewrite>
                    <product_attribute_backend_media>M2e_Plugin_Model_Resource_Product_Attribute_Backend_Media</product_attribute_backend_media>
                </rewrite>
            </catalog_resource>
        </models>
        <helpers>
            <m2e_plugin>
                <class>M2e_Plugin_Helper</class>
            </m2e_plugin>
        </helpers>
    </global>
</config>

*Create Data.php file and its directory as follows
app/code/local/M2e/Plugin/Helper/Data.php
Content for this file:
<?php
class M2e_Plugin_Helper_Data extends Mage_Core_Helper_Abstract
{}

*Create Media.php file (and direcotories) which overrides our target file as follows:
app/code/local/M2e/Plugin/Model/Resource/Product/Attribute/Backend/Media.php
and its content:
<?php
/**
 * Class M2e_Plugin_Model_Resource_Product_Attribute_Backend_Media
 */
class M2e_Plugin_Model_Resource_Product_Attribute_Backend_Media extends Mage_Catalog_Model_Resource_Product_Attribute_Backend_Media
{
    /**
     * Load gallery images for product using reusable select method
     *
     * @param Mage_Catalog_Model_Product $product
     * @param Mage_Catalog_Model_Product_Attribute_Backend_Media $object
     * @return array
     */
    public function loadGallery($product, $object)
    {
        $eventObjectWrapper = new Varien_Object(
            array(
                'product' => $product,
                'backend_attribute' => $object
            )
        );
        Mage::dispatchEvent(
            $this->_eventPrefix . '_load_gallery_before',
            array('event_object_wrapper' => $eventObjectWrapper)
        );

        if ($eventObjectWrapper->hasProductIdsOverride()) {
            $productIds = $eventObjectWrapper->getProductIdsOverride();
        } else {
            $productIds = array($product->getId());
        }

        $select = $this->_getLoadGallerySelect($productIds, $product->getStoreId(), $object->getAttribute()->getId());

        $adapter = $this->_getReadAdapter();
        $result = $adapter->fetchAll($select);
        /** Overriding bellow to avoid duplicate images removal. */
        // $this->_removeDuplicates($result);
        return $result;
    }

    /**
     * Get media gallery set for given product IDs
     *
     * @param array $productIds
     * @param $storeId
     * @return array
     */
    public function loadGallerySet(array $productIds, $storeId)
    {
        $select = $this->_getLoadGallerySelect($productIds, $storeId, $this->_getAttributeId());

        $adapter = $this->_getReadAdapter();
        $result = $adapter->fetchAll($select);
        /** Overriding bellow to avoid duplicate images removal. */
        // $this->_removeDuplicates($result);
        return $result;
    }
}

I had similar situation as my client is using M2e Pro to list on amazon. M2E pro has no option to chose which product image is used for listing when submitting configurable type. Many magento owners, who deal with configurable products, do not even bother creating images for simple associated products, so option to use configurable product image for children would be very useful.
Thanks to Marius for pointing in right direction.


text:
Q: Configuring CXF web service client to read XML 1.1 responses I'm using CXF to generate an interface to a .NET web service client.  However, sometimes when I use the client, I get an error:
WARNING: Interceptor for {http://xxxxxx.com}ChangeRequestWebService#{http://xxxxxx.com/ChangeRequestWebService}GetChangeRequestById has thrown exception, unwinding now
[com.ctc.wstx.exc.WstxLazyException] com.ctc.wstx.exc.WstxParsingException: Illegal character entity: expansion character (code 0x1b
 at [row,col {unknown-source}]: [76,44]

From many other sources online, it's obvious that this is because the webservice is encoding its response in XML 1.1, while my CXF client is reading that response expecting XML 1.0, and the special character 0x1b is illegal in XML 1.0.  Now, I don't want to argue about whether the .NET service should be using XML 1.1 in its response, when the WSDL is obviously 1.0 (since that's the spec).  I just want to be able to read what they send without errors.
Looking at the dependencies in the CXF client, they use WoodStox 4.1.1 which (from their site) clearly supports XML 1.1.  What I want to know is, is there any way to configure my CXF client (via binding at wsdl2java time, or during run-time) to use an XML 1.1 parser when receiving responses?  All I can find is people saying that they shouldn't be using 1.1, or having the server-side filter these characters.  Note that I can't filter the characters client-side, as I have to send the data back to the server, and validation would fail.
As an alternative, I suppose the .NET service could in some fashion SPECIFY that they're using XML 1.1 in their response, but I don't control that service, so it would be more troublesome to figure out their problem for them and then suggest they fix it.  Plus, the data they're sending is in a DB, so it's not the web service's fault that it has XML 1.1-only characters in it.

A: It looks like the answer is... there is no way to pre-configure CXF to expect XML 1.1 by default.
Essentially, if XML comes in without a version tag:
<?xml version="1.1">

Then it isn't XML 1.1.  That's the problem here.  If the xml header existed and specified XML 1.1, then the parser in CXF would parse it as XML 1.1.  .NET web services don't (by default) send any XML header tag, so the parser in CXF parses it (correctly) as XML 1.0.
That said, there might be a way to catch the input stream before it gets parsed by CXF, and "insert" an XML version header that specifies 1.1, which would "fix" the problem for me.  If I find a way to get it to work, I'll post it.


text:
Q: gnome keyring pkcs11 warning I get a gnome-keyring warning when I try to do many different things from the command line, like svn. Example:
$ lp README.txt
WARNING: gnome-keyring:: couldn't connect to: /run/user/dargaud/keyring-kAKdPw/pkcs11: No such file or directory
request id is lpsc0204pnb-366 (1 file(s))

/run/user/dargaud/keyring-kAKdPw/pkcs11 doesn't exist (there's only a 'control' socket in there).
I'm using Kubuntu, so why is anything trying to use the gnome keyring instead of kwallet in the first place ?
Thanks

A: You can run it as startup job:
 /usr/bin/gnome-keyring-daemon --start --components=pkcs11


text:
Q: Getting elements in getelementsbyclassname not working var list = document.getElementsByClassName("sidebar-holder");
console.log(list);// html collection of length 2
console.log(list[0]);// undefined

Here I have run the following code and I have used the comments to console.log() the results.
While the elements with that class name are being rendered asynchronously, I do not believe that this is the problem as the first console.log() renders the expected result. The second one does not.

A: Add Array.from(list) to convert the HTML element to array before you can iterate over it. That's so because HTML element are array-like but not pure arrays.


text:
Q: Docker devicemapper storage space Am getting the "no space left on device" error while removing a container.
# docker rm orientdb1
Error response from daemon: Driver devicemapper failed to remove root filesystem ba18ea8014b6024eb738502612130244ff363b433f146102c64eb2eb0f3a321c: devmapper: Error saving transaction metadata: devmapper: Error creating metadata file: open /var/lib/docker/devicemapper/metadata/.tmp636968871: no space left on device

Here is a snippet from "df -kh" output.
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  3.8T  3.8T   20K 100% /

Here is a snippet from "du -ksh " output. Which shows that 3.8TB is used.
3.8T    /var/lib/docker

This is the "docker info" output.
# docker info
Containers: 56
 Running: 8
 Paused: 0
 Stopped: 48
Images: 18
Server Version: 1.12.0
Storage Driver: devicemapper
 Pool Name: docker-253:0-1196768-pool
 Pool Blocksize: 65.54 kB
 Base Device Size: 10.74 GB
 Backing Filesystem: xfs
 Data file: /dev/loop0
 Metadata file: /dev/loop1
 Data Space Used: 24.51 GB
 Data Space Total: 107.4 GB
 Data Space Available: 20.48 kB
 Metadata Space Used: 29.18 MB
 Metadata Space Total: 2.147 GB
 Metadata Space Available: 20.48 kB
 Thin Pool Minimum Free Space: 10.74 GB
 Udev Sync Supported: true
 Deferred Removal Enabled: false
 Deferred Deletion Enabled: false
 Deferred Deleted Device Count: 0
 Data loop file: /var/lib/docker/devicemapper/devicemapper/data
 WARNING: Usage of loopback devices is strongly discouraged for
 production use. Use `--storage-opt dm.thinpooldev` to specify a custom
 block storage device.
 Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
  Library Version: 1.02.107-RHEL7 (2016-06-09)
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host overlay null
 Swarm: inactive
 Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 3.10.0-327.22.2.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 12
Total Memory: 251.7 GiB
Name: my-host1
ID: KTTY:PSTQ:YQSP:9KZJ:VSVU:DFUZ:CEMF:DYWQ:CA3I:6KUB:6J2J:D4NG
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: bridge-nf-call-ip6tables is disabled
Insecure Registries:
 127.0.0.0/8

Would like to understand how 3.8 TB is accounted for from the following (snippet from "docker info")
 Data Space Used: 24.51 GB
 Data Space Total: 107.4 GB
 Data Space Available: 20.48 kB
 Metadata Space Used: 29.18 MB
 Metadata Space Total: 2.147 GB
 Metadata Space Available: 20.48 kB
 Thin Pool Minimum Free Space: 10.74 GB

Also how can I clean /var/lib/docker to get some free space.

A: I believe the disk space figures are for the loopback driver and the file /var/lib/docker/devicemapper/devicemapper/data that is used by devicemapper in the loopback mode.
To cleanup the docker, you can run docker system prune on a newer release. Older releases can use commands like:
docker ps -aqf status=exited | xargs docker rm
docker images -qf dangling=true | xargs docker rmi

Beyond that, you will need to go through containers and images to docker stop, docker rm on the container, and docker rmi on the image.

A: To add to BMitch's answer, you can also remove dangling volumes to free up space using something like docker volume ls -f dangling=true | xargs docker volume rm


text:
Q: How do I use request-response using HTTP libraries in C#.NET/Mono Right now I have been trying to use Launchpad's API to write a small wrapper over it using C#.NET or Mono.
As per OAuth, I first need to get the requests signed and Launchpad has it's own way of doing so.
What I need to do is to create a connection to https://edge.launchpad.net/+request-token with some necessary HTTP Headers like Content-type. In python I have urllib2, but as I glanced in System.Net namespace, it blew off my head. I was not able to understand how to start off with it. There is a lot of confusion whether I can use WebRequest, HttpWebRequest or WebClient. With WebClient I even get Certificate errors since, they are not added as trusted ones.
From the API Docs, it says that three keys need to sent via POST

*

*auth_consumer_key: Your consumer key

*oauth_signature_method: The string "PLAINTEXT"

*oauth_signature: The string "&".

So the HTTP request might look like this:
POST /+request-token HTTP/1.1
Host: edge.launchpad.net
Content-type: application/x-www-form-urlencoded

oauth_consumer_key=just+testing&oauth_signature_method=PLAINTEXT&oauth_signature=%26

The response should look something like this:
200 OK

oauth_token=9kDgVhXlcVn52HGgCWxq&oauth_token_secret=jMth55Zn3pbkPGNht450XHNcHVGTJm9Cqf5ww5HlfxfhEEPKFflMqCXHNVWnj2sWgdPjqDJNRDFlt92f

I changed my code many times and finally all I can get it something like
HttpWebRequest clnt = HttpWebRequest.Create(baseAddress) as HttpWebRequest;
// Set the content type
clnt.ContentType =  "application/x-www-form-urlencoded";
clnt.Method = "POST";

string[] listOfData ={
    "oauth_consumer_key="+oauth_consumer_key,
    "oauth_signature="+oauth_signature,
    "oauth_signature_method"+oauth_signature_method
};

string postData = string.Join("&",listOfData);
byte[] dataBytes= Encoding.ASCII.GetBytes(postData);

Stream newStream = clnt.GetRequestStream();
newStream.Write(dataBytes,0,dataBytes.Length);

How do I proceed further? Should I do a Read call on clnt ?
Why can't .NET devs  make one class which we can use to read and write instead of creating hundreds of classes and confusing every newcomer.

A: No, you need to close the request stream before getting the response stream.
Something like this:
Stream s= null;
try
{
    s = clnt.GetRequestStream();
    s.Write(dataBytes, 0, dataBytes.Length);
    s.Close();

    // get the response
    try
    {
        HttpWebResponse resp = (HttpWebResponse) req.GetResponse();
        if (resp == null) return null;

        // expected response is a 200
        if ((int)(resp.StatusCode) != 200)
            throw new Exception(String.Format("unexpected status code ({0})", resp.StatusCode));
        for(int i=0; i < resp.Headers.Count; ++i)
                ;  //whatever

        var MyStreamReader = new System.IO.StreamReader(resp.GetResponseStream());
        string fullResponse = MyStreamReader.ReadToEnd().Trim();
    }
    catch (Exception ex1)
    {
        // handle 404, 503, etc...here
    }
}
catch
{
}

But if you don't need all the control, you can do a WebClient request more simply.
string address = "https://edge.launchpad.net/+request-token";
string data = "oauth_consumer_key=just+testing&oauth_signature_method=....";
string reply = null;
using (WebClient client = new WebClient ())
{
  client.Headers.Add("Content-Type","application/x-www-form-urlencoded");
  reply = client.UploadString (address, data);
}

Full working code (compile in .NET v3.5):
using System;
using System.Net;
using System.Collections.Generic;
using System.Reflection;

// to allow fast ngen
[assembly: AssemblyTitle("launchpad.cs")]
[assembly: AssemblyDescription("insert purpose here")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Dino Chiesa")]
[assembly: AssemblyProduct("Tools")]
[assembly: AssemblyCopyright("Copyright © Dino Chiesa 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("1.1.1.1")]

namespace Cheeso.ToolsAndTests
{
    public class launchpad
    {
        public void Run()
        {
            // see http://tinyurl.com/yfkhwkq
            string address = "https://edge.launchpad.net/+request-token";

            string oauth_consumer_key = "stackoverflow1";
            string oauth_signature_method = "PLAINTEXT";
            string oauth_signature = "%26";

            string[] listOfData ={
                "oauth_consumer_key="+oauth_consumer_key,
                "oauth_signature_method="+oauth_signature_method,
                "oauth_signature="+oauth_signature
            };

            string data = String.Join("&",listOfData);

            string reply = null;
            using (WebClient client = new WebClient ())
            {
                client.Headers.Add("Content-Type","application/x-www-form-urlencoded");
                reply = client.UploadString (address, data);
            }

            System.Console.WriteLine("response: {0}", reply);
        }

        public static void Usage()
        {
            Console.WriteLine("\nlaunchpad: request token from launchpad.net\n");
            Console.WriteLine("Usage:\n  launchpad");
        }

        public static void Main(string[] args)
        {
            try
            {
                new launchpad()
                    .Run();
            }
            catch (System.Exception exc1)
            {
                Console.WriteLine("Exception: {0}", exc1.ToString());
                Usage();
            }
        }
    }
}


text:
Q: Activerecord select columns from a triple join query I have 3 models Passenger, Taxi, Order i want to get a certain column of these tables. I used this to join them successfully.
Taxi.joins(:orders => :passenger).where(:taxi =>{:taxi_id =>2 } )

I want to select some of the columns of passenger table and some of the column of order,
but i do not know how can i do that?
The other problem is that, the result of this query is only columns of Taxi and not the column of taxi+order+passenger
I think i have a problem with my query

A: Taxi
  .joins(orders: :passenger)
  .where(taxi: {taxi_id: 2 })
  .pluck('passengers.column_name, orders.column_name')

A: Taxi.joins(orders: :passenger).where(taxi:{taxi_id: 2}).includes(orders: :passenger).map do |taxi|
  #this will not query again as the includes directive above already fetched
  taxi.orders.map {|p| puts p}
end


text:
Q: How to split a time series data by range of date in R? I am a beginner in R, and working on a time series monthly data:
I have selected the following  data columns from my dataframe
df = select(data, Date, Location, Production,  Value)

There are 13 different locations, multiple production sectors and their values. Date range is from 2016-01-2020-09.
I want to split the data into two columns: before covid (2016-01 to 2020-01), and after covid (2020-02 to 2020-09).
How do I do this in R ? Is there a simple method ?

A: I think you're looking for something like this. Here's a tidy solution. There are several similar ways to do this, but I think this is pretty straightforward to follow.
library(dplyr)
df %>%
  mutate(PreCovid = ifelse(Date < as.Date("2020-02-01"), Value, NA),
         PostCovid = ifelse(Date >= as.Date("2020-02-01"), Value, NA))

A: We can convert to date class first and then specify the range in which we want to divide the data.
library(dplyr)

df <- df %>%
       mutate(Date = as.Date(paste0(Date, '-01')),
              period = case_when(between(Date, as.Date('2016-01-01'),
                                    as.Date('2020-01-01')) ~ 'Before covid',
                                  between(Date, as.Date('2020-01-02'),
                                    as.Date('2020-11-01')) ~ 'After covid'))


text:
Q: How does PuLP (Linear Programming) LpMaximize pick the Optimal Solution? I'm using PuLP in Python and maximizing a decision variable using LpMaximize. Let's say I have several combinations with certain points for each combination. The decision variable in this case is "points" as points are what I'm trying to maximize. My intended objective of this exercise is to find the combinations with highest points. My code for this:
prob = LpProblem("Allocation",LpMaximize)

alloc_vars = LpVariable.dicts("Allocation",combinations,0,1,LpBinary)

prob += lpSum(binary.loc[i]["points"]*alloc_vars[i] for i in combinations)

for j in vendors:
prob += lpSum([alloc_vars[i]*binary.loc[i][j] for i in combinations]) == 1

#"binary" is a matrix file/dataframe that's commonly used in PuLP solver

prob.solve()
print("Status: ", LpStatus[prob.status])

var_output = []
for i in alloc_vars:
for j in vendors:
    var_output += [{
        'Vendor': j,
        'Combination': i,
        'Allocation': alloc_vars[i].varValue*binary.loc[i][j],
    }]

[i for i in var_output if i['Allocation']==1]

value(prob.objective)

selected_combinations = set([i['Combination'] for i in var_output if i['Allocation']==1])

Sample input: (this is jut dummy data)
| Combination | Vendor 1 | Vendor 2 | Vendor 3 | Vendor 4 | Points |  A  |  B  |  C  |  D |
|   Comb1     |     A    |          |          |          |   73   |  1  |  0  |  0  |  0 |
|   Comb2     |     B    |          |          |          |   54   |  0  |  1  |  0  |  0 |
|   Comb3     |     C    |          |          |          |   47   |  0  |  0  |  1  |  0 |
|   Comb4     |     D    |          |          |          |   89   |  0  |  0  |  0  |  1 |
|   Comb5     |     A    |     B    |          |          |   73   |  1  |  1  |  0  |  0 |
|   Comb6     |     B    |     A    |          |          |   -43  |  1  |  1  |  0  |  0 |
|   Comb7     |     D    |     C    |   A      |          |   111  |  1  |  0  |  1  |  1 |
...
...
...

As output I get combinations with maximum points. I'm not sure how exactly these combinations are selected though. As a corner case, I had an input dataframe with all the combinations having 0 points, but still got some combinations after running PuLP solver. So this got me wondering, how does PuLP find which combination will give the maximum points?


text:
Q: Github actions syntax: Invalid workflow file I started using github actions and I am trying to let a few lines of shell script running before I create a python package. But I can't get my code to run. It always stops on the line run: | - which is odd because I have been using this exact line before before (see further down). Does anyone know what I am doing wrong?
name: Python packaging

on: [push]

jobs:
    job1:
        name: Update version
        runs-on: ubuntu-latest
        steps:
            - name: checkout repo
               uses: actions/checkout@v3

               # ----- This is where the error occurs. Error message:
               # Check failure on line 11 in .github/workflows/main.yml
               # GitHub Actions / .github/workflows/main.yml
               # Invalid workflow file
               # You have an error in your yaml syntax on line 11

            - name: Increase version
               run: |
               old_version=$(grep -oP '(?<=0.0.)[0-99]+' contrib/_version.py)
               new_version=$(($old_version + 1))
               str="__version__=\"0.0."
               out="$str$new_version\""
               sed -i '1s/.*/'$out'/' contrib/_version.py

     job2:
        name: Build and upload
        needs: job1
        runs-on: ubuntu-latest
        strategy:
          matrix:
            python-version: ["3.9"]
        steps:
        - name: checkout repo
            uses: actions/checkout@v3
        - name: Set up Python ${{ matrix.python-version }}
            uses: actions/setup-python@v3
            with:
            python-version: ${{ matrix.python-version }}
        - name: Install dependencies
            run: |
            python -m pip install --upgrade pip setuptools wheel
            python -m pip install setuptools wheel
            python -m pip install --upgrade build
            python -m pip install --upgrade twine
            if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
        - name: Create package
            run: |
            python3 -m build
        - name: Upload to Test PyPI
            env:
            TWINE_USERNAME: "__token__"
            TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
            TWINE_REPOSITORY_URL: "https://test.pypi.org/legacy/"
            run: |
            twine check dist/*
            twine upload --verbose --skip-existing dist/*

A: The file is in YAML syntax which highly depends on indentation.
Based on your example:

*

*job1: and job2: must have the same indentation.

*Under steps:, name: and uses: must have the same indentation.

*...

name: Python packaging

on: [push]

jobs:
    job1:
        name: Update version
        runs-on: ubuntu-latest
        steps:
            - name: checkout repo
              uses: actions/checkout@v3

            - name: Increase version
              run: |
                old_version=$(grep -oP '(?<=0.0.)[0-99]+' contrib/_version.py)
                new_version=$(($old_version + 1))
                str="__version__=\"0.0."
                out="$str$new_version\""
                sed -i '1s/.*/'$out'/' contrib/_version.py

    job2:
        name: Build and upload
        # ...


text:
Q: Access View - Export to database failed Access Services are active for the site and site collection in SharePoint 2010. MS Access is installed at notebook of the user. When the user clicks at Access View in List Views, the message appears : « Export to database failed. To export a list, you must have a Microsoft SharePoint Foundation compatible application »
Any ideas on what could be the reason for this message ? Has anybody solved such issue in the past ?


text:
Q: Why are @ variables used in Ruby class models? Why are @variables needed in classes? What value do they add? I couldn't find anything online for this but maybe I'm searching for the wrong terms.  Is there a resource online I can look this up?  Thanks!
car.rb
class Car
  attr_accessor :make, :model

  def initialize(make = '')
    @make = ''
    @model = ''
  end
end

A: These variables are called instance variables.  Every instance of the class has it's own copy of these variables.
In your example, you would like every instance of the class Car to have it's own make and model.
Note the following example
car1 = Car.new("Toyota", "Carola")
car2 = Car.new("Mitsubishi", "Lancer")

Both car1 and car2 each have their own private make and model.  The way to tell the Ruby interpreter to do this is to use @.

A: That's the syntax for defining instance variables in ruby.

A: Instance variables are available in all areas of each instance of a class.
Each time you create an instance of car the variable is specific to that particular one.
e.g.
car1 = Car.new('Ford', 'Falcon')
car2 = Car.new('Toyota', 'Camry')

Now car1 and car2 have different instances of @make and @model.
If you declare the variable as a class variable using @@make, then every Car has access to it and every time it is changed, it is changed for everyone.
Basically class variables allow you to put some 'walls' around your data.
The attr_accessor creates two methods in your call
def make=(value)
@make = value
end

def make
@make
end

This allows you to call the instance variable within and from outside your class without the @
e.g.
car1.make

returns
'Ford'

www.codecademy.com has some great free courses in basic Ruby that will teach you this stuff really well.

A: Objects are said to have behaviours and properties, much like real world object.
The properties of objects are defined by instance variables. And @ prefix is
ruby's way of telling particular variable is an instance variable/characteristic.

What value they add ?

They help you to have a variable that is accessible across all your instance methods.
Let us disect your example
   class Car
    attr_accessor :make, :model #attr_accessor methods creates a getter method.    car_instance.make and
                 #a setter method car_instance.make=(val), which otherwise you would have to do explicitly.

    def initialize(make = '')   #constructor
      @make = '' #initializing your instance variables. I guess you meant @make = make here
      @model = ''
    end
   end

I couldn't find anything online for this but maybe I'm searching for the wrong terms.

Yup you were.

Is there a resource online I can look this up?

Yup, Ruby User Guide By Matz
Bit more details
In ruby, the scope of a variable inside a class is identified by the compiler by first two characters of the
   varaible name.

*

*@@variable_name -> Two '@' s. Class variables/ Scope across all instances of the class. Eg: If you want to have a count on total number of cars you made.

*@variable       -> One '@' Instance varaibles/ Scope across an instance.

*variable        -> No  '@' Local variables/ Scope to the block they belong.

A: Look at the below code,which I changed a bit for understanding:
class Car
  attr_accessor :make, :model

  def initialize(make = '')
    @make = make
    @model = ''
  end
end

car1 = Car.new("Toyota")
car2 = Car.new("Roxin")
p car1.instance_variables #<~~ A
p car2.instance_variables #<~~ B
p car1 #<~~C
p car2#<~~D

Output:
[:@make, :@model]
[:@make, :@model]
#<Car:0x1bc89e8 @make="Toyota", @model="">
#<Car:0x1bc8940 @make="Roxin", @model="">

Explanation: Here in A and B you might think of that both car1,car2 are using the same copy of instance variables. But Not is the case. See when I am printing car1 and car2, in C and D,outputs shows that car1 and car2 are holding different values for the instance variable @make. This fact objects has their own unique instance variables.
Hope this helps.
Cheers!!


text:
Q: What's the difference between [[False] * 26] * 26] and [[False] * 26 for _ in range(0, 26)]? What's the difference between [[False] * 26] * 26] and [[False] * 26 for _ in range(0, 26)] in Python ?

A: It's all about aliasing.  It becomes apparent when you modify the inner list.
>>> a = [[False] * 26] * 26
>>> a[0][0] = True
>>> a[1][0]
True
>>> b = [[False] * 26 for _ in range(0, 26)]
>>> b[0][0] = True
>>> b[1][0]
False


text:
Q: About monitoring a server (and a HTTP status of 200) This is probably a very silly question, but I'm new to this. I am currently learning about system administration, and was asked to set basic monitoring in place (that checks a website returns HTTP 200). Here's the setup:

*

*Server one runs a web site and backups daily to server two.

*Server two stores the backups.

So, if I am tasked to "set basic monitoring in place", so that the website on server one returns an HTTP status of 200, where should I place the monitoring software? On server two? I am thinking it must be that way because if server one's site didn't return an OK HTTP status, then that'd mean the monitoring tool would fail as well?
I am planning to use Nagios for this, but I'm very confused and don't even know where to start. Sorry for the dumb question!
Thanks.

A: If your monitoring requirements are simple (just checking one page for a HTTP 200) you could use the free tier of https://www.pingdom.com/ or https://www.statuscake.com/alternative-to-pingdom/
The problem with Server two monitoring Server one, is they are on the same network. If your connection to the outside world goes down your two servers would still be able to talk to one another. A real solution has to be on the same network as your users and if Server one serves the public then the monitor should simulate a user as best it can.

A: The answer here, if possible, is to use a third server specifically for the purpose of monitoring Server One (which can then also be expanded to monitor Server Two). Where it's possible to do so, each server should have a single function - and in doing it this way, your monitoring system's health is not tied to the health of the monitored systems.
If it is not possible to add a third server, for whatever reason, then you would monitor Server One from the outside using Server Two as you correctly state in your question, and for the reason you outlined - if Server One is down, and Server One is also running Nagios, Nagios can't tell you that Server One is down!


text:
Q: Unable to scp to another server I am unable to scp to another machine in the same segment.Its getting stalled. I did a strace on the scp and i am seeing it as below. The other machines in this segment are fine except this server alone? What could possibly go wrong on this server?
open("diff.mov", O_RDONLY|O_NONBLOCK)   = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=5368709120, ...}) = 0
fcntl(4, F_GETFL)                       = 0x8800 (flags O_RDONLY|O_NONBLOCK|O_LARGEFILE)
fcntl(4, F_SETFL, O_RDONLY|O_LARGEFILE) = 0
write(7, "C0644 5368709120 diff.mov\n", 26) = 26
read(8, "\0", 1)                        = 1
fstat(4, {st_mode=S_IFREG|0644, st_size=5368709120, ...}) = 0
clock_gettime(CLOCK_BOOTTIME, {45632, 43976552}) = 0
ioctl(1, TIOCGWINSZ, {ws_row=47, ws_col=190, ws_xpixel=0, ws_ypixel=0}) = 0
getpgrp()                               = 38769
ioctl(1, TIOCGPGRP, [38769])            = 0
clock_gettime(CLOCK_BOOTTIME, {45632, 44308721}) = 0
diff.mov                                                                                0%    0     0.0KB/s   --:-- ETA) = 190
rt_sigaction(SIGALRM, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGALRM, {0x55707452abf0, [], SA_RESTORER|SA_INTERRUPT, 0x7f2d0c3e2280}, NULL, 8) = 0
rt_sigaction(SIGWINCH, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGWINCH, {0x55707452a2f0, [], SA_RESTORER, 0x7f2d0c3e2280}, NULL, 8) = 0
alarm(1)                                = 0
fcntl(7, F_GETFL)                       = 0x1 (flags O_WRONLY)
fcntl(7, F_SETFL, O_WRONLY|O_NONBLOCK)  = 0
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=7, events=POLLOUT}], 1, -1)   = 1 ([{fd=7, revents=POLLOUT}])
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=7, events=POLLOUT}], 1, -1)   = 1 ([{fd=7, revents=POLLOUT}])
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=7, events=POLLOUT}], 1, -1)   = 1 ([{fd=7, revents=POLLOUT}])
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=7, events=POLLOUT}], 1, -1)   = 1 ([{fd=7, revents=POLLOUT}])
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=7, events=POLLOUT}], 1, -1)   = 1 ([{fd=7, revents=POLLOUT}])
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=7, events=POLLOUT}], 1, -1)   = 1 ([{fd=7, revents=POLLOUT}])
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=7, events=POLLOUT}], 1, -1)   = 1 ([{fd=7, revents=POLLOUT}])
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=7, events=POLLOUT}], 1, -1)   = 1 ([{fd=7, revents=POLLOUT}])
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=7, events=POLLOUT}], 1, -1)   = 1 ([{fd=7, revents=POLLOUT}])
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=7, events=POLLOUT}], 1, -1)   = 1 ([{fd=7, revents=POLLOUT}])
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
read(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=7, events=POLLOUT}], 1, -1)   = 1 ([{fd=7, revents=POLLOUT}])
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384) = 16384

A: Not an actual answer, I cannot comment so answering.
Instead of scp to another machine, try scp from another machine
This may help.


text:
Q: How to use Django models in for loop? Query = 'com pu'
Query = Query.split()
busi = ""
for data in Query:
    busi += Business.objects.filter(Keywords__icontains=data)

When I use '+' symbol after busi variable for add all data according to filter that give error

Exception Type:   TypeError
Exception Value:Can't convert 'QuerySet' object to str implicitly

How can I achieve that different Query part which split by that all give different-2 data and and both data in single busi object

A: from django.db.models import Q
Query = Query.split()
query = Q()
for data in Query:
    query |= Q(keyword_name__icontains=data)
Business= Business.objects.filter(query)

A: Instead use &:
busi = None

q = Business.objects.filter(Keywords__icontains=data)

if busi is None:
    busi = q
else:
    busi = busi & q


text:
Q: Closing threads methods What is the difference between
ExitThread(exitcode);

and
CloseHandle(threadHandle);

?
It seems that they do the same thing, but they must have a difference.

A: These functions do very different things. ExitThread immediately ends the calling thread. CloseHandle just destroys a handle, thus removing a reference to a thread object. It has no affect on the thread which handle is closed; the thread will continue its normal execution. Typically, a thread handle is closed after the thread has finished (e.g. after waiting for its completion with WaitForSingleObject). But sometimes, a handle is closed for the thread that is still running; it's often referred as detaching a thread. This needs to be done if the application "forgets" the thread and will not wait for its completion; handles to such a thread should be closed to let the kernel automatically destroy associated resources when the thread completes.
Also see answers to a similar question: Windows C++ - closing thread with CloseHandle


text:
Q: Haskell - How to print some value in a function for debugging purpose? I'm a Haskell newbie and I want to do something which has a side effect like this:
i = 3.0

main :: IO ()
main = let m = print i in putStrLn "Hello world"

Then I can know the value of i when main runs, but the I didn't print. I add ! before m but it also doesn't work. I would like to know how to hack this, thanks in advance!

A: For debugging, use trace  and friends.
import Debug.Trace
i = 3.0

main :: IO ()
main = traceShow i $ putStrLn "Hello world"

See it live
Note the trace appears on the standard error stream, as debugging output should.
The function you use trace in doesn't have to be IO-typed. This for example will also work:
add a b = a + traceShow i b

Trace functions are a bit foreign to Haskell because they are technically impure. However the side effects are limited in scope and not observable by the program itself, so it's kinda OK.
More info

A: You created m but never used it. To fix that you can try:
i = 3.0

main :: IO ()
main = let m = print i in m >> putStrLn "Hello world"

A: In an IO action, you can just use putStrLn or print as usual, like
do
  print i
  putStrLn "Hello world"

Which desugars to print i >> putStrLn "…". This is equivalent, but not really any better because the action m doesn't really need to be named:
let m = print i  -- define an action
in do
  m  -- ensure the action is actually executed
  putStrLn "Hello world"

In a pure function, you can use trace or traceShow from Debug.Trace:
traceShow i (putStrLn "Hello world")

But be aware that these print when the expression is forced, which may be in a different order than you may expect due to lazy evaluation, or not at all if a value is never used. You can add strictness annotations with seq or BangPatterns as you tried for the monadic code to assist with making sure that things are forced when you expect—the reason !m = … didn't work for your IO action is that the strictness annotation only makes the expression evaluated, producing an IO action but not executing it because it's not sequenced with another action as part of main. Remember: you can only (purely) construct IO actions and bind them together; the runtime is what actually executes them.
Finally, in a "pure" monad where you don't have IO available, you can still use trace &c., for example in the list monad:
numbers :: [Int]
numbers = do
  x <- [1, 2, 3]
  traceShow x (pure ())
  y <- [4, 5, 6]
  traceShow y (pure ())
  pure (x * y)


text:
Q: how to Use Filter operator in foreach in pig latin I am trying to use FILTER operator within foreach to filter some of my data, but it is throwing an error. I am using the below query:
ctm_pm_v1_stg = LOAD '/datalake/uhc/ei/pi_ara/hive/warehouse/ctm_pm.db/ctm_pm_t1' USING PigStorage ('\u0001') AS (lob:chararray,day_phnno:chararray,eve_phnno:chararray,mbr_name:chararray,hic_no:chararray,contract_no:chararray,ctm_risk_category:chararray);
ctm_pm_v1 = FOREACH ctm_pm_v1_stg {
fdata = FILTER ctm_pm_v1_stg by ctm_risk_category=='High';
GENERATE ctm_risk_category;
};

if anyone have some idea on this please help me.
Thanks in advance.

A: Nested FOREACH will work only with bags but your relation(ctm_pm_v1_stg) doesn't have any bags. To fix this issue just remove the nested part and use only FILTER stmt.
ctm_pm_v1_stg = LOAD '/datalake/uhc/ei/pi_ara/hive/warehouse/ctm_pm.db/ctm_pm_t1' USING PigStorage ('\u0001') AS (lob:chararray,day_phnno:chararray,eve_phnno:chararray,mbr_name:chararray,hic_no:chararray,contract_no:chararray,ctm_risk_category:chararray);
fdata = FILTER ctm_pm_v1_stg by (ctm_risk_category=='High');
DUMP fdata;


text:
Q: What's wrong here? Ittirating through HTMLCollection and changing class name I'm trying to make certain options show in a drop menu according to what radio button the user has clicked. The problem is I'm only able to change the class name to the even indexes (0,2,4,...) of the HTMLCollection.
The result is that only the even indexes show in the drop menu.
Of course this also happens when trying to hide the other options but I'll only share here the show loop because I guess the problem is the same.
HTML:
<select class="custom-select mr-sm-2" id="inlineFormCustomSelectType" disabled>
 <option selected>Type</option>
 <option class="tea-options-hidden" value="tea1">tea1</option>
 <option class="tea-options-hidden" value="tea2">tea2</option>
 <option class="tea-options-hidden" value="tea3">tea3</option>
 <option class="tea-options-hidden" value="tea4">tea4</option>
 <option class="tea-options-hidden" value="tea5">tea5</option>
</select>

JavaScript:
var teaRadio = document.getElementById("tea-radio");
teaRadio.onclick = function() {
    document.getElementById("inlineFormCustomSelectType").removeAttribute("disabled");
    var elements = document.getElementsByClassName('tea-options-hidden');
    console.log(elements.length);
    for (var i = 0; i < elements.length; i++) {
        console.log(i)
        console.log(elements[i]);
        elements[i].className = 'tea-options-shown';
        console.log(elements[i]);
    }
}

CSS:
.tea-options-hidden {
display: none;
}

.tea-options-shown {
}

I tried to debug this with console logs and this is what I got (same consoloe.log() as in the code snippet:

What's going on here? It seems to me like there is a problem with actions happening to fast.
Thanks for your answers.


text:
Q: function to go to website if button is ON I am trying to implement a simple ON/OFF button.
i just want to go to a link (in the background if possible) when the button is ON , and a different link when it is OFF
pls help me in javascript too as im a beginner in it.

<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch2" onclick="javascript:location.href='www.google.com" >
<label class="onoffswitch-label" for="myonoffswitch2">

A: <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch2" onclick="javascript:location.href='https://www.google.com';" >

//this code for button is on but what do you mean by off when your button is on then your page is redirect

A: You can add an onchange listener and direct the user based on the checked status of the check box.

$(document).ready(function(){
  $('#myonoffswitch2').change(function(){
    if(this.checked){
      window.location="url to site 1";
    }
    else{
      window.location="url to site 2";
    }
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch2">
<label class="onoffswitch-label" for="myonoffswitch2">Check</label>


text:
Q: Angular 13 error with variables of the same type Good evening everyone,
while developing an application with Angular 13 I encountered an error that puzzles me:
Type 'Geolocation' is missing the following properties from type 'Geolocation': ip, location, domains, as, and 2 more.

the application is an ip address tracker and it is a task found on FE mentor website.
practically in the header component I take the ip that the user types and execute the call to the api res geo.ipfy and the result I leave it to a subject of type Geolocation that I created in my Service then in the tracker-info component I subscribe and I assign the result to a variable of type Geolocation I leave you the code of the single components below for a better understanding:
geolocation.model.ts
export interface Location {
  country: string;
  region: string;
  city: string;
  lat: number;
  lng: number;
  postalCode: string;
  timezone: string;
  geonameId: number;
}

export interface As {
  asn: number;
  name: string;
  route: string;
  domain: string;
  type: string;
}

export interface Proxy {
  proxy: boolean;
  vpn: boolean;
  tor: boolean;
}

export interface Geolocation {
  ip: string;
  location: Location;
  domains: string[];
  as: As;
  isp: string;
  proxy: Proxy;
}

header.component.ts
import { Component, OnInit } from '@angular/core';
import { Subject, takeUntil } from 'rxjs';
import { TrackerService } from '../tracker.service';

@Component({
  selector: 'maury-header',
  templateUrl: './header.component.html',
  styleUrls: ['./header.component.scss'],
})
export class HeaderComponent implements OnInit {
  destory$: Subject<any>;
  constructor(private trackerService: TrackerService) {
    this.destory$ = new Subject<any>();
  }

  ngOnInit(): void {}

  onSubmit(value: string) {
    this.trackerService
      .GetInfoTrackerIp(value)
      .pipe(takeUntil(this.destory$))
      .subscribe((resp) => {
        this.trackerService.trackerInformation$.next(resp);
      });
  }
}

tracker.service.ts
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable, Subject } from 'rxjs';

@Injectable({ providedIn: 'root' })
export class TrackerService {
  header: HttpHeaders = new HttpHeaders({
    'Content-Type': 'application/json',
  });
  trackerInformation$: Subject<Geolocation>;
  constructor(private http: HttpClient) {
    this.trackerInformation$ = new Subject<Geolocation>();
  }

  GetInfoTrackerIp(ip: string): Observable<Geolocation> {
    let params = new HttpParams();
    params = params.append('apiKey', 'My_api_key');
    params = params.append('ipAddress', ip);
    return this.http.get<Geolocation>(
      'https://geo.ipify.org/api/v2/country,city,vpn',
      { params }
    );
  }
}

info-tracker.component.ts
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Subject, takeUntil } from 'rxjs';
import { Geolocation } from '../models/geolocation.model';
import { TrackerService } from '../tracker.service';

@Component({
  selector: 'maury-info-tracker',
  templateUrl: './info-tracker.component.html',
  styleUrls: ['./info-tracker.component.scss'],
})
export class InfoTrackerComponent implements OnInit, OnDestroy {
  infoTracker: Geolocation;
  destroy$: Subject<any>;

  constructor(private trackerService: TrackerService) {
    this.destroy$ = new Subject<any>();
  }

  ngOnDestroy(): void {
    this.destroy$.unsubscribe();
  }

  ngOnInit(): void {
    this.GetInfoTracker();
  }

  GetInfoTracker() {
    this.trackerService.trackerInformation$
      .pipe(takeUntil(this.destroy$))
      .subscribe((resp) => {
        this.infoTracker = resp; <---- this generates the error
      });
  }
}

for completeness I also leave you my tsconfig.json:
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "forceConsistentCasingInFileNames": true,
    "strict": false,
    "noImplicitOverride": true,
    "noPropertyAccessFromIndexSignature": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "es2017",
    "module": "es2020",
    "lib": [
      "es2020",
      "dom"
    ]
  },
  "angularCompilerOptions": {
    "enableI18nLegacyMessageIdFormat": false,
    "strictInjectionParameters": true,
    "strictInputAccessModifiers": true,
    "strictTemplates": true
  }
}

A: Resolved! I didn't import the model into service.ts thanks @akotech


text:
Q: Ajax call api time Hi I'm tring to use an api to get time and data but in log appear always error 403 forbidden. Api:https://www.mashape.com/parsify/format#!endpoint-Phone-Number.
Is there an ajax call error?
$.ajax({
type: 'GET',

headers: {"X-Mashape-Authorization": "SEK2****7Egqx******hshVCG"},

async:false,
//dataType: "jsonp",
url: 'https://parsify-format.p.mashape.com/api/format/time?value=1362446014869&lang=it',
success: function(data) {
    console.log(data);
 time_now=data;
},
error: function(data) {
  console.log("ko" );
}

});

A: A 403 is most likely caused by either the site not getting correct authorization, or cross domain ajax.
If you're testing locally, cross domain ajax is blocked in some browsers, most notably chrome.


text:
Q: 2010 Workflow Designed in Sharepoint Designer 2013 Fails on Start Using Designer 2013 I created a 2010 WF (d/t having certain capabilities that a 2013 WF does not) and deployed it.
It is set to start manually. I went to the list added a new item and started the WF.
However, I get the error below:

I am not using a System Account so that's not the issue.Can anyone assist in what's causing the issue?


text:
Q: SQL Max Group By Query Help I have a quick question. How do I select the two values I need in one query? Currently I'm doing this, which works fine, but it's obviously running two queries when one should do the trick. I tried MAX(columnA) and GROUP BY ColumnB, but that returns multiple row. I only want one row returned.
DECLARE @biID  bigint
, @dtThreshold      DateTime

  SELECT @biID = MAX(biID)
FROM tbPricingCalculationCount WITH (NOLOCK)

  SELECT @dtThreshold = dtDateTime
FROM tbPricingCalculationCount WITH (NOLOCK)
WHERE biID = @biID

I would like both those variables to be set correctly in one query. How can I do that?
Thanks,
~ck

A: can you not just do this?
SELECT TOP 1 @biID = biID, @dtThreshold = dtDateTime
  FROM tbPricingCalculationCount WITH (NOLOCK)
ORDER BY biID DESC;

A: How about
SELECT TOP 1 @biID = biID, @dtThreshold = dtDateTime
FROM tbPricingCalculationCount (NOLOCK)
ORDER BY biID desc

A: This returns dtDateTime for the row with the largest biID:
SELECT t1.dtDateTime
FROM tbPricingCalculationCount t1
LEFT JOIN tbPricingCalculationCount t2
ON t2.biID > t1.biID
WHERE t2.biID IS NULL

If more than one row shares the same "largest" biID, then you need to limit the results to one using TOP:
SELECT TOP 1 t1.dtDateTime
FROM tbPricingCalculationCount t1
LEFT JOIN tbPricingCalculationCount t2
ON t2.biID > t1.biID
WHERE t2.biID IS NULL

A: How about:
DECLARE
  @biID bigint,
  @dtThreshold DateTime

SELECT
  @dtThreshold = A.dtDateTime,
  @biID = B.biID
FROM tbPricingCalculationCount A
  INNER JOIN (SELECT MAX(biID) biID
              FROM tbPricingCalculationCount) B
    ON A.biID = B.biID

If you're not using the biID elsewhere, you can even trim it to:
DECLARE
  @dtThreshold DateTime

SELECT
  @dtThreshold = A.dtDateTime
FROM tbPricingCalculationCount A
  INNER JOIN (SELECT MAX(biID) biID
              FROM tbPricingCalculationCount) B
    ON A.biID = B.biID


text:
Q: Strip escape sequences for invalid XML characters According to the XML spec, only the following charcters are legal:
Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] /* any Unicode character, excluding the surrogate blocks, FFFE, and FFFF. */

I have a string named foo containing the JSON representation of an object. Some strings of the JSON object contain escape sequences for characters that are illegal in XML, e.g. \u0002 and \u000b.
I want to strip those escape sequences from foo before throwing it to a JSON to XML converter, because the converter is a black box that provides no ability to handle those invalid characters.
Example for what I would like to do:
MAGIC_REGEX = "<here's what needs to be found>"  # TODO

String foo = "\\u0002bar b\\u000baz qu\\u000fx"
String clean_foo = foo.replace(MAGIC_REGEX, "�")  # � Unicode replacement character

System.out.println(clean_foo)  # Output is "bar baz qux"

How can I achieve that? Bonus points for solutions that use a regex instead of parsing the string and comparing Unicode codepoints.
I am aware of this SO question. However, my problem here are the escape sequences of the illegal characters, not the real characters themselves.

A: I finally came up with this regex, which matches almost all illegal characters according to the XML spec, except the ones above #x10000 (#x11000 and onwards):
# case-sensitive version
\\\\u(00(0[^9ADad]|1[0-9A-Fa-f])|D[8-9A-Fa-f][0-9A-Fa-f]{2}|[Ff]{3}[EFef])

# case-insensitive version
\\\\u(00(0[^9ad]|1[0-9a-f])|D[8-9a-f][0-9a-f]{2}|fff[ef])