text:
Q: How to remove all FIFO files with a shell command I can't find a shell command to remove all the FIFO files inside a directory. In fact, for the removal of directories, the rm command offers the options -d, --dir, but for FIFOs it offers no option.
For now, the only workaround found is to call the FIFO like foo.fifo so that it is easy to remove them with rm *.fifo.

A: To delete all FIFOs in the current directory and all sub-folders use
find . -type p -delete

To delete FIFOs only in the current directory use
find .  -maxdepth 1 -type p -delete

A: shell only for current directory...
set -- ./*
for f do
    [ -p "$f" ] && rm "$f"
done

A: Try this:
find -maxdepth 1 -type p -exec rm {} \;

Manpage of find:
-type c
      File is of type c:

      p      named pipe (FIFO)


text:
Q: Auctex: bug in LaTeX-mark-environment? Before I send this on to the developers, I'd like to know if others can confirm this problem. Consider these two environments:
\begin{flalign*}
sdfsdf
\end{flalign*}

\begin{flalign*}
   && A \rightarrow \End_{B}(M) && {; B=\End_{A}(M)}
\end{flalign*}

If I set the cursor in the first one and execute LaTeX-mark-environment (C-c .), then I get the expected result, i.e. marked the flalign* environment, including the \begin/end lines.
However if I do the same in the other one, it never covers the env. What ever is marked depends on where the cursor is. It is clearly having an issue with the \End, presumably because it is ignoring case.
Can others confirm?
(LaTeX-mark-environment together with narrow-to-region is a really nice feature to have when writing macros).

A: The problem is that the LaTeX-find-matching-end performs case insensitive searches.  To make the search for the \end case sensitive, you have to bind the case-fold-search variable to nil.  To do that you can advice the LaTeX-find-matching-end function.  This will fix your problem but won't work if there is an \end inside the environment (think about a verbatim environment).
(defadvice LaTeX-find-matching-end
  (around LaTeX-find-matching-end-case-sensitive activate)
  "Perform case-sensitive search."
  (let ((case-fold-search nil))
    ad-do-it))

PS development version of AUCTeX has a new function to narrow to an environment (LaTeX-narrow-to-environment), so you'll need a single key binding (C-x n e) instead of C-c . C-x n r

(daleif addition), one also need to change add to LaTeX-find-matching-begin:
(defadvice LaTeX-find-matching-begin
  (around LaTeX-find-matching-begin-case-sensitive activate)
  "Perform case-sensitive search."
  (let ((case-fold-search nil))
   ad-do-it))

redpajama_set_name: RedPajamaStackExchange


text:
Q: Optional in builder pattern, get() I'm working on a backend for a web application in Java (using Spring) und try to use the builder pattern.
I have the classes

*

*Example (as a Data object)

*ExampleDocument (as another Data object)

*ExampleMapper

*ExampleRepository (extends MongoRepository)

*ExampleController(REST)

*ExampleService

Now I have a problem with a function returning an Optional (findById, Mongo-Repo) to my service:
@Service
@RequiredArgsConstructor
public class ExampleService {

    private final ExampleMapper exampleMapper;
    private final ExampleRepository exampleRepository;

    public Example getExample(String exampleId) {
        Optional<ExampleDocument> document = exampleRepository.findById(exampleId);
        return exampleMapper.mapToDto(document);
    }

I want to map the document in my mapper class as I'm used to do it with other documents (without the Optional it looks like this, I took an example from another class:
@Component
public class OtherExampleMapper {

    public OtherExample mapToDto(OtherExampleDocument document) {
        return OtherExample.builder()
                .id(document.getId())
                .existingSolutions(document.getExistingSolutions())
                ...
                .build();
    }

)
I tried to use ifPresent, but the builderPattern seems not to recognize the expression, since I have a yellow mark on "getId()", telling me "Result of 'PitchEventDocument.getId()' is ignored" and a red mark on ".build()"
@Component
public class PitchEventMapper {
public Example mapToDto(Optional<ExampleDocument> document) {
        return Example.builder()
                .id(document.ifPresent(id -> document.get().getId())
                .build();
    }

How can I still use the builder pattern in combination with the Optional?

A: Your basic problem is that ifPresent doesn't return a value at all—it's void. Instead, you want orElse (since I think you want null or another default value in that case), and you shouldn't use get—all the relevant "if" and "or" methods already unwrap the value for you.
Instead:
Example.builder()
  .id(document.map(Document::getId).orElse(null))
  .build()


text:
Q: EnvCommandError when Poetry installing dependencies I'm having the following issue when trying to install the dependencies of my project with poetry:
ERROR: pywin32-301-cp38-cp38-win32.whl is not a supported wheel on this platform.
ERROR: pyrsistent-0.18.0-cp38-cp38-win32.whl is not a supported wheel on this platform.
my python version is 3.8 (64bit)
I don't know why is trying to install 32bit whl...
thanks!


text:
Q: Speed up multilple matrix products with numpy In python I have 2 three dimensional arrays:
T with size (n,n,n)
U with size (k,n,n)
T and U can be seen as many 2-D arrays one next to the other. I need to multiply all those matrices, ie I have to perform the following operation:
for i in range(n):
        H[:,:,i] =  U[:,:,i].dot(T[:,:,i]).dot(U[:,:,i].T)

As n might be very big I am wondering if this operation could be in some way speed up with numpy.

A: Carefully looking into the iterators and how they are involved in those dot product reductions, we could translate all of those into one np.einsum implementation like so -
H = np.einsum('ijk,jlk,mlk->imk',U,T,U)


text:
Q: How to add default value in an existing table in sql server I am trying to add default value to an existing table, but it is not working at all. I am expecting to see 'NO' when I add data in my table but it is not happening. I am not sure what is going on or if my syntax is wrong here. Please help. Thanks
ALTER TABLE [myTable]
ADD  CONSTRAINT [DF_myTable_FLAG]  DEFAULT ('NO') FOR [FLAG]

The datatype for this column is varchar.

A: Only new records will get the default.
Test this:
CREATE TABLE #TEST(NAME VARCHAR(5), FLAG VARCHAR(3))
INSERT INTO #TEST (NAME) SELECT 'DAVE'
ALTER TABLE #TEST ADD  CONSTRAINT [DF_TEST_FLAG]  DEFAULT ('NO') FOR [FLAG]
INSERT INTO #TEST (NAME) SELECT 'MOE'

SELECT * FROM #TEST

Old records must be manually updated.


text:
Q: Linq to MySql GetTable I am trying to insert/add a data into my Database but it seems that this part of code won't work The name of the table that I am trying to add data on is "People"
Table<People> users = myDb.GetTable<People>;

Has an error on the Table<People> users why is this error occurring?? how would I fix this?
just in case you need the stack trace, here it is.

Error 1
  The type or namespace name 'Table' could not be found (are you missing a using directive or an assembly
  reference?)
  C:\Users\John\documents\visual studio 2010\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs    23  13  WindowsFormsApplication1

A: You need to add
using System.Data.Linq;

to the top of your file to bring the Table class into scope. Alternatively you could use:
var users = myDb.GetTable<People>();


text:
Q: Unable to import tables and data from .dmp file from S3 to AWS RDS I am trying to import data from .dmp file from AWS S3 to my RDS instance Oracle DB.
I am able to download the file from S3 to my oracle directory DATA_PUMP_DIR.
I am able to run the below script and able to view the dump file here.
SELECT * FROM TABLE (RDSADMIN.RDS_FILE_UTIL.LISTDIR(p_directory => 'DATA_PUMP_DIR'));

But when I try to import the data from this dump file I am getting error saying invalid arguments. What needs to be done?
The command I have used:
DECLARE
  hdnl NUMBER;
BEGIN
  hdnl := DBMS_DATAPUMP.OPEN(
    operation => 'IMPORT',
    job_mode  => 'FULL',
    job_name  => null);
  DBMS_DATAPUMP.ADD_FILE(
    handle    => hdnl,
    filename  => 'testDump.dmp',
    directory => 'DATA_PUMP_DIR',
    filetype  => dbms_datapump.ku$_file_type_dump_file,
    reusefile => 1
   );
  DBMS_DATAPUMP.ADD_FILE(
    handle    => hdnl,
    filename  => 'testDump.log',
    directory => 'DATA_PUMP_DIR',
    filetype  => dbms_datapump.ku$_file_type_log_file);
  DBMS_DATAPUMP.METADATA_FILTER(hdnl,'SCHEMA_EXPR','IN (''Test_SCHEMA'')');
  DBMS_DATAPUMP.START_JOB(hdnl);
END;

A: AWS Importing using Oracle Data Pump

When you use Oracle Data Pump to import data into an Oracle DB
instance, we recommend the following best practices:
Perform imports in schema or table mode to import specific schemas and
objects.
Limit the schemas you import to those required by your application.
Don't import in full mode.
Because Amazon RDS for Oracle does not allow access to SYS or SYSDBA
administrative users, importing in full mode, or importing schemas for
Oracle-maintained components, might damage the Oracle data dictionary
and affect the stability of your database.

DECLARE
  hdnl NUMBER;
BEGIN
  hdnl := DBMS_DATAPUMP.OPEN(
    operation => 'IMPORT',
    job_mode  => 'SCHEMA',
    job_name  => null);
  DBMS_DATAPUMP.ADD_FILE(
    handle    => hdnl,
    filename  => 'testDump.dmp',
    directory => 'DATA_PUMP_DIR',
    filetype  => dbms_datapump.ku$_file_type_dump_file);
  DBMS_DATAPUMP.ADD_FILE(
    handle    => hdnl,
    filename  => 'testDump.log',
    directory => 'DATA_PUMP_DIR',
    filetype  => dbms_datapump.ku$_file_type_log_file);
  DBMS_DATAPUMP.METADATA_FILTER(hdnl,'SCHEMA_EXPR','IN (''Test_SCHEMA'')');
  DBMS_DATAPUMP.START_JOB(hdnl);
END;


text:
Q: Plot two columns of a different matrix on the same graph based on a different matrix using cex I have a question that my title probably hinted at but giving the example will probably be easier. I am working on the lines of codes given by Borcard et al. 2011 with the distribution of fish. There is a matrix of geographical coordinate (x,y) of sites (spa), a matrix of fish species abundance at these sites (spe) and a matrix of environmental factors (env).
One way to represent the fish distribution according to the sites is to use the following code:
windows(title="Species Locations", 9, 9)
par(mfrow=c(2,2))
plot(spa, asp=1, col="brown", cex=spe$TRU, main="Brown trout",
xlab="x coordinate (km)", ylab="y coordinate (km)")
lines(spa, col="light blue")
plot(spa, asp=1, col="brown", cex=spe$OMB, main="Grayling",
xlab="x coordinate (km)", ylab="y coordinate (km)")
lines(spa, col="light blue")

etc...
However, this plots 2 different graphs for the OMB and TRU species.
How is it possible to obtain the same graph, but with both the OMB and TRU species on the same graph, still using cex but to get circles of different colors for the two species?
This would help a lot!
Thanks by advance,

A: I think you want (something like)
plot(spa, asp = 1, type = "n", main = "Brown trout",
     xlab = "x coordinate (km)", ylab = "y coordinate (km)")
lines(spa, col="light blue")
points(spa, col = "brown", cex = spe$TRU)
points(spa, col = "green", cex = spe$OMB)
legend("topright", legend = c("Brown Trout", "Grayling"),
       col = c("brown","green"), pch = 1, bty = "n")

The main idea here is to just add the data points sequentially with points() calls, just as lines() was used to add lines to each plot after the data were drawn (note here I draw them in the background to avoid overplotting the data).
There is one clear issue with what you want to do however; the two points() calls are essentially plotting data in the same locations on the plot and hence you may run into issues with one set of data overplotting the one for the other species.
If you want to have many species (not just two) on the same figure (multiple plots like their example), then I would suggest switching to lattice or ggplot2 to do the plotting, but you'd need to massage the data a bit first. If you care to update your question with the code needed to get the data for Borcard et al's example then I will update my answer with such an example. I feel this would be a better way of showing this data than overlaying two or more species on the same real estate.


text:
Q: Can't parse JSON string returned because it adds the data type to the JSON string I have a basic AJAX function that calls a PHP script and the script returns a perfect JSON string, I have checked it.
Here's what the AJAX code looks like:
function onLoad() {
    $.ajax({
        url: "php/api.php",
        data: {symbol: "MSFT"},
        async: true,
        dataType: 'text',
        contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
        success:  function (data) {
            console.log("data is: ");
            console.log(JSON.parse(data));
            },
            error: function (xhr, ajaxOptions, thrownError) {
                console.log("There was an error");
                console.log(thrownError);
            }
    });
}

Here is what the php code looks like:
<?php

error_reporting(0);

$symbol =$_GET['symbol'];

$data = array("year" => 2018);
$data_string = json_encode($data);

function grabHTML($function_host_name, $url)
{

$ch = curl_init();
$header=array('GET /1575051 HTTP/1.1',
    "Host: $function_host_name",
    'Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
    'Accept-Language:en-US,en;q=0.8',
    'Cache-Control:max-age=0',
    'Connection:keep-alive',
    'User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36',
    );

    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, 300);
    curl_setopt( $ch, CURLOPT_COOKIESESSION, true );

    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

    curl_setopt($ch,CURLOPT_COOKIEFILE,'cookies.txt');
    curl_setopt($ch,CURLOPT_COOKIEJAR,'cookies.txt');
    curl_setopt($ch,CURLOPT_HTTPHEADER,$header);

    curl_setopt($ch, CURLOPT_VERBOSE, true);
    curl_setopt($ch, CURLOPT_STDERR,$f = fopen(__DIR__ . "/error.log", "w+"));

    $returnHTML = curl_exec($ch);

if($errno = curl_errno($ch)) {
    $error_message = curl_strerror($errno);
    echo "cURL error ({$errno}):\n {$error_message}";
}
   curl_close($ch);
    return $returnHTML;

} // end of function grabHTML

$url = "https://newsapi.org/v2/everything?q=" . $symbol . "&from=2018-10-29&sortBy=publishedAt&apiKey=0cc1ee750c69497899f81b14d32dfbf9";

$results = grabHTML("newsapi.org", $url);

echo $results;

However, at the front end, the data type gets pre-pended to the JSON string, i.e.
string(17484) " (perfect JSON string here) "

So another " gets appended to the end of the data. This crashes the JSON.parse() function.
I have tried all  "dataType: 'text'", "dataType: 'html'", and "dataType:
'json'" and it still adds the data type every time.
I need to stop it from adding the data type.
Brent.

A: The solution was to set
    curl_setopt($ch, CURLOPT_VERBOSE, false);
In the PHP script.


text:
Q: How do you make responsive logos that change completely when the screensize changes? I was quite amazed at Responsive Logos, when you resize the browser the image width doesn't just say 100% but the image itself changes. It's not a font. I think its a svg image, but how Im dont exactly sure how he managed to make the image change. Is it via the CSS at the bottom of the source code:
@media only screen and (min-width: 15em) {
    .logo1, .logo2, .logo3, .logo4, .logo5, .logo6, .logo7, .logo8 {background-position: left -900px;}
}

@media only screen and (min-width: 28em) {
    .logo1, .logo2, .logo3, .logo4, .logo5, .logo6, .logo7, .logo8 {background-position: left -600px;}
}

@media only screen and (min-width: 45em){
    .logo1, .logo2, .logo3, .logo4, .logo5, .logo6, .logo7, .logo8 {background-position: left -300px;}
}

@media only screen and (min-width: 60em){
    .logo1, .logo2, .logo3, .logo4, .logo5, .logo6, .logo7, .logo8 {background-position: left 0px;}
 }

Thanks in advance for your helps!

A: The background image is an image sprite.
The sprite includes several versions of the logo, each at a different position. background-position is used to horizontally shift the image by 0px, 300px, 600px, or 900px to select the desired logo.


text:
Q: Animations are choppy and jerky after a day (Mountain Lion) After my 13" MacBook Pro (2010) has been on/sleeping for a day, the changing desktop animation and mission control gets choppy. Only a reboot fixes this problem and it stays good for several hours. I've already reset the SMC but it didn't work.
I have 8GB RAM and 4GB is always free.
How can I fix this problem?

A: You will need to figure out what is causing a processing bottleneck on the Mac.
You'll need some understudying of basics like being able to tell if the virtual memory system is swapping (vm_stat 5 will show paging when you reproduce the issue) as well as Activity Monitor to see what the overall RAM and disk IO are as well as look for processes that are not responding or taking a lot of CPU time.
The fact that a reboot cures things shows that it's not a hardware issue or a software conflict, but instead a resource issue. Experience in doing this leads me to guess you either have some apps that have memory leaks and once the system starts swapping, you have enough CPU busy things that on occasion that slows the GPU / graphics subsystem.
You could also try quitting all apps when you notice the slowness and then just starting one or two apps to see if that resolves things. It seems odd that you always have 4 GB free, since I would expect you to reach a state over time where almost all the "free" memory converts to inactive to cache things that were used, but now out of active memory use.

Hopefully this process helps you find the culprit since there isn't enough detail to guess what's really happening. Good luck hunting this down.


text:
Q: Change Color of Background Input Field For Autofill Values I currently have a Rails 4 application running bootstrap-sass for Bootstrap 2.  I use localhost for my testing.  I have applications with a login screen.  The input fields are white with a really thin gray border with blue text.  When I type in the fields the background of the input fields are white with blue text.  However when I go to the login screen where I have saved my login information the information fills up the fields but changes the background of both fields to yellow with the text black.  One is text-field and the other is password-field.
I would like the information to fill in using the css I have defined in the view.  Is there a way I can do this with CSS?  I have not found anything with this specific issue.
Any help would be appreciated.  I will continue searching.
UPDATE 3/28/2014 9:15 am CDT
I successfully implemented the solution from the link that was suggested by Martin to change the background color for autofill.  I decided to guess and did a search on webkit font color text and found the solution to change the font color for autofill.
Here is my solution:
input:-webkit-autofill {
  -webkit-text-fill-color: $textColor;
  -webkit-box-shadow: 0 0 0px 1000px white inset;
}
input:-moz-autofill {
  -moz-text-fill-color: $textColor;
  -moz-box-shadow: 0 0 0px 1000px white inset;
}
input:-o-autofill {
  -o-text-fill-color: $textColor;
  -o-box-shadow: 0 0 0px 1000px white inset;
}
input:-khtml-autofill {
  -khtml-text-fill-color: $textColor;
  -khtml-box-shadow: 0 0 0px 1000px white inset;
}

A: I had to extend your solution to address the input fields on :focus as well. This code currently works for my needs:
input:-webkit-autofill {
    -webkit-text-fill-color: $black;
    -webkit-box-shadow: 0 0 0px 1000px white inset;
}
input:-moz-autofill {
    -moz-text-fill-color: $black;
    -moz-box-shadow: 0 0 0px 1000px white inset;
}
input:-o-autofill {
    -o-text-fill-color: $black;
    -o-box-shadow: 0 0 0px 1000px white inset;
}
input:-khtml-autofill {
    -khtml-text-fill-color: $black;
    -khtml-box-shadow: 0 0 0px 1000px white inset;
}

input:focus:-webkit-autofill {
    -webkit-text-fill-color: $black;
    -webkit-box-shadow: 0 0 0px 1000px white inset;
}
input:focus:-moz-autofill {
    -moz-text-fill-color: $black;
    -moz-box-shadow: 0 0 0px 1000px white inset;
}
input:focus:-o-autofill {
    -o-text-fill-color: $black;
    -o-box-shadow: 0 0 0px 1000px white inset;
}
input:focus:-khtml-autofill {
    -khtml-text-fill-color: $black;
    -khtml-box-shadow: 0 0 0px 1000px white inset;
}


text:
Q: How to populate WPF window from database I want to auto load some data from database to populate some text boxes and combo boxes when a new window is loaded.
For example when I click a button in window1, window1 will show a new window window2 and pass an ID to window2 (id is required for querying database).
How can i do that?
Thanks,

A: Use Entity Framework.
Follow below tutorials..
http://blogs.msdn.com/b/wriju/archive/2010/06/09/ado-net-entity-framework-4-0-loading-data-in-4-ways.aspx
https://msdn.microsoft.com/en-us/library/aa697427(v=vs.80).aspx

A: This is just a very simple example of what you can do:
MainWindow.xaml
<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Button Name="btn1" Click="btn1_Click" Content="Button" Margin="10,10,361,283"></Button>
    </Grid>
</Window>

MainWindow.xaml.cs
  private void btn1_Click(object sender, RoutedEventArgs e)
        {
            Window2 win2 = new Window2(1);
            win2.Show();
        }

Window2.xaml
<Window x:Class="WpfApplication1.Window2"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window2" Height="300" Width="300">
    <Grid Margin="0,0,170,249">
        <TextBox Name="txtBox1" Margin="18,160,-18,-173"></TextBox>
        <TextBox Name="txtBox2" Margin="18,119,-18,-134"></TextBox>
        <TextBox Name="txtBox3" Margin="18,76,-18,-93"></TextBox>
        <TextBox Name="txtBox4" Margin="18,36,-18,-50"></TextBox>
    </Grid>
</Window>

Window2.xaml.cs
public partial class Window2 : Window
    {
        public Window2(int Id)
        {
            InitializeComponent();
            ReadDataFromDB(Id);
        }

        public void ReadDataFromDB(int Id)
        {

            //read your data
            txtBox1.Text = "Some value 1";
            txtBox2.Text = "Some value 2";
            txtBox3.Text = "Some value 3";
            txtBox4.Text = "Some value 4";
        }
    }

A:
1)Create ui elements in the window
2)Create a model class with the required fields.
3)While clicking the
   button in window1 pass the id to the constructor of the next window.
4).Using the id query the database based on your need.Get the results
  and bind the fields to the ui elements values.
5).These database querying and all can be written inside your
  constructor or window load event.

You can accomplish this using MVVM.No need to write excess code for setting the values to the ui.


text:
Q: ORA-01722: invalid number for Number datatype in oracle I am trying to insert a value in KPI_DEFINITION table and i am getting amn error ORA-01722: invalid number. The error is for KPI_FREQUENCY field which NUMBER datatype and it has trying to insert value '0,5'. I think number datatype allows integer as well as float values. But still its giving an error.
Insert into RATOR_MONITORING_CONFIGURATION.KPI_DEFINITION (KPI_DEF_ID,KPI_NAME,KPI_DESC,KPI_FREQUENCY) values ('10003881','Backlog Resul11t','Backlog Result11','0,5');

A: In SQL numbers are not specified using single quotes.
Additionally: fractional digits are separated using a dot . not a comma. So you need to write this as:
Insert into RATOR_MONITORING_CONFIGURATION.KPI_DEFINITION
  (KPI_DEF_ID,KPI_NAME,KPI_DESC,KPI_FREQUENCY)
values
  ('10003881','Backlog Resul11t','Backlog Result11', 0.5);
                                                      ^
                                                      Here

If KPI_DEF_ID is also a number column, remove the single quotes for that value as well:
For a complete documentation on how to specify numbers or string literals, please see the manual:
https://docs.oracle.com/database/121/SQLRF/sql_elements003.htm#i139891

A: Possible data type for KPI_FREQUENCY in your case is number(2,1)
Modification of your insert statement
Insert into  RATOR_MONITORING_CONFIGURATION.KPI_DEFINITION (KPI_DEF_ID,KPI_NAME,KPI_DESC,KPI_FREQUENCY)
    values ('10003881','Backlog Resul11t','Backlog Result11',0.5);


text:
Q: I am doing an if statement with multiples of a number I am doing an exercise, the problem is that my if/else structure does not work properly and I do not know why.
Here is the exercise statement and my code
Your task is to write a function, fizzBuzz, that accepts a number and returns a string:
'fizz' if the number is divisible by 3;
'buzz' if the number is divisible by 5;
'fizzbuzz' if the number is divisible by both 3 and 5.
'{number}' if the number doesn't fulfil any of the above conditions.

function fizzBuzz(number) {

  if (number % 3 === 0) {
    return "fizz"
  };
  if (number % 5 === 0) {
    return "buzz"
  };
  if (number % 3 === 0 && number % 5 === 0) {
    return "fizzbuz"
  };
  else return number
}

A: Try a little mental debugging. Look at your code and run different values through it in your mind:

*

*What happens if you run the value 6 through it?

*What happens if you run the value 10 through it?

*What happens if you run the value 15 through it?

Ask yourself, "How could I fix this?" (hint: order of operations is important).
Something like this would do what you expect:
function fizzBuzz(n) {
  const fizz = n % 3 ? '' : 'fizz' ;
  const buzz = n % 5 ? '' : 'buzz' ;

  return !fizz && !buzz ? '{number}' : `${fizz}${buzz}` ;

}

or this:
function fizzBuzz( n ) {
  let s;

  if ( n % 3 === 0 ) {
    s = 'fizz' ;
    if ( n % 5 === 0 ) {
      s = 'fizzbuzz' ;
    }
  } else if ( n % 5 == 0 ) {
    s = 'buzz' ;
  } else {
    s  = '{number}' ;
  }

  return s;
}

This does [at most] 2 divisions and 2 comparisions.
The former does 2 divisions and 3-4 comparisons, so it is nominally less efficient.
But I know which version I'd rather look at.

A: The problem is, if a number is divisible by 5 and 3 (ex 15) "fizz" would only be returned (as a factor of 3) because every block {...} terminates the function with a return (this technique is called a "short-circuit", which isn't a bad practice). So you need to put the 5 and 3 condition first. Also that condition had an undefined variable called solution so that would've been the first error. One minor thing is that each block {...} was suffixed with a semi-colon: ; which is just bad formatting but it doesn't affect functionality.

function fB(number) {
  if (number % 3 === 0 && number % 5 === 0) {
    return "fizzbizz";
  }
  if (number % 3 === 0) {
    return "fizz";
  }
  if (number % 5 === 0) {
    return "bizz";
  }
  return number;
}

console.log(fB(15));
console.log(fB(575));
console.log(fB(49));
console.log(fB(51));
console.log(fB(80));
console.log(fB(375));
console.log(fB(99));
console.log(fB(Infinity));


text: Q: Extract point data to polygon features I am trying to import data from a point that lies on a certain polygon feature (or raster). As an output I would like the polygon feature to have the point data as a new field in the attribute table. How can this be done in QGIS?


text:
Q: Excel customer data validation for chars and numbers I am trying to validate a combination of char and numbers that looks like this XXXX0000000.
I have tried this formula; =OR((LEFT(B2,3)="XXXX",LEN(B2)=11),AND(LEFT(B2,3)="XXXX",LEN(B2)=11).
The error message I receive is as follows:
excel error message

A: You have two formulas but no joining of them
IE you have an OR formula
=OR((LEFT(B2,3)="XXXX",LEN(B2)=11)
Which will return a true/false answer
You also have an AND formula
=AND(LEFT(B2,3)="XXXX",LEN(B2)=11)
Which will return a true/false answer
when you work through it you are being given a return of:
=True(or false), true (or false)
That isn't a formula and is causing the error output
I think you want to use an IF statement to join them and get an output as desired:
E.g.
=If(OR(LEFT(B2,3)="XXXX",LEN(B2)=11),AND(LEFT(B2,3)="XXXX",LEN(B2)=11), DO SOEMTHING IF TRUE, DO SOMETHING IF FALSE)

A: I suggest this:
OR(LEFT(B2,3)="XXX",LEN(B2)=11,AND(LEFT(B2,3)="XXX",LEN(B2)=11))

It corrects the number of characters error and sorts the logic.

A: Title: "Excel customer data validation for chars and numbers"
...I have the feeling it's not just about validating XXXX0000000 but it's about the pattern of characters and numbers. Therefor try:

Formula in B1:
=IF(ISERROR(FILTERXML("<t><s>"&A1&"</s></t>","//s[translate(substring(.,1,4), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','')=''][string-length()=11][substring(.,5)*0=0]")),"Invalid","Valid")

Where:

*

*//s[translate(substring(.,1,4), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','')=''] - Check if when we translate the first 4 characters to nothing this also equals empty string;

*[string-length()=11] - Check that node is 11 characters long;

*[substring(.,5)*0=0] - Check that substring from 5th position onwards equals zero when multiplied by zero.

Note: FILTERXML() is case sensitive and is currently checking for uppercase alpha-chars.

EDIT:
To use this in data-validation; Ditch the IF() since you don't need that in validation and nest the remainder in NOT():
=NOT(ISERROR(FILTERXML("<t><s>"&A1&"</s></t>","//s[translate(substring(.,1,4), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','')=''][string-length()=11][substring(.,5)*0=0]")))

When you select your range, make sure the validation rule has the topleft cell in the reference.


text:
Q: Python: VTK Distances in a TubeFilter I have the follwoing problem. I want to create a Tube with vtk TubeFilter and want to calculate all distances of the points in the tube to the inner line in order to score them in dependence of their distance to the line. Is that possible with some vtk or other method? (maybe  with implicitPolyDataDistance or vtkDistancePolyDataFilter ?)
Best regards


text:
Q: Android - How can I set an Image in a layout file with code from an adapter class? I am working on an Android project that follows the tutorial at this youtube link:
https://www.youtube.com/watch?v=YCHNAi9kJI4
.
It is an animated listView deletion.
I have an image setup within part of the opaque_text_view.xml file:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/image_text_vew_list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/tv_background_with_divider"
    android:textAppearance="?android:attr/textAppearanceListItemSmall"
    android:gravity="center_vertical"
    android:drawableLeft="@drawable/ic_launcher"   <--------------------------
    android:paddingStart="?android:attr/listPreferredItemPaddingStart"
    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
    android:minHeight="?android:attr/listPreferredItemHeightSmall"
/>

Which comes up perfectly, but, I would like to change the image dynamically so that it will adjust with gmail-like icons that reflect the letters and colors of the mail itself. I already have the code for setting an image to look like the Gmail client which I obtained here: Colored boxed with letters a la Gmail .
The issue I am having is that the code to adjust the opaque_text_view.xml is only found in an adapter:
public class ListViewRemovalAnimation extends Activity {

    StableArrayAdapter mAdapter;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list_view_deletion);

        mBackgroundContainer = (BackgroundContainer) findViewById(R.id.listViewBackground);

        //Set the adapter here
        --> mAdapter = new StableArrayAdapter(this,R.layout.opaque_text_view, list, mTouchListener);** <--
        mListView.setAdapter(mAdapter);
}

The StableArrayAdapter is its own class and is defined like this:
public class StableArrayAdapter extends ArrayAdapter<String> {
...
}

I basically have to edit the picture from within that StableArrayAdapter, but as it does not extend to an activity, I can't find a way to do it. I tried working in the code from this How to programmatically set drawableLeft on Android button? link, but same problem.
To phrase it another way, how do I change the image in the opaque_text_view (drawableleft) to update it to this:
final LetterTileProvider tileProvider = new LetterTileProvider(this);
final Bitmap letterTile = tileProvider.getLetterTile("name", "key", tileSize, tileSize);
//SET BITMAP IMAGE HERE!!!

without the benefit of an activity.
Anyone have any recommendations?

A: I'm not sure I understand as there isn't much code provided. The full Activity code, ArrayAdapter code and the code for the class of your items would have helped.
In the activity onCreate you want something like:
    yourListView.setAdapter(yourAdapter);
    yourListView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int pos, long id) {
            YourItemClass itemClicked = view.yourGetData();
            yourAdapter.changeIcon(itemClicked);
        }
    });

In the ArrayAdapter you want to create a function like:
public void changeIcon(YourItemClass item) {
    YourItemClass.setClicked(true);
    notifyDataSetChanged();
}

Also in your ArrayAdapter in getView(int position, View convertView, ViewGroup parent) add:
if (yourArray.get(position).isClicked()) {
    yourTextView.setCompoundDrawables(getContext().getResources().getDrawable( R.drawable.your_clicked_icon), null, null, null);
}

In your item class you would then need some way of storing what type it is. For example, as coded here you need an isClicked boolean with setClicked() and isClicked() methods.


text:
Q: Parcel Fabric visible in ArcCatalog but not in Pro I'm new to Pro and very new to parcel fabrics.  I followed some instructions I found online and ran an Append on a feature class to create a parcel fabric.  It said it was successful, and in Arc Catalog I can see all of the new feature classes in the feature dataset.  However, when I try and add the parcel fabric to Pro it is not there to add.  I was able to drag the feature dataset from the Pro catalog into the table of contents but the parcel fabric isn't in it.

A: You have to then 'add parcel type' and append parcel polygons into that. You should then see those when you view the fabric.


text:
Q: How to get the bundle product options via SOAP api? This one is making me feel right stupid!
I can see how to add product options when creating a product over the API, as catalogProductCustomOptionAdd describes fields for options like sku etc.
But I don't want to add, i just want to make product information available - and here when I look at my product information over soap... i can't seem to get options for my bundles
catalogProductCustomOptionList (or more precisely $client->catalogProductCustomOptionList($sess_id, $productid,1); )  returns empty array(0) {}
my basic product information clearly reports it has options: $client->catalogProductInfo($sess_id, $productid) correctly returns ["has_options"]=> string(1) "1"
so where are they?
What am I missing, What's the way to get the options from a bundle?
Or is it another thing not available in API?


text:
Q: What is a good synonym for "interesting"? What's a good synonym for the word "interesting" or "interested"? I find that I use those words a bit too often (e.g. "I'm definitely interested!", "Yeah, that sounds really interesting, I would love learning more about it!", "That's interesting!", etc.)... but I can't seem to find any good synonyms. (Online sites don't really give me good synonyms.)
Any ideas?

A: Well. Here are a few that might be apt in specific situations. But remember, it is the situation and your comfort with the phrase that works best. Do not try too hard to not sound redundant. Nobody cares about too much redundancy in spoken english.
I'm definitely interested! = Count me in; You have my attention go on (from my boss)
Yeah, that sounds really interesting, I would love learning more about it! = Sounds pretty cool to me; Goodness me, is it true;
That's interesting! = Oh Cool...; That's fantastic; That's awesome
And how about these??
"I'll keep that in mind" or " I am going to make a mental note of it "

A: How about 'thought-provoking', 'compelling', or 'problematic'?

A: Though it's not a 100% fit -- you should be prepared to learn more if your response is followed up on -- I find that intriguing works in many such situations.

A: Edited
For "I would love learning more about it" you might also say

*

*"That's worth looking into".

For "I can't find my glasses -- that's interesting"

*

*"I can't find my glasses -- Oh, that's weird!"

A: You probably want to stick with simpler words to express approval or interest. Words like cool, great, sweet, awesome, etc., are fine slang expressions to indicate interest but can even be used in a non-committal way.

A: What counts as a synonym for interested, interesting, etc. depends on your intent. Based on how you've used interesting in the posts on this page, I am going to hazard a guess and say that one of your uses of interesting is to indicate that you are somewhat uncertain about something, e.g., maybe it is unclear what the other person has said, or uncertain about how to reply. The point here is not to psycho-analyze, but rather to suggest that, instead of trying to find a synonym for interesting, perhaps you might consider simply using it less often, or even choose to simply not say anything if it's something that's unimportant to you.
In any case, even if you do find suitable synonyms, eventually you'll get tired of those, too, and sooner-or-later, we will run out of English words to suggest, which will lead to all of us spending countless hours making up new words for you, which will lead to significantly lower productivity world-wide, which will lead to an eventual global financial meltdown, global chaos, and the end of civilization. Which would be interesting, I guess. :-)

A: I've heard the Singaporeans/Malaysians say this - "I'll keep that in view".

A: Spock drew a distinction between Interesting and
Fascinating

Fascinating is a word I use for the unexpected. In this case, I should think interesting would suffice.

(from Star Trek's The Squire of Gothos)

A: Alain has some good synonyms (I use "appealing" in cases like yours).  It sounds from your comment to him that a synonym might not actually be what you're looking for.  A phrase conveying the same idea as "I'm definitely interested" is "You've got my attention".  (This works in the case where somebody else proposed an idea; it's not going to help with your search for your glasses.)

A: Here are my two coins:

Captivating
  Enthralling.

As in, "I'm definitely captivated!", "That sounds enthralling!"

A:
absorbing, attractive, captivating,
  enchanting, appealing, seductive

Taken from  http://www.wie-sagt-man-noch.de/synonyme/interesting


text:
Q: How to check if a remote server is up through a proxy? I have a series of lab linux server (centos/rh) that are built using an automated PXE install via kickstart file.  I would like to use another automated process (ansible) to monitor when the installations have completed.  Normally I would use a simple tool like ping but these servers can only be accessed remotely through an internal proxy.
One idea was to add httpd and a simple index.html page via the kickstart, then use curl to loop over requesting the page.  While this will work, it seems pretty heavy for such a simple check and then requires the extra step of removing all this baggage afterwards.
I understand that ping can't operate at this level in the stack, but is there a way to accomplish something like:
ping labhost --proxy 192.168.0.2:3128

A: Allow ssh from the host running Ansible to the new instance. Either directly routed, or through something like a ssh bastion in front of it with ProxyJump. You will need to know an initial credential, so install a ssh key with the kickstart.
Add the host to inventory and run a play on it.  wait_for_connection module will attempt to connect to it several times.  The play will need  gather_facts: False to skip the implicit gathering of host information, as it is not reachable to start.
Ansible's ping module is not ICMP echo. It remotes into the box, ssh by default, and gets a simple response back.

ICMP is a feature of IP, at a different layer than TCP or UDP. Does not make much sense to proxy an ICMP packet beyond where an IP packet would go.


text:
Q: How to access Running Services screen programmatically? I am unable to find a way to access the Running Services screen which we normally access using:
Menu -> Setting -> Applications -> Running Services

As per some programmers its impossible and even i did not get anything after searching for few days on internet but few apps like Advance task killer and Advance task manager easily accessing this screen by one click from their apps.

A: There is no intent for that in android settings code. Check the code below.
<activity android:name="RunningServices"
              android:label="@string/runningservices_settings_title"
              android:clearTaskOnLaunch="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.MONKEY" />
            <category android:name="android.intent.category.VOICE_LAUNCH" />
            <category android:name="com.android.settings.SHORTCUT" />
        </intent-filter>
    </activity>

As commonsware said in other thread, the closet is  manage application intent. Are you sure the third party apps does it. If so what is the name of the app ? I think they get the running services via package manager and then create a UI similar to that.

A: Maybe this is what you search for?
http://developer.android.com/reference/android/app/ActivityManager.html#getRunningServices%28int%29

A: Here is solution for this question
Click Here


text:
Q: selected items from listview not working Basing off http://lalit3686.blogspot.in/2012/06/today-i-am-going-to-show-how-to-deal.html, here is my getView:
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    final Model m = getItem(position);

    final ViewHolder viewHolder;
    /* convertView will be null if convertView isn't from recycler
     */
    if(convertView == null) {
        Log.d("SELECT_ADAPTER", "convertView is null; Position=" + position + " and " +
              " model=" + m.getTitle());
        LayoutInflater inflater = LayoutInflater.from(getContext());
        convertView = inflater.inflate(R.layout.selection_item, parent, false);

        // inflate individual views and cache them into viewholder
        viewHolder = new ViewHolder();

        viewHolder.cb = (CheckBox) convertView.findViewById(R.id.cb);
        viewHolder.cb.setChecked(m.isSelected());
        viewHolder.cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                int getPosition = (Integer) buttonView.getTag();
                allModels.get(getPosition).setSelected(buttonView.isChecked());
            }
        });

        viewHolder.pictureIV = (ImageView) convertView.findViewById((R.id.Picture));
        viewHolder.playBtnIV = (ImageView) convertView.findViewById((R.id.ivPlayBtn));

        // associate view memory with these views
        convertView.setTag(viewHolder);

        convertView.setTag(R.id.cb, viewHolder.cb);

    }
    else {
        Log.d("SELECT_ADAPTER", "Reusing convertView, position=" + position + "and " +
               " model=" + model.getTitle());
        viewHolder = (ViewHolder) convertView.getTag();
    }

    viewHolder.cb.setTag(position);
    viewHolder.cb.setChecked(allModels.get(position).isSelected());
    // associate play button with model so listener callback knows which video to launch
    viewHolder.playBtnIV.setTag(m);

    // set values in views
    ImageLoader.getInstance().displayImage(m.getImageUrl(), viewHolder.pictureIV);

    return convertView;
}

When I click on a button in Activity A I go through all the models and based on the flag set in the aforementioned listener, creates a list of "selected" model instances like so:
public void onClickResultsBtn(View v) throws Exception {
    for (MyModel m: allModels) {
        if (m.isSelected())
            selectedModels.add(m);
    }
....

Then Activity B is started.  When I press back on Activity B to return to Activity A, I override Activity A's onResume to clear this selected models list so that if I edit my selection, the selected models list will be properly updated and not contain duplicates from the last button press:
@Override
public void onResume() {
    super.onResume();
    if(results != null && results.size() > 0) {
        results.clear();
        selectedModels.clear();
    }
}

If I press back on Activity B and edit my selections in Activity A the selectedModels list is not correct(I see extra values).


text:
Q: If two tangents can be drawn to different tangents of a hyperbola $\frac{x^2}{1}-\frac{y^2}{4}=1$ from the point $(a,a^2)$, then find range of $a$ The equation of tangent for hyperbola is
$$y=mx\pm \sqrt {a^2m^2-b^2}$$
$$a^2=ma\pm \sqrt {m^2-4}$$
$$a^4+m^2a^2-2a^3m=m^2-4$$
$$a^4+m^2(a^2-1)-2a^3m+4=0$$
There will be two distinct values of $m$
$$4a^6-4(a^2-1)(a^4+4)>0$$
$$a^6-a^6-4a^2+a^4+4>0$$
$$a^4-4a^2+4>0$$
$$(a^2-2)^2>0$$
$$a^2>2$$ Or
$$a^2<2$$
But the given answer for it is $a\in (-\infty, -2)\cup (2,\infty)$
Where have I gone wrong?

A: Your solution is correct
Let me verify by a separate method
We know two  distinct tangents can be drawn for any point $P$ if it lies outside the hyperbola
So, we need $$\dfrac{a^2}1-\dfrac{a^4}4-1<0$$
$$\iff a^4-4a^2+4>0$$
$$\iff(a^2-2)^2>0$$ which is true if $a^2-2\ne0$ and real

A: Your reasoning works for $a^2\neq1$.
But for $a^2=1$ we obtain $(1,1)$ and $(-1,1)$,  and they are  valid!

A: With the given solution, I believe that the problem statement should read: "If two tangents can be drawn to different branches of a hyperbola..." This requires the $x$-coordinates of the tangency points to have opposite signs, and this indeed occurs for $a\in(-\infty,-2)\cup(2,\infty)$.
If you're reproducing the problem statement correctly here, then there must be a typo in the original.


text:
Q: How to write Hello World in pure c (Without using any c library)? I know that linux kernel source is in pure c. So I want to know how can I write simple Hello, World program in pure C without using printf api?

A:
I know that linux kernel source is in pure c.

It is most certainly not. The Linux kernal is infamous for the frequent use of non-standard extensions from the GCC compiler.

So I want to know how can I write simple Hello, World program in pure C without using printf api?

printf is just a wrapper around the OS API functions. Do you mean to ask how to write printf using only Linux API functions? Becase "pure C" is defined in the C standard ISO 9899, which has nothing to do with the Linux OS.

A: When running in a process in any operating system, you have no direct access to hardware resources. So there's no way to print anything without asking the OS to do it for you.
Instead of printf, you can use a lower level API, such as write.
You can go further and issue a system call yourself, using the right machine instruction (which is OS and architecture dependent). This way you won't use any library, but will still rely on the OS.


text:
Q: Corona sdk : Is there a difference between audio.play() and media.play() and which one is better? Is there a difference between audio.play() and media.play() and which one is better?

A: media API:Only one sound can be playing using this sound API. Calling this API with a different sound file will stop the existing sound and play the new sound.

A: The audio.* API calls use the OpenAL audio layer to play. They are considered a safer and better way to play audio in Corona SDK.  You can have 32 different sounds playing at once. You can control the volume on each channel independently, pause and resume, fade in, fade out, etc.  It is the preferred way to play sound.
The media.* API calls write directly to the hardware and you cannot control the volume, have multiple sounds going on.  The media.* API Calls though are good for video, playing long clips, like podcasts since that audio can be backgrounded, but more importantly, on Android, Google has decided to poorly implement OpenAL and under 4.x there is a significant lag from the time you tell audio.play() to play a sound and it really happening.  The lag isn't as bad under 2.2 and 2.3, but there still is a lag.  The media.* api calls, if you're playing a short clip will play in a timely fashion.


text:
Q: Clear cache from Console app Is there any way to clear my web application cache from console application?
Both of them are one server.
I tried to call reset cache method but reset cache event in console not web app

A: I create a page in webapp that run   HttpRuntime.Close(), in console app call this page,thus Cache reset


text:
Q: How to replace both space and newline form the string using regex  lstIQCodes = IQcodeString.replaceAll(' ','').split(',');

I have tried the above code and able to replace spaces and now I want to replace newline as well.

A: If you just want to get rid of all the white space, you can just delete it:
lstIQCodes = IQcodeString.deleteWhitespace().split(',');

ReplaceAll actually takes a regular expression for the first parameter, so the following is also valid:
lstIQCodes = IQcodeString.replaceAll('\\s+','').split(',');

\\s refers to all white space, including tabs, new lines, carriage returns, and spaces.
Or, if you really just wanted spaces and newlines:
lstIQCodes = IQcodeString.replaceAll('[\\n ]+','').split(',');

A: You can follow the same approach to remove the new lines as well
for(String lines : IQcodeString.replaceAll(' ','').split(','))
     system.debug(lines.replaceAll('\n','').replaceAll('\r','') );

A: Here is a sample utility function for this specifically because of the presence of the legacy carriage return character (ASCII 13) I was seeing in data.
  public static String removeAsciiCharFromString(String str, Integer c) {
    String ret = '';
    List<Integer> chars = new List<Integer>();
    for (Integer i = 0; i < str.length(); i++) {
      if (str.charAt(i) != c) {
        chars.add(str.charAt(i));
      }
    }
    ret = String.fromCharArray(chars);
    return ret;
  }

Usage:
    String test = String.fromCharArray(new List<Integer> { 65, 13, 65 });
    String expected = 'AA';

    String actual = UtilConvert.removeAsciiCharFromString(test, 13);

    System.assertEquals(expected, actual);

Of course you can pass in any ASCII value, such as 32 for whitespace.


text:
Q: Why is the contact form not working in my site? The contact form doesnt work
Here is the code im using in the page.
Jquery in Index.html

Here is the HTML Code for the Container
Contact-Form in HTML @ index.html

<form action="index.php" method="post" id="contact_form">

Your Name:
  <input name="name" class="field" id="name" type="text">

 Please enter your name

Your Email:

<input name="email" class="field" id="email" type="text">

 OOps!! i can't get back to you in this mail id

The Message:

<textarea name="message" class="field" id="message"></textarea>

 Forgot why you came here?

 Thank you. The mailman is on his way.

 Sorry, don't know what happened. Try later.

<input id="send_message" value="Send The Message" class="submit" type="submit">

</form>

And at last here is the PHP code as
send_email.php
 //we need to get our variables first

$email_to =   'mail@mail.com'';
//the address to which the email will be sent
    $name     =   $_POST['name'];
    $email    =   $_POST['email'];
    $message  =   $_POST['message'];

    /*the $header variable is for the additional headers in the mail function,
 we are asigning 2 values, first one is FROM and the second one is REPLY-TO.
 That way when we want to reply the email gmail(or yahoo or hotmail...) will know
 who are we replying to. */
$headers  = "From: $email\r\n";
$headers .= "Reply-To: $email\r\n";

if(mail($email_to, $subject, $message, $headers)){
    echo 'sent'; // we are sending this text to the ajax request telling it that the mail is sent..
}else{
    echo 'failed';// ... or this one to tell it that it wasn't sent
    }

A: Your error is at your first line in your PHP-code:
$email_to = 'email@email.com'


text:
Q: Backup SSAS via SSMS Job with Date Appended I'd like to backup my SSAS database via a SQL Server Agent job in SSMS – and I'd also like to append the day number to the end of the file and allow overwrites.
This will ensure that I only ever have a month of backups (i.e. Jan 1st backup will be called backup_01.abf, Jan 2nd = backup_02.abf etc.)
I connected to the SSAS DB via SSMS and scripted out the backup procedure, which is as follows:
    {
      "backup": {
        "database": "ExampleDB",
        "file": "Backup.abf",
        "allowOverwrite": true,
        "applyCompression": false
      }
    }

I believe I can simply add this as a Step in a server agent job as a SQL Server Analysis Services Command.
But how can I then append the day of the month to the file?
Can't seem to find much about this online
[EDIT]
Using a combination of what Vaishali responded with below, and another article I've found online about this, I've performed the following:
Created a linked server (Link_SSAS)
Generated the following script:
    Declare @XMLA nvarchar(1000),
        @DateSerial nvarchar(35)

    -- Get Day Number from GETDATE()
    Set @DateSerial =   RIGHT('0' + RTRIM(DAY(GETDATE())),2)

    -- Create the XMLA string
    Set @XMLA = N'<Backup xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
      <Object>
        <DatabaseID>ExampleDB</DatabaseID>
      </Object>
      <File>C:\bak\Backup_' + @DateSerial + '.abf</File>
    </Backup>'

    -- Execute the string across the linked server
    Exec (@XMLA) AT Link_SSAS;

The above xmla runs perfectly if I just execute it through a query window in SSMS
However, when I try to put the XMLA into a job-step, i get an error
With Job Type set to T-SQL I get:
The Specified '@server' is invalid (valid values are returned by sp_helpserver)
If I run sp_helpserver, it does show my linked server as being there.
Tried disconnected / reconnecting to the server.

A: You can with 'dynamic xmla script' execute via sql. below link will be useful:
https://www.mssqltips.com/sqlservertip/2790/dynamic-xmla-using-tsql-for-sql-server-analysis-services/


text:
Q: Is a surjective maps from a projective module to another projective module bijection? Let $M$ and $N$ be projective $A$-modules. If we know that $f: M \to N$ is surjective and $g: N \to M$ is surjective, can we conclude that $M$ is isomorphic to $N$? More generally, if $M$ and $N$ are not necessarily projective, can we conclude that $M$ is isomorphic to $N$?
I am asking this question because it seems that in the first four lines of page 30 of the book elements of representation theory of associative algebras volumn 1 (see the picture below), it is said that g is a surjective map $P'$ to $P(M)$ and g' is a surjective map from $P(M)$ to $P'$ imply that g is a bijection. Thank you very much.

A: As noted in the comments and the answer by Bob, this does not hold in general. What holds in general is that if you have a surjective map (i.e. epimorphism) $f:M\to P$. Then $P$ is a direct summand of $M$.
However, there are some general assumptions in the book you are reading. One that is crucial here is that $A$ is finite dimensional and the modules, they are talking about are finite dimensional. And this implies that if you have surjective maps $f:M\to N$ and $g:N\to M$, then $\dim M=\dim N$. And furthermore $$\dim M=\dim \operatorname{ker} f + \dim\operatorname{im} f=\dim \operatorname{ker} f+ \dim M.$$
Hence $f$ is also injective and hence an isomorphism.
This can be a made a bit more general: It holds whenever $M$ and $N$ are of finite length.

A: No, only surjectivity doesnt imply isomorphism.
$g: N \to M$ is surjective doesn't imply that $f: M \to N$ is injective, what might be what your thinking.
The 3 necessary conditions are:
$\bullet$ the mapping is linear
$\bullet$ the mapping is injective
$\bullet$ the mapping is surjective
For less abstract cases showing there's an inverse might be time saving.


text:
Q: From bash prompt to a bash function: How to escape args and quotes properly? I have a CouchDB database that contains some daily updated status information. I can use curl to query the database from my bash prompt:
curl 'http://localhost:5984/db/_design/state/_view/stateinfo?group=true&startkey=\["2016-02-10",0\]&endkey=\["2016-02-10\u9999",\{\}\]'

Now I want to write a little function dbq in my .bash_aliases that can be used like so: dbq mm-dd where mm-dd is a date such as 02-10. I tried (among other variations):
dlq() { curl  \'http://localhost:5984/db/_design/state/_view/stateinfo?group=true\&startkey=\[2016-{$1},0\]\&endkey=\[2016-{$1}\u9999,\{\}\] \' ;}

I just can't get the argument interpolation (of $1) and the escaping of brackets, quotes, slashes and ampersands in the bash function right. Any ideas on how to do this properly? (BTW, this escaping business when transitioning from a working bash prompt solution towards a reusable bash function with arguments has slowed me down several times. Any hints and pointers to some helpful resources are much appreciated.)

A: The body of a function is effectively quoted (one reason they are superior to aliases), so you don't need to escape the single quote or anything inside them. You do, however, need to use double quotes so that $1 is expanded.
Something like...
dlq() {
    baseurl="http://localhost:5984/db/_design/state/_view/stateinfo"
    curl "$baseurl?group=true&startkey=[2016-{$1},0\]&endkey=[2016-{$1}\u9999,{}]"
}

(Please double-check the parameters; I'm not sure what was escaped erroneously and what might need escaping for the API.)

A: I find the fact that you need to pass backslashes in your original command very odd, and worry a bit that it may indicate that your backend is vulnerable to some sort of remote-code-execution attack. But putting that aside:
The thing to remember about bash quoting is that the rules around ' are very short and simple, but are so short and simple that they often surprise people. Specifically, the rule is this: absolutely nothing is special until the next ' mark. Nothing. Not backslashes, not newlines, nothing. Everything gets passed through.
This is different from most programming languages, which trips people up.
In your original command line, when you pass this:
curl 'http://localhost:5984/db/_design/state/_view/stateinfo?group=true&startkey=\["2016-02-10",0\]&endkey=\["2016-02-10\u9999",\{\}\]'

That means that the argument to curl is literally
http://localhost:5984/db/_design/state/_view/stateinfo?group=true&startkey=\["2016-02-10",0\]&endkey=\["2016-02-10\u9999",\{\}\]

with all the backslashes intact.
Now, in your function the easiest way to pass what you want is to use the fact that two adjacent strings in bash get passed together as a single argument, and do:
dlq() {
  curl  'http://localhost:5984/db/_design/state/_view/stateinfo?group=true&startkey=\["2016-'"$1"'",0\]&endkey=\["2016-'"$2"'\u9999",\{\}\]'
}

Note that what I have there is a string in single quotes that ends with "2016-, then a string in double quotes that is "$1", then a string in single quotes that begins with a double quote character and continues until it also ends in "2016- and then a double quoted "$2", and then a single quoted string until the end of the line.


text:
Q: Django Celery email, celery is not working i am working on django celery for sending the regsitration email ,but the celery is not working correct.
my error is in celery
[2014-09-10 19:11:44,349: WARNING/MainProcess] celery@Jeet-PC ready.
[2014-09-10 19:13:38,586: INFO/MainProcess] Received task:       apps.kashmiri.tasks.SignUpTask[17ca2ae1-8c72-426c-babd-470a55ac19
5]
[2014-09-10 19:13:38,936: ERROR/Worker-1] Pool process <Worker(Worker-1, started)> error:     RuntimeError(RuntimeError("App reg
stry isn't ready yet.",), <function model_unpickle at 0x034E4B30>, (('auth', 'User'), [],     <function simple_class_factory at
x034E4AF0>))
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\billiard\pool.py", line 289, in run
sys.exit(self.workloop(pid=pid))
File "C:\Python27\lib\site-packages\billiard\pool.py", line 350, in workloop
req = wait_for_job()
File "C:\Python27\lib\site-packages\billiard\pool.py", line 441, in receive
ready, req = _receive(1.0)
File "C:\Python27\lib\site-packages\billiard\pool.py", line 413, in _recv
return True, loads(get_payload())
File "C:\Python27\lib\site-packages\billiard\common.py", line 77, in pickle_loads
return load(BytesIO(s))
File "C:\Python27\lib\site-packages\django\db\models\base.py", line 1450, in model_unpickle
model = apps.get_model(*model_id)
File "C:\Python27\lib\site-packages\django\apps\registry.py", line 187, in get_model
self.check_ready()
File "C:\Python27\lib\site-packages\django\apps\registry.py", line 119, in check_ready
raise RuntimeError("App registry isn't ready yet.")
RuntimeError: (RuntimeError("App registry isn't ready yet.",), <function model_unpickle at    0x034E4B30>, (('auth', 'User'), [
, <function simple_class_factory at 0x034E4AF0>))
[2014-09-10 19:13:39,233: ERROR/MainProcess] Process 'Worker-3' pid:7100 exited with 'signal -1'

forms.py
from apps.kashmiri.tasks import SignUpTask
SignUpTask.delay(user=user)

celery.py
from __future__ import absolute_import

import os

from celery import Celery
from django.conf import settings

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'kb.settings')

app=Celery('kb')

app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)

@app.task(bind= True)
def debug_task(self):
print('Request:{0!r}'.format(self.request))

tasks.py
from __future__ import absolute_import
from celery.registry import tasks
from celery.task import Task
from celery.app import shared_task
from django.utils.html import strip_tags
from django.core.mail import EmailMultiAlternatives
from django.template.loader import render_to_string

class SignUpTask(Task):
def run(self, user):
    subject, from_email, to ='Welcome to Kashmiri Bhatta', 'info@seekersguru.com', user.email
    html_content = render_to_string('registration.html',{'user':user.email})
    text_content= strip_tags(html_content)
    msg= EmailMultiAlternatives(subject, text_content, from_email, [to])
    msg.attach_alternative(html_content, "text/html")
    msg.send()

tasks.register(SignUpTask)

When i m using  >> celery -A proj worker -l info
error for RuntimeError: (RuntimeError("App registry isn't ready yet.",)
please help for solving it..

A: This problem occurs only with Django 1.7. It was reported on github and was fixed recenlty. Upgrade to latest version of Celery. It should solve the problem
pip install celery --upgrade


text:
Q: Yii transaction where to start it I wonder whether it matters where to start the transaction.
Example 1:
            $transaction = Yii::app()->db->beginTransaction();
            try
            {
                $savedSuccessfully = $object->save();
                $transaction->commit();
            }
            catch (Exception $ex)
            {

                $transaction->rollBack();
                $result = $e->getMessage();
            }

Example 2:
            $transaction = Yii::app()->db->beginTransaction();
            try
            {
                $object = $model()::model()->findByPk(1); //!!!!!!! - line
             //   what makes the difference
                $savedSuccessfully = $object->save();
                $transaction->commit();
            }
            catch (Exception $ex)
            {

                $transaction->rollBack();
                $result = $e->getMessage();
            }

Should transaction be started before selecting data from db or or just before updating/inserting data? Will yii take care of it instead of me?
Thanks

A: Example 2 would be the solution of choice.
By retrieving the model within the transaction, you make sure that it is consistent throughout your changes.
If you retrieve the model, like in example 1, outside the transaction, other threads/users could change the corresponding database entry before you commit your changes. So you could end up with potentially inconsistent data.

A: Actually 2nd one  is correct ,  if you are saving data which is more critical like banking transaction or payment system then example 2 is very correct way. for example , you are doing some code like this.
insert into table 1
select from table 1
insert into table 2
update table 2
select from table 1.

so if you start transaction from first , it will rollback all query if any query fails which will be more efficient. for example in online payment system.


text:
Q: Remove hard line breaks from text with Ruby I have some text with hard line breaks in it like this:
This should all be on one line
since it's one sentence.

This is a new paragraph that
should be separate.

I want to remove the single newlines but keep the double newlines so it looks like this:
This should all be on one line since it's one sentence.

This is a new paragraph that should be separate.

Is there a single regular expression to do this? (or some easy way)
So far this is my only solution which works but feels hackish.
txt = txt.gsub(/(\r\n|\n|\r)/,'[[[NEWLINE]]]')
txt = txt.gsub('[[[NEWLINE]]][[[NEWLINE]]]', "\n\n")
txt = txt.gsub('[[[NEWLINE]]]', " ")

A: text.gsub!(/(\S)[^\S\n]*\n[^\S\n]*(\S)/, '\1 \2')

The two (\S) groups serve the same purposes as the lookarounds ((?<!\s)(?<!^) and(?!\s)(?!$)) in @sln's regexes:

*

*they confirm that the linefeed really is in the middle of a sentence, and

*they ensure that the [^\S\n]*\n[^\S\n]* part consumes any other whitespace surrounding the linefeed, making it possible for us to normalize it to a single space.

They also make the regex easier to read, and (perhaps most importantly) they work in pre-1.9 versions of Ruby that don't support lookbehinds.

A: Replace all newlines that are not followed by or preceded by a newline:
text = <<END
This should all be on one line
since it's one sentence.

This is a new paragraph that
should be separate.
END

p text.gsub /(?<!\n)\n(?!\n)/, ' '
#=> "This should all be on one line since it's one sentence.\n\nThis is a new paragraph that should be separate. "

Or, for Ruby 1.8 without lookarounds:
txt.gsub! /([^\n])\n([^\n])/, '\1 \2'

A: There is more to formatting (turning off word wrap) than you think.
If the output is a result of a formatting operation, then you should go by
those rules to reverse engineer the original.
For instance, the test you have there is
This should all be on one line
since it's one sentence.
This is a new paragraph that
should be separate.
If you removed just the single newlines only, it would look like this:
This should all be on one line since it's one sentence.
This is a new paragraph thatshould be separate.
Also, other formatting such as intentional newlines will be lost, so something like:
This is Chapter 1
   Section a
   Section b

Turns into
This is Chapter 1   Section a   Section b

Finding the newline in question is easy /(?<!\n)\n(?!\n)/
but, what do you replace it with.
Edit: Actually, its not that easy even to find standalone newlines, because visually they sit amongst hidden from view (horizontal) whitespaces.
There are 4 ways to go.
Remove newline, keep the surrounding formatting
$text =~ s/(?<!\s)([^\S\n]*)\n([^\S\n]*)(?!\s)/$1$2/g;
Remove newline and formatting, substitute a space
$text =~ s/(?<!\s)[^\S\n]*\n[^\S\n]*(?!\s)/ /g;
Same as above but ignore newline at beginning or end of string
$text =~ s/(?<!\s)(?<!^)[^\S\n]*\n[^\S\n]*(?!$|\s)/ /g;
$text =~ s/(?<!\s)(?<!^)([^\S\n]*)\n([^\S\n]*)(?!$|\s)/$1$2/g;
Example breakdown of regex (this is the minimum required just to isolate a single newline):
(?<!\s)      # Not a whitespace behind us (text,number,punct, etc..)
[^\S\n]*     # 0 or more whitespaces, but no newlines
\n           # a newline we want to remove
[^\S\n]*     # 0 or more whitespaces, but no newlines
(?!\s)/      # Not a whitespace in front of us (text,number,punct, etc..)

A: Well, there is this:
s.gsub /([^\n])\n([^\n])/, '\1 \2'

It won't do anything to leading or trailing newlines. If you don't need leading or trailing white space at all, then you will win with this variation:
s.gsub(/([^\n])\n([^\n])/, '\1 \2').strip

A: $ ruby -00 -pne 'BEGIN{$\="\n\n"};$_.gsub!(/\n+/,"\0")' file
This should all be on one line since it's one sentence.

This is a new paragraph thatshould be separate.


text:
Q: Is it Possible to send incall audio stream to pc via wifi from android phone I am looking for a way to send incoming call on android phone to pc via wifi. I have to develop a client-server application which connects android phone to pc. But I don't know how to send call audio stream.
In simple words.
I want to attend and answer calls through my pc which has been connected to my android phone via wifi.


text:
Q: Can you limit the scope of a TypeScript global type? Our team has configured TypeScript to make the jest types available globally:
// tsconfig.json
{
  ...,
  "types": ["jest", "@testing-library/jest-dom", ...]
}

This is really nice for *.test.ts files, but today I realized that it also accepts jest (and related functions) in regular old *.ts files—which makes sense after I read up on the tsconfig docs.  Is it possible to limit the availability of a type (jest in our case) to a certain directory or subset of files?
// component.tsx (error - 'jest' should not be defined)
const mockFn = jest.fn();

// component.test.tsx (no error - 'jest' should be defined)
const mockFn = jest.fn();


text:
Q: Jolt Transformation - Match Values in Separate Branches - JSON I want to achieve the following JSON transformation using Jolt processor in Nifi
Input JSON
{
    "topLevel": {
        "secondLevelA": {
            "thirdLevelA": [
                {
                    "norsemen": "huntinSouth",
                    "value": "AAA"
                },
                {
                    "norsemen": "huntinNorth",
                    "value": "BBB"
                }
                ]
        },
        "secondLevelB": {
            "thirdLevelB": [
                {
                    "norsemen": "huntinNorth",
                    "oddCode": "AAA301"
                },
                {
                    "norsemen": "huntinNorth",
                    "oddCode": "BBB701"
                },
                {
                    "norsemen": "huntinWest",
                    "oddCode": "AAA701"
                }
            ]
        }
    }
}

Output JSON
{
    "NAME": [
        {
            "norsemen": "huntinSouth",
            "value": "AAA",
            "refValue": []
        },
        {
            "norsemen": "huntinNorth",
            "value": "BBB",
            "refValue": [
                {
                    "oddCode": [
                        "BBB701"
                    ]
                }
            ]
        }
    ]
}

I would like to test for matches between the values of  secondLevelA.thirdLevelA.norsemen and secondLevelB.thirdLevelB.norsemen. If one or more matches is found, all values of secondLevelB.thirdLevelB.oddCode contained in the same set as the matching norsemen would be placed in the output in the same set as the corresponding matching norsemen.
Is there a way to do this using existing Jolt Operations?

A: seems you have some non-declarative logic that could not be covered with jolt.
From jolt description:
Jolt :

*

*focuses on transforming the structure of your JSON data, not manipulating specific values

*

*The idea being: use Jolt to get most of the structure right, then write code to fix values

The Stock transforms are:
shift       : copy data from the input tree and put it the output tree
default     : apply default values to the tree
remove      : remove data from the tree
sort        : sort the Map key values alphabetically ( for debugging and human readability )
cardinality : "fix" the cardinality of input data.  Eg, the "urls" element is usually a List, but if there is only one, then it is a String

I don't see here kind of if/then/else
So, I think your task could not be covered with just jolt
for me the easiest way will be script processor with JavaScript or Groovy language.


text:
Q: Laravel Eloquent How to fetch results from array I have been spending hours searching to find this.
I am very new to Laravel, ( coming from CodeIgniter ) and I am trying to do everything the Laravel way instead of using pure php/sql anywhere unless it is very necessary.
$role_id = Role::select('role_id')
                    ->where('type','Admin')
                    ->get();
    var_dump($role_id);

I am trying to fetch $role_id.
The var_dump gives me this.
object(Illuminate\Database\Eloquent\Collection)#249 (1) { ["items":protected]=> array(1) { [0]=> object(App\Role)#252 (26) { ["connection":protected]=> string(5) "mysql" ["table":protected]=> string(5) "roles" ["primaryKey":protected]=> string(2) "id" ["keyType":protected]=> string(3) "int" ["incrementing"]=> bool(true) ["with":protected]=> array(0) { } ["withCount":protected]=> array(0) { } ["perPage":protected]=> int(15) ["exists"]=> bool(true) ["wasRecentlyCreated"]=> bool(false) ["attributes":protected]=> array(1) { ["role_id"]=> int(99) } ["original":protected]=> array(1) { ["role_id"]=> int(99) } ["changes":protected]=> array(0) { } ["casts":protected]=> array(0) { } ["dates":protected]=> array(0) { } ["dateFormat":protected]=> NULL ["appends":protected]=> array(0) { } ["dispatchesEvents":protected]=> array(0) { } ["observables":protected]=> array(0) { } ["relations":protected]=> array(0) { } ["touches":protected]=> array(0) { } ["timestamps"]=> bool(true) ["hidden":protected]=> array(0) { } ["visible":protected]=> array(0) { } ["fillable":protected]=> array(0) { } ["guarded":protected]=> array(1) { [0]=> string(1) "*" } } } }

I expected just a mysql result row instead of this.
What I am looking for is just this ["role_id"]=> int(99).
I am missing a function to directly get this, and I cant find it from the docs.
$role_id->role_id gives me property not found.

A: You have items with get method. This of the reasons cannot access role_id.
You can use first instead of get method if you want to one record.
and you can use dd() function.
$role_id = Role::select('role_id')
                ->where('type','Admin')
                ->first();
dd($role_id);

A: Use ->first() instead of ->get().
get() returns collection.

A: You can do this:
$role_id = Role::all(['role_id'])->where('type','Admin')->first(); or Role::where('type', 'Admin');

Instead of var_dump you can use dd($role_id) or var_dump($role_id), it dies and dumps at the same time .

A: This is the right way of doing it.
$response = Role::select('role_id')
                       ->where('type','Admin')
                       ->first();
        $admin_id = $response->role_id;


text:
Q: virtualbox-5.2 installation not working I am trying to install VirtualBox 5.2 on Ubuntu 18.04.2 LTS from the CLI as it is the server edition. I have followed the instructions from:
https://websiteforstudents.com/virtualbox-5-2-on-ubuntu-16-04-lts-server-headless/
However, I get the following error about packages having unmet dependencies:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 virtualbox-5.2 : Depends: libcurl3 (>= 7.16.2) but it is not going to be installed
                : Depends: libpng12-0 (>= 1.2.13-4) but it is not installable
                : Depends: libvpx3 (>= 1.5.0) but it is not installable
                : Recommends: libsdl-ttf2.0-0 but it is not going to be installed
                : Recommends: pdf-viewer
E: Unable to correct problems, you have broken packages.

A: That manual is for 16.04.
I suggest installing VirtualBox-6.0 from VirtualBox site
Current build is here:
https://download.virtualbox.org/virtualbox/6.0.4/virtualbox-6.0_6.0.4-128413~Ubuntu~bionic_amd64.deb
If you specifically want the 5.2 version, there is an Ubuntu 18.04 build here
https://download.virtualbox.org/virtualbox/5.2.26/virtualbox-5.2_5.2.26-128414~Ubuntu~bionic_amd64.deb
Install it this way
wget https://download.virtualbox.org/virtualbox/5.2.26/virtualbox-5.2_5.2.26-128414~Ubuntu~bionic_amd64.deb
sudo dpkg -i virtualbox-5.2_5.2.26-128414~Ubuntu~bionic_amd64.deb
sudo apt install -f


text:
Q: GitHub fork a forked repository Does anyone know how to fork a forked repository on GitHub?
what I'm trying to achieve is to fork the updated repository from a user that forked the original repository and maintained it.
e.g.:
Original repository and abandoned repository

*

*john/some-random-stuff

Forked repository from another user who maintained it

*

*smith/some-random-stuff

Now, I want to fork the smith/some-random-stuff and not the john/some-random-stuff.
So now in my profile it'll show forked from smith/some-random-stuff
Edit:
when I click the fork on smith/some-random-stuff it still forking the original repo which is john/some-random-stuff

A: Just clicking the Fork button on the GitHub page of the forked repo would create you a fork of the forked repo. If you hover on the Fork button on the page of smith/some-random-stuff fork, it would show

Fork your own copy of smith/some-random-stuff to your account

So you just need to click on the Fork button on the page of the fork smith/some-random-stuff


text:
Q: How can I Axtinguish enemy Pyros? The following is under the trivia section of the Axtinguisher page on the TF2 wiki:

Although Pyros and Demomen using the Chargin' Targe are resistant to afterburn, they can be crit by the Axtinguisher if the hit connects before resistance takes effect.

Now, I know how to inflict critical damage against these opponents with the flare gun: simply hold down M1 (keeping hold of the button), and scroll down.
This works, apparently, because the nature of particle-based weapons mean that fire particles linger for a short period after being fired, during which time the enemy is counted as being "on fire" (I don't have a source for this, but remember reading it somewhere).
However, when I try doing the same thing with the Axtinguisher (using the melee key, as opposed to scrolling down), no inflicted critical hit occurs.
Now, why does this not work for the Axtinguisher? The same conditions are met, so surely I should inflict critical damage (from behind).
More importantly, how can I get this to work?
I've tried it on tr_walkway with stationary Pyros, and the Degreaser-Axtinguisher combo doesn't work.
I have noticed, however, that if an ally continuously blasts an enemy pyro with his flamethrower, and I, during that time, hit the enemy with the Axtinguisher from behind, it will score a critical hit.
Is there any way I can Axtinguish Pyros (and Charge Demoknights) without the help of an ally Pyro?

A: Since the flamethrower projectiles have a travel time, you have to time it so that by the time the flame hits the pyro, and before it goes away due to afterburn immunity,  you have your axtinguisher out already hitting the pyro.
Here's an example by sketchek, a popular TF2 youtuber:

In the video you'll notice that from a high distance (which is much easier to get critical axtinguisher kills on enemy pyro), he jumps down, shoots the flamethrower down. Since it has travel time, the pyro is travelling at roughly the same speed as the flames.  By the time he's nearly all the way down, he has axtinguisher out and ready to melee the pyro.  When he hits the bottom, the flames have hit the Pyro but not triggered afterburn immunity, allowing you to crit the pyro.

This doesn't have to be done while airborned, as you can see from the second video you can critflare on pyros who are being airblasted upwards if you time it correctly.


text:
Q: Is $ \{A\in \mathbb{R}^{n,n}: 0<\det(A)<2\} $ compact? I have the set $ K:=\{A\in \mathbb{R}^{n,n}: 0<\det(A)<2\} $ in $ (\mathbb{R}^{n,n},\|.\|_F) $.
I don't know how to show if this set is compact or not compact in $ (\mathbb{R}^{n,n},\|.\|_F) $.
My first idea was to show that this set is compact by contradiction.
Assume there exists an open cover $ (U_i)_{i\in I} $ which contains $ K $ such that for all finite open covers $ (U_i)_{i\in E} $ with $ E\subseteq I $ finite don't contain $ K $ which means $ K\nsubseteq \bigcup\limits_{i\in E} U_i$.

A: The set is not even bounded as the diagonal matrices
$$
\pmatrix{ k \\ & \frac1k \\ && 1\\ &&&\ddots\\ &&&&1}
$$
belong to the set for all $k$. That is, changing the restriction to $\det (A)=1$ would not affect non-compactness.

A: $K$ is not compact. To see this, note that $\det : \mathbb{R}^{n,n} \to \mathbb{R}$ is a continuous map. Thus, $$K = \mathrm{det}^{-1} (0,2)$$
is a nonempty open subset of $\mathbb{R}^{n,n}$. Since $\mathbb{R}^{n,n} \cong \mathbb{R}^{n^2}$ is connected, it follows that $K$ is not compact.

A: Let $n=1$ then $K=\{ A \in \mathbb{R}^1 | 0<\det(A)<2\}$. Hence $K=(0,2)$ which is non compact set.


text:
Q: Is there a way to bring together the objects drawn with Android OpenGL ES 1.1? ** I created a class to draw a line of one.↓↓
public class LINETEST{
float[] vertices = null;
private short[] indices = null;

public FloatBuffer verticesBuffer;
private ShortBuffer indexBuffer;
private int LINE_NUMBER = 0;

public LINETEST() {

}

public void draw(GL10 gl) {

    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, verticesBuffer);
    gl.glLineWidth(2);
    gl.glColor4f(0f, 0f, 0f, 0f);

    gl.glDrawElements(GL10.GL_LINE_STRIP, indices.length,
              GL10.GL_UNSIGNED_SHORT, indexBuffer);

    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
}

public void setBuffer() {

            ByteBuffer vbb = ByteBuffer.allocateDirect(vertices.length * 4);
            vbb.order(ByteOrder.nativeOrder());
            verticesBuffer = vbb.asFloatBuffer();
            verticesBuffer.put(vertices);
            verticesBuffer.position(0);

            ByteBuffer ibb = ByteBuffer.allocateDirect(indices.length * 2);
            ibb.order(ByteOrder.nativeOrder());
            indexBuffer = ibb.asShortBuffer();
            indexBuffer.put(indices);
            indexBuffer.position(0);
}

public void setVertices(float[] verticesAl, short[] indicesAl, int number){

    this.vertices = verticesAl;
    this.indices = indicesAl;
    this.LINE_NUMBER = number;

}

public int getLineNumber(){
    return this.LINE_NUMBER;
    }
}

** And drew value of the position of the array object declared by using this class is given in a different way.↓↓
linetest = new LINETEST[2000];
**And I will create a new object each time the line is drawn.↓↓↓
public void setVertices(float[] vertice, short[] indice, int lineNumber){
    this.vertices = vertice;
    this.indices = indice;
    this.number = lineNumber;

 linetest[number] = new LINETEST();
 linetest[number].setVertices(vertices, indices, lineNumber);
 linetest[number].setBuffer();

}

** Finally, I will draw an object that is generated by the OnDrawFrame of rendering class.↓↓↓
@Override
public void onDrawFrame(GL10 gl) {
         if(vertices != null){
             if(linetest[number] != null){
                for(int i = 0; i<number; i++){
                    linetest[i].draw(gl);

                }
                 linetest[number].draw(gl);
             }

         }
}

** Can I be declared as one face of the line drawn in this way?
** Why I try to do this job is I wanted to put the color on the inside of the surface that are declared in this way.

A: Forgive me if I misunderstand the question, but I believe you are trying to draw a face (or polygon) instead of lines. If your vertex and index buffers are set up appropriately then you may just need to change the type of primitive from GL_LINE_STRIP to something like GL_TRIANGLE_STRIP. You will need to make sure your buffers are specified correctly for the primitive type you choose, and perhaps worry about face culling. From there you will need to apply a material or texture or both to fill in the polygons.


text:
Q: How to make a certain file openable with your own program? I want to design a file based program that can manipulate files in java and I can do it fine in the program but I want to be able to right click on my file and select "Open with" so users know if my program can open their file.

A: There is a tutorial by Oracle that describes how you can create a file association:
https://docs.oracle.com/javase/tutorial/deployment/selfContainedApps/fileassociation.html
I do not know how to do it by myself. I just thought the reference would be better than nothing.


text:
Q: Volume issue with pulseaudio on Debian 11 I recently installed new Debian 11 on my desk, my audio devices are managed by pulseaudio and pavucontrol. I mainly use DragonFly red DAC to listen music or something else on Chromium. Everything is fine until there. However, I have one annoying problem with this config. I really think that is link with my DAC because I don't occur this problem with my other devices (like Logitech PRO X).
I set my DragonFly red DAC to 50% of volume through pavucontrol but after each reboot of my computer, the volume bar still appears at 50% BUT the sound seems to be at 100% of volume (RIP my ears). I have to go in pavucontrol and change manually 1 or 2 percents of the bar to get the expected volume (in this case 50%)
I searched all the day a solution, I only find something like "add line flat-volumes = no inside of this file -> /etc/pulse/daemon.conf". It does not change anything at all ! The problem is still here. By the way this line is already set in this file by default.
I also find this link which is the same problem than me : https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1002
But it was for pipewire and not pulseaudio...
Does anyone have a solution to this ? Thanks !

A: I just find something that seems to work for me.
e.g https://askubuntu.com/questions/15069/how-do-i-change-the-way-ubuntu-adjusts-my-volume-mixer-levels
EDIT
If someone has the same issue, try to replace this line : load-module module-udev-detect by this line : load-module module-udev-detect ignore_dB=1 inside of /etc/pulse/default.pa


text:
Q: Why I can't set vertical-align middle for img tag Hello I am very new to HTML and CSS and I am trying to do a site for just learning. I just made a header and I put logo in it but I can't set it's vertical-align. Can someone explain it?
Here is HTML file:
<!DOCTYPE html>

    <link href="https://fonts.googleapis.com/css?family=Open+Sans&display=swap" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="style.css">
    <title>Scienitive</title>

Scienitive

Here is CSS file:
.header {
width: 100%;
height: 80px;
display: block;
background-color: #FF5733;
}
.logo-container {
height: 100%;
display: table;
float: left;
}
.logo-container h1{
color: white;
height: 100%;
display: table-cell;
vertical-align: middle;
font-family: "Open Sans";
font-size: 48px;

}
.logo {
display: table;
height: 80px;
}
.logo img{
width: 48px;
height: 48px;
vertical-align: middle;
display: table-cell;
}

Here is how site looks like
Image

A: You actually don't want to set the display: table-cell or vertical-align: middle on the img tag directly, but instead on its container/parent:

.header {
  width: 100%;
  height: 80px;
  display: block;
  background-color: #FF5733;
}

.logo-container {
  height: 100%;
  display: table;
  float: left;
}

.logo-container h1 {
  color: white;
  height: 100%;
  display: table-cell;
  vertical-align: middle;
  font-family: "Open Sans";
  font-size: 48px;
}

.logo {
  display: table-cell;
  vertical-align: middle;
  height: 80px;
}

.logo img {
  width: 48px;
  height: 48px;
}

  <link href="https://fonts.googleapis.com/css?family=Open+Sans&display=swap" rel="stylesheet">
  <link rel="stylesheet" type="text/css" href="style.css">
  <title>Scienitive</title>

Scienitive

A: vertical-align is to be set on the table-cell container , which .logo should be
reminder to read about vertical-align : https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align

  .header {
  width: 100%;
  height: 80px;
  display: block;
  background-color: #FF5733;
}

.logo-container {
  height: 100%;
  display: table;
  float: left;
}

.logo-container h1 {
  display: table-cell;
  vertical-align: middle;
  font-family: "Open Sans";
  font-size: 48px;
}

.logo {
  display: table-cell;
  vertical-align:middle;;
  height: 80px;
}

.logo img {
  width: 48px;
  height: 48px;
}
<link href="https://fonts.googleapis.com/css?family=Open+Sans&display=swap" rel="stylesheet">

Scienitive

If the area to click should only be the image, then you can consider using flex to center content or reduce the click area via pointer-events . Plese clarify if so


text:
Q: Need working example of i18n webpack plugin with angular2-webpack-plugin supporting multiple locales I am using the following webpack config for prod env. Though it's working fine, its not the most optimised code as it runs every plugin for all locales. For example, ideally, copy plugin should be called only after the i18n plugin has run for all locales. or for example suppose i want to internationalize only main.bundle.js entry file and not others. Please help me write a more optimized config.
const helpers = require('./helpers');
const webpackMerge = require('webpack-merge');
const commonConfig = require('./webpack.common.js');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ProvidePlugin = require('webpack/lib/ProvidePlugin');
const DefinePlugin = require('webpack/lib/DefinePlugin');
const NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplacementPlugin');
const IgnorePlugin = require('webpack/lib/IgnorePlugin');
const DedupePlugin = require('webpack/lib/optimize/DedupePlugin');
const UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin');
const WebpackMd5Hash = require('webpack-md5-hash');

const ENV = process.env.NODE_ENV = process.env.ENV = 'production';
const HOST = process.env.HOST || 'localhost';
const PORT = process.env.PORT || 8080;
const METADATA = webpackMerge(commonConfig({env: ENV}).metadata, {
  host: HOST,
  port: PORT,
  ENV: ENV,
  HMR: false
});

const I18nPlugin  = require("webpack/node_modules/i18n-webpack-plugin");
var languages = {
  "en" : null,
  "hi": require("./locales/hi.json"),
  "de": require("./locales/de.json")
};

var path = require("path");
module.exports = function(env) {
 return Object.keys(languages).map(function(locale) {

  return  webpackMerge(commonConfig({env: ENV}), {

    debug: false,

    devtool: 'source-map',

    output: {

      path: helpers.root('dist'),
      //path: helpers.root('dist/' + METADATA.title + '/static'),

      filename: ((locale  == "en" )? "" : (locale +'.'))   + '[name].[chunkhash].bundle.js',

      sourceMapFilename: ((locale  == "en" )? "" : (locale +'.')) + '[name].[chunkhash].bundle.map',

      chunkFilename: ((locale  == "en" )? "" : (locale +'.')) + '[id].[chunkhash].chunk.js'

    },

    plugins: [
      new HtmlWebpackPlugin({
        template: 'src/index.html',
        filename: 'index.' + ((locale  == "en" )? "" : (locale +'.'))  +'html',
        chunksSortMode: 'dependency'
      }),
       new I18nPlugin(
                languages[locale]
            ),

      new WebpackMd5Hash(),

      new DefinePlugin({
        'ENV': JSON.stringify(METADATA.ENV),
        'HMR': METADATA.HMR,
        'process.env': {
          'ENV': JSON.stringify(METADATA.ENV),
          'NODE_ENV': JSON.stringify(METADATA.ENV),
          'HMR': METADATA.HMR,
        }
      }),
      new UglifyJsPlugin({
        beautify: false, //prod
        mangle: { screw_ie8 : true, keep_fnames: true }, //prod
        compress: { screw_ie8: true }, //prod
        comments: false //prod
      }),

      new NormalModuleReplacementPlugin(
        /angular2-hmr/,
        helpers.root('config/modules/angular2-hmr-prod.js')
      ),

    ],

    tslint: {
      emitErrors: true,
      failOnHint: true,
      resourcePath: 'src'
    },

    *ngFor
    htmlLoader: {
      minimize: true,
      removeAttributeQuotes: false,
      caseSensitive: true,
      customAttrSurround: [
        [/#/, /(?:)/],
        [/\*/, /(?:)/],
        [/\[?\(?/, /(?:)/]
      ],
      customAttrAssign: [/\)?\]?=/]
    },

    /*
     * Include polyfills or mocks for various node stuff
     * Description: Node configuration
     *
     * See: https://webpack.github.io/docs/configuration.html#node
     */
    node: {
      global: 'window',
      crypto: 'empty',
      process: false,
      module: false,
      clearImmediate: false,
      setImmediate: false
    }

  });

});

}

A: When I was implementing localization for my angular 2 project I ended up making a service.  Pass in the locale and key then return the localized string.  I'm not sure what advantage adding localization as a web pack plugin would provide.

A: Seems intl-webpack-plugin much simple to use:
  module: {
    rules: [
      { test: /\.(intl|i18n|yml|yaml)$/i,
        use: [
          IntlPlugin.loader()
        ]
      },
    ]
  },
  plugins: [
    new IntlPlugin({
      search: [ './locales/**/*.json' ]
    })


text:
Q: error when scafolding controller mvc5 Hi when i try adding a controller using the controller actions and entity framework, it gives me an error saying:

"there was an error with the selected code generator: unable to
  retrieve metadata for 'Music.Model.Customer'. one or more validation
  errors were detected during model generation:
Music.Data.Customer : EntityType 'Customer' has no key defined. Define
  the key for this entity type.
Images: EntityType:EntitySet 'images' is based on type 'Customer that
  has no keys defined.

I did build my context before adding the controller

A: In your model, you should decorate a property with the [Key] attribute. For example:
public partial class Customer
{
    [Key]
    public int CustomerId { get; set; }
    ...
    ...

}

Entity Framework will recognise the primary key of a table if the column is named Id. If your table does not have a primary key field named Id, you can identify the primary key field by setting the [Key] attribute.


text:
Q: why is prepared statement not working for creating tables? Can someone tell me what is wrong with my code. It is giving a syntax error.
$email = $email."_account";
$stat1 = $conn->prepare("create table ?(acc varchar(50) NOT NULL)");

echo mysqli_error($conn);

$stat1->bind_param("s",$email);
$b = $stat1->execute();

This is the error :

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '?(acc varchar(50) NOT NULL)'

Also I would like to ask if I should prepare seperate tables for every user. For example if I am preparing a budget manager software then I need accounts for that. So should I store accounts for every user in same table or create seperate tables for every user?


text:
Q: salesforce integration with java using REST API help me out to go forward in salesforce integration with java using REST API.
These are the steps i came across and unable to find the way.

*

*Post a request to login.salesforce.com through REST client using my client_id and client_secret and username and password along with user's security token.

https://login.salesforce.com/services/oauth2/token?grant_type=password&client_id{}&client_secret={}&username={}&password={}{}
I got the response from salesforce along with access_token as follows :
{
id: "https://login.salesforce.com/id/{}"
issued_at: "{}"
token_type: "Bearer"
instance_url: "{}"
signature: "{}"
access_token: "{}"
}

*Till now i am getting proper response. Now i am using the curl operation to get the available objects with the instance_url and access_token.

curl https://{}.salesforce.com/services/data/v31.0/ -H "Authorization: Bearer {access_token}"
Here i am getting the response as follows :
[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]

Same response getting for different versions and for different instance_url.
Can you please shed some light on this issue and help me???

A: after a long trial, i succeeded in getting the proper response.
Hit through the rest-client chrome extension by passing URL and giving the
Authorization: Bearer 00D9..........................................................Daar787@asU
in the headers list would give you the result as a response.


text:
Q: Azure: Every few hours, REST request to database takes many seconds to return response. Why? I have a web site whose backend is being deployes on Azure as an App Service, and it uses "Azure Database for PostgreSQL server" as its database.
I use the free Azure license.
On my frontend, I use a JS promise on my FE to access my BE.
Generally, everything works well!
But what I noticed is that every few hours (24 maybe - I'm not sure), it takes many seconds, maybe even more than 60 for the response to arrive!
What I understood so far is that I need to restart the db and then the app to have normal responses time, since I make the first request on app startup.
But it doesn't really work for me...
Is it an Azure known issue? How can I handle this?
Frontend js function:
function populateTeamsMenu(btnElem) {

    try {

        //Populate with new items:
        (async () => {
            const response = await fetch(BASE_URL + PORT + "/teams");
            var teamsArrObj = await response.json();
            console.log(teamsArrObj);
         ...
    }

Backend spring\jpa code:
private final TeamRepository teamRepository;

public List<Team> retrieveAllTeams() {

    List<Team> lst;
    lst = teamRepository.findAll();
    return lst;
}

Thanks!

A: The "problem" is probably becuase I am using a free account, a consumption plan.
You can see the details here: https://learn.microsoft.com/en-us/azure/azure-functions/functions-scale#consumption-plan