text:
Q: C++ Pass a argument through a class with array index/ is there anyway I can pass a argument through a class like below for example.
class cat
{public:
  void dog(int ID, char *value) // int ID I'd like to be the index array it was called from?
  {
    debug(ID, value);
  }
}

cat cats[18];

cats[1].dog("value second arg, first arg auto filled from index array");

A: You can use static variable and increment it in constructor, to keep the track of all intances:
#include<iostream>

class cat
{
    int ID;
    static int IDTracker;
public:
    cat();
    void dog(char* value);
};

int cat::IDTracker = 0;
cat::cat()
{
    this->ID = cat::IDTracker;
    cat::IDTracker++;
}
void cat::dog(char *value)
{
    std::cout << value << this->ID;
}

int main()
{
    cat cats[18];
    cats[1].dog("Second instance, with index value: ");
    cats[2].dog("Third instance, with index vlaue: ");

    return 0;
}

A: I tested this out and it worked well:
#include <vector>

// Forward declaration of the class
class CatArray;

class Cat {
    // This line means that the CatArray class can
    // access the private members of this class.
    friend class CatArray;

    private:
        static int ID;

    public:
        void dog(const char* value) {
            // Use ID here any way you want.
        }
};

// Static variables need to be defined.
int Cat::ID = 0;

class CatArray {
    private:
        std::vector<Cat> cats;

    public:
        // explicit means that the argument passed to this constructor must
        // be an unsigned int. The ": cats(size)" part is an initializer
        // list that initializes the cats vector so that it would have the
        // specified size.
        explicit CatArray(unsigned int size) : cats(size) {}

        Cat& operator [](unsigned int index) {
            Cat::ID = index;
            return cats[index];
        }
};

Now use it like this:
CatArray cats(18);

cats[1].dog("oh lol hi");

This method works for any number of arrays you'd wish to declare.

A: I am not entirely sure this will work but some variant of it might...
#include <stdio.h>
#include <stdlib.h>

void *foo;

class cat
{
  public:

  void dog(char *value) // int ID I'd like to be the index array it was called from?
  {
    int ID = (this - ((cat *)foo))/(sizeof(cat));
    printf("%d - %s",ID, value);
  }

};

int main ( void )
{
   cat cats[18];
   foo = &(cats);
   cats[1].dog("Fido");
}


text:
Q: Time that appium takes to run a test I'm new to Appium and I would like to know about the time that it takes to run a test.
This is my scenario:

*

*Real device;

*My test case: Steps to answer 16 questions (changing the question by clicking on a button) and checking the results.

It is taking about 160 seconds to run each test. Is this a normal execution time?
I think that it could be minimized if I use "noReset" = true and "fullReset" = false. Am I wrong?
My code:
public class AndroidSetup {

AndroidDriver driver;

public void setConfig() throws MalformedURLException, InterruptedException{

    File appPath = new File("C:\\app\\p");
    File appFile = new File(appPath, "App_1.0.apk");

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("deviceName","0424618914");
    capabilities.setCapability("platformName","Android");

    capabilities.setCapability("noReset", "true");
    capabilities.setCapability("fullReset", "False");*/

    capabilities.setCapability(MobileCapabilityType.APP, appFile.getAbsolutePath());

    driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

}

public class TestCases extends AndroidSetup {

    String app_package_name = "br.name.name_:id/";
    String start_button_id = "btnStart";
    String next_button_id = "btnNext";
    String value_1_id = "radioButton1";
    String value_2_id = "radioButton2";
    String value_3_id = "radioButton3";
    String value_4_id = "radioButton4";
    String value_5_id = "radioButton5";
    String value_6_id = "radioButton6";
    String value_7_id = "radioButton7";
    String value_na_id = "radioButton8";
    String overall_value = "overwall";
    String sys_qual_value = "sysQual";
    String info_qual_value = "infoQual";
    String int_qual_value = "intQual";

@Before
public void setup() throws Exception{

    setConfig();

}

@After
public void tearDown() throws Exception{
    driver.quit();
}

@Test
public void Scenario001() throws Exception{

    driver.findElement(By.id(app_package_name + start_button_id)).click();
    driver.findElement(By.id(app_package_name + value_1_id)).click();
    driver.findElement(By.id(app_package_name + next_button_id)).click();
    driver.findElement(By.id(app_package_name + value_1_id)).click();
    driver.findElement(By.id(app_package_name + next_button_id)).click();
    driver.findElement(By.id(app_package_name + value_1_id)).click();
    driver.findElement(By.id(app_package_name + next_button_id)).click();
    driver.findElement(By.id(app_package_name + value_1_id)).click();
    driver.findElement(By.id(app_package_name + next_button_id)).click();
    driver.findElement(By.id(app_package_name + value_1_id)).click();
    driver.findElement(By.id(app_package_name + next_button_id)).click();
    driver.findElement(By.id(app_package_name + value_1_id)).click();
    driver.findElement(By.id(app_package_name + next_button_id)).click();
    driver.findElement(By.id(app_package_name + value_1_id)).click();
    driver.findElement(By.id(app_package_name + next_button_id)).click();
    driver.findElement(By.id(app_package_name + value_1_id)).click();
    driver.findElement(By.id(app_package_name + next_button_id)).click();
    driver.findElement(By.id(app_package_name + value_1_id)).click();
    driver.findElement(By.id(app_package_name + next_button_id)).click();
    driver.findElement(By.id(app_package_name + value_1_id)).click();
    driver.findElement(By.id(app_package_name + next_button_id)).click();
    driver.findElement(By.id(app_package_name + value_1_id)).click();
    driver.findElement(By.id(app_package_name + next_button_id)).click();
    driver.findElement(By.id(app_package_name + value_1_id)).click();
    driver.findElement(By.id(app_package_name + next_button_id)).click();
    driver.findElement(By.id(app_package_name + value_1_id)).click();
    driver.findElement(By.id(app_package_name + next_button_id)).click();
    driver.findElement(By.id(app_package_name + value_1_id)).click();
    driver.findElement(By.id(app_package_name + next_button_id)).click();
    driver.findElement(By.id(app_package_name + value_1_id)).click();
    driver.findElement(By.id(app_package_name + next_button_id)).click();
    driver.findElement(By.id(app_package_name + value_1_id)).click();
    driver.findElement(By.id(app_package_name + next_button_id)).click();

    assertEquals("1,00", driver.findElement(By.id(app_package_name + sys_qual_value)).getText());

}

redpajama_set_name: RedPajamaStackExchange


text:
Q: Raising/Setting WIN32 event I created a small Windows application that creates an event and waits for it to be triggered, using the CreateEvent() and WaitForSingleObject() Win32 APIs.
I also created another application that is used to trigger the event that was created by the previously mentioned application, using the SetEvent() API.
They work well with each other, but I am looking to simplify how the triggering is done. Is there a way via command prompt or PowerShell to trigger an event that was created by a Win32 C++ application? I want to remove the need for maintaining an additional application.
I've tried looking at what PowerShell provides, but have not had much luck yet.

A:
Is there a way via command prompt or PowerShell to trigger an event that was created by a Win32 C++ application?

PowerShell scripts have access to .NET classes, so you can use the EventWaitHandle class to open and trigger the C++ app's event.
$SetEventName = 'MyEvent'

function Signal-SetEvent {
    $SetEventObject = [System.Threading.EventWaitHandle]::OpenExisting( $SetEventName )
    $SetEventObject.Set()
}


text:
Q: Getting variable value from the REST response code(SoapUI) This is the response(as XML) I get from TestCase1 when I run my REST request:
<data contentType="text/plain" contentLength="88">
    <![CDATA[{"message":"success","data":{"export_id":"064c1948fe238d892fcda0f87e361400_1467676599"}}]]>
</data>

I want to use the value of export_id(dynamic) which is 064c1948fe238d892fcda0f87e361400_1467676599 in the Test Case 2.
How Can I achieve this? I tried using property transfer but I am not sure how to configure.

A: The response you have is complex, not just an xml to extract the required value using property transfer. Because, it contains cdata and it internally again contains json and you need the value which is inside the of it.
So, in order to get that value, need to use Groovy Script test step instead of Property Transfer test step. Having said that, you remove the Property Transfer and have Groovy Script step in the same place.
And the contents of the Groovy Script goes here:

/**
* This script reads a response xml string, extracts cdata at the specified xpath
* Then parse that string as Json and extract the required value
**/
import com.eviware.soapui.support.XmlHolder
import net.sf.json.groovy.JsonSlurper
//For testing using fixed value as you mentioned in the question
//However, you can use the dynamic response as well which is coming from the
//previous step as well if you want
def soapResponse = '''
<data contentType="text/plain" contentLength="88"><![CDATA[{
           "message":"success",
           "data":
           {
               "export_id":"064c1948fe238d892fcda0f87e361400_1467676599"
           }
      }]]>
</data>'''
def holder = new XmlHolder(soapResponse)
//Extract the data inside of CDATA section from the response
def data = holder.getNodeValue('//*:data')
//Parse the string with JsonSlurper
def json = new JsonSlurper().parseText(data)
log.info json
//Extract the export_id
def exportId =  json.data."export_id"
log.info "Export id : ${exportId}"
//Since you wanted to use the extracted value in another test case,
//Saving the value at test suite level custom property EXPORT_ID
//So that it can be used in any of the test case once the value is set
context.testCase.testSuite.setPropertyValue('EXPORT_ID', exportId)

How to use the export_id value in other test cases?

*

*If you want to use the value in a (REST / SOAP) Test Request test step, then you can simple use it using property expansion i.e., ${#TestSuite#EXPORT_ID}.

*If you want to use the value in a Groovy Script test step, then you need get the value using log.info context.expand('${#TestSuite#EXPORT_ID}')
How to use dynamic response in the Groovy Script?
As mentioned in the in-line comments in the script above, I have shown how to get the required value using your sample data.
But it may be difficult for you to each time replace the value for variable soapRespone in the script or you may also want to automate the stuff as well.
In such cases, you just need to replace def soapResponse statement with below code :

//Replace the previous step request test step name in place of "Test Request"
//Where you get the response which needs to be proceed in the groovy script
def soapResponse = context.expand('${Test Request#Response}')


text:
Q: How do I create a project in WebStorm for Node.js? I have created a project in WebStorm by watching a tutorial Node.js + Express - Tutorial - Insert and Get Data with MongoDB (check from 1:49 to 1:53 (I get error when I run www.js))
when i run localhost:8000, im able to insert the data,but i am not able to get the data,i get the below error

GET / 200 44.467 ms - 1968 GET /stylesheets/style.css 200 27.109 ms -
  962 GET /favicon.ico 404 6.245 ms - 199 POST /insert 302 245.066 ms -
  46 GET / 304 5.643 ms - - GET /stylesheets/style.css 304 1.362 ms - -
  C:\Users\ptech-user\WebstormProjects\aishuuu\node_modules\mongodb\lib\mongo_client.js:421
            throw err
            ^
AssertionError [ERR_ASSERTION]: null == 'MongoError: failed to connect
  to server [localhost:27017] on first connect [MongoError: connect
  ECONNREFUSED 127.0.0.1:27017]'
      at C:\Users\ptech-user\WebstormProjects\aishuuu\routes\index.js:37:12
      at connectCallback (C:\Users\ptech-user\WebstormProjects\aishuuu\node_modules\mongodb\lib\mongo_client.js:515:5)
      at C:\Users\ptech-user\WebstormProjects\aishuuu\node_modules\mongodb\lib\mongo_client.js:418:11
      at _combinedTickCallback (internal/process/next_tick.js:131:7)
      at process._tickCallback (internal/process/next_tick.js:180:9)

GitHub link for source code
How to solve this?
im not able to get the data

A: You do not have and 'http://' module instead of this you have 'http'.
Edit the require statement in the following way
Incorrect
var http=require('http://');

Correct
var http=require('http');

For a better understanding of what you do take a more in-depth tutorial about Node.Js and how it works.
Resource:
https://www.guru99.com/node-js-tutorial.html


text:
Q: fit an image inside a div without cutting it I have a problem with images and their container div element. My images are smaller than the container div and when I try to fit them the images are cut in the lower part. How can I fix this?
I browsed the web and find a lot of solution but I wasn't able to apply them to my work. Can you help me?
here is my code:
css:
#box_foto_1{
    clear: both;
    float: left;
    width: 400px;
    height: 262px;
    border: 1px solid;
    margin-left: 100px;
    margin-top: 20px;
    overflow: hidden;
}

#box_foto_1 img{
    height: auto;
    width: 100%;
}

here the html/php:
$html .= "
";
$html .= "";
$html .= "
 ";

the html/php code is part of a php function to create the page.

A: I'm replying from mobile phone so I cannot give you specific code but, if I got tight your question, the best way is to handle your image size by php.
You can do like this:
1) Remove #box_foto_1 img  from your css
2) Add some if/else to your PHP
    $html .= '
$img_w) {
         $html .= '';

    } else {
     $html .= '';
    }

    $html .= '
';

Search how to get image dimensions with php...  can't help you with this now ... because i'm on phone.
You can find here how to get your image size:
http://php.net/manual/ro/function.getimagesize.php

Update: I added the getimagesize function.

A: IF you want the image to fit the box and display the whole image:
All you need to do is remove your #box_foto_1 height height:262px value or set this as a min-height or max-height whichever is appropriate for you.
IF you want the image contained within the fixed size of the box:
Remove the max-/min- values (in my now deleted previous answer) in the CSS for the size of the box and then set the width and height to auto values on the #box_foto_1 img. As so:
   #box_foto_1 {
        /* added or changed rules */
        display:block;
    }
    #box_foto_1{
        clear: both; /* Clear before float is probably useless */
        float: left;
        width: 400px;
        height: 262px;
        border: 1px solid;
        margin-left: 100px;
        margin-top: 20px;
        overflow: hidden;
    }

    #box_foto_1 img{
        height: 100%;
        width: 100%;
    }

Setting both values to 100% will stretch the image, you need to set one as auto such as height:auto; which will cause width overflow.
https://jsfiddle.net/bvkurufq/3/

The best way of solving this in general is to set the image value as a CSS background image and then you are free for a lot more CSS manipulation of it. You can do this by defining the image inline with a style section at the top of your  filled with the database SRC references.
Example:
PHP/ HTML output:
<?php
/*within the PHP image loop */
{

<?php
}
?>

CSS:
#box_foto_1{
    min-width: 400px;
    min-height: 262px;
    float: left;
    border: 1px solid;
    margin-left: 100px;
    margin-top: 20px;
    overflow: hidden;
}

.imageClass {
        display:block;
        min-width: 400px;
        min-height: 262px;
        background-repeat: no-repeat;
        background-position: center;
        background-size: contain;
    }
See https://jsfiddle.net/bvkurufq/33/

A: I just tried this in the fiddle provided by Martin, so you may try something like this to contain your image inside the div without cropping or distorting the proportion:
Just add this to your image class:
#box_foto_1 img{
        max-width: 100%;
        object-fit: contain;
        height: 100%;
        }

If you want to fit the image exactly the size of your div than in that case you need to specify the same dimensions as your block to the image but this will distort the proportion.
or replace object-fit:contain with object-fit:fill.


text:
Q: Total Memory capped far below available memory We are testing out a new install of SQL Server 2012 on a virtual server and the memory allocated to SQL Server seems to be capped around 16 GB even though much more is available. What could cause this?
I've tried bumping up the SQL minimum server memory setting, but the change had no effect. I've listed some of the server details below.
SQL Server 2012 Enterprise
Windows Server 2008 R2 Enterprise x64
29.93 GHz (8 processors)
77 GB RAM
Min Server Memory: 48 GB
Max Server Memory: 56 GB
Database size: 44 GB

PerfMon info:
Working Set: ~17 GB
Page life expectency: ~7,500
Target Server Memory: ~73 GB
Total Server Memory: ~15.7 GB

A: SQL Server is not guaranteed to allocate the min server memory. If the load on the server never needs the minimum SQL Server will work with less - BOL http://msdn.microsoft.com/en-us/library/ms178067.aspx
As long as your configurations allow for the use of all memory you have allocated (they do), SQL Server will use what it needs, and generally no more. Since you are running a VM I would make sure you allocate 10% for the OS, remove the minimum as it can cause performance problems and let it run. If your CPU is pegged at 100%, queries are slow, and SQL Server is not allocating all of its available memory then it would be time to further troubleshoot.

A: One additional thing to check as you are using a VM: Make sure the Hypervisor (e.g. VMware ESX) allows the VM to actually take that amount of memory from the host.
Usually this is not the case per default and stuff like "memory ballooning" comes into place to prevent the virtual OS from using all the VMs memory for its own buffer cache.
While this is usually ok for application servers, it can really hurt on virtual database servers as they think they can allocate a lot of memory more than the hypervisor will actually allow ...


text:
Q: ember.js: transitioning to the same route creates a stack overflow issue this is my route:
photo: Ember.Route.extend({
      route: '/photo/:photo_id',
      showPhoto: Ember.Route.transitionTo('root.photo'),
      connectOutlets: function(router, photo) {
        console.log("TEST");
        router.get('applicationController').connectOutlet('photo', photo);
      },
    })

Within my PhotoView, I have a few places, where i have to show "related photos", whose thumbnails should also be clickable, so I have this
<a {{action showPhoto this href=true}}> ...photo... </a>

However, if I click on the links afterwards, I get a stack overflow error. How do I resolve this? I really need to route to the same view, but with new data

A: Replace
action showPhoto this href=true with
action showPhoto photo href=true
without jsfiddle it is hard to check my answer.


text:
Q: How to select the file which is already opened using OpenFileDialog I am trying to select the file which is already opened in quickbook software.
code :
 OpenFileDialog ofdBrowseVInv = new OpenFileDialog();

            ofdBrowseVInv.Title = "Locate QuickBook Company File";
            ofdBrowseVInv.Filter = "QuickBook Company File (*.qbw,*.qbw)|*.qbw;*.qbm";
            ofdBrowseVInv.FileName = "";

           if (ofdBrowseVInv.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string strfilename = ofdBrowseVInv.InitialDirectory + ofdBrowseVInv.FileName;

            }

After selecting the file .. i am getting message : File in use
can any one tell me how can i select the file which is already opened...

A: The following code seems to help:
ofdBrowseVInv.ValidateNames = false;

see more here http://social.msdn.microsoft.com/Forums/vstudio/en-US/56fbbf9b-31d5-4e89-be85-83d9cb1d538c/openfiledialog-this-file-is-in-use?forum=netfxbcl

A: This code worked for me perfectly.
ofdBrowseVInv.ValidateNames = false;


text:
Q: OpenCV in Python - resize without anti-aliasing I have a 512x160 pixel black and white image that I want to upscale (to 4096x1280) using OpenCV. It is very important that pixels that were negative (white) remain negative. cv2.resize appears to anti-alias the image by default, thereby creating falsely-positive pixels. Is there a way to disable the anti-aliasing?
Edit: From what I can see here are the interpolation methods:

*

*INTER_NEAREST - nearest neighbor interpolation

*INTER_LINEAR - bilinear interpolation

*INTER_CUBIC - bicubic interpolation

*INTER_AREA - resampling using pixel area relation. It may be a
preferred method for image decimation, as it gives moire'-free
results. But when the image is zoomed, it is similar to the INTER_NEAREST method.

*INTER_LANCZOS4 - Lanczos interpolation over 8x8 neighborhood.

*INTER_MAX - mask for interpolation codes.

*WARP_FILL_OUTLIERS - flag, fills all of the destination image pixels.
If some of them correspond to outliers in the source image, they are
set to zero.

*WARP_INVERSE_MAP - flag, inverse transformation.

A: Interpolation decides how to do the antialiasing, its sort of the reverse because in this case the image doesn't have enough resolution to display its original resolution.
In python the solution would be to use cv2.INTER_NEAREST:

scale_ratio = 0.5
img_resized = cv2.resize(img, None, fx=scale_ratio, fy=scale_ratio, interpolation=cv2.INTER_NEAREST)


text:
Q: Possible to scroll inside a div while body overflow hidden? I have body overflow set to hidden, but I want to be able to scroll inside a div if it exceeds viewport height, is that posible? With the following, a scrollbar appears but it is not scrollable.

body {
  background: black;
  height: 3000px;
  overflow: hidden !important;
}

.green {
  background: green;
  width: 100%;
  height: 1500px;
  overflow-y: scroll;
}

fiddle: https://jsfiddle.net/q5a43c63/

A: You should set a max height to the div, and of course put elements within this div:

body {
  background: black;
/*   height: 3000px; */
  overflow: hidden;
}

.green {
  background: lightgrey;
  width: 100%;
  height: 1500px;
  overflow-y: auto;
  max-height: 1500px;
  display: block;
}

  Where does it come from?
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
Where does it come from?
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
Where does it come from?
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
Where does it come from?
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
Where does it come from?
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
Where does it come from?
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
Where does it come from?
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
Where does it come from?
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.

A: you can't see scroll bar because div content is empty i hope you should write some content in .green class div content for example below

     test

    test

    test

    test

    test

    test

    test

    test

    test

    test

you can get help from this link
Div vertical scrollbar show

A: It depends on what you want to achieve, but an easy fix to your problem is to change your code to this:
body {
  background: black;
  height: 3000px;
  overflow-x: hidden !important;
}

If your content is hidden by a parent container in the y-direction, then the content in the child container cannot be scrolled in that same direction.
Edit: You need to add a wrapping container to the green area if you want the green to be scrollable, but not the body. Check the updated fiddle.
https://jsfiddle.net/q5a43c63/1/


text:
Q: How to implement a complex NSDocument-based app that imports and exports non-native file types? I'm working on an app that supports a very complicated set of operations. It's akin to something like Xcode, in that the main document is represented by something like a project window, with numerous entries in it. The document on disk is a bundle (meaning a directory with a file & folder structure underneath).
There is at least one file type that it can import and export (.mfst), but it's not intended to directly edit this file type. That is, opening this file type results in a native document type being created, and the contents of the file being imported into it. The on-disk file is a bundle  (.mproj) with numerous files contained within it.
Technically, that file is copied verbatim into the proper location inside the native document bundle. Any changes to the data contained in that file are saved into the copy in the bundle, not the copy that was imported.
That file type can be exported, too.
Question 1: Is this app a Viewer of the imported type, or an Editor? I think it's the former.
Question 2: This question on supporting imported types shows how to implement import via the NSDocument subclass, but it seems that perhaps subclassing NSDocumentController is a good way to go.
One reason for this is that if the user has already imported a .mfst file, I want to catch that fact. There are other files that might be related to an open document, and should import into that document rather than creating a new one.
Question 3: Unfortunately, some of the code to operate on the project requires that certain files exist on disk. This means that even when a new document is created in response to opening the importable file type, I need to go ahead and create the bundle on disk and copy the file there so it can be operated on. I'd like to maintain the illusion to the user that this is an untitled, unsaved document. Is that possible?
I realize this goes against Apple's "modern" notion of documents that don't need to be saved. Maybe it would be better to just have all operations auto-save. I know I've never been comfortable not being able to explicitly save a document. I'm not actually sure what the recommended UI is these days (Apple seems to have reversed course on this).
Recommendations welcome.

A: *

*The behaviour sounds like a Viewer of the original file because it can not alter the file.
For exported file types, add these to your application's Info.plist file using the UTExportedTypeDeclarations key value. An example from Font Pestle is below. Font Pestle does not open or edit CSS, but it does export the format:
 <key>UTExportedTypeDeclarations</key>
     <array>
         <dict>
            <key>UTTypeConformsTo</key>
            <array>
                <string>public.source-code</string>
                <string>public.utf8-plain-text</string>
            </array>
            <key>UTTypeDescription</key>
            <string>Cascading Style Sheet</string>
            <key>UTTypeIdentifier</key>
            <string>eu.miln.font-pestle.css</string>
            <key>UTTypeReferenceURL</key>
            <string>http://www.w3.org/Style/CSS/</string>
            <key>UTTypeTagSpecification</key>
            <dict>
                <key>public.filename-extension</key>
                <array>
                    <string>css</string>
                </array>
            </dict>
        </dict>

*Subclassing NSDocumentController is a reasonable place to check for previously imported copies of the file being opened.
If you find yourself writing hundreds of lines of code in your NSDocumentController subclass, reconsider your design. The subclassing required should be minimal.

*Use NSDocument's support for NSFileWrapper.
NSFileWrapper is designed to help ease the managing bundle based documents. NSDocument and NSFileWrapper will handle saving temporary copies of your untitled documented before the user actively saves or needs to pick a destination for the document.
I highly recommend reading Apple's About the Cocoa Document Architecture and following its guidelines as closely as possible. This will save you time and, hopefully, make maintaining your application easier as Apple evolve their underlying frameworks.


text:
Q: App works locally but getteting error on heroku I'm working on an amazon clone app from a turorial.  It works locally and it will deploy to heroku with no errors but I get a Module Not Found for the productsController.
The file structure is
├── backend
|   ├── config
│   ├── controllers
│   │   ├── productController.js
│   ├── models
│   ├── routes
│   │   ├── productRoutes.js
│   ├── server.js

Here is the heroku error log:
2023-01-06T01:09:09.693860+00:00 app[web.1]: ^
2023-01-06T01:09:09.693860+00:00 app[web.1]:
2023-01-06T01:09:09.693861+00:00 app[web.1]: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/app/backend/controllers/productController.js' imported from /app/backend/routes/productRoutes.js
2023-01-06T01:09:09.693861+00:00 app[web.1]: at new NodeError (node:internal/errors:393:5)
2023-01-06T01:09:09.693862+00:00 app[web.1]: at finalizeResolution (node:internal/modules/esm/resolve:323:11)
2023-01-06T01:09:09.693862+00:00 app[web.1]: at moduleResolve (node:internal/modules/esm/resolve:916:10)
2023-01-06T01:09:09.693862+00:00 app[web.1]: at defaultResolve (node:internal/modules/esm/resolve:1124:11)
2023-01-06T01:09:09.693863+00:00 app[web.1]: at nextResolve (node:internal/modules/esm/loader:163:28)
2023-01-06T01:09:09.693863+00:00 app[web.1]: at ESMLoader.resolve (node:internal/modules/esm/loader:841:30)
2023-01-06T01:09:09.693863+00:00 app[web.1]: at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
2023-01-06T01:09:09.693864+00:00 app[web.1]: at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
2023-01-06T01:09:09.693875+00:00 app[web.1]: at link (node:internal/modules/esm/module_job:75:36) {
2023-01-06T01:09:09.693875+00:00 app[web.1]: code: 'ERR_MODULE_NOT_FOUND'
2023-01-06T01:09:09.693875+00:00 app[web.1]: }
2023-01-06T01:09:09.693880+00:00 app[web.1]:
2023-01-06T01:09:09.693880+00:00 app[web.1]: Node.js v18.12.1
2023-01-06T01:09:09.881953+00:00 heroku[web.1]: Process exited with status 1
2023-01-06T01:09:09.926097+00:00 heroku[web.1]: State changed from starting to crashed
2023-01-06T01:09:09.936162+00:00 heroku[web.1]: State changed from crashed to starting
2023-01-06T01:09:18.922072+00:00 heroku[web.1]: Starting process with command `npm start`
2023-01-06T01:09:20.986680+00:00 app[web.1]:
2023-01-06T01:09:20.986716+00:00 app[web.1]: > amazona-2@1.0.0 start
2023-01-06T01:09:20.986716+00:00 app[web.1]: > node backend/server.js
2023-01-06T01:09:20.986717+00:00 app[web.1]:
2023-01-06T01:09:21.087388+00:00 app[web.1]: node:internal/errors:484
2023-01-06T01:09:21.087389+00:00 app[web.1]: ErrorCaptureStackTrace(err);
2023-01-06T01:09:21.087390+00:00 app[web.1]: ^
2023-01-06T01:09:21.087390+00:00 app[web.1]:
2023-01-06T01:09:21.087391+00:00 app[web.1]: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/app/backend/controllers/productController.js' imported from /app/backend/routes/productRoutes.js
2023-01-06T01:09:21.087391+00:00 app[web.1]: at new NodeError (node:internal/errors:393:5)
2023-01-06T01:09:21.087392+00:00 app[web.1]: at finalizeResolution (node:internal/modules/esm/resolve:323:11)
2023-01-06T01:09:21.087392+00:00 app[web.1]: at moduleResolve (node:internal/modules/esm/resolve:916:10)
2023-01-06T01:09:21.087392+00:00 app[web.1]: at defaultResolve (node:internal/modules/esm/resolve:1124:11)
2023-01-06T01:09:21.087393+00:00 app[web.1]: at nextResolve (node:internal/modules/esm/loader:163:28)
2023-01-06T01:09:21.087393+00:00 app[web.1]: at ESMLoader.resolve (node:internal/modules/esm/loader:841:30)
2023-01-06T01:09:21.087393+00:00 app[web.1]: at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
2023-01-06T01:09:21.087394+00:00 app[web.1]: at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
2023-01-06T01:09:21.087395+00:00 app[web.1]: at link (node:internal/modules/esm/module_job:75:36) {
2023-01-06T01:09:21.087396+00:00 app[web.1]: code: 'ERR_MODULE_NOT_FOUND'
2023-01-06T01:09:21.087396+00:00 app[web.1]: }
2023-01-06T01:09:21.087426+00:00 app[web.1]:
2023-01-06T01:09:21.087427+00:00 app[web.1]: Node.js v18.12.1
2023-01-06T01:09:21.248317+00:00 heroku[web.1]: Process exited with status 1
2023-01-06T01:09:21.315476+00:00 heroku[web.1]: State changed from starting to crashed
2023-01-06T01:09:23.209214+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=mern-amazona2-judo2000.herokuapp.com request_id=dd865b46-6a9f-478d-87ea-bfef1a20773d fwd="136.144.43.249" dyno= connect= service= status=503 bytes= protocol=https
2023-01-06T01:09:23.521669+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=mern-amazona2-judo2000.herokuapp.com request_id=2c983834-c3e2-4a60-b39a-f55ecf4fa2fd fwd="172.98.33.99" dyno= connect= service=
 status=503 bytes= protocol=https
2023-01-06T01:11:30.804412+00:00 heroku[web.1]: State changed from crashed to starting
2023-01-06T01:11:39.211361+00:00 heroku[web.1]: Starting process with command `npm start`
2023-01-06T01:11:41.347517+00:00 app[web.1]:
2023-01-06T01:11:41.347544+00:00 app[web.1]: > amazona-2@1.0.0 start
2023-01-06T01:11:41.347544+00:00 app[web.1]: > node backend/server.js
2023-01-06T01:11:41.347545+00:00 app[web.1]:
2023-01-06T01:11:41.460279+00:00 app[web.1]: node:internal/errors:484
2023-01-06T01:11:41.460280+00:00 app[web.1]: ErrorCaptureStackTrace(err);
2023-01-06T01:11:41.460281+00:00 app[web.1]: ^
2023-01-06T01:11:41.460281+00:00 app[web.1]:
2023-01-06T01:11:41.460281+00:00 app[web.1]: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/app/backend/controllers/productController.js' imported from /app/backend/routes/productRoutes.js
2023-01-06T01:11:41.460282+00:00 app[web.1]: at new NodeError (node:internal/errors:393:5)
2023-01-06T01:11:41.460282+00:00 app[web.1]: at finalizeResolution (node:internal/modules/esm/resolve:323:11)
2023-01-06T01:11:41.460283+00:00 app[web.1]: at moduleResolve (node:internal/modules/esm/resolve:916:10)
2023-01-06T01:11:41.460283+00:00 app[web.1]: at defaultResolve (node:internal/modules/esm/resolve:1124:11)
2023-01-06T01:11:41.460283+00:00 app[web.1]: at nextResolve (node:internal/modules/esm/loader:163:28)
2023-01-06T01:11:41.460285+00:00 app[web.1]: at ESMLoader.resolve (node:internal/modules/esm/loader:841:30)
2023-01-06T01:11:41.460285+00:00 app[web.1]: at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
2023-01-06T01:11:41.460285+00:00 app[web.1]: at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
2023-01-06T01:11:41.460285+00:00 app[web.1]: at link (node:internal/modules/esm/module_job:75:36) {
2023-01-06T01:11:41.460286+00:00 app[web.1]: code: 'ERR_MODULE_NOT_FOUND'
2023-01-06T01:11:41.460286+00:00 app[web.1]: }
2023-01-06T01:11:41.460297+00:00 app[web.1]:
2023-01-06T01:11:41.460298+00:00 app[web.1]: Node.js v18.12.1
2023-01-06T01:11:41.609123+00:00 heroku[web.1]: Process exited with status 1
2023-01-06T01:11:41.742528+00:00 heroku[web.1]: State changed from starting to crashed
2023-01-06T01:11:42.461013+00:00 heroku[web.1]: State changed from crashed to starting
2023-01-06T01:11:52.618745+00:00 heroku[web.1]: Starting process with command `npm start`
2023-01-06T01:11:54.470268+00:00 app[web.1]:
2023-01-06T01:11:54.470310+00:00 app[web.1]: > amazona-2@1.0.0 start
2023-01-06T01:11:54.470311+00:00 app[web.1]: > node backend/server.js
2023-01-06T01:11:54.470311+00:00 app[web.1]:
2023-01-06T01:11:54.565973+00:00 app[web.1]: node:internal/errors:484
2023-01-06T01:11:54.565975+00:00 app[web.1]: ErrorCaptureStackTrace(err);
2023-01-06T01:11:54.565975+00:00 app[web.1]: ^
2023-01-06T01:11:54.565976+00:00 app[web.1]:
2023-01-06T01:11:54.565977+00:00 app[web.1]: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/app/backend/controllers/productController.js' imported from /app/backend/routes/productRoutes.js
2023-01-06T01:11:54.565986+00:00 app[web.1]: at new NodeError (node:internal/errors:393:5)
2023-01-06T01:11:54.565986+00:00 app[web.1]: at finalizeResolution (node:internal/modules/esm/resolve:323:11)
2023-01-06T01:11:54.565986+00:00 app[web.1]: at moduleResolve (node:internal/modules/esm/resolve:916:10)
2023-01-06T01:11:54.565987+00:00 app[web.1]: at defaultResolve (node:internal/modules/esm/resolve:1124:11)
2023-01-06T01:11:54.565987+00:00 app[web.1]: at nextResolve (node:internal/modules/esm/loader:163:28)
2023-01-06T01:11:54.565987+00:00 app[web.1]: at ESMLoader.resolve (node:internal/modules/esm/loader:841:30)
2023-01-06T01:11:54.565987+00:00 app[web.1]: at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
2023-01-06T01:11:54.565993+00:00 app[web.1]: Node.js v18.12.12023-01-06T01:11:54.697714+00:00 heroku[web.1]: Process exited with status 1
2023-01-06T01:11:54.792281+00:00 heroku[web.1]: State changed from starting to crashed
2023-01-06T01:11:55.983110+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=mern-amazona2-judo2000.herokuapp.com request_id=e373b75d-6a72-432d-9709-29e6c62063bd fwd="173.239.224.8" dyno= connect= service= status=503 bytes= protocol=https
2023-01-06T01:11:56.274300+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=mern-amazona2-judo2000.herokuapp.com request_id=368733e0-a442-422d-97a1-1c3e0bc7681f fwd="173.239.224.10" dyno= connect= service= status=503 bytes= protocol=https
2023-01-06T01:11:30.571160+00:00 app[api]: Release v21 created by user judo2000@comcast.net
2023-01-06T01:11:30.571160+00:00 app[api]: Remove MONGO_URI config vars by user judo2000@comcast.net
2023-01-06T01:11:42.194061+00:00 app[api]: Set MONGODB_URI config vars by user judo2000@comcast.net
2023-01-06T01:11:42.194061+00:00 app[api]: Release v22 created by user judo2000@comcast.net

Here is the server.js
import express from 'express';
import path from 'path';
import dotenv from 'dotenv';
import connectDB from './config/connection.js';

import seedRoutes from './routes/seedRoutes.js';
import productRoutes from './routes/productRoutes.js';
import userRoutes from './routes/userRoutes.js';
import orderRoutes from './routes/orderRoutes.js';

dotenv.config();

connectDB();

const app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));

app.get('/api/keys/paypal', (req, res) => {
  res.send(process.env.PAYPAL_CLIENT_ID || 'sb');
});

app.use('/api/seed', seedRoutes);
app.use('/api/products', productRoutes);
app.use('/api/users', userRoutes);
app.use('/api/orders', orderRoutes);

const __dirname = path.resolve();
app.use(express.static(path.join(__dirname, '/frontend/build')));

app.get('*', (req, res) => {
  res.sendFile(path.join(__dirname, '/frontend/build/index.html'));
});

app.use((err, req, res, next) => {
  res.status(500).send({ message: err.message });
});

const port = process.env.PORT || 5000;
app.listen(port, () => {
  console.log(`Server listening at http://localhost:${port}`);
});

Here is the productRoutes.js
import express, { Router } from 'express';
const router = express.Router();
import {
  getProducts,
  getProductBySlug,
  getProductById,
} from '../controllers/productController.js';

router.route('/').get(getProducts);
router.route('/slug/:slug').get(getProductBySlug);
router.route('/:id').get(getProductById);

export default router;

And here is the productController
import Product from '../models/ProductModel.js';

const getProducts = async (req, res) => {
  const products = await Product.find({});
  res.send(products);
};

const getProductBySlug = async (req, res) => {
  const product = await Product.findOne({ slug: req.params.slug });

  if (product) {
    res.send(product);
  } else {
    res.status(404).send({ message: 'Product Not Found' });
  }
};

const getProductById = async (req, res) => {
  const product = await Product.findById(req.params.id);
  if (product) {
    res.send(product);
  } else {
    res.status(404).send({ message: 'Product not found.' });
  }
};

export { getProducts, getProductBySlug, getProductById };

A: You have a path mis-match. Change controllers to controller or vise-versa (whichever is true).

*

*The error is:
Cannot find module '/app/backend/controllers/productController.js'

*and your path is:
/app/backend/controller/productController.js


text:
Q: How to draw mirrored x-axis(inverted) bar chart in d3? I am trying to create a bar chart which uses brush and zoom. I want the graph to show buy price and sell price in a day. So far I was able to add buy price to the chart like this https://jsfiddle.net/070yqew2/
I found this and this as interesting graphs that are relevant to the design. I do not find any idea to implement this, any graph that show mirrored representation with brush and zoom should help a lot.
<!DOCTYPE html>
<meta charset="utf-8">

<style type="text/css">

body {
  font-family: avenir next, sans-serif;
  font-size: 12px;
}

.zoom {
  cursor: move;
  fill: none;
  pointer-events: all;
}

.axis {
  stroke-width: 0.5px;
  stroke: #888;
  font: 10px avenir next, sans-serif;
}

.axis > path {
  stroke: #888;
}

</style>

<body>
</body>

<script src="https://d3js.org/d3.v4.min.js"></script>
<script>

     function randomData(samples) {
            var data = [],
                random = d3.randomNormal();

            for (i = 0; i < samples; i++) {
                data.push({
                    "Date" : new Date("May"+ (i+1)+", 2016 "),
                    "Buy" : Math.floor(Math.random()*100000),
                    "Sell" : Math.floor(Math.random()*100000)
                });
            }
            return data;
        }

    var data = randomData(30);

  var xMin = d3.min(data, function(d) { return d["Date"] });
  var yMax = Math.max(20, d3.max(data, function(d) { return d["Buy"] }));

var margin = {top: 20, right: 20, bottom: 90, left: 50},
    margin2 = {top: 230, right: 20, bottom: 30, left: 50},
    width = 960 - margin.left - margin.right,
    height = 300 - margin.top - margin.bottom,
    height2 = 300 - margin2.top - margin2.bottom;

var x = d3.scaleTime().range([0, width]),
    x2 = d3.scaleTime().range([0, width]),
    y = d3.scaleLinear().range([height, 0]),
    y2 = d3.scaleLinear().range([height2, 0]);

      x.domain([xMin, new Date()]);
      y.domain([0, yMax]);
      x2.domain(x.domain());
      y2.domain(y.domain());

var xAxis = d3.axisBottom(x).tickSize(0),
    xAxis2 = d3.axisBottom(x2).tickSize(0),
    yAxis = d3.axisLeft(y).tickSize(0);

var brush = d3.brushX()
    .extent([[0, 0], [width, height2]])
    .on("brush", brushed);

var zoom = d3.zoom()
    .scaleExtent([1, Infinity])
    .translateExtent([[0, 0], [width, height]])
    .extent([[0, 0], [width, height]])
    .on("zoom", zoomed);

var svg = d3.select("body").append("svg")
    .attr("width", width + margin.left + margin.right)
    .attr("height", height + margin.top + margin.bottom);

svg.append("defs").append("clipPath")
    .attr("id", "clip")
  .append("rect")
    .attr("width", width)
    .attr("height", height);

var focus = svg.append("g")
    .attr("class", "focus")
    .attr("transform", "translate(" + margin.left + "," + margin.top + ")");

var context = svg.append("g")
    .attr("class", "context")
    .attr("transform", "translate(" + margin2.left + "," + margin2.top + ")");

  var bars = focus.append("g");
    bars.attr("clip-path", "url(#clip)");
    bars.selectAll("bar")
        .data(data)
        .enter().append("rect")
        .attr('class', 'bar')
        .attr('x',function(d) { return x(d["Date"]) })
        .attr('y',function(d) { return y(d["Buy"]) })
        .attr('width',7)
        .attr('height',(d=>height-y(d["Buy"])))
        .style("fill","03a63c")
        .style("opacity",0.8)

  focus.append("g")
        .attr("class", "axis x-axis")
        .attr("transform", "translate(0," + height + ")")
        .call(xAxis);

  focus.append("g")
        .attr("class", "axis axis--y")
        .call(yAxis);

  // Summary Stats
  focus.append("text")
        .attr("transform", "rotate(-90)")
        .attr("y", 0 - margin.left)
        .attr("x",0 - (height / 2))
        .attr("dy", "1em")
        .style("text-anchor", "middle")
        .text("bars (in the day)");

  svg.append("text")
        .attr("transform",
              "translate(" + ((width + margin.right + margin.left)/2) + " ," +
                             (height + margin.top + margin.bottom) + ")")
        .style("text-anchor", "middle")
        .text("Date");

  svg.append("rect")
    .attr("class", "zoom")
    .attr("width", width)
    .attr("height", height)
    .attr("transform", "translate(" + margin.left + "," + margin.top + ")")
    .call(zoom);

  // append scatter plot to brush chart area
   var bars = context.append("g");
       bars.attr("clip-path", "url(#clip)");
       bars.selectAll("bar")
           .data(data)
           .enter().append("rect")
           .attr('class', 'barContext')
           .attr('x',function(d) { return x2(d["Date"]) })
           .attr('y',function(d) { return y2(d["Buy"]) })
           .attr('width',2)
           .attr('height',(d=>height2-y2(d["Buy"])))
           .style("fill","03a63c")
           .style("opacity",0.8)

  context.append("g")
        .attr("class", "axis x-axis")
        .attr("transform", "translate(0," + height2 + ")")
        .call(xAxis2);

  context.append("g")
        .attr("class", "brush")
        .call(brush)
        .call(brush.move, x.range());
    function brushed() {
  if (d3.event.sourceEvent && d3.event.sourceEvent.type === "zoom") return; // ignore brush-by-zoom
  var s = d3.event.selection || x2.range();
  x.domain(s.map(x2.invert, x2));
  focus.selectAll(".bar")
        .attr("x", function(d) { return x(d["Date"]); })
        .attr("y", function(d) { return y(d["Buy"]); });
  focus.select(".x-axis").call(xAxis);
  svg.select(".zoom").call(zoom.transform, d3.zoomIdentity
      .scale(width / (s[1] - s[0]))
      .translate(-s[0], 0));
}

function zoomed() {
  if (d3.event.sourceEvent && d3.event.sourceEvent.type === "brush") return; // ignore zoom-by-brush
  var t = d3.event.transform;
  x.domain(t.rescaleX(x2).domain());
  focus.selectAll(".bar")
        .attr("x", function(d) { return x(d["Date"]); })
        .attr("y", function(d) { return y(d["Buy"]); });
  focus.select(".x-axis").call(xAxis);
  context.select(".brush").call(brush.move, x.range().map(t.invertX, t));
};

</script>

I need something like this

A: After doing some research, I found the answer to the question. I used d3.stack() function which is really cool.
Here is my code https://jsfiddle.net/zuueksc5/
<!DOCTYPE html>
<meta charset="utf-8">

<style type="text/css">

body {
  font-family: avenir next, sans-serif;
  font-size: 12px;
}

.zoom {
  cursor: move;
  fill: none;
  pointer-events: all;
}

.axis {
  stroke-width: 0.5px;
  stroke: #888;
  font: 10px avenir next, sans-serif;
}

.axis > path {
  stroke: #888;
}

#tooltip {
        background-color: rgba(187, 187, 187, 0.7);
        border-radius: 5px;
        height: 18px;
        opacity: 0;
        pointer-events: none;
        position: absolute;
        text-align: center;
        }

</style>

<body>
</body>

<script src="https://d3js.org/d3.v4.min.js"></script>
<script>

    var data = [{"Date":"2015-01-02T00:00:00.000Z","Buy":554646.5,"Sell":-406301.3547},{"Date":"2015-02-02T00:00:00.000Z","Buy":565499.5,"Sell":-673692.5697},{"Date":"2015-03-02T00:00:00.000Z","Buy":421954.5,"Sell":-571685.4629},{"Date":"2015-04-02T00:00:00.000Z","Buy":466242.0,"Sell":-457477.7121},{"Date":"2015-05-02T00:00:00.000Z","Buy":350199.7,"Sell":-579682.8772},{"Date":"2015-06-02T00:00:00.000Z","Buy":391035.1,"Sell":-338816.6205},{"Date":"2015-07-02T00:00:00.000Z","Buy":437644.6,"Sell":-502329.557},{"Date":"2015-08-02T00:00:00.000Z","Buy":291978.9,"Sell":-504067.0329},{"Date":"2015-09-02T00:00:00.000Z","Buy":360913.8,"Sell":-489519.6652},{"Date":"2015-10-02T00:00:00.000Z","Buy":505799.1,"Sell":-723353.7089},{"Date":"2015-11-02T00:00:00.000Z","Buy":510691.0,"Sell":-374061.8139},{"Date":"2015-12-02T00:00:00.000Z","Buy":527757.1,"Sell":-597800.0116},{"Date":"2016-01-02T00:00:00.000Z","Buy":564799.1,"Sell":-451779.1593},{"Date":"2016-02-02T00:00:00.000Z","Buy":336533.7,"Sell":-522601.1707},{"Date":"2016-03-02T00:00:00.000Z","Buy":460684.6,"Sell":-643556.0079999999},{"Date":"2016-04-02T00:00:00.000Z","Buy":428388.1,"Sell":-349216.2376},{"Date":"2016-05-02T00:00:00.000Z","Buy":525459.5,"Sell":-597258.4075},{"Date":"2016-06-02T00:00:00.000Z","Buy":677659.1,"Sell":-513192.107},{"Date":"2016-07-02T00:00:00.000Z","Buy":365612.8,"Sell":-287845.8089},{"Date":"2016-07-03T00:00:00.000Z","Buy":358775.2,"Sell":-414573.209}]

    data.forEach(d => {
                  d["Date"] = new Date(d["Date"]);
    })
  var xMin = d3.min(data, function(d) { return d["Date"] });
  var yMax = Math.max(20, d3.max(data, function(d) { return d["Buy"] }));

var margin = {top: 20, right: 20, bottom: 230, left: 50},
    margin2 = {top: 250, right: 20, bottom: 30, left: 50},
    width = 960 - margin.left - margin.right,
    height = 900 - margin.top - margin.bottom,
    height2 = 350 - margin2.top - margin2.bottom;

var series = d3.stack()
    .keys(["Buy", "Sell"])
    .offset(d3.stackOffsetDiverging)
    (data);

   var tooltip = d3.select('body').append('div')
     .attr('id', 'tooltip');

 var x = d3.scaleTime().rangeRound([0, width]),
    x2 = d3.scaleTime().rangeRound([0, width]),
    y = d3.scaleLinear().rangeRound([height ,0]),
    y2 = d3.scaleLinear().rangeRound([height2, 0]);

      x.domain(d3.extent(data,function(d) { return d["Date"]; }))
      y.domain([d3.min(series, stackMin), d3.max(series, stackMax)])
      x2.domain(x.domain());
      y2.domain(y.domain());

    function stackMin(serie) {
    return d3.min(serie, function(d) { return d[0]; });
        }

    function stackMax(serie) {
    return d3.max(serie, function(d) { return d[1]; });
        }

var z = d3.scaleOrdinal(d3.schemeCategory10)

var xAxis = d3.axisBottom(x).tickSize(0),
    xAxis2 = d3.axisBottom(x2).tickSize(0),
    yAxis = d3.axisLeft(y).tickSize(0);

var brush = d3.brushX()
    .extent([[0, 0], [width, height2]])
    .on("brush", brushed);

var zoom = d3.zoom()
    .scaleExtent([1, 50])
    .translateExtent([[0, 0], [width, height]])
    .extent([[0, 0], [width, height]])
    .on("zoom", zoomed);

var svg = d3.select("body").append("svg")
    .attr("width", width + margin.left + margin.right)
    .attr("height", height + margin.top + margin.bottom);

svg.append("defs").append("clipPath")
    .attr("id", "clip")
  .append("rect")
    .attr("width", width)
    .attr("height", height);

var focus = svg.append("g")
    .attr("class", "focus")
    .attr("transform", "translate(" + margin.left + "," + margin.top + ")");

var context = svg.append("g")
    .attr("class", "context")
    .attr("transform", "translate(" + margin2.left + "," + (height+80)+ ")");

  var bars = focus.append("g");
    bars.attr("clip-path", "url(#clip)")
        .attr("fill", "steelblue")
        .attr("height",height)
        .attr("width",width);
  svg.append("rect")
    .attr("class", "zoom")
    .attr("width", width)
    .attr("height", height)
    .attr("transform", "translate(" + margin.left + "," + margin.top + ")")
    .call(zoom);
  focus.append("g")
        .attr("class", "axis x-axis")
        .attr("transform", "translate(0," + height + ")")
        .call(xAxis);

  focus.append("g")
        .attr("class", "axis axis--y")
        .call(yAxis);

 bars.selectAll("g")
      .data(series)
      .enter().append("g")
        .attr("fill", function(d) { return z(d.key) })
      .selectAll("rect")
      .data(function(d) { return d; })
      .enter().append("rect")
      .attr('class', 'bar')
        .transition()
        .duration(1000)
        .attr("width",10)
        .attr("x", function(d) { return x(d.data["Date"])})
        .attr("y", function(d) { return y(d[1])})
        .attr("height", function(d) { return y(d[0]) - y(d[1])})

  //appending brush to context
   var bars = context.append("g");
       bars.attr("clip-path", "url(#clip)");
       bars.selectAll("bar")
          .data(series)
          .enter().append("g")
            .attr("fill", function(d) { return z(d.key); })
          .selectAll("rect")
          .data(function(d) { return d; })
          .enter().append("rect")
            .attr('class', 'barContext')
            .attr("width",5)
            .attr("x", function(d) { return x2(d.data["Date"])})
            .attr("y", function(d) { return y2(d[1])})
            .attr("height", function(d) { return y2(d[0]) - y2(d[1])})

  context.append("g")
        .attr("class", "axis x-axis")
        .attr("transform", "translate(0," + height2 + ")")
        .call(xAxis2);

  context.append("g")
        .attr("class", "brush")
        .call(brush)
        .call(brush.move, x.range());
    function brushed() {
          if (d3.event.sourceEvent && d3.event.sourceEvent.type === "zoom") return; // ignore brush-by-zoom
          var s = d3.event.selection || x2.range();

          x.domain(s.map(x2.invert, x2));

          focus.selectAll(".bar")

                    .attr("x", function(d) { return x(d.data["Date"])})
                    .attr("y", function(d) { return y(d[1])})
          focus.select(".x-axis").call(xAxis);
          svg.select(".zoom").call(zoom.transform, d3.zoomIdentity
              .scale(width / (s[1] - s[0]))
              .translate(-s[0], 0));
        }

    function zoomed() {
      if (d3.event.sourceEvent && d3.event.sourceEvent.type === "brush") return; // ignore zoom-by-brush
      var t = d3.event.transform;
      x.domain(t.rescaleX(x2).domain());
      focus.selectAll(".bar")
            .attr("x", function(d) { return x(d.data["Date"])})
            .attr("y", function(d) { return y(d[1])})
      focus.select(".x-axis").call(xAxis);
      context.select(".brush").call(brush.move, x.range().map(t.invertX, t));
    }

</script>


text:
Q: Partial order on the set of non-split short exact sequences ending at a MCM module Let $R$ be a Henselian Cohen-Macaulay (CM) local ring with maximal ideal $\mathfrak m_R$. For an indecomposable finitely generated maximal Cohen-Macaulay (MCM) $R$-module $M$, the set $\mathfrak S(M)$ contains all non-split short exact sequences of the form
$$s:0\to N_s\to E_s\to M\to 0,$$
where $N_s,E_s$ are also finitely generated MCM $R$-modules and $N_s$ is indecomposable.

For $s,t\in \mathfrak S(M)$, write $s\ge t$ if $\exists f\in \mathsf{Hom}_R(N_s,N_t)$ with $\mathsf{Ext}_R^1(M,f)(s)=t$; write $s\simeq t$ if moreover $f$ is an isomorphism. I intend to show that $\ge$ is a partial order on $\mathfrak S(M)$ modulo $\simeq$.

It is clear that $\ge$ is reflexive and transitive, so it suffices to show that $\ge$ is anti-symmetric. Let $s,t\in \mathfrak S(M)$ with $s\ge t$ and $t\ge s$. This means $\exists f:N_s\to N_t$, $\exists g:N_t\to N_s$ with $\mathsf{Ext}_R^1(M,f)(s)=t$ and $\mathsf{Ext}_R^1(M,g)(t)=s$. Letting $h:=g\circ f\in \mathsf{End}_R(N_s)$, we have $\mathsf{Ext}_R^1(M,h)(s)=s$. It is clear that if $h$ is an isomorphism, then $g$ is surjective and $f$ is injective, and by symmetry this will finish the proof. However, I have difficulty showing $h$ is an isomorphism.
Thank you very much for any help!

A: Fixing $s$, let me drop the suffixes. We have the natural map $\phi:\operatorname{End}(N)\to \operatorname{Ext}^1(M,N)$. $S=R[h]\subset\operatorname{End}(N)$, a commutative subring. Since $R$ is hensel and $S$ is a finite module over $R$, it is a product of local rings. If it is not local, then $S$ has non-trivial idempotents, which is impossible, since $N$ is indecomposable. Thus $S$ is local. The induced map $\phi$ from $S\to \operatorname{Ext}^1(M,N)$ has kernel an ideal (I may have missed something here) of $S$. Now, $h-1$ is in the kernel and the kernel is a proper ideal (since the sequence does not split) says $h-1$ is in the maximal ideal of $S$ and so $h$ is a unit. This is what we wanted to prove.


text:
Q: Dart: Comparing two times from string Is there any way to compare two times in dart, suppose we have: 13:45 and 15:34, is there any way to find out that 15:34 is after 13:45.
I was looking at this question, and there are functions to check isBefore or isAfter, but is it possible to parse time without having to parse year, month and day?

A: You can convert them to datetime and compare. ie:
void main() {
   var s1 = '13:45';
   var s2 = '15:34';

   var t1 = DateTime.parse('2000-01-01 ${s1}');
   var t2 = DateTime.parse('2000-01-01 ${s2}');
   print(t1.isBefore(t2));
}

EDIT: For a more direct, string sort like comparison (which I wouldn't suggest at all for Date\time values, unless you are 100% sure they are in sortable format) you could use compareTo(). ie:
print(s1.compareTo(s2) < 0);


text:
Q: How can i access a file (say .xml) from a native code,invoked from an android activity class, where do i need to place that XML file? I am trying out an example of OpenCV from http://github.com/billmccord/OpenCV-Android and am stuck at the point where it is mentioned "Before attempting to run the VideoEmulator application, you must first copy this XML file into the emulator in the following location: /data/data/org.siprop.opencv/files/haarcascade_frontalface_alt.xml "
Where in my eclipse workspace do I need to place this haar xml file to be copied to the location /data/data/org.siprop.opencv/files/ of the emulator?
The library "libopencv.so" when placed under libs/amreabi in the eclipse workspace, is picked and appropriately placed under data/data/org.siprop.opencv/lib as seen from the fileexplorer via DDMS

A: This is location not in Eclipse workspace, but in emulator/phone filesystem. Try to place this haar xml file into this folder via DDMS, for example.


text:
Q: Can I to make svg icon using data-uri with built-in data for the properties of the background? I want it to look like the result of this code:

html {
  font-size: 16px;
}

.ico {
  display: inline-block;
}

.ico_size_s {
  width: 1.3rem;
  height: 1.3rem;
}

.ico_size_m {
  width: 2rem;
  height: 2rem;
}

.ico_first {
  background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNiAxNiI+PHBhdGggZD0iTTEzLjUxMi40NTMgNS40NzUgMTIuNDc4IDEuNzA4IDguMjguNjY3IDkuNjA1IDUuNjAzIDE1LjA2IDE0LjcyMiAxLjYxM3oiLz48L3N2Zz4K);
  background-color: yellow;
}

.ico_last {
  background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNnB4IiBoZWlnaHQ9IjE2cHgiIHZpZXdCb3g9IjAgMCAxNiAxNiI+DQo8cGF0aCBkPSJNMTUsMGMtMC40NDYsMC0wLjcxOSwwLjM0NC0wLjkzOSwwLjY5OUw2LjgwNywxMy4zOTNsLTUuMS01LjFsMCwwQzEuNTI2LDguMTEyLDEuMjc2LDgsMSw4QzAuNDQ4LDgsMCw4LjQ0OCwwLDkNCgljMCwwLjI3NiwwLjExMiwwLjUyNiwwLjI5MywwLjcwN2w2LDZDNi40NzQsMTUuODg4LDYuNzI0LDE2LDcsMTZjMC40NDYsMCwwLjgxMi0wLjM0NCwwLjk4NC0wLjY5OWw3LjY3Mi0xMy41MDQNCglDMTUuNjU2LDEuNzk3LDE2LDEuMjY2LDE2LDFDMTYsMC40NDgsMTUuNTUyLDAsMTUsMHoiLz4NCjwvc3ZnPg0K);
  background-color: orange;
}

There are two different data-uri for the two icons.
One behaves as if it had the following properties:
background-repeat: no-repeat;
background-size: contain;
background-position: bottom;

How is it done?

A: If you do a Base64 decode of the first icon you get:
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
  <path d="M13.512.453 5.475 12.478 1.708 8.28.667 9.605 5.603 15.06 14.722 1.613z"/>
</svg>

Whereas decoding the second one gives:
<svg xmlns="http://www.w3.org/2000/svg" width="16px" height="16px" viewBox="0 0 16 16">
  <path d="M15,0c-0.446,0-0.719,0.344-0.939,0.699L6.807,13.393l-5.1-5.1l0,0C1.526,8.112,1.276,8,1,8C0.448,8,0,8.448,0,9
c0,0.276,0.112,0.526,0.293,0.707l6,6C6.474,15.888,6.724,16,7,16c0.446,0,0.812-0.344,0.984-0.699l7.672-13.504
C15.656,1.797,16,1.266,16,1C16,0.448,15.552,0,15,0z"/>

Notice that the second specifies a width and height of "16px" for the SVG.  That means it will always be drawn at that size no matter what.  So when it is used as a background image it gets repeated if the container is larger than 16px in width or height.
The first icon does not specify a width or height. So those attributes default to "100%". That means the icon gets scaled to fit the container.


text:
Q: Change function on javascript prototype I want to change the XMLHttpRequest send function so that a function is called before the request is made and after the request is complete. Here is what I have so far:
var oldSend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function() {
    //this never gets called
    oldOnReady = this.onreadystatechange;
    this.onreadystatechange = function() {
        oldOnReady();
        ajaxStopped();
    }

    ajaxStarted();

    // according to http://www.w3.org/TR/XMLHttpRequest/
    // there's only ever 0 or 1 parameters passed into this method
    if(arguments && arguments.length > 0) {
        oldSend(arguments[0]); //gets to here, calls this method, then nothing happens
    } else {
        oldSend();
    }
}

function ajaxStarted() {
    ajaxCount++;
    document.getElementById("buttonClicky").innerHTML = "Count: " + ajaxCount;
}

function ajaxStopped() {
    $("#isRunning")[0].innerHTML = "stopped";
    ajaxCount--;
    document.getElementById("buttonClicky").innerHTML = "Count: " + ajaxCount;
}

However, I'm doing something wrong here because once it hits the oldSend() call, it never returns or triggers the onreadystatechange event. So I must be doing somethingclickCount wrong here.  Any ideas? I set a breakpoint and it gets hit just fine when I call this:
$.ajax({
    type: "GET",
    url: "file.txt",
    success: function(result) {
                    //this never gets called
        document.getElementById("myDiv").innerHTML = result;
    }
});

So my new function is getting called. I guess just don't know how to call the old function. Any ideas on how to fix this code so that the Ajax Request is actually made and my new callback gets called?
Note: I'm aware of the JQuery events that essentially do this. But I'm doing this so I can get it to work with any Ajax call (Mootools, GWT, etc). I am just happening to test it with Jquery.

A: You need to call old functions in the context of this.
E.g.: oldSend.call(this)


text:
Q: Angular Fire (Google) Analytics events show in Chrome GA debug tool but are not logged on to Firebase First of all, apologies if this as a totally silly question, as I haven't really used Google Analytics before nor Angular.
The problem is that no analytics events (neither custom events nor the automatically generated screen_views) show up on Firebase. They do show, however, in Chrome with the GA Debug tool. I've also tried this without the debug mode enabled to no avail. Nothing can be seen in any of the Firebase (or Analytics) views, including DebugView.
Here's a sample from the browser console:
Screenshot from Chrome console with GA Debug output
Here's the relevant code. The event logging function is accessed by the components via an injected DatabaseService.
In a service feature module:
...

import { AngularFireModule } from '@angular/fire';
import { AngularFirestore } from '@angular/fire/firestore';
import { AngularFireAnalyticsModule,
         ScreenTrackingService,
         DEBUG_MODE } from '@angular/fire/analytics';
import { AngularFirestoreModule } from '@angular/fire/firestore';

import { DatabaseService } from './database.service';

@NgModule({
  imports: [
    CommonModule,
    AngularFireModule.initializeApp(environment.firebase),
    AngularFireAnalyticsModule,
    AngularFirestoreModule,
  ],
  providers: [
    AngularFirestore,
    ScreenTrackingService,
    DatabaseService,
    { provide: DEBUG_MODE, useValue: true },
  ],
})
export class DatabaseModule {}

Logging function in DatabaseService:
...

import { AngularFirestore,
         DocumentData,
         DocumentSnapshot,
         QuerySnapshot } from '@angular/fire/firestore';
import { AngularFireAnalytics } from '@angular/fire/analytics';
import * as firebase from 'firebase/app';
import 'firebase/firestore';

...

@Injectable({
  providedIn: 'root'
})
export class DatabaseService {

  constructor(
    private firestore: AngularFirestore,
    private analytics: AngularFireAnalytics,
  ) {}

...

  public logEvent(eventName: string, eventParams: any = {}): void {
    this.analytics.logEvent(eventName, eventParams);
  }

...

Logging example in a component that uses DatabaseService:
this.databaseService.logEvent('candidate_show', {id: '6_25'});

Any help would be greatly appreciated. I already scoured through similar questions and tried the following with no help:

*

*Checked event view filters on Firebase

*Waited at least 24h for after logging events

*Explicitly enabled collection with AngularFireAnalytics.setAnalyticsCollectionEnabled(true)

A: This is a known issue with the latest version of AngularFire. Reverting to version 6.0.0 will fix the issue. However, that version has some issues with Firebase Auth, so if you are using Auth as well, I suggest reverting to the latest 5.x version

A: This is known issue of angular-fire and it is still open so please revert back to @angular/fire@5.4.2 you will able to see the data in firestore.


text:
Q: get multiple words after a specific word of HTML using linux/unix scripting i have a file 'movie.html' :

<title>Index of /Data/Movies/Hollywood/2016_2017/</title>

Index of /Data/Movies/Hollywood/2016_2017/

../
1 Buck (2017)/                                     25-Nov-2019 10:25       -
1 Mile to You (2017)/                              25-Nov-2019 10:26       -
1 Night (2016)/                                    25-Nov-2019 10:27       -

I want to get multiple word with pipe delimited like this:
title | link
1 Buck (2017) | 1%20Buck%20%282017%29/
1 Mile to You (2017) | 1%20Mile%20to%20You%20%282017%29/
1 Night (2016) | 1%20Night%20%282016%29/

I tried this code:
awk -F'[><]' 'BEGIN{ print "title","link" } /%29/ {print $3,$2}' movie.html > output.txt

but the output isn't as my expectation please help me, i am still a beginner

A: Parsing html with regex is not advised for several reasons (see https://stackoverflow.com/a/1732454/12957340), but here is one potential solution:
awk -F'[<>/"]' 'BEGIN{ print "title | link" }; /\(.*\)/ {print $6 " | " $3}' movie.html

A: With your shown samples, could you please try following. I prefer to this with match function.
awk '
BEGIN{
  OFS=" | "
  print "title | link"
}
match($0,/^.*<\/a>/)
  print substr($0,RSTART+1,RLENGTH-6),val
}' Input_file

Explanation: Adding detailed explanation for above.
awk '                                      ##Starting awk program from here.
BEGIN{                                     ##Starting BEGIN section of this program from here.
  OFS=" | "                                ##Setting OFS as space | space here.
  print "title | link"                     ##Printing title space | space link here.
}
match($0,/^<a href="[^"]*/){               ##Using match to match regex from starting of line .*<\/a>/)                     ##Using match to match from > till  here.
  print substr($0,RSTART+1,RLENGTH-6),val  ##Printing current matched sub string(by above match function) and val value here.
}
' Input_file                               ##Mentioning Input_file name here.

A: If ed is available/acceptable and you understand the risk of using non html parser to parse hmtl files.
script.ed
0a
title | link
.
p
g/^<a href=.\{1,\}/s/^.\{1,\}="//\
s/\/[[:blank:]]*<\/a>.*$//\
s/">/ /\
s/^\([^ ]\{1,\}\) \(.\{1,\}\)/\2 | \1/p
Q

Then
ed -s file.html < script.ed

A: Another way, I think you could get the processed lines with grep and then use awk format the output content.
grep -oP 'href="([^".]*)">([^</.]*)' movie.html | awk -F'[">]' 'BEGIN{print "title | link"}{print $4" | "$2}'

grep will get the lines like below:
href="1%20Buck%20%282017%29/">1 Buck (2017)
href="1%20Mile%20to%20You%20%282017%29/">1 Mile to You (2017)
href="1%20Night%20%282016%29/">1 Night (2016)

A: Adding sub() and gsub() functions to the code:
awk -F'[><]' 'BEGIN{ print "title","|", "link" } /%29/ {sub(/\//, " |", $3);gsub(/^a href="|"$/, "", $2);print $3,$2}' file
title | link
1 Buck (2017) | 1%20Buck%20%282017%29/
1 Mile to You (2017) | 1%20Mile%20to%20You%20%282017%29/
1 Night (2016) | 1%20Night%20%282016%29/

With file > output:
awk -F'[><]' 'BEGIN{ print "title","|", "link" } /%29/ {sub(/\//, " |", $3);gsub(/^a href="|"$/, "", $2);print $3,$2}' file > output.txt


text:
Q: How to rename an iPhone project in Xcode4? I am developing an iPhone application using XCode4 editor. I have to rename my project. I can't create a new project with new name because I have proceeded too far with my coding and there are too many files in the project.
How can I rename my project in Xcode4? I have searched on net but cant find such options in xcode4 to rename the project.

A: You can click on project name in xcode and then click again. The field becomes editable. Rename it and it will prompt you to rename the other files and delegate class names.
Its really simple in xcode 4. Renaming files, folders, groups and project names can be done using the above method.

A: You can set bundle display name in info.plist. it shows your name with icon. and for renaming the folder name simply select the folder and single click on the name then you can change the name.
When you rename your folder name, you can also change your app delegate class name and product name in info where you give provisioning profile for installing on device.


text:
Q: When I request a request, it returns 401 unauthorized for each request in the security section I am making a project for Register and Login operations. I am using spring security and jwt. It always returns 401 unauthorized to any request I throw in Postman. I couldn't find the reason. Could you help? I am using spring boot new version. 3.0.0 version.
@EnableWebSecurity
@RequiredArgsConstructor
public class SecurityConfiguration {

    private final JwtAuthenticationFilter jwtAuthFilter;
    private final AuthenticationProvider authenticationProvider;

    @Bean
    public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
        http.csrf().disable()
            .authorizeHttpRequests()
            .requestMatchers("/auth/**").permitAll()
            .anyRequest()
            .authenticated()
            .and()
            .sessionManagement()
            .sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
            .authenticationProvider(authenticationProvider)
            .addFilterBefore(jwtAuthFilter, UsernamePasswordAuthenticationFilter.class);

        return http.build();
    }
}
@RestController
@RequestMapping("/auth")
@RequiredArgsConstructor
public class AuthenticationController {

  private final AuthenticationService service;

  @PostMapping("/register")
  public ResponseEntity<AuthenticationResponse> register(
      @RequestBody RegisterRequest request
  ) {
    return ResponseEntity.ok(service.register(request));
  }
  @PostMapping("/authenticate")
  public ResponseEntity<AuthenticationResponse> authenticate(
      @RequestBody AuthenticationRequest request
  ) {
    return ResponseEntity.ok(service.authenticate(request));
  }
}

@Component
@RequiredArgsConstructor
public class JwtAuthenticationFilter extends OncePerRequestFilter {

  private final JwtService jwtService;
  private final UserDetailsService userDetailsService;

  @Override
  protected void doFilterInternal(
      @NonNull HttpServletRequest request,
      @NonNull HttpServletResponse response,
      @NonNull FilterChain filterChain
  ) throws ServletException, IOException {
    final String authHeader = request.getHeader("Authorization");
    final String jwt;
    final String userEmail;
    if (authHeader == null ||!authHeader.startsWith("Bearer ")) {
      filterChain.doFilter(request, response);
      return;
    }
    jwt = authHeader.substring(7);
    userEmail = jwtService.extractUsername(jwt);
    if (userEmail != null && SecurityContextHolder.getContext().getAuthentication() == null) {
      UserDetails userDetails = this.userDetailsService.loadUserByUsername(userEmail);
      if (jwtService.isTokenValid(jwt, userDetails)) {
        UsernamePasswordAuthenticationToken authToken = new UsernamePasswordAuthenticationToken(
            userDetails,
            null,
            userDetails.getAuthorities()
        );
        authToken.setDetails(
            new WebAuthenticationDetailsSource().buildDetails(request)
        );
        SecurityContextHolder.getContext().setAuthentication(authToken);
      }
    }
    filterChain.doFilter(request, response);
  }
}

@Configuration
@RequiredArgsConstructor
public class ApplicationConfig {

  private final CustomerRepository repository;

  @Bean
  public UserDetailsService userDetailsService() {
    return username -> repository.findByEmail(username)
        .orElseThrow(() -> new UsernameNotFoundException("User not found"));
  }

  @Bean
  public AuthenticationProvider authenticationProvider() {
    DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
    authProvider.setUserDetailsService(userDetailsService());
    authProvider.setPasswordEncoder(passwordEncoder());
    return authProvider;
  }

  @Bean
  public AuthenticationManager authenticationManager(AuthenticationConfiguration config) throws Exception {
    return config.getAuthenticationManager();
  }

  @Bean
  public PasswordEncoder passwordEncoder() {
    return new BCryptPasswordEncoder();
  }

}

I want to register and then login. I want to access some controllers based on role.


text:
Q: creating a GWT ValueProxy and sending to a service method I want to call a method on a Service with a ValueProxy param - if I do personProxy.setName("test") and then request.callFn(personProxy).fire(), the name property doesn't get passed to server.
Should I do a request.edit(personProxy) before setting the name or something else?
This is the implementation I'm using:
//somewhere in MyActivity.java ...
PersonProxy cp = requestFactory.myRequest().create(PersonProxy.class);
cp.setName("John Doe");
requestFactory.myRequest().doSomething(cp,"extra_param_value").fire(new Receiver<List<PersonProxy>>() {

    @Override
    public void onSuccess(List<PersonProxy> response) {
        //response from server...
    }

});

//------------------------
public interface MyRequestFactory extends RequestFactory {
    MyRequest myRequest();
}

//------------------------
@ServiceName(value="com.server.MyService", locator="com.server.MyServiceLocator")
public interface MyRequest extends RequestContext {
    public Request<Integer> doSomething(PersonProxy param, String extraParam);
}

//------------------------
public class MyServiceLocator implements ServiceLocator {

    public Object getInstance(Class<?> clazz) {
        return new MyService();
    }

}

//------------------------
public class MyService {
    public Integer doSomething(Person param, String extraParam) {
            System.out.println("person.name="+param.getName()); ---> prints NULL!!! why?
            return 0;
        }
}

//------------------------
@ProxyForName(value="com.server.Person")
public interface PersonProxy extends ValueProxy {
    String getName();
    void setName(String name);
}

//-----------------------
public class Person {
    public Person() {
        super();
    }

    protected String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

Thanks.

A: The PersonProxy is being created by one instance of a RequestContext and used in another.  Turns out there's a bug in AbstractRequestContext.retainArg() that should have thrown an exception to tell you about the API mis-use.  Editable proxies aren't supposed to be usable between different RequestContext instances.
TreeRequest ctx = factory.treeRequest();
PersonProxy person = ctx.create(PersonProxy.class);
person.setName("John Doe");
ctx.doSomething(person, "more stuff");

As discussed on IRC, the -Dgwt.rpc.dumpPayload=true JVM flag can be turned on when trying to diagnose where data is going (or isn't).


text:
Q: incorrect values change (plugin gauge.js) My Gauge is made using the plugin "gauge.js" http://bernii.github.io/gauge.js/
http://jsfiddle.net/aYqPT/42/
var opts2 = {
      lines: 1, // The number of lines to draw
      angle: 0, // The length of each line
      lineWidth: 0.15, // The line thickness
      pointer: {
        length: 0.9, // The radius of the inner circle
        strokeWidth: 0.042, // The rotation offset
        color: '#000000' // Fill color
      },
      colorStart: '#6b6b6b',   // Colors
      colorStop: '#E0E0E0',    // just experiment with them
      strokeColor: '#EEEEEE',   // to see which ones work best for you
      generateGradient: true
    };
    var target2 = document.getElementById('gauge2'); // your canvas element
    var gauge2 = new Gauge(target2).setOptions(opts2); // create gauge!
    gauge2.maxValue = 3000; // set max gauge value
    gauge2.animationSpeed = 32; // set animation speed (32 is default value)
    //gauge2.set(700); // set actual value

function getValue() {
   gauge2.set(1900);
}
setInterval(getValue, 2000);

Required to Gauge smoothly change from the previous value to the next.
How to make correct change value? For example, as is
http://jsfiddle.net/gliljas/gsmAL/
Thanks!


text:
Q: Inner Join along with left Join I have 4 tables as described below:
auth_user_profiles ( Table which contains user details )
CREATE TABLE IF NOT EXISTS `auth_user_profiles` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `first_name` varchar(255) NOT NULL,
  `last_name` varchar(255) NOT NULL,
  `birthdate` int(11) NOT NULL,
  `relationship` smallint(6) NOT NULL COMMENT '1-single 2-married 3-Engaged 4- Separated 5- Divorced 6-Other',
  `address` varchar(255) NOT NULL,
  `city` varchar(50) NOT NULL,
  `zipcode` int(11) NOT NULL,
  `phone_no` char(12) NOT NULL,
  `country` int(11) NOT NULL,
  `work` varchar(255) NOT NULL,
  `registeredip` char(15) NOT NULL,
  `registerdate` int(11) NOT NULL,
  `profileimage` varchar(200) NOT NULL DEFAULT 'default',
  `gender` smallint(6) NOT NULL,
  `profession` varchar(50) NOT NULL,
  `aboutme` varchar(250) NOT NULL,
  `referral_balance` decimal(10,2) NOT NULL,
  `website` varchar(255) DEFAULT NULL,
  `google_open_id` varchar(256) DEFAULT NULL,
  `yahoo_open_id` varchar(256) DEFAULT NULL,
  `facebook_id` varchar(256) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=22 ;

INSERT INTO `auth_user_profiles` (`id`, `user_id`, `first_name`, `last_name`, `birthdate`, `relationship`, `address`, `city`, `zipcode`, `phone_no`, `country`, `work`, `registeredip`, `registerdate`, `profileimage`, `gender`, `profession`, `aboutme`, `referral_balance`, `website`, `google_open_id`, `yahoo_open_id`, `facebook_id`) VALUES
(1, 1, 'dfdfa', 'ddfm', 638649000, 1, 'fghfllgdfg', 'kdddd', 9887888, '25896589518', 67, 'NNNooo', '127.0.0.1', 1393409056, 'cind.jpg', 1, '', 'sssssssppp', 34.03, NULL, 'https://www.google.com/accounts/o8/id?id=AItOawlUhpWgJhYxjlgg8UjhsKR0u40IvYQrGZ0', 'https://me.yahoo.com/a/Yl_iKDxqkIJIvZ7y5KHTBdkNDw2L#79ed5', NULL),
(2, 2, 'Kichu', 'K', 0, 0, '', '', 0, '8958698565', 20, '', '127.0.0.1', 1394014161, 'default', 0, '', '', 0.00, NULL, NULL, NULL, NULL);

video ( Table which stores video details )
CREATE TABLE IF NOT EXISTS `video` (
  `videoid` int(11) NOT NULL AUTO_INCREMENT,
  `videocode` varchar(20) NOT NULL,
  `title` varchar(250) NOT NULL,
  `videotype` smallint(6) NOT NULL COMMENT '0-main or 1-trailer',
  `category` int(11) NOT NULL,
  `length` int(11) NOT NULL,
  `associatedvideo` int(11) NOT NULL COMMENT 'trailer link',
  `videolink` varchar(255) NOT NULL,
  `videothumbnail` varchar(250) NOT NULL,
  `uploaderid` int(11) NOT NULL,
  `description` text NOT NULL,
  `views` int(11) NOT NULL,
  `likes` int(11) NOT NULL,
  `dislikes` int(11) NOT NULL,
  `permission` smallint(6) NOT NULL COMMENT '0-pending 1-approved 2-rejected',
  `genre` int(11) NOT NULL,
  `language` int(11) NOT NULL,
  `keywords` varchar(256) NOT NULL,
  `ticket_price` varchar(50) NOT NULL,
  `added_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`videoid`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

INSERT INTO `video` (`videoid`, `videocode`, `title`, `videotype`, `category`, `length`, `associatedvideo`, `videolink`, `videothumbnail`, `uploaderid`, `description`, `views`, `likes`, `dislikes`, `permission`, `genre`, `language`, `keywords`, `ticket_price`, `added_on`) VALUES
(1, '', 'Video 1', 0, 0, 10, 0, 'teamwork.mp4', 'images (1).jpg', 1, 'The first video uploaded.', 0, 0, 0, 1, 11, 2, 'cartoon', '', '2014-04-28 12:16:31'),
(2, '', 'dddddd', 0, 0, 10, 0, 'video.mp4', 'images (6).jpg', 1, 'vc fdsdf sdfsdf dfgdf sdfd ghg.', 0, 0, 0, 1, 6, 2, 'dfgfdg sd fsdf', '', '2014-04-28 12:46:17'),
(3, '', 'asdasfsd', 0, 0, 10, 5, 'video.mp4', 'images_(6).jpg', 1, 'dg', 282, 1, 0, 1, 5, 2, 'tdgfg', '11.2', '2014-04-28 12:54:17'),
(4, '', 'asedas sfgv', 0, 0, 66, 0, 'teamwork.mp4', 'images (8).jpg', 1, 'hdgh xdg fg dfgdf', 11, 0, 0, 1, 11, 2, 'video ', '', '2014-04-28 13:00:46'),
(5, '', 'sdfftgesgsdfgsd', 1, 0, 33, 3, 'test.mkv', 'images (2).jpg', 0, 'fgdfg', 242, 0, 0, 1, 5, 2, 'fdgdfg,video', '12.99', '2014-04-29 06:18:32');

ticket ( Table which stores ticket details for videos )
CREATE TABLE IF NOT EXISTS `ticket` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `video_id` int(11) NOT NULL,
  `ticket_key` varchar(100) NOT NULL,
  `attempt` smallint(6) NOT NULL,
  `generated_on` int(11) NOT NULL,
  `status` smallint(6) NOT NULL COMMENT '0-new 1-expired',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;

INSERT INTO `ticket` (`id`, `user_id`, `video_id`, `ticket_key`, `attempt`, `generated_on`, `status`) VALUES
(1, 1, 5, '0b9d4d5aee', 0, 1399262972, 0),
(2, 1, 5, '1f5de2cde3', 0, 1399263032, 0),
(3, 1, 5, 'ba2376bb21', 0, 1399263036, 0),
(4, 1, 2, 'd571360f37', 0, 1399267971, 0),
(5, 1, 5, '99d98364e4', 0, 1399276280, 0),
(6, 1, 5, '290486a5f5', 1, 1399281061, 0),
(7, 1, 5, 'cccc1c72ab', 1, 1399281148, 0);

sendticket ( Table which stores details when ticket is gifted to a friend)
CREATE TABLE IF NOT EXISTS `sendticket` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `ticketid` int(11) NOT NULL,
  `sendby_id` int(11) NOT NULL,
  `sendto_id` varchar(60) NOT NULL,
  `send_on` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

INSERT INTO `sendticket` (`id`, `ticketid`, `sendby_id`, `sendto_id`, `send_on`) VALUES
(1, 2, 1, '10', 1399276280),
(2, 4, 2, 'sdasd@fjjgf.com', 1399276280);

What I need is to get the details of tickets which are gifted to me. I am using the following query but even if I don't have any tickets received, it is returning records.
$userid=1;

$query=$this->db->query("select s.send_on,s.sendby_id,t.ticket_key,t.video_id,a.first_name,a.last_name,v.title,v.videothumbnail from sendticket as s LEFT JOIN ticket as t ON s.ticketid=t.id
        LEFT JOIN auth_user_profiles as a ON a.user_id=s.sendby_id LEFT JOIN video as v ON t.video_id=v.videoid and s.sendto_id=$userid order by s.send_on desc");

Here what I expect is to get the ticket details, video details for which the ticket was purchased and the details of user who have gifted me the ticket which is sendby_id in sendticket table. Currently I don't have any gifted tickets, so it should return null records. But instead it is now returning records which doesn't match with my requirement.
I know that left join won't work in this case. I tried with INNER JOIN along with LEFT JOIN. But it didn't worked. Can anyone help me to fix this issue? Thanks in advance.

A: You are filtering your records by using ON() clause (and s.sendto_id=$userid) this will filter records only for the table i.e is in right position it will not filter the whole result set,the result you are getting is due to you are using LEFT join,for your concern result set you need to use the WHERE clause
SELECT
  s.send_on,
  s.sendby_id,
  t.ticket_key,
  t.video_id,
  a.first_name,
  a.last_name,
  v.title,
  v.videothumbnail ,
  s.sendto_id
FROM
  sendticket AS s
  LEFT JOIN ticket AS t
    ON s.ticketid = t.id
  LEFT JOIN auth_user_profiles AS a
    ON a.user_id = s.sendby_id
  LEFT JOIN video AS v
    ON t.video_id = v.videoid
    WHERE s.sendto_id = 1
ORDER BY s.send_on DESC

So if i check for s.sendto_id = 1 there are not sent tickets for id 1 but if you want to test for existing tickets you can try using s.sendto_id = 10

one thing is confusing regarding your table structure for sendticket ,i saw values in column sendto_id i.e(10 ,sdasd@fjjgf.com) you are saving emails and ids which i guess is not a good idea ,also if you are getting the user ids from request then i recommend you to use codeigniter's Active record library

Edit from comments

I want to get the tickets which are purchased by me and not yet gifted
  to any other and also those tickets that are gifted to me in a single
  query

Below are the two ways but both solution uses UNION
Solution 1 with NOT EXISTS
The first query is simply getting the tickets which are purchased by user whose id is 1 and no records from sendticket where sendby_id is from same user the query after union is giving those tickets which are gifted to this user
SELECT * FROM `ticket` t
WHERE NOT EXISTS (
SELECT 1 FROM `sendticket` s
    WHERE  s.`ticketid` = t.`id`
    AND  s.`sendby_id` =1
)
AND  t.user_id =1
UNION
SELECT t.* FROM `ticket` t
JOIN sendticket s ON(s.`ticketid` = t.`id`)
WHERE s.`sendto_id` =1

Solution 2 using joins only
SELECT t.* FROM `ticket` t
LEFT JOIN sendticket s ON(s.`ticketid` = t.`id` AND s.`sendby_id` =1)
WHERE s.`sendby_id` IS NULL AND  t.user_id =1
UNION
SELECT t.* FROM `ticket` t
JOIN sendticket s ON(s.`ticketid` = t.`id`)
WHERE s.`sendto_id` =1