text:
Q: Place a background relative to the position of an environment I am trying to place a background that extends the entire page width and whose height depends on the height of the environment contained. For example, the following code provides something to what I am looking for:
\documentclass[letterpaper]{article}
\usepackage{xcolor}
\usepackage{amsmath,amssymb,calc}
\usepackage{framed}
\setlength{\parindent}{0pt}

\newenvironment{test}[1]{%
\def\FrameCommand{\fboxsep=\FrameSep\colorbox{green!15}}%
\MakeFramed {\advance\hsize -\width \FrameRestore}}%
{\endMakeFramed}

\begin{document}
\begin{test}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu-
lum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.
Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec
vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et ne-
tus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus
rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu
tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium
quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean
faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Cur-
abitur auctor semper nulla. Donec varius orci eget risus. Duis nibh mi, congue
eu, accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim
rutrum.
\end{test}

\end{document}

But of course this frame only extends to the text width. I want to cover the entire margins on both sides while keeping whatever environment within the \textwidth. I was thinking of using the TikZ or its affiliate the background package. I would reall appreciate solutions within the scope of the framed package, mdframed package, TikZ or background package.

A: After consulting with the author of the framed package, the following code generates the desired result:
\documentclass[letterpaper]{article}
\usepackage{xcolor}
\usepackage{framed}
\setlength{\parindent}{0pt}

\usepackage{lipsum}

\newenvironment{test}[1][green!15]{%
\def\FrameCommand##1{%
\setlength\leftmargin{1in+
    \ifodd\value{page}\oddsidemargin\else\evensidemargin\fi}%
    \setlength\rightmargin{\paperwidth-\textwidth-\leftmargin}%
    %
    \hspace{-\leftmargin}%
    \colorbox{#1}{%
    \hspace{-\fboxsep}%
    \hspace{\leftmargin}%
    ##1%
    \hspace{\rightmargin}%
    \hspace{-\fboxsep}%
    }%
    \hspace{-\rightmargin}%
    }
\MakeFramed {\advance\hsize -\width \FrameRestore}}%
{\endMakeFramed}
\begin{document}
\begin{test}
\lipsum[1-2]
\end{test}
\end{document}

A: Use mdframed and give margins in wide excess, so that this will work even in twosided printing:
\documentclass[letterpaper]{article}
\usepackage{xcolor}
\usepackage{mdframed}
\setlength{\parindent}{0pt}

\usepackage{lipsum}

\newmdenv[skipabove=\topsep,skipbelow=\topsep,
  leftmargin=-10cm,rightmargin=-10cm,
  innerleftmargin=10cm,innerrightmargin=10cm,
  innertopmargin=\fboxsep,innerbottommargin=\fboxsep,
  backgroundcolor=green!15,
  hidealllines=true,
]{test}

\begin{document}
\lipsum[2]

\begin{test}
\lipsum[1]
\end{test}

\lipsum[3]

\end{document}


text:
Q: which technologies shall I use to offer an out-of-box server installation I want to build a client-server architecture software, and I want the server component can be easily installed by average people on their Windows or Mac OS X operating systems.
The server-side:
1. contains a self-running web server
2. hosts a web-based administrator site to manage business data and master data
3. provides API endpoints (in JSON) over WIFI
4. has sqlite 3 or MySQL database to hold business data
5. the data volume is low, the
The client-side are mobile applications which talk with server via API endpoints over WIFI.
I started thinking about Java, as JVM is installed on almost every computer, but what about the web-server and database? In a sense, as I use MAMP on my Mac a lot, I like the approach of this nice product, easy install, one click to launch all services.
Can anyone point me a possible direction?

A: You have suggested MySQL.  That sounds fine to me.
I would suggest Tomcat as a pretty widely used web-server.

redpajama_set_name: RedPajamaStackExchange


text:
Q: How should I install homebrew into /usr/local subdirectory manually? Manual installation directions in docs.brew.sh are very brief and unsatisfactory, resulting in some errors if I try it in a subdirectory of /usr/local without using sudo. Directions in this question along with its accepted answer are a little better but also do not work without using sudo.
I understand that I may need to use sudo to install Homebrew itself but hope I do not need to continue using sudo to install new packages, update, etc. (Standard Homebrew install scripts seem to use sudo but only when absolutely necessary, while the standard result is that there is no need to use sudo to install new packages, update, etc.)
How should I manually install Homebrew into a /usr/local subdirectory?
Motivation for manual installation info /usr/local subdirectory:

*

*Manual installation gives me the best control over the process of installation and management of Homebrew.

*Installation into subdirectory of my home directory is not ideal since Homebrew manages a combination of locally built packages and system-wide packages.

Motivation for avoiding the need for the user to use sudo after installation:

*

*consistency with standard installation

*easier to manage existing Homebrew packages

*lower security risk if Homebrew itself or Homebrew packages do not compel the user to run some things as root

A: NOTE: This answer assumes that the macOS user is setup as an administrator. Please see IMPORTANT note:
IMPORTANT: do not use sudo unless absolutely necessary as described below. The end result should be a Homebrew installation that does not need the use of sudo ever again.
Recommended method as of June 2021:
Use sudo to make a subdirectory such as opt that Homebrew can be installed under, and use your own login password if needed:
sudo mkdir /usr/local/opt

and sudo sudo only once more to take ownership of the subdirectory under the staff group, for example:
sudo chown brodybits:staff /usr/local/opt

At this point sudo should no longer be needed for installing or using Homebrew.
ls -al /usr/local should now show the new subdirectory, for example:
total 0
drwxr-xr-x   5 root       wheel  160 May 13 17:13 .
drwxr-xr-x@ 11 root       wheel  352 Jan  1  2020 ..
-rw-r--r--   1 root       wheel    0 Oct 16  2018 .com.apple.installer.keep
drwxr-xr-x   4 root       wheel  128 May 13 17:13 bak
drwxr-xr-x   2 brodybits  staff   64 May 13 17:03 opt

Now use Git to clone Homebrew/brew from GitHub into the new subdirectory, for example:
cd /usr/local/opt
git clone https://github.com/Homebrew/brew
ls -al /usr/local/opt # recommended

Optional: It is possible to rename the newly installed brew subdirectory, if so desired. It is also optional to move the new brew subdirectory up to the /usr/local level (sudo may be needed just once more for this).
Update the desired profile file ($HOME/.zprofile or $HOME/.zshenv in case of zsh, for example) to add the new Homebrew bin subdirectory to the PATH environment variable. Here is an example:
export PATH=/usr/local/opt/brew/bin:$PATH

(See also this answer.)
Restart the shell, start a new shell, or source the profile file. It is recommended to check that which brew shows it in the right place,  /usr/local/opt/brew/bin/brew.
At this point, brew --version should show some information (with no homebrew-core installed at this point), for example:
Homebrew 3.1.7-36-g7c68b17
Homebrew/homebrew-core N/A

Then run brew update to include homebrew-core and run brew doctor to verify proper installation. It will likely output some warning messages about the non-standard Homebrew prefix but this should be an issue for most packages.
brew --version after brew doctor should show homebrew-core included, for example:
Homebrew 3.1.7-36-g7c68b17
Homebrew/homebrew-core (git revision 61cc59c956; last commit 2021-05-13)

Try installing a simple formula such as autoconf:
brew install autoconf

autoconf --version should now show that it is installed.
See further below for some optional followup steps.

Outdated solution from 2018 no longer tested or updated:
First make a temporary directory within /usr/local using sudo (enter password if requested):
sudo mkdir /usr/local/brewtmp1

Check the results of ls -l /usr/local:
total 0
drwxr-xr-x   2 root       wheel   64 Jul  2 16:16 brewtmp1

Fix the user and group ownership of the temporary directory:
sudo chown $USER:admin brewtmp1

Check the results of ls -l /usr/local again:
total 0
drwxr-xr-x   2 brodybits  admin   64 Jul  2 16:16 brewtmp1

Then within the temporary directory download and extract the contents of master branch of Homebrew/brew on GitHub without using sudo:
cd /usr/local/brewtmp1
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz

Check the results of ls -l within /usr/local/brewtmp1:
total 0
drwxr-xr-x  16 brodybits  admin  512 Jul  2 14:46 Homebrew-brew-cbc3184

Check the results of ls -l Homebrew-brew-*:
total 48
-rw-r--r--   1 brodybits  admin    98 Jul  2 14:46 CHANGELOG.md
-rw-r--r--   1 brodybits  admin  3161 Jul  2 14:46 CODE_OF_CONDUCT.md
-rw-r--r--   1 brodybits  admin   720 Jul  2 14:46 CONTRIBUTING.md
-rw-r--r--   1 brodybits  admin  1334 Jul  2 14:46 LICENSE.txt
drwxr-xr-x   7 brodybits  admin   224 Jul  2 14:46 Library
-rw-r--r--   1 brodybits  admin  7374 Jul  2 14:46 README.md
drwxr-xr-x   3 brodybits  admin    96 Jul  2 14:46 bin
drwxr-xr-x   5 brodybits  admin   160 Jul  2 14:46 completions
drwxr-xr-x  48 brodybits  admin  1536 Jul  2 14:46 docs
drwxr-xr-x   5 brodybits  admin   160 Jul  2 14:46 manpages

This should show the contents of Homebrew with correct user and group.
Rename Homebrew-brew-??????? to homebrew (without using sudo) (it should be OK to use another name, with adaptations to other steps below):
mv Homebrew-brew-??????? homebrew

and double-check the results of ls -l:
total 0
drwxr-xr-x  16 brodybits  admin  512 Jul  2 14:46 homebrew

Move the new homebrew directory to the right place using sudo:
sudo mv /usr/local/brewtmp1/homebrew /usr/local

Double-check the results of ls -l /usr/local:
total 0
drwxr-xr-x   2 brodybits  admin   64 Jul  2 16:20 brewtmp1
drwxr-xr-x  16 brodybits  admin  512 Jul  2 14:46 homebrew

Add the following line to profile file (.profile or .bash_profile as appropriate) (as directed by this answer to another question):
export PATH=/usr/local/homebrew/bin:$PATH

Restart shell, start new shell, or source the profile file. Check that which brew shows /usr/local/homebrew/bin/brew. Check that brew --version works (though with no homebrew-core installed) for example:
Homebrew >=1.4.0 (shallow or no git repository)
Homebrew/homebrew-core N/A

It is recommended to do brew doctor at this point, which will include homebrew-core and verify proper installation. It may output a warning about non-standard Homebrew prefix but this should be an issue for most packages. Then brew --version should show homebrew-core included:
Homebrew >=1.4.0 (shallow or no git repository)
Homebrew/homebrew-core (git revision 2f937; last commit 2018-07-02)

Try installing a simple formula such as autoconf:
brew install autoconf

autoconf --version should now show that it is installed.
ls -l /usr/local/homebrew should now look like this:
total 48
-rw-r--r--   1 brodybits  admin    98 Jul  2 16:43 CHANGELOG.md
-rw-r--r--   1 brodybits  admin  3161 Jul  2 16:43 CODE_OF_CONDUCT.md
-rw-r--r--   1 brodybits  admin   720 Jul  2 16:43 CONTRIBUTING.md
drwxr-xr-x   3 brodybits  admin    96 Jul  2 16:43 Cellar
-rw-r--r--   1 brodybits  admin  1334 Jul  2 16:43 LICENSE.txt
drwxr-xr-x   8 brodybits  admin   256 Jul  2 16:43 Library
-rw-r--r--   1 brodybits  admin  7374 Jul  2 16:43 README.md
drwxr-xr-x  10 brodybits  admin   320 Jul  2 16:43 bin
drwxr-xr-x   5 brodybits  admin   160 Jul  2 16:43 completions
drwxr-xr-x  48 brodybits  admin  1536 Jul  2 16:43 docs
drwxr-xr-x   3 brodybits  admin    96 Jul  2 16:43 etc
drwxr-xr-x   5 brodybits  admin   160 Jul  2 16:43 manpages
drwxr-xr-x   4 brodybits  admin   128 Jul  2 16:43 opt
drwxr-xr-x   8 brodybits  admin   256 Jul  2 16:43 share
drwxr-xr-x   3 brodybits  admin    96 Jul  2 16:42 var

It is now recommended to add some possibly missing directories and fix some directory permissions to match the results of the Homebrew install script (I wish brew doctor would check and offer to take care of this part):
cd /usr/local/homebrew
mkdir -p include Caskroom Cellar lib opt share var
chmod g+w include Caskroom Cellar lib opt share var

And finally cleanup /usr/local/brewtmp1 (using sudo):
sudo rm -rf /usr/local/brewtmp1

Optional followup steps:
To disable analytics (thanks to this article, must be done after installing a package):
brew analytics off

You can Homebrew/homebrew-cask-versions to get access to alternate versions such as daily and beta versions, as they have documented:
brew tap homebrew/cask-versions

Additional reading and other resources from 2018:

*

*this answer to another question

*How to install Homebrew by OSX Daily (using standard script)

*9 of the best Homebrew packages for mac by OSX Daily


text:
Q: Regex check for compulsory prefixes +1 or +44 or +2 or 99 I have following regex that check for compulsory prefix + and it works fine.
^\+[0-9]+$

Now I want it to check for compulsory prefixes +1 or +44 or +2 or 99
46541324654 (false)
+1465465423646 (true)
+4421326546546654654 (true)
+24654654321323 (true)
+246546543 (true)
Edit more examples
+946546543 (false)
+0046546543 (false)
9946546543 (true)

A: This should work
^(\+(1|2|44)|99)[0-9]+$

Capture testing +946546543

A: Just replace your \+ with a sub pattern that matches +44, +2 or +1.
^\+(?:44|1|2)[0-9]+$


text:
Q: How to count records by store, day wise and in 2 hours range period with pivot table format? I have multiple stores records with user's punch records.
I would like to create a report for each store' day-wise which 2 hours have how many employees was working?
Clock In ID Last Name   First Name  In time Out time
912 Bedolla Jorge   1/1/2021 7:29   1/1/2021 11:31
912 Romero  Gabriel 1/1/2021 10:55  1/1/2021 14:07
912 Bedolla Jorge   1/1/2021 12:00  1/1/2021 16:07
912 Zaragoza    Daniel  1/1/2021 13:06  1/1/2021 14:57
912 Thaxton Christopher 1/1/2021 14:01  1/1/2021 16:57
912 Jones   Elena   1/1/2021 14:01  1/1/2021 16:35
912 Zaragoza    Daniel  1/1/2021 15:12  1/1/2021 17:09
912 Jones   Elena   1/1/2021 16:45  1/1/2021 18:05
912 Smith   Kirsten 1/1/2021 17:30  1/1/2021 20:01
912 Zaragoza    Daniel  1/1/2021 17:41  1/1/2021 21:49

Looking for a result something like below. (below result data is incorrect)
store   ForDate 0-2 2-4 4-6 6-8 8-10 10-12 12-14 14-16 16-18 18-20 20-22 22-0
912 2021-01-01  0   0   0   1   0   1   2   3   3   2   3   0
912 2021-01-02  0   0   2   1   2   3   2   4   2   3   3   0
912 2021-01-03  0   0   1   1   2   2   2   2   3   0   2   0
912 2021-01-04  0   0   2   0   2   1   2   2   3   3   1   0
912 2021-01-05  0   0   2   1   1   3   4   4   2   2   1   0
912 2021-01-06  0   0   2   0   2   1   2   3   3   2   3   0
912 2021-01-07  0   0   2   1   2   1   3   4   2   2   0   0
912 2021-01-08  0   0   2   2   2   1   3   2   1   2   1   0
912 2021-01-09  0   0   1   1   0   3   1   3   2   2   3   0
912 2021-01-10  0   0   2   2   1   2   2   1   1   2   2   0

I tried to solve with below query but it's wrong and stil it's just inTime but outTime is pending.
SELECT TOP 10 store, ForDate,
ISNULL([0], 0) + ISNULL([1], 0) AS [0-1],
ISNULL([2], 0) + ISNULL([3], 0) AS [2-3],
ISNULL([4], 0) + ISNULL([5], 0) AS [4-5],
ISNULL([6], 0) + ISNULL([7], 0) AS [6-7],
ISNULL([8], 0) + ISNULL([9], 0) AS [8-9],
ISNULL([10], 0) + ISNULL([11], 0) AS [10-11],
ISNULL([12], 0) + ISNULL([13], 0) AS [12-13],
ISNULL([14], 0) + ISNULL([15], 0) AS [14-15],
ISNULL([16], 0) + ISNULL([17], 0) AS [16-17],
ISNULL([18], 0) + ISNULL([19], 0) AS [18-19],
ISNULL([20], 0) + ISNULL([21], 0) AS [20-21],
ISNULL([22], 0) + ISNULL([23], 0) AS [22-23]
FROM (
select *
from
(
  select store, CAST(InTime as date) AS ForDate, DATEPART(hour,InTime) AS OnHour, COUNT(*) AS Totals
  from Punches
  GROUP BY store, CAST(InTime as date),
       DATEPART(hour,InTime)
) src
pivot
(
  sum(Totals)
  for OnHour in  ([0],[1], [2], [3],[4], [5], [6],[7],[8], [9], [10],[11], [12], [13],[14], [15], [16],[17],[18], [19],[20],[21], [22], [23])
) piv
) t1
order by store, ForDate

Here is SQL Fiddle with data.
https://www.db-fiddle.com/f/jo4atDmmj8cshyK1CWWo7x/2

A: That is insane but worth trying

SELECT storeid, ForDate,
ISNULL([0], 0) + ISNULL([1], 0) AS [0-1],
ISNULL([2], 0) + ISNULL([3], 0) AS [2-3],
ISNULL([4], 0) + ISNULL([5], 0) AS [4-5],
ISNULL([6], 0) + ISNULL([7], 0) AS [6-7],
ISNULL([8], 0) + ISNULL([9], 0) AS [8-9],
ISNULL([10], 0) + ISNULL([11], 0) AS [10-11],
ISNULL([12], 0) + ISNULL([13], 0) AS [12-13],
ISNULL([14], 0) + ISNULL([15], 0) AS [14-15],
ISNULL([16], 0) + ISNULL([17], 0) AS [16-17],
ISNULL([18], 0) + ISNULL([19], 0) AS [18-19],
ISNULL([20], 0) + ISNULL([21], 0) AS [20-21],
ISNULL([22], 0) + ISNULL([23], 0) AS [22-23]
FROM (
select *
from
(
    SELECT [Dates].StoreId, [Dates].ForDate, Hours.hour OnHour, COUNT(*) Totals FROM (
        SELECT storeId, CAST(InTime as date) AS ForDate FROM Punches
        UNION
        SELECT storeId, CAST(OutTime AS date) AS ForDate FROM Punches
    ) [Dates] JOIN (
        SELECT * FROM (VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17),(18),(19),(20),(21),(22),(23)) hours([hour])
    ) [Hours] ON 1=1
    JOIN
    (
        SELECT * FROM dbo.Punches
    ) p
        ON p.StoreId = [Dates].StoreId
        AND (DATEADD(HOUR, [Hours].[hour], CAST([Dates].ForDate AS DATETIME)) BETWEEN CAST(p.InTime AS DATETIME) AND CAST(p.Outtime AS DATETIME))
    GROUP BY [Dates].StoreId, Dates.ForDate, [hour]
) src
pivot
(
  sum(Totals)
  for OnHour in  ([0],[1], [2], [3],[4], [5], [6],[7],[8], [9], [10],[11], [12], [13],[14], [15], [16],[17],[18], [19],[20],[21], [22], [23])
) piv
) t1
order by storeid, ForDate

Let's go a bit deeper:
I generated all possible dates by this part:
SELECT storeId, CAST(InTime as date) AS ForDate FROM Punches
UNION
SELECT storeId, CAST(OutTime AS date) AS ForDate FROM Punches

And all possible hours by doing this:
SELECT * FROM (VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17),(18),(19),(20),(21),(22),(23)) hours([hour])

Then I joined them to find all possible date-hours.
After that, I just joined them with punches and counted the punch if the generated date-hour is between inTime and OutTime by adding this condition:
(DATEADD(HOUR, [Hours].[hour], CAST([Dates].ForDate AS DATETIME)) BETWEEN CAST(p.InTime AS DATETIME) AND CAST(p.Outtime AS DATETIME))

The rest is exactly the same as your code

A: You can use simple CASE statement to get what you so far try-
SELECT StoreId, CAST(InTime as Date) as ForDate,
SUM(CASE WHEN DATEPART(hour,InTime) in (0,1) THEN 1 ELSE 0 END) AS [0-1],
SUM(CASE WHEN DATEPART(hour,InTime) in (2,3) THEN 1 ELSE 0 END) AS [2-3],
SUM(CASE WHEN DATEPART(hour,InTime) in (4,5) THEN 1 ELSE 0 END) AS [4-5],
SUM(CASE WHEN DATEPART(hour,InTime) in (6,7) THEN 1 ELSE 0 END) AS [6-7],
SUM(CASE WHEN DATEPART(hour,InTime) in (8,9) THEN 1 ELSE 0 END) AS [8-9],
SUM(CASE WHEN DATEPART(hour,InTime) in (10,11) THEN 1 ELSE 0 END) AS [10-11],
SUM(CASE WHEN DATEPART(hour,InTime) in (12,13) THEN 1 ELSE 0 END) AS [12-13],
SUM(CASE WHEN DATEPART(hour,InTime) in (14,15) THEN 1 ELSE 0 END) AS [14-15],
SUM(CASE WHEN DATEPART(hour,InTime) in (16,17) THEN 1 ELSE 0 END) AS [16-17],
SUM(CASE WHEN DATEPART(hour,InTime) in (18,19) THEN 1 ELSE 0 END) AS [18-19],
SUM(CASE WHEN DATEPART(hour,InTime) in (20,21) THEN 1 ELSE 0 END) AS [20-21],
SUM(CASE WHEN DATEPART(hour,InTime) in (22,23) THEN 1 ELSE 0 END) AS [22-23]
FROM Punches
GROUP BY StoreId, CAST(InTime as Date)

And for your final result use below query:-
         Select StoreId,ForDate,
        SUM(CASE WHEN [0-2]>0 THEN 1 ELSE 0 END) AS [0-2],
        SUM(CASE WHEN [2-4]>0 THEN 1 ELSE 0 END) AS [2-4],
        SUM(CASE WHEN [4-6]>0 THEN 1 ELSE 0 END) AS [4-6],
        SUM(CASE WHEN [6-8]>0 THEN 1 ELSE 0 END) AS [6-8],
        SUM(CASE WHEN [8-10]>0 THEN 1 ELSE 0 END) AS [8-10],
        SUM(CASE WHEN [10-12]>0 THEN 1 ELSE 0 END) AS [10-12],
        SUM(CASE WHEN [12-14]>0 THEN 1 ELSE 0 END) AS [12-14],
        SUM(CASE WHEN [14-16]>0 THEN 1 ELSE 0 END) AS [14-16],
        SUM(CASE WHEN [16-18]>0 THEN 1 ELSE 0 END) AS [16-18],
        SUM(CASE WHEN [18-20]>0 THEN 1 ELSE 0 END) AS [18-20],
        SUM(CASE WHEN [20-22]>0 THEN 1 ELSE 0 END) AS [20-22],
        SUM(CASE WHEN [22-24]>0 THEN 1 ELSE 0 END) AS [22-24]
     from
     (SELECT StoreId,FirstName+LastName as Name, CAST(InTime as Date) as ForDate,
        SUM(CASE WHEN DATEPART(hour,InTime) in (0,1) OR (DATEPART(hour,InTime)<0 AND DATEPART(hour,OutTime)>=1) THEN 1 ELSE 0 END) AS [0-2],
        SUM(CASE WHEN DATEPART(hour,InTime) in (2,3) OR (DATEPART(hour,InTime)<2 AND DATEPART(hour,OutTime)>=2) THEN 1 ELSE 0 END) AS [2-4],
        SUM(CASE WHEN DATEPART(hour,InTime) in (4,5) OR (DATEPART(hour,InTime)<4 AND DATEPART(hour,OutTime)>=4) THEN 1 ELSE 0 END) AS [4-6],
        SUM(CASE WHEN DATEPART(hour,InTime) in (6,7) OR (DATEPART(hour,InTime)<6 AND DATEPART(hour,OutTime)>=6)  THEN 1 ELSE 0 END) AS [6-8],
        SUM(CASE WHEN DATEPART(hour,InTime) in (8,9) OR (DATEPART(hour,InTime)<8 AND DATEPART(hour,OutTime)>=8) THEN 1 ELSE 0 END) AS [8-10],
        SUM(CASE WHEN DATEPART(hour,InTime) in (10,11) OR (DATEPART(hour,InTime)<10 AND DATEPART(hour,OutTime)>=10) THEN 1 ELSE 0 END) AS [10-12],
        SUM(CASE WHEN DATEPART(hour,InTime) in (12,13) OR (DATEPART(hour,InTime)<12 AND DATEPART(hour,OutTime)>=12) THEN 1 ELSE 0 END) AS [12-14],
        SUM(CASE WHEN DATEPART(hour,InTime) in (14,15) OR (DATEPART(hour,InTime)<14 AND DATEPART(hour,OutTime)>=14) THEN 1 ELSE 0 END) AS [14-16],
        SUM(CASE WHEN DATEPART(hour,InTime) in (16,17) OR (DATEPART(hour,InTime)<16 AND DATEPART(hour,OutTime)>=16)   THEN 1 ELSE 0 END) AS [16-18],
        SUM(CASE WHEN DATEPART(hour,InTime) in (18,19) OR (DATEPART(hour,InTime)<18 AND DATEPART(hour,OutTime)>=18) THEN 1 ELSE 0 END) AS [18-20],
        SUM(CASE WHEN DATEPART(hour,InTime) in (20,21) OR (DATEPART(hour,InTime)<20 AND DATEPART(hour,OutTime)>=20) THEN 1 ELSE 0 END) AS [20-22],
        SUM(CASE WHEN DATEPART(hour,InTime) in (22,23) OR (DATEPART(hour,InTime)<22 AND DATEPART(hour,OutTime)>=22)  THEN 1 ELSE 0 END) AS [22-24]
        FROM Punches
        GROUP BY StoreId,FirstName+LastName,CAST(InTime as Date))  detailsQuery
        GROUP BY  StoreId,ForDate


text:
Q: Include JS library in Windows I need to create a simple utility to make my life a little easier. It creates a folder that gets name generated from the next Monday date with DateJS library. I am obviously to use this utility locally in Windows. What are the ways to include this DateJS library to my utility JS file?

A: I assume you're using WSH – in other words, putting some script in a .js file and running it.  Your options:

*

*Simply copy the DateJS code from date.js and paste it to the bottom of your script.  Easy, but messy and not maintainable.

*Use the hacky method outlined in the "Importing External Script Code" section of this article.  Basically, you read the external code in to a variable and eval() it.  I would not recommend this method.

*Save your script in the wsf format, a simple XML format which allows you to reference external scripts.  This is probably your best route.

myscript.wsf:
<job id="myscript">
   <script language="JScript" src="date.js"/>
   <script language="JScript">
      // ...
   </script>
</job>

A: Couple of ways to do this:

*

*Go the hardcore route and write a C++ program that embeds V8

*Use something like Adobe Air, which is "basically" HTML and JavaScript in a standalone window

*Use Windows only .hta, but you need some J/VBScript stuff then in order to create the folder

If you want more specific answers, you should add more information to your question.


text:
Q: AttributeError: 'list' object has no attribute 'replace' out = [j.replace("on", "re") for j in out] I am trying to replace the words with the user word. Both the words are taken from the user. But i dont know whats going wrong in this.
def practiseeight():
    number = str(request.args.get('num'))
    on = str(request.args.get('one'))
    re = str(request.args.get('two'))
    value = number.split('<')
    print(value)
    out = []
    for i in value:
        i = i.split('>')
        out.append(i)
        print("This is",out)

    out = [j.replace("on", "re") for j in out]
    print("new list", out)

A: Issue in  your code:
out = []
    for i in value:
        i = i.split('>') # so you are splitting i, split return a list
        out.append(i) # you are appending i which is a list
        print("This is",out)
    out = [j.replace("on", "re") for j in out] # now you are going through each element in out, each element is a list. List do not have replace, strings do!

To replace in a list of list:
out = [['abc'], ['abc', 'bcd']]
for i in out: # go through each element in out
    for j,v in enumerate(i): i[j] = v.replace('b','e') # go through each element in the list of list and replace
print(out)

[['aec'], ['aec', 'ecd']]

A: As rightfully mentioned by the other answers your variable 'out' becomes a list of list since you are appending 'i' (which is a list) into the variable 'out'. Try using 'out.extend' instead.
out = []
for i in value:
    i = i.split('>')
    out.extend(i)  ## this will add the element 'i' to the end of the existing list 'out'
    print("This is",out)

out = [j.replace("on", "re") for j in out]
print("new list", out)


text:
Q: Display "No Results" message with jQuery checkbox filter I found a jQuery filter that works really well for my needs (http://jsfiddle.net/n3EmN/171/). My only issue is that I want it to display a "No results found" message when the filtered results do not produce a result.
    var $filterCheckboxes = $('input[type="checkbox"]');

$filterCheckboxes.on('change', function() {

  var selectedFilters = {};

  $filterCheckboxes.filter(':checked').each(function() {

    if (!selectedFilters.hasOwnProperty(this.name)) {
      selectedFilters[this.name] = [];
    }

    selectedFilters[this.name].push(this.value);

  });

  // create a collection containing all of the filterable elements
  var $filteredResults = $('.flower');

  // loop over the selected filter name -> (array) values pairs
  $.each(selectedFilters, function(name, filterValues) {

    // filter each .flower element
    $filteredResults = $filteredResults.filter(function() {

      var matched = false,
        currentFilterValues = $(this).data('category').split(' ');

      // loop over each category value in the current .flower's data-category
      $.each(currentFilterValues, function(_, currentFilterValue) {

        // if the current category exists in the selected filters array
        // set matched to true, and stop looping. as we're ORing in each
        // set of filters, we only need to match once

        if ($.inArray(currentFilterValue, filterValues) != -1) {
          matched = true;
          return false;
        }
      });

      // if matched is true the current .flower element is returned
      return matched;

    });
  });

  $('.flower').hide().filter($filteredResults).show();

});

If you use the Fiddle to select both "Red" and "Africa", the results show blank. An ideal UX would be to say "No results found, try changing your filters."
How can I accomplish this with the provided code?

A: Add the css class for hide
.hide{display:none; }

Add this div at the bottom of all your .flowers div

No results found, try changing your filters.

Add this inside your change event
if(!$('.flower').is(':visible'))
 {
  $("#NoResult").removeClass("hide");
 }
 else
 {
 $("#NoResult").addClass("hide");

 }

Here is the altered fiddle : http://jsfiddle.net/r97L1zvf/1/


text:
Q: GCP Cloud Functions helpers Assume we're deploying GCP Cloud Functions from a GitHub repo (mirrored via GCP Source Repositories). Is it possible to set up shared code that can be accessed by both functions below? (e.g. via helpers.py).
helpers.py
function_one/
├── main.py
function_two/
├── main.py

A: Not exactly, since each function is a separate entity. But you could move your helpers.py to its own repository, then import the repository within each individual function.

A: Normally you make a library out of your helpers (like any other libs in your requirements), then you import it as a dependency of function1 or function2.
Cloud Functions will get all your functions dependencies before running the function1.


text:
Q: Need help working with footer in IE Being a web designer I hope to make websites that at least work in as many browsers as possible. I still try to design for IE 7 for those visitors only using IE and who don't know anything else. However I'm not too familiar id IE and it's spacing and it's hacks.
My website looks good, you can view it here, in every browser except IE. :s Thankfully it's only the footer now.
I'm hoping someone can give me advice and help me fix this hiccup and then maybe give me some references or articles about IE & it's spacing issues & hacks.
My footer doesn't work in either IE 7 or 8.
IE 7:

IE 8:

CSS
#footer { width: 100%; height: 503px; background: url(img/FOOTER-bg.jpg) repeat-x; background-color: #821d20; margin-top: 100px;/*border: 1px solid #0C0;*/}
#footer a { text-decoration: underline; color: #c7bd89 !important; }
#footer a:hover { text-decoration: none; color: #fff; }

#footer h6 { background: url(img/FOOTER-HR-BG.jpg) left center repeat-x; text-align: left;}
#footer h6 span { background: #8e2023; display: inline-block; padding-right: 5px; }

I've tried a bunch of different ways but I'm not sure whats happening in IE with this footer. If anyone can shed some light on what might be happening, it would be greatly appreciated!

A: I'm not sure of the root of the problem but instead of using "float: right;", using "position: absolute; right: -2px;" seems to solve the issue (also ensure #searchform has a relative position).

A: you have an unclosed aside element for starters. if you view it in ie8 and use f12 developer tools you can see how the footer is now a child of the element. close that guy out....should help out.


text:
Q: How could I enable bootchart for Android L MR1 5.1 I am investigating android first time boot up, and want to enable bootchart, but I always get failed, below is what I have done, someone could help me?
because the bootchart service start up earlier than  /data partition mount, so every time bootchart failed to init.
the failure message from kernel log is : bootcharting init failure
so in order to ensure bootchart init sucessfully,  I have changed related code. and this solution can work well in Android L, but failed in Android L MR1.
phone keep restart after implement below change; after I disable selinux, phone block at first logo.

init/bootchart.c
/* called to setup bootcharting */
int   bootchart_init( void )
{
    int  ret;
    char buff[4];
    int  timeout = 0, count = 0;

    buff[0] = 0;

+    /* wait until /data mounted */
+    struct stat datadir;
+    if(stat("/data/bootchart-start", &datadir) == -1) {
+    ERROR("Bootchart, /data/bootchart-start not exists\n");
+    return -1;
+    }
    proc_read( LOG_STARTFILE, buff, sizeof(buff) );
    if (buff[0] != 0) {
        timeout = atoi(buff);
    }

init/init.c
static int bootchart_init_action(int nargs, char **args)
{
    bootchart_count = bootchart_init();
    if (bootchart_count < 0) {
        ERROR("bootcharting init failure\n");
+   queue_builtin_action(bootchart_init_action, "bootchart_init");
    } else if (bootchart_count > 0) {
        NOTICE("bootcharting started (period=%d ms)\n", bootchart_count*BOOTCHART_POLLING_MS);
    } else {
        NOTICE("bootcharting ignored\n");
    }

rootdir/init.rc
on post-fs-data
    # We chown/chmod /data again so because mount is run as root + defaults
    chown system system /data
    chmod 0771 /data
    # We restorecon /data in case the userdata partition has been reset.
    restorecon /data

+    write /data/bootchart-start 600
    # Avoid predictable entropy pool. Carry over entropy from previous boot.
    copy /data/system/entropy.dat /dev/urandom

/system/core/init/Android.mk

+ INIT_BOOTCHART :=true
ifeq ($(strip $(INIT_BOOTCHART)),true)
LOCAL_SRC_FILES += bootchart.c
LOCAL_CFLAGS    += -DBOOTCHART=1
endif

Is there someone ever enable bootchart on android L MR1 ? How could you change code for?
How could I modify code to ensure bootchart init running after /data/ partition mounted?
Thank you in advance! It is very serious to me.

A: I was able to enable bootchart for first boot by this init.rc:
on post-fs-data
    # We chown/chmod /data again so because mount is run as root + defaults
    chown system system /data
    chmod 0771 /data
    # We restorecon /data in case the userdata partition has been reset.
    restorecon /data

    # start debuggerd to make debugging early-boot crashes easier.
    start debuggerd
    start debuggerd64

    # Make sure we have the device encryption key.
    start vold
    installkey /data

    # Start bootcharting as soon as possible after the data partition is
    # mounted to collect more data.
    mkdir /data/bootchart 0755 shell shell
    # if you need to enable bootchart uncomment next line
    # Old Android
    # write /data/bootchart-start 120
    # Android > 7.0
    # write /data/bootchart/start 120
    bootchart_init


text:
Q: cordova InAppPurchase Plugin gives error "ERROR TypeError: Cannot read property 'getProducts' of undefined" I use cordova in-app-purchase plugin in my App, but getting error of "ERROR TypeError: Cannot read property 'getProducts' of undefined"
.ts File is like:
window['plugins'].inAppPurchase.getProducts(productIds).then(products => {
      console.log('got products: ', JSON.stringify(products));
      self.buyProducts(products[0].productId);

    });

Stuck in this. Thanks in advance.

A: The way you are using inAppPurchase class object is not right, Follow below approach to make it work.
To add plugin run this command:
cordova plugin add cordova-plugin-inapppurchase
After successfully installing and configuring the plugin. import and use the plugin in the required component as follows.
import { InAppPurchase } from '@ionic-native/in-app-purchase/ngx';
and inject in the constructor like this
constructor(
    private iap: InAppPurchase,
  ) {
        this.iap
        .getProducts(PaymentPage.PRODUCT_IDS)
        .then((products) => {
          console.log('Get products', JSON.stringify(products));
         })
        .catch((err) => {
          console.log(JSON.stringify(err));
        });
}

Hope it will solve your problem.


text:
Q: Access $app or $request in Eloquent using Slim Framework I am building a Slim Framework 4 Api Application, with Eloquent.
public/index.php
$capsule = new \Illuminate\Database\Capsule\Manager;
$capsule->addConnection($dbconfig);
$capsule->setAsGlobal();
$capsule->bootEloquent();

$app->add(new RequestUser()); // for calling middleware that adds user

Middlware
 class RequestUser
  {

public function __invoke(Request $request, RequestHandler $handler): Response
{
     ....................
    $user = User::where('emailid', $email)->first();
    $request = $request->withAttribute('user', $user);
    $request = $request->withAttribute('token', (string) $exploded_authorization[1]);
    return $handler->handle($request);
  }
  }

Controller
use Psr\Http\Message\ServerRequestInterface as Request;

public function create(Request $request, Response $response, $args)
    {
$user = $request->getAttribute('user'); // gives me the request user information

    }

Model
<?php

namespace App\Models\TableModel;

use Illuminate\Database\Eloquent\Model;
use DateTime;
use Psr\Http\Message\ServerRequestInterface as Request;

class Details extends Model
{
    protected $table = 'my_table';

    protected $primaryKey = 'Id';

    public $timestamps = false;

    protected $fillable = [];

    protected $hidden = [];

    protected $casts = [

    ];

    protected $appends = ['can_edit', 'can_delete'];

    public function getCanEditAttribute(){
        $now = date('Y-m-d H:i:s');
        return $this->Start_Date >= $now;
    }

    public function getCanDeleteAttribute(){
        //request contains the user information from the middleware? How to access here
        return
    }

}

I want to access the $request in my Model so that i could get the user information, who is trying to access on CanDelete.

A: You got the wrong kind of middleware, it needs to be a routing middleware and binded to route or route group directly, not $app->add


text:
Q: Not geting value while Parsing Json String in C# I am getting the json string "jasonContent" from nyTimes. When I write the following code I can get the values of total and offset but i am interested in results,but I am getting nothing for results.The string I am receiving is something like this
{

  "offset": "0",

   "results": [

    {
      "body": " news goes here",

      "byline": "By SANA SIWOLOP",
      "date": "20110511",
      "title": "SQUARE FEET; Chelsea Piers, a Manhattan Sports Center, Expands Close to Home",
      "url": "http:\/\/www.nytimes.com\/2011\/05\/11\/realestate\/commercial\/chelsea-piers-a-manhattan-sports-center-expands-close-to-home.html"
    },
    {
      "body": "news 2 goes here",
      "byline": "By ROB HUGHES",
      "date": "20110511",
      "title": "ON SOCCER; Racial Politics Rear Their Head in French Soccer",
      "url": "http:\/\/www.nytimes.com\/2011\/05\/11\/sports\/soccer\/11iht-SOCCER11.html"
    },
    {
      "body": "news3 does here",
      "byline": "By RICHARD SANDOMIR",
      "date": "20110511",
      "title": "Gus Johnson Joins Fox Sports",
      "url": "http:\/\/www.nytimes.com\/2011\/05\/11\/sports\/gus-johnson-joins-fox-sports.html"
    },],"tokens": [
 "sports" ],
  "total": 152539
}

For parsing this string I am writing the following code
 public class nytimesnews
{
    public string offset { get; set; }
    public resultobject news2;
    public string total { get; set; }
}

public class resultobject
{
    public results[] news;
}

public class results
{
    public string body { get; set; }
    public string byline { get; set; }
    public string date { get; set; }
    public string title { get; set; }
    public string url { get; set; }
}

nytimesnews parse = JsonConvert.DeserializeObject<nytimesnews>(jasonContent);

A: The problem is solved. (I was using Json.NET). I noticed that the variables of the nytimesnews class should be named according to the json string. I made following changes to the code and it worked perfectly.
 public class nytimesnews
 {
       // name of these variables are just like the  data tags in json string
       public string offset { get; set; }
       public result[] results;
       public string total { get; set; }
 }

 public class results
 {
       public string body { get; set; }
       public string byline { get; set; }
       public string date { get; set; }
       public string title { get; set; }
       public string url { get; set; }
 }

Then in my main class I just used following code
 // jasonContent is the jason string
 nytimesnews parse = JsonConvert.DeserializeObject<nytimesnews>(jasonContent);
 jasonContent = parse.results[1].body;


text:
Q: A tough integral $\int_0^{\infty}\frac{\operatorname{sech}(\pi x)}{1+4x^2}\, \mathrm dx $ I was working on an integral which I found on Quora. I simplified it a lot and ended up with this intgeral
$$\int_0^{\infty}\dfrac{\operatorname{sech}(\pi x)}{1+4x^2}\, \mathrm dx $$
I tried converting this into exponential form and using geometric series which ended up in this.
$$2\sum_{k=0}^\infty (-1)^k\int_0^\infty \dfrac{e^{-(2k+1)\pi x}}{4x^2+1}\, \mathrm dx $$
I didn't try to solve this using exponential integral, as I am not that much familiar with it.
Using Wolfram|Alpha, I figured out that this integral is equal to $\frac{1}{2}\ln{2}$. The simple answer makes me suspect if the integral is just a tricky one.
How can I evaluate this integral, using this method or any other method, except contour integration?

A: The question asks for anything "except contour integration", but actually the latter is the very first thing I would apply here. So this answer follows the contour integration approach for reference.
The integral is $\frac12\int_{-\infty}^\infty$, so that if $I_{R,N}=\int_{C_{R,N}}\frac{\operatorname{sech}\pi z}{1+4z^2}\,dz$ where, for $R>0$ and $N$ a positive integer, we take $C_{R,N}$ to be the boundary of $[-R,R]+i[0,N]$, then $\lim\limits_{R\to\infty}\lim\limits_{N\to\infty}I_{R,N}$ is twice the given integral, and it equals $2\pi i$ times the sum of the residues of the integrand at $z=i(n+1/2)$ over $n\in\mathbb{Z}_{\geqslant 0}$ ($n=0$ is a double pole, $n>0$ are simple poles): $$\operatorname*{Res}_{z=i/2}\frac{\operatorname{sech}\pi z}{1+4z^2}=\frac1{4\pi i},\quad\operatorname*{Res}_{z=i(n+1/2)}\frac{\operatorname{sech}\pi z}{1+4z^2}=\frac1{4\pi i}\frac{(-1)^{n-1}}{n(n+1)}.\quad(n>0)$$ Hence the value of the given integral is, as conjectured, $$\frac14\left[1+\sum_{n=1}^\infty(-1)^{n-1}\left(\frac1n-\frac1{n+1}\right)\right]=\frac14\big(1+\ln2-(1-\ln2)\big)=\frac{\ln2}{2}.$$

A: A short solution by using the series of $\operatorname{sech}(x)$.
Since $$\operatorname{sech}(x)= 4\sum_{k=0}^{\infty}\frac{(-1)^k(2k+1)\pi}{(2k+1)^2\pi^2+4x^2}$$ and then we have $$\int_0^{\infty}\frac{\operatorname{sech}(\pi x)}{1+4x^2}dx=\frac{4}{\pi}\sum_{k=0}^{\infty}{(-1)^k(2k+1)}\int_0^{\infty}\frac{dx}{(m^2+4x^2)(1+4x^2)}=$$ where $m=2k+1$ and by partial fraction decomposition  we easily can deduce the integral $$\int_0^{\infty}\frac{dx}{(m^2+4x^2)(1+4x^2)}=\frac{\pi}{4m(m+1)}=\frac{\pi}{4(2k+1)(2k+2)}$$ and hence we have $$\sum_{k=0}^{\infty}\frac{(-1)^k}{2(k+1)}=\frac{1}{2}\sum_{k=1}^{\infty}\frac{(-1)^{k-1}}{k}=\frac{\log(2)}{2}$$

A: Note that your integrand is even in $x$, so that you are really concerned with
$$ \frac{1}{2}\int_{\mathbb{R}} \operatorname{sech}(\pi x) \frac{1}{1+4x^2}\,dx.$$
If you're willing to accept Fourier transform techniques, we have
$$ \frac{1}{\sqrt{2\pi}}\int_{\mathbb{R}} e^{-ixy}\operatorname{sech}(\pi x)\,dx = \frac{1}{\sqrt{2\pi}}\operatorname{sech}\bigg(\frac{y}{2}\bigg) $$
and also
$$ \frac{1}{\sqrt{2\pi}} \int_{\mathbb{R}} e^{-ixy} \frac{1}{1+4x^2}\,dx = \frac{1}{2}\sqrt{\frac{\pi}{2}} e^{-|y|/2}. $$
Then from Parseval's theorem,
\begin{align}
\frac{1}{2}\int_{\mathbb{R}} \operatorname{sech}(\pi x) \frac{1}{1+4x^2}\,dx &= \frac{1}{2} \int_{\mathbb{R}} \frac{1}{\sqrt{2\pi}} \operatorname{sech}\bigg(\frac{y}{2}\bigg) \frac{1}{2}\sqrt{\frac{\pi}{2}} e^{-|y|/2}\,dy \\
&= \frac{1}{4} \int_0^{\infty} \operatorname{sech}\bigg(\frac{y}{2}\bigg) e^{-y/2}\,dy.
\end{align}
As for this integral, note that $\operatorname{sech}(x) = \frac{2}{e^x + e^{-x}}$ so that we are left to evaluate
$$ \frac{1}{2}\int_0^{\infty} \frac{e^{-y/2}}{e^{y/2} + e^{-y/2}}\,dy. $$
Let $z = e^{-y/2}$, then $dz = -\frac{1}{2} e^{-y/2}\,dy$, to give
$$ \int_0^1 \frac{1}{z^{-1}+z}\,dz = \int_0^1 \frac{z}{1+z^2}\,dz = \frac{\log(2)}{2}.$$

A: Integrate as follows
\begin{align}
&\int_0^{\infty}\frac{\operatorname{sech}(\pi x)}{1+4x^2}\>dx\\
\overset{t=2\pi x }=& \frac\pi2 \int_{-\infty}^{\infty}\frac{e^{\frac t2}}{(e^t+1)(\pi^2+t^2)}dt\\
=& \frac\pi2 \int_{-\infty}^{\infty}\frac{e^{\frac t2}}{e^t+1}Re\left(\frac1\pi \int_0^\infty e^{-(\pi-i t)y }dy\right)dt\\
 =& \frac12 Re\int_{0}^{\infty}e^{-\pi y} \left(\int_{-\infty}^\infty \frac{e^{a t}}{e^t+1}dt \right)dy
\>\>\>\>\>\>\>a= iy+\frac12\\
\overset{x=e^t}=& \frac12 Re\int_{0}^{\infty}e^{-\pi y} \left(\int_{0}^\infty \frac{x^{a-1}}{x+1}dx \right)dy \\
 =& \frac12Re \int_{0}^{\infty}e^{-\pi y}\pi\csc(\pi a)\,dy \\
=& \int_{0}^{\infty} \frac\pi{e^{2\pi y}+1}dy
\overset{t=e^{-2\pi y}}=\frac12\int_0^1 \frac1{1+t}dt\\
=&\frac12\ln2
\end{align}

A: All proposed different ways of solution to the problem are really nice. In my opinion, contour integration "catches" the symmetry of this problem deeper and allows to get the closed answer to more general problem.
Let's denote
$$I(a)=\int_{-\infty}^\infty\frac{dx}{(e^{\pi x}+e^{-\pi x})(a^2+x^2)}$$
Then $$I_0=\int_0^{\infty}\dfrac{\operatorname{sech}(\pi x)}{1+4x^2}\, \mathrm dx=\frac{1}{4}\int_{-\infty}^\infty\frac{dx}{(e^{\pi x}+e^{-\pi x})(\bigl(\frac{1}{2}\bigr)^2+x^2)}=\frac{1}{4}I\Bigl(\frac{1}{2}\Bigr)$$
Let's also consider $$J(a)=\int_{-\infty}^\infty\frac{\log\bigl(a^2+x^2\bigr)}{e^{\pi x}+e^{-\pi x}}dx$$
Then $I(a)=\frac{1}{2a}\frac{\partial}{\partial a}J(a)$ and
$$J(a)=2\,\Re\int_{-\infty}^\infty\frac{\log\bigl(a-ix\bigr)}{e^{\pi x}+e^{-\pi x}}dx=\frac{2}{\pi}\Re\int_{-\infty}^\infty\frac{\log\bigl(a-\frac{it}{\pi}\bigr)}{e^t+e^{-t}}dt$$ $$=\frac{2}{\pi}\Re\int_{-\infty}^\infty\frac{\log\bigl(\frac{a}{2}-\frac{it}{2\pi}\bigr)+\log2}{e^t+e^{-t}}dt=J_1(a)+J_2$$
where $$J_2=\frac{2\log2}{\pi}\int_{-\infty}^\infty\frac{dt}{e^t+e^{-t}}=\frac{2\log2}{\pi}\int_{-\infty}^\infty\frac{e^tdt}{e^{2t}+1}=\frac{2\log2}{\pi}\int_{0}^\infty\frac{dx}{x^2+1}=\log2$$
To evaluate $J_1(a)$ we follow the approach developed by Iaroslav V. Blagouchine (here)
Noting that $\log z=\log\Gamma (z+1)-\log\Gamma(z)$
$$J_1(a)=\frac{2}{\pi}\Re\int_{-\infty}^\infty\frac{\log\bigl(\frac{a}{2}-\frac{it}{2\pi}\bigr)}{e^t+e^{-t}}dt=\frac{2}{\pi}\Re\int_{-\infty}^\infty\frac{\log\Gamma\bigl(\frac{a}{2}-\frac{it}{2\pi}+1\bigr)-\log\Gamma\bigl(\frac{a}{2}-\frac{it}{2\pi}\bigr)}{e^t+e^{-t}}dt$$
Next, we choose a rectangular contour C in the complex plane

Noting that integral along the path $(1)$ and $(2)$ wanish as $R\to\infty$ and that $e^{2\pi i+t}=e^t$, we can write:
$$J_1(a)=-\frac{2}{\pi}\Re\oint_C\frac{\log\Gamma\bigl(\frac{a}{2}-\frac{iz}{2\pi}\bigr)}{e^z+e^{-z}}dz=\Re\biggl(-2\pi i \frac{2}{\pi}\operatorname*{Res}_{\binom{z=\pi i/2}{z=3\pi i/2}}\frac{\log\Gamma\bigl(\frac{a}{2}-\frac{iz}{2\pi}\bigr)}{e^z+e^{-z}}\biggr)=2\Bigl(\log\Gamma\bigl(\frac{a}{2}+\frac{3}{4}\bigr)-\log\Gamma\bigl(\frac{a}{2}+\frac{1}{4}\bigr)\Bigr)$$
$$J(a)=\int_{-\infty}^\infty\frac{\log\bigl(a^2+x^2\bigr)}{e^{\pi x}+e^{-\pi x}}dx=J_1(a)+J_2=2\Bigl(\log\Gamma\bigl(\frac{a}{2}+\frac{3}{4}\bigr)-\log\Gamma\bigl(\frac{a}{2}+\frac{1}{4}\bigr)\Bigr)+\log2$$
Taking derivative with respect to $a$ we can easily evaluate expressions like $\int_{-\infty}^\infty\frac{dx}{(e^{\pi x}+e^{-\pi x})(a^2+x^2)^n}$.
For example,
$$I_0=\int_0^{\infty}\dfrac{\operatorname{sech}(\pi x)}{1+4x^2}\, \mathrm dx=\frac{1}{4}I\bigl(a=\frac{1}{2}\bigr)=\frac{1}{4}\frac{1}{2a}\frac{\partial}{\partial a}J(a)|_{a=1/2}=\frac{1}{8a}\Bigl(\Psi\bigl(\frac{a}{2}+\frac{3}{4}\bigr)-\Psi\bigl(\frac{a}{2}+\frac{1}{4}\bigr)\Bigr)|_{a=1/2}$$
$$I_0=\frac{1}{4}\Bigl(\Psi(1)-\Psi(\frac{1}{2})\Bigr)=\frac{\log2}{2}$$
where $\Psi(x)=\frac{\partial}{\partial x}\log\Gamma(x)$ - digamma function.


text:
Q: Unable to build release apk I am trying to build my project to get the release apk I'm getting bunch of warnings where I'm not able to get it working
Warning:
Note: duplicate definition of library class [org.apache.http.HttpRequestInterceptor]
Note: duplicate definition of library class [org.apache.http.HttpServerConnection]
Note: duplicate definition of library class [org.apache.http.ProtocolVersion]
Note: duplicate definition of library class [org.apache.http.params.BasicHttpParams]
Note: duplicate definition of library class [org.apache.http.params.CoreProtocolPNames]
Note: duplicate definition of library class [org.apache.http.params.HttpProtocolParamBean]
Note: duplicate definition of library class [org.apache.http.params.HttpAbstractParamBean]
Note: duplicate definition of library class [org.apache.http.params.HttpConnectionParams]
Note: duplicate definition of library class [org.apache.http.params.DefaultedHttpParams]
Note: duplicate definition of library class [org.apache.http.params.HttpProtocolParams]
Note: duplicate definition of library class [org.apache.http.params.HttpConnectionParamBean]
Note: duplicate definition of library class [org.apache.http.params.HttpParams]
Note: duplicate definition of library class [org.apache.http.params.CoreConnectionPNames]
Note: duplicate definition of library class [org.apache.http.params.AbstractHttpParams]
Note: duplicate definition of library class [org.apache.http.HttpConnectionMetrics]
Note: duplicate definition of library class [org.apache.http.message.BasicHeaderIterator]
Note: duplicate definition of library class [org.apache.http.message.BasicHeaderElement]
Note: duplicate definition of library class [org.apache.http.message.BasicHeaderElementIterator]
Note: duplicate definition of library class [org.apache.http.message.BasicHeaderValueFormatter]
Note: duplicate definition of library class [org.apache.http.message.BasicHeader]
Note: duplicate definition of library class [org.apache.http.message.LineParser]
Note: duplicate definition of library class [org.apache.http.message.HeaderGroup]
Note: duplicate definition of library class [org.apache.http.message.BasicLineParser]
Note: duplicate definition of library class [org.apache.http.message.BufferedHeader]
Note: duplicate definition of library class [org.apache.http.message.BasicHttpRequest]
Note: duplicate definition of library class [org.apache.http.message.BasicLineFormatter]
Note: duplicate definition of library class [org.apache.http.message.BasicTokenIterator]
Note: duplicate definition of library class [org.apache.http.message.BasicListHeaderIterator]
Note: duplicate definition of library class [org.apache.http.message.BasicHttpEntityEnclosingRequest]
Note: duplicate definition of library class [org.apache.http.message.HeaderValueFormatter]
Note: duplicate definition of library class [org.apache.http.message.BasicNameValuePair]
Note: duplicate definition of library class [org.apache.http.message.BasicHttpResponse]
Note: duplicate definition of library class [org.apache.http.message.AbstractHttpMessage]
Note: duplicate definition of library class [org.apache.http.message.BasicHeaderValueParser]
Note: duplicate definition of library class [org.apache.http.message.LineFormatter]
Note: duplicate definition of library class [org.apache.http.message.BasicRequestLine]
Note: duplicate definition of library class [org.apache.http.message.HeaderValueParser]
Note: duplicate definition of library class [org.apache.http.message.ParserCursor]
Note: duplicate definition of library class [org.apache.http.message.BasicStatusLine]
Note: duplicate definition of library class [org.apache.http.HttpVersion]
Note: duplicate definition of library class [org.apache.http.cookie.params.CookieSpecParamBean]
Note: duplicate definition of library class [org.apache.http.cookie.params.CookieSpecPNames]
Note: duplicate definition of library class [org.apache.http.cookie.CookiePathComparator]
Note: duplicate definition of library class [org.apache.http.cookie.ClientCookie]
Note: duplicate definition of library class [org.apache.http.cookie.CookieSpec]
Note: duplicate definition of library class [org.apache.http.cookie.SetCookie]
Note: duplicate definition of library class [org.apache.http.cookie.CookieOrigin]
Note: duplicate definition of library class [org.apache.http.cookie.SM]
Note: duplicate definition of library class [org.apache.http.cookie.CookieSpecRegistry]
Note: duplicate definition of library class [org.apache.http.cookie.CookieSpecFactory]
Note: duplicate definition of library class [org.apache.http.cookie.MalformedCookieException]
Note: duplicate definition of library class [org.apache.http.cookie.CookieAttributeHandler]
Note: duplicate definition of library class [org.apache.http.cookie.SetCookie2]
Note: duplicate definition of library class [org.apache.http.cookie.CookieIdentityComparator]
Note: duplicate definition of library class [org.apache.http.cookie.Cookie]
Note: duplicate definition of library class [org.apache.http.HttpEntityEnclosingRequest]
Note: duplicate definition of library class [org.apache.http.TokenIterator]
Note: duplicate definition of library class [org.apache.http.ProtocolException]
Note: duplicate definition of library class [org.apache.http.ReasonPhraseCatalog]
Note: duplicate definition of library class [org.apache.http.io.HttpMessageWriter]
Note: duplicate definition of library class [org.apache.http.io.HttpTransportMetrics]
Note: duplicate definition of library class [org.apache.http.io.HttpMessageParser]
Note: duplicate definition of library class [org.apache.http.io.SessionOutputBuffer]
Note: duplicate definition of library class [org.apache.http.io.SessionInputBuffer]
Note: duplicate definition of library class [org.apache.http.NameValuePair]
Note: duplicate definition of library class [org.apache.http.auth.params.AuthPNames]
Note: duplicate definition of library class [org.apache.http.auth.params.AuthParams]
Note: duplicate definition of library class [org.apache.http.auth.params.AuthParamBean]
Note: duplicate definition of library class [org.apache.http.auth.NTUserPrincipal]
Note: duplicate definition of library class [org.apache.http.auth.NTCredentials]
Note: duplicate definition of library class [org.apache.http.auth.Credentials]
Note: duplicate definition of library class [org.apache.http.auth.UsernamePasswordCredentials]
Note: duplicate definition of library class [org.apache.http.auth.AuthSchemeFactory]
Note: duplicate definition of library class [org.apache.http.auth.InvalidCredentialsException]
Note: duplicate definition of library class [org.apache.http.auth.AuthenticationException]
Note: duplicate definition of library class [org.apache.http.auth.AuthState]
Note: duplicate definition of library class [org.apache.http.auth.BasicUserPrincipal]
Note: duplicate definition of library class [org.apache.http.auth.AUTH]
Note: duplicate definition of library class [org.apache.http.auth.AuthScheme]
Note: duplicate definition of library class [org.apache.http.auth.AuthScope]
Note: duplicate definition of library class [org.apache.http.auth.AuthSchemeRegistry]
Note: duplicate definition of library class [org.apache.http.auth.MalformedChallengeException]
Note: duplicate definition of library class [org.apache.http.HttpHost]
Note: duplicate definition of library class [org.apache.http.HttpStatus]
Note: duplicate definition of library class [org.apache.http.HttpRequest]
Note: duplicate definition of library class [org.apache.commons.logging.LogSource]
Note: duplicate definition of library class [org.apache.commons.logging.impl.NoOpLog]
Note: duplicate definition of library class [org.apache.commons.logging.impl.LogFactoryImpl]
Note: duplicate definition of library class [org.apache.commons.logging.impl.Jdk14Logger]
Note: duplicate definition of library class [org.apache.commons.logging.impl.WeakHashtable]
Note: duplicate definition of library class [org.apache.commons.logging.impl.SimpleLog]
Note: duplicate definition of library class [org.apache.commons.logging.LogConfigurationException]
Note: duplicate definition of library class [org.apache.commons.logging.Log]
Note: duplicate definition of library class [org.apache.commons.logging.LogFactory]
Note: duplicate definition of library class [org.apache.commons.codec.StringDecoder]
Note: duplicate definition of library class [org.apache.commons.codec.BinaryDecoder]
Note: duplicate definition of library class [org.apache.commons.codec.binary.Hex]
Note: duplicate definition of library class [org.apache.commons.codec.binary.Base64]
Note: duplicate definition of library class [org.apache.commons.codec.binary.BinaryCodec]
Note: duplicate definition of library class [org.apache.commons.codec.EncoderException]
Note: duplicate definition of library class [org.apache.commons.codec.DecoderException]
Note: duplicate definition of library class [org.apache.commons.codec.BinaryEncoder]
Note: duplicate definition of library class [org.apache.commons.codec.Decoder]
Note: duplicate definition of library class [org.apache.commons.codec.StringEncoder]
Note: duplicate definition of library class [org.apache.commons.codec.language.RefinedSoundex]
Note: duplicate definition of library class [org.apache.commons.codec.language.DoubleMetaphone]
Note: duplicate definition of library class [org.apache.commons.codec.language.Metaphone]
Note: duplicate definition of library class [org.apache.commons.codec.language.Soundex]
Note: duplicate definition of library class [org.apache.commons.codec.language.DoubleMetaphone$DoubleMetaphoneResult]
Note: duplicate definition of library class [org.apache.commons.codec.StringEncoderComparator]
Note: duplicate definition of library class [org.apache.commons.codec.Encoder]
Note: duplicate definition of library class [org.apache.commons.codec.net.URLCodec]
Note: duplicate definition of library class [org.apache.commons.codec.net.RFC1522Codec]
Note: duplicate definition of library class [org.apache.commons.codec.net.BCodec]
Note: duplicate definition of library class [org.apache.commons.codec.net.QCodec]
Note: duplicate definition of library class [org.apache.commons.codec.net.QuotedPrintableCodec]
Note: duplicate definition of library class [android.net.http.SslCertificate$DName]
Note: duplicate definition of library class [android.net.http.SslCertificate]
Note: duplicate definition of library class [android.net.http.HttpResponseCache]
Note: duplicate definition of library class [android.net.http.SslError]

Note: there were 408 duplicate class definitions.
      (http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)

Initializing...
Note: the configuration refers to the unknown class 'com.android.vending.billing.IInAppBillingService'
Note: the configuration refers to the unknown class 'com.android.vending.billing.IInAppBillingService'
Note: the configuration refers to the unknown class 'com.android.vending.billing.IInAppBillingService'
Note: the configuration refers to the unknown class 'com.android.vending.billing.IInAppBillingService'

Warning: org.apache.commons.logging.impl.ServletContextCleaner: can't find superclass or interface javax.servlet.ServletContextListener
Warning: library class android.net.http.AndroidHttpClient extends or implements program class org.apache.http.client.HttpClient
Warning: library class android.net.http.AndroidHttpClientConnection extends or implements program class org.apache.http.HttpInetConnection
Warning: library class android.net.http.AndroidHttpClientConnection extends or implements program class org.apache.http.HttpConnection
Warning: library class com.android.internal.http.multipart.MultipartEntity extends or implements program class org.apache.http.entity.AbstractHttpEntity
Warning: com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient
Warning: com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient
Warning: com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient
Warning: com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient
Warning: com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient
Warning: com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Cache
Warning: com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.Cache
Warning: com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient
Warning: okio.DeflaterSink: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced
Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Category
Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Category
Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Priority
Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Priority
Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Priority
Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Priority
Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Priority
Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Logger
Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Category
Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Category
Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Category
Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Priority
Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Category
Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Logger
Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Logger
Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Priority
Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Logger
Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Logger
Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Logger
Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced
Warning: org.apache.commons.logging.impl.ServletContextCleaner: can't find referenced class javax.servlet.ServletContextListener
Warning: org.apache.commons.logging.impl.ServletContextCleaner: can't find referenced class javax.servlet.ServletContextEvent
Warning: org.apache.commons.logging.impl.ServletContextCleaner: can't find referenced class javax.servlet.ServletContextEvent
Warning: org.apache.commons.logging.impl.ServletContextCleaner: can't find referenced class javax.servlet.ServletContextEvent
Warning: org.apache.commons.logging.impl.ServletContextCleaner: can't find referenced class javax.servlet.ServletContextEvent
Warning: retrofit2.Platform$Java8: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

Note: com.google.android.youtube.player.internal.aa: can't find dynamically referenced class com.google.android.youtube.api.locallylinked.LocallyLinkedFactory
Note: com.google.common.util.concurrent.MoreExecutors: can't find dynamically referenced class com.google.appengine.api.ThreadManager
Note: com.google.common.util.concurrent.MoreExecutors: can't find dynamically referenced class com.google.apphosting.api.ApiProxy
Note: com.google.gson.internal.UnsafeAllocator: can't find dynamically referenced class sun.misc.Unsafe
Note: com.google.protobuf.zzc: can't find dynamically referenced class com.google.protobuf.ExtensionRegistry
Note: com.google.protobuf.zzd: can't find dynamically referenced class com.google.protobuf.Extension
Note: com.google.protobuf.zze: can't find dynamically referenced class libcore.io.Memory
Note: com.google.protobuf.zze: can't find dynamically referenced class org.robolectric.Robolectric
Note: com.squareup.picasso.Utils: can't find dynamically referenced class com.squareup.okhttp.OkHttpClient
Note: okhttp3.internal.platform.AndroidPlatform: can't find dynamically referenced class com.android.org.conscrypt.SSLParametersImpl
Note: okhttp3.internal.platform.AndroidPlatform: can't find dynamically referenced class org.apache.harmony.xnet.provider.jsse.SSLParametersImpl
Note: okhttp3.internal.platform.AndroidPlatform$CloseGuard: can't find dynamically referenced class dalvik.system.CloseGuard
Note: okhttp3.internal.platform.Platform: can't find dynamically referenced class sun.security.ssl.SSLContextImpl
Note: org.apache.commons.logging.LogSource: can't find dynamically referenced class org.apache.log4j.Logger
Note: org.apache.commons.logging.impl.Log4JLogger: can't find dynamically referenced class org.apache.log4j.Priority
Note: org.apache.commons.logging.impl.Log4JLogger: can't find dynamically referenced class org.apache.log4j.Level
Note: org.apache.commons.logging.impl.Log4JLogger: can't find dynamically referenced class org.apache.log4j.Level

Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.HttpRequest
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.HttpEntity
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.params.HttpParams
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.conn.ClientConnectionManager
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.client.methods.HttpUriRequest
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.HttpResponse
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.client.methods.HttpUriRequest
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.protocol.HttpContext
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.HttpResponse
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.HttpHost
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.HttpRequest
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.HttpResponse
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.HttpHost
Warning: library class android.net.http.AndroidHttpClient depends on program

Note: the configuration keeps the entry point 'com.facebook.login.widget.LoginButton { void setDefaultAudience(com.facebook.login.DefaultAudience); }', but not the descriptor class 'com.facebook.login.DefaultAudience'
Note: the configuration keeps the entry point 'com.facebook.login.widget.LoginButton { void setLoginBehavior(com.facebook.login.LoginBehavior); }', but not the descriptor class 'com.facebook.login.LoginBehavior'
Note: the configuration keeps the entry point 'com.facebook.login.widget.LoginButton { void setToolTipStyle(com.facebook.login.widget.ToolTipPopup$Style); }', but not the descriptor class 'com.facebook.login.widget.ToolTipPopup$Style'
Note: the configuration keeps the entry point 'com.facebook.login.widget.LoginButton { void setToolTipMode(com.facebook.login.widget.LoginButton$ToolTipMode); }', but not the descriptor class 'com.facebook.login.widget.LoginButton$ToolTipMode'
Note: the configuration keeps the entry point 'com.facebook.login.widget.LoginButton { void setProperties(com.facebook.login.widget.LoginButton$LoginButtonProperties); }', but not the descriptor class 'com.facebook.login.widget.LoginButton$LoginButtonProperties'
Note: the configuration keeps the entry point 'com.facebook.login.widget.LoginButton { void setLoginManager(com.facebook.login.LoginManager); }', but not the descriptor class 'com.facebook.login.LoginManager'
Note: the configuration keeps the entry point 'com.facebook.login.widget.ProfilePictureView { void setOnErrorListener(com.facebook.login.widget.ProfilePictureView$OnErrorListener); }', but not the descriptor class 'com.facebook.login.widget.ProfilePictureView$OnErrorListener'
Note: the configuration keeps the entry point 'com.facebook.share.internal.LikeBoxCountView { void setCaretPosition(com.facebook.share.internal.LikeBoxCountView$LikeBoxCountViewCaretPosition); }', but not the descriptor class 'com.facebook.share.internal.LikeBoxCountView$LikeBoxCountViewCaretPosition'
Note: the configuration keeps the entry point 'com.facebook.share.widget.DeviceShareButton { void setShareContent(com.facebook.share.model.ShareContent); }', but not the descriptor class 'com.facebook.share.model.ShareContent'
Note: the configuration keeps the entry point 'com.facebook.share.widget.LikeView { void setLikeViewStyle(com.facebook.share.widget.LikeView$Style); }', but not the descriptor class 'com.facebook.share.widget.LikeView$Style'
Note: the configuration keeps the entry point 'com.facebook.share.widget.LikeView { void setAuxiliaryViewPosition(com.facebook.share.widget.LikeView$AuxiliaryViewPosition); }', but not the descriptor class 'com.facebook.share.widget.LikeView$AuxiliaryViewPosition'
Note: the configuration keeps the entry point 'com.facebook.share.widget.LikeView { void setHorizontalAlignment(com.facebook.share.widget.LikeView$HorizontalAlignment); }', but not the descriptor class 'com.facebook.share.widget.LikeView$HorizontalAlignment'
Note: the configuration keeps the entry point 'com.facebook.share.widget.LikeView { void setOnErrorListener(com.facebook.share.widget.LikeView$OnErrorListener); }', but not the descriptor class 'com.facebook.share.widget.LikeView$OnErrorListener'
Note: the configuration keeps the entry point 'com.facebook.share.widget.ShareButtonBase { void setShareContent(com.facebook.share.model.ShareContent); }', but not the descriptor class 'com.facebook.share.model.ShareContent'
Note: the configuration keeps the entry point 'com.google.android.gms.flags.impl.FlagProviderImpl { void init(com.google.android.gms.dynamic.IObjectWrapper); }', but not the descriptor class 'com.google.android.gms.dynamic.IObjectWrapper'
Note: the configuration keeps the entry point 'com.google.android.youtube.player.YouTubePlayerView { YouTubePlayerView(android.content.Context,android.util.AttributeSet,int,com.google.android.youtube.player.YouTubePlayerView$b); }', but not the descriptor class 'com.google.android.youtube.player.YouTubePlayerView$b'
Note: there were 4 references to unknown classes.
      You should check your configuration for typos.
      (http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass)
Note: there were 16 unkept descriptor classes in kept class members.
      You should consider explicitly keeping the mentioned classes
      (using '-keep').
      (http://proguard.sourceforge.net/manual/troubleshooting.html#descriptorclass)
Note: there were 17 unresolved dynamic references to classes or interfaces.
      You should check if you need to specify additional program jars.
      (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)

Warning: there were 126 unresolved references to classes or interfaces.
         You may need to add missing library jars or update their versions.
         If your code works fine without the missing classes, you can suppress
         the warnings with '-dontwarn' options.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Warning: there were 33 instances of library classes depending on program classes.
         You must avoid such dependencies, since the program classes will
         be processed, while the library classes will remain unchanged.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#dependency)

Exception while processing task java.io.IOException: Please correct the above warnings first.
:app:transformClassesAndResourcesWithProguardForFreeRelease FAILED

This is how it is in release build type:
 release {
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
                    'proguard-rules.pro'
        }

Now I have added some rules in proguard.txt as well as proguard.pro but sometimes its taking long time to build and its not happening.
Where do I need to add the rules correctly and what are the rules I need to add ?
Here are my dependencies:
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:recyclerview-v7:26.1.0'
    compile 'com.android.support:cardview-v7:26.1.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    compile "com.squareup.picasso:picasso:2.5.2"
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.nononsenseapps:filepicker:4.1.0'
    compile 'com.pes.materialcolorpicker:library:1.2.0'
    compile 'com.google.code.gson:gson:2.7'
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:converter-gson:2.3.0'
    compile 'com.squareup.retrofit2:converter-scalars:2.3.0'
    compile 'com.squareup.okhttp3:okhttp:3.3.1'
    compile 'com.squareup.okhttp3:logging-interceptor:3.8.0'
    compile 'com.github.myinnos:AwesomeImagePicker:1.0.2'
    compile 'com.android.support:multidex:1.0.1'

    // Dependency for Google Sign-In
    compile 'com.google.android.gms:play-services-auth:11.0.1'

    // Dependencies for the REST API example
    compile 'com.google.api-client:google-api-client:1.22.0'
    compile 'com.google.api-client:google-api-client-android:1.22.0'
    compile 'com.google.apis:google-api-services-people:v1-rev4-1.22.0'

    //Dependency for Facebook Sign-In
    compile 'com.facebook.android:facebook-android-sdk:4.+'

}

A: Found the solution posting here if someone like me who is struggling to get it worked.
Add this to your proguard.pro file
-dontwarn org.apache.commons.**
-keep class org.apache.http.** { *; }
-dontwarn org.apache.http.**
-dontwarn com.squareup.okhttp.**
-dontwarn okio.**
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions
-keepclasseswithmembers class * {
    @retrofit2.http.* <methods>;
}

A: You can tell gradle not to allow duplicate classes (take only the first) by adding the following to your build.gradle:
jar {
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

A: In my case, the problem get solved after adding this to build file:
configurations {
    all {
        exclude module: 'httpclient'
    }
}

And to proguard config:
-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault
-keep class * extends com.google.api.client.json.GenericJson {
*;
}
-keep class com.google.api.services.drive.** {
*;
}


text:
Q: Grafana build from source with docker-compose.yml and Dockerfile, path setup error, go command not found I am trying to install Grafana with docker-compose.yml and Dockerfile. This is giving me error of "go command not found"; I think this is because gopath is not setup properly. Same commands I have run one by one in host machine everything is working but same process I am trying with Docker and it is giving me error.
NOTE for error checking please click on link in last.
My docker-compose.yml file
version: '3'
services:
   web:
      build: .
      container_name: grafana
      ports:
        - "9000:3000"
      expose:
        - 9000
      volumes:
        - .:/newvolebs
      networks:
        - overlay
      environment:
         MYSQL_HOST: mysql
         MYSQL_DATABASE: grafana
         MYSQL_USERNAME: root
         MYSQL_PASSWORD: 12345
   mysql:
      image: mysql:5.6
      ports:
        - "3306:3306"
      expose:
        - 3306
      volumes:
        - newvolebs:/var/lib/mysql
      networks:
        - overlay
      environment:
          MYSQL_ROOT_PASSWORD: 12345
          MYSQL_DATABASE: grafana
volumes:
 newvolebs:
   driver: local
networks:
 overlay:
   driver: "bridge"

my DockerFile
FROM centos:centos7
RUN     useradd centos && \
        yum install -y sudo && \
        echo "centos ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
USER centos
ENV PATH="/home/centos/go:${PATH}"
RUN     sudo cd /home/centos && \
        sudo yum -y update && \
        sudo yum --setopt=tsflags=nodocs -y install \
        wget \git \
        gcc-c++ make \tar && \
        sudo wget https://storage.googleapis.com/golang/go1.11.2.linux-amd64.tar.gz && \
        sudo tar -xzvf go1.11.2.linux-amd64.tar.gz && \
        sudo mv go gocode && \
        curl --silent --location https://rpm.nodesource.com/setup_9.x | sudo bash && \
        sudo yum -y install nodejs && \
        yum clean all && \
        sudo chmod 666 ~/.bashrc && \
        sudo echo "export GOROOT=$HOME/gocode" >> ~/.bashrc \
        && sudo echo "export PATH=$PATH:$GOROOT/bin" >> ~/.bashrc \
        && sudo echo "export GOPATH=$HOME/go" >> ~/.bashrc \
        && sudo echo "export PATH=$PATH:$GOPATH/bin" >> ~/.bashrc && \
        PATH="${GOROOT}/bin:$PATH}" && \
        export GOPATH=/home/centos/go && \
        export GOROOT=/home/centos/gocode && \
        source /home/centos/.bashrc && \
        sudo mkdir -p $HOME/go/{src,pkg,bin} && \
        cd $GOPATH/src && \
        go get github.com/grafana/grafana && \
        cd $GOPATH/src/github.com/grafana/grafana && \
        go run build.go setup \
        go run build.go build && \
        npm install -g yarn && \
        yarn install --pure-lockfile && \
        yarn watch && \
        cd go/src/github.com/grafana/grafana/bin/  && \
        grafana-server \
        echo "[main_settings]" > /var/www/html/config.ini \
        && echo "headerTitle='Dashboard'" >> /var/www/html/config.ini \
        && echo "encryptKey='ffgfjhvjhvjcfgfjj'" >> /var/www/html/config.ini \
        && echo ";Timezone Setting. ex: 'America/New_York'" >> /var/www/html/config.ini \
        && echo "defaultTimezone=''" >> /var/www/html/config.ini \
        && echo ";Database parameters for system usage (Should not be used by custom dashboard/charts)" >> /var/www/html/config.ini \
        && echo "dashboardDatabaseServer=mysql" >> /var/www/html/config.ini \
        && echo "dashboardDatabaseName=dashboard" >> /var/www/html/config.ini \
        && echo "dashboardDatabaseUserName=root" >> /var/www/html/config.ini \
        && echo "dashboardDatabasePassword=12345 >> /var/www/html/config.ini \
        && echo ";grafana credentials" >> /var/www/html/config.ini \
        && echo "grafanaDatabaseServer=mysql" >> /var/www/html/config.ini \
        && echo "grafanaDatabaseName=grafana" >> /var/www/html/config.ini \
        && echo "grafanaDatabaseUserName=root" >> /var/www/html/config.ini \
        && echo "grafanaDatabasePassword=12345" >> /var/www/html/config.ini && \
EXPOSE  9000
WORKDIR  /home/centos

This is the error when I execute docker-compose build


text:
Q: Mercurial: Find and delete folder from repository history A former colleague somehow made a large commit in a mercurial repo and now its very large. I haven't found the commit but bitbucket reports that the repo is > 1gb which it shouldn't be.
Is there any way to find which revision added alle the large files and delete it from history?


text:
Q: can return type mix? or workaround solution I have a Fraction class, works fine within its own yard, like 1/2+1/3=5/6 or even with int,1/2+2=5/2.
It is okay for me to see 3/2+3/2=3/1, however, is there a way to return a type conditioned? For example, if the denominator is 1, it returns an int, otherwise returns a Fraction.
If not possible, any other detour?
class Fraction{
__int64 _num,_dem;
public:
    friend Fraction const operator+(Fraction const& lhs,Fraction const& rhs);
}

Fraction const operator+(Fraction const& lhs,Fraction const& rhs){
    return Fraction(lhs)+=rhs;
}

thanks a lot for any advice!

A: No, it's not possible in C++ to have the return type depend on the values of the operands in the way you're hoping for.  What would be the point anyway, since the next layer of code out from there will need to know statically what the result type is?
Now, if your values are all known at compile time, you can do some template magic to make things happen during compilation, but that doesn't seem to be what you're trying to accomplish.

A: You can't conditionally change the return type. (You could have polymorphism if you had a super class, but that's not what you're asking for here since int is an intrinsic type.) Consider this case:
Fraction A, B;
//  initialize to 3/2 and 3/2
sometype C = A + B;

What is the type of C? The compiler must know. Even in cases of polymorphism or type inference, there must be a deterministic solution at compile time as to what the type of C is.
And there's no way to know whether the Fraction represents a whole number until runtime.

A: A possible (runtime) solution is to have implicit convertion operator to int that assert that your fraction is x/1.
class Fraction
{
   operator __int64() const
   {
      assert(den == 1);
      return num;
   }
}

It will allow you to pass Fraction to integers and check at runtime that it is correct.
Not maybe what you exactly want, but this is the best you can have.

A: A possible solution would be an amalgamation of std::pair and boost::optional.
std::pair< boost::optional<Fraction>, boost::optional<int> > const operator+(Fraction const& lhs,Fraction const& rhs);


text:
Q: Find and Replace text in Eclipse I am using eclipse IDE.I need to modify thousands of hbm.xml file by replacing the text generate="always" to generate="never". Please tell  me the easiest way.

A: Click on the "Search" button, click on the "File Search" tab, set the filename to hbm.xml, set the text to generate="always" and click on the "Replace" button at the bottom. When it's search for all matches, it'll offer you another dialog to say what to replace it with.

A: The eclipse search dialogs offer a global find and replace in text files.


text:
Q: Pinecoder Backtesting Engine External Signal Picture of Oscillator Malfunction
I went in and took an example from tradingview that was designed for Pinecoders Backtesting engine where you design a external input signal that is typically -3 to positive 3 to be recognized by a strategy as a binary long or short signal. Well if you compile mine you see the Signal plot jumps up to the actual literal market price of a moving crossover or cross under and not the oscillator value I'm trying to assign to it, big problem since I can't get a strategy to read an unknowable value that isn't a -2 or 2 or -1 or 1 etc. I've tried a lot of things and it keeps reading through and plotting the actual crossover or crossunder of the moving average. Any ideas?
//@version=4

// Original Author - Rajandran R
// Updated to Pinescript version 3 by Cosmic_Coin

study(title="TestRiskExternalInput", shorttitle="TestRiskExternalInput")

////////////////////////////////////////////////////////////////////////////////
// Allow selection of signal content.
IncludeFilter = input(true, "Include Filter")
IncludeEntries = input(true, "Include Entries")
IncludeStops = input(true, "Include Stops with Entries")
IncludeExits = input(true, "Include Exits")

// ——————————————————————————————————————————————————————————————————————————————————————
// ▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼
// This part is the section where you would put your own indicator and define conditions.

// ————— TV built-in MACD code.
fastLength = input(12)
slowlength = input(26)
MACDLength = input(9)
MACD = ema(close, fastLength) - ema(close, slowlength)
aMACD = ema(MACD, MACDLength)
quickMa = sma(close, fastLength)
slowMa = sma(close, slowlength)
// ————— Exits.
//SourceTypeL = 0//crossover(quickMa, slowMa)//[idx]
//SourceTypeS = 0 //crossunder(quickMa, slowMa)//[idx]
tempcharL = 0
tempcharS = 0
if crossover(quickMa, slowMa)
    tempcharL := 2
    tempcharS := 0
if crossunder(quickMa, slowMa)
    tempcharS := -2
    tempcharL := 0

// ————— Filter.
FilterLong = MACD > 0
FilterShort = MACD < 0

// ————— Entries.

EnterLong = tempcharL
EnterShort = tempcharS
// ————— Stops.
Atr = atr(14)
StopLong = min(lowest(5), min(close, open) - Atr * 1.5)
StopShort = max(highest(5), max(close, open) + Atr * 1.5)

// ————— Exits.
ExitLong = crossunder(MACD, aMACD) and MACD > 0
ExitShort = crossover(MACD, aMACD) and MACD < 0

// ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲
// ——————————————————————————————————————————————————————————————————————————————————————

// ————— This function ensures that no stop value equal to one of the protocol's reserved values is sent, so it isn't misinterpreted as a signal.
// The fudge is in the direction where the trade's risk is decreased by a tick, so added for longs and subtracted for shorts.
FudgeStop(_stop, _fudgedir) =>
    _stop == 1.0 or _stop == 2.0 or _stop == 3.0 ?
       _stop + syminfo.mintick * _fudgedir : _stop

// ————— Build required values corresponding to states.
Filter = FilterLong ? 1 : FilterShort ? -1 : 0
Entries = tempcharL == 2 ? 2 : tempcharS == -2 ? -2 : 0
FudgeStop__1 = FudgeStop(StopLong, 1)
FudgeStop__2 = FudgeStop(StopShort, -1)
Stops = EnterLong ? FudgeStop__1 : EnterShort ? -FudgeStop__2 : 0
Exits = ExitLong ? 3 : ExitShort ? -3 : 0

// ————— We must decide which value will be sent in case more than one is different than 0, since only one value can be sent at each bar.
// Priority is given to exits, with filter states coming last.
Signal = IncludeExits and Exits != 0 ? Exits : IncludeStops and Stops != 0 ? Stops :
   IncludeEntries and Entries != 0 ? Entries :
   IncludeFilter and Filter != 0 ? Filter : na

// ————— Plot signal which is to be connected to the Engine through the External Indicator field at the very bottom of the Engine's Settings/Inputs.
plot(Signal, "Signal")

A: The oscillator's value jump to the "unexpected" numbers because of the Stops variable at line 73
Stops = EnterLong ? FudgeStop__1 : EnterShort ? -FudgeStop__2 : 0

FudgeStop function calculate the stoploss value, it is close to the price so depends on the ticker loaded on your chart. Stops variable mutate to one of the results of this function - FudgeStop__1 for long trades and FudgeStop__2 for short trades. You can see the result if you'll plot all variables that are parts of your Signal variable and see them in the data window as in the picture below

If you don't need to include the stoploss value to the Signal variable - remove ternary conditional element in line 78(of your code, without plotted variables on my screenshot above) so it will look like this:
Signal = IncludeExits and Exits != 0 ? Exits :
  IncludeEntries and Entries != 0 ? Entries :
  IncludeFilter and Filter != 0 ? Filter : na


text:
Q: Nodejs Express - Is it expected for the leading whitespaces in HTTP headers to be stripped? I am using Postman to make a POST request to my nodejs API. Notice how my password value has many leading spaces:

Postman code also shows the spaces:

But in my nodejs API using express, when I console log the headers req.header("password"), it only prints the thisHasALeadingSpace and doesn't have the spaces before.
Is this a bug? I tested with trailing spaces and they are printed fine. But leading spaces are not. Is this a bug in express?
EDIT: I just found this:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers
It says "Leading white space before the value is ignored." So I guess I shouldn't be using HTTP header for sending username/password in case user uses a space in the beginning of their password?


text:
Q: woocommerce coupon - get all listed products ids I working on a website that generate coupon when someone register i have code it -
$coupon_code =  "ex".$resulted_coupon_code ;// Code

$amount = '20'; // Amount
$discount_type = 'percent_product'; // Type: fixed_cart, percent,     fixed_product, percent_product

$coupon = array(
'post_title' => $coupon_code,
'post_content' => '',
'post_status' => 'publish',
'post_author' => 1,
'post_type'  => 'shop_coupon'
 );

$new_coupon_id = wp_insert_post( $coupon );

// Add meta
update_post_meta( $new_coupon_id, 'discount_type', $discount_type );
update_post_meta( $new_coupon_id, 'coupon_amount', $amount );
update_po st_meta( $new_coupon_id, 'individual_use', 'yes' );
update_post_meta( $new_coupon_id, 'product_ids', '4454,4452,4451,4449' );
update_post_meta( $new_coupon_id, 'exclude_product_ids', '' );
update_post_meta( $new_coupon_id, 'usage_limit', '1' );
update_post_meta( $new_coupon_id, 'usage_limit_per_user', '1' );
update_post_meta( $new_coupon_id, 'expiry_date', '' );
update_post_meta( $new_coupon_id, 'apply_before_tax', 'yes' );
update_post_meta( $new_coupon_id, 'free_shipping', 'no' );
update_post_meta( $new_coupon_id, 'customer_email', $user_email );

now how can i to get the coupon products ids ??
like from this
update_post_meta( $new_coupon_id, 'product_ids', '4454,4452,4451,4449' );
i want to retrieve  these 4454,4452,4451,4449

A: WooCommerce is storing these values in the postmeta table, so you can use the get_post_meta() to retrieve the product IDs.
get_post_meta( $new_coupon_id, 'product_ids', true );

To get all of the coupon post types first, then loop over them to get the products, then loop over them to get the product post types, you would use the following:
// get all coupons that are published
$coupons = get_posts( array(
    'posts_per_page'   => -1,
    'post_type'        => 'shop_coupon',
    'post_status'      => 'publish',
) );

// loop through the coupons
foreach ( $coupons as $coupon ){
    // get the product ids meta value
    $product_ids = get_post_meta( $coupon->ID, 'product_ids', true );
    // make sure something has been saved
    if ( !empty( $product_ids ){
        // convert from comma separated string to array
        $id_list = explode( ',', $product_ids );
        // loop over each ID
        foreach( $id_list as $product_id ){
            // get the product for each ID
            $product = get_post( $product_id );
            // each product associated
        }
    }
}

A: update_post_meta( $new_coupon_id, 'product_ids', get_post_meta( 4461, 'product_ids', true ));

try to use that code


text:
Q: unable to get the content of passed parameters in ast module GAE I have an endpoint from which I am calling webapp post url
Here is endpoint
userId = '14'
data = {"userId" :userId,"a":"s"}
encodedData = urllib.urlencode(data)
result = urlfetch.fetch(url=DELETE_CHANNEL_URL,payload=encodedData,follow_redirects=False,deadline=30,method=urlfetch.POST,
                            headers={'Content-Type': 'application/x-www-form-urlencoded'})

and I am getting this in webapp like
class DeleteChannel(webapp.RequestHandler):
    def post(self):
        logging.info("Delete channel")
        parameters = ast.literal_eval(self.request.body)

        userId  = str(parameters["userId"])
        logging.info('userId' + userId)

but this is showing error
File "/base/data/home/apps/s~dimension-dev-endpoint/1.389460063849645110/Channel.py", line 34, in post
    parameters = ast.literal_eval(self.request.body)
  File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/ast.py", line 49, in literal_eval
    node_or_string = parse(node_or_string, mode='eval')
  File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/ast.py", line 37, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 1
    a=s&userId=14
     ^
SyntaxError: invalid syntax

what is the issue?

A: I tried following code the get the userId from paramters and this is working for me
userId  = self.request.get("userId", default_value='')


text:
Q: Converting adjacency list tables to MPTT in SQL Server 2008 Is there a helpful tool or script resource to aid conversion from old-school adjacency list tables to MPTT?
I would have thought it was a problem faced by a few cleverer souls than I in the past, and thought I'd check here first in case they came up with a clever solution in their travels - before embarking on my own journey to do such a thing.

A: This link includes code to make the conversion. Look at the bottom for the SQL version of the code (there's also a PHP script to do it).
I know that I've seen code from Joe Celko on how to do it, but I don't recall if that was on the intertubes or in his book on trees and hierarchies in SQL.


text:
Q: POST with multipart/form-data using node.js supertest I was trying to use the Node.js supertest to test some REST API.
request(app)
      .post("/products")
      .set(
        "Authorization",
        "Bearer my jwt token here"
      )
      .set("Content-Type", "multipart/form-data")
      .field("name", "Tomato")
      .field("userId", "5d921d306e96d70a28989127")
      .attach(
        "productImage",
        "D:/NodeJS/node-rest-shop/uploads/1558612339690managing-redis.jpg"
      )
      .expect(201)
      .then(res => {
        const body = res.body;
        expect(body).to.contain.property("message");
        expect(body).to.contain.property("productId");
        expect(body).to.contain.property("date");
        expect(body).to.contain.property("user");
        expect(body).to.contain.property("request");
        done();
      })
      .catch(err => done(err));

.field("userId", userId)

Is there any way to set the value of userId as a variable without setting a hardcoded string value? It is a MongoDB object id.
When I'm using value as a variable this error occurred.
TypeError: source.on is not a function
    at Function.DelayedStream.create (node_modules\delayed-stream\lib\delayed_stream.js:33:10)
    at FormData.CombinedStream.append (node_modules\combined-stream\lib\combined_stream.js:45:37)
    at FormData.append (node_modules\form-data\lib\form_data.js:74:3)
    at Test.RequestBase.field (node_modules\superagent\lib\request-base.js:406:23)
    at Context.done (test\api\product\product.js:77:8)

A: I can interpret this as 2 different ways, so I'll just answer both:

Can the value be specified as a non-string, e.g. a number.

multipart/form-data doesn't really have any sort of typing. Everything will be interpreted as a string usually. Your controller will need to do any conversion.

Can I use a variable in place of a hardcoded string.

Yes, you can.
Instead of:
.field("userId", "5d921d306e96d70a28989127")

You can just use:
.field("userId", userId)

As long as you defined a userId variable earlier

A: userId is a new mongoose.Types.ObjectId(). So, it does not return a string, it returns an object. You need to convert it to a string.
We can use this.
.field("userId", String(userId))


text:
Q: 301 redirect router for Django project I have a website building tool created in Django and I'd like to add easy user defined 301 redirects to it.
Webflow has a very easy to understand tool for 301 redirects. You add a path (not just a slug) and then define where that path should lead the user.

I'd like to do the same for the Django project I'm working on. I currently allow users to set a slug that redirects /<slug:redirect_slug>/ and they can set to go to any URL. But I'd like them to be able to add, for example, the path for an old blog post '/2018/04/12/my-favorite-thing/'
What's the best URL conf to use in Django to safely accept any path the user wants?

A: You can use the Path Converters that convert the path parameters into appropriate types, which also includes a converter for urls.
An example would be like the following:
path('api/<path:encoded_url>/', YourView.as_view()),

As per the docs:

Matches any non-empty string, including the path separator, '/'. This allows you to match against a complete URL path rather than just a segment of a URL path as with str.

In your view, you can get your URL like this:
encoded_url = self.kwargs.get('encoded_url')

A: Add a RerouteMiddleware which first checks if the request can be served by the existing URLs from the urls.py. If it cannot be served, check if the requested path is from the old -> new URLs mapping, if a match found redirect it to the new URL.
Sample piece of code to try it out.
    try:
        resolve(request.path_info)
    except Resolver404:
        # Check if the URL exists in your database/constants
        # where you might have stored the old -> new URL mapping.
        if request.path is valid:
            new_url = # Retrieve the new URL
            return redirect(new_url)

    response = self.get_response(request)
    return response


text:
Q: To what extent can I specify the angular defect at the vertices of a polyhedron? Suppose $p_1,\ldots,p_n$ are points in $\mathbb{R}^3$, and suppose $\delta_1,\ldots,\delta_n$ are positive real numbers, each less than $2\pi$, whose sum is $4\pi$. Is there a polyhedron $\mathcal P$ which has a vertex at $p_i$ of angular defect $\delta_i$ (meaning that the sum of the interior angles of the faces meeting at $p_i$ is $2\pi-\delta_i$) for each $i=1,\ldots, n$, and possibly some extra vertices all of whose angular defect $0$? That is, I am specifying some of the vertices and angular defects, but allowing the addition of extra vertices on the condition that those vertices have angular defect zero.
If so, is there a constructive proof? If not, are there known constraints on the points and/or defects?
The question can be extended more broadly: the condition that the defects are positive could be dropped and we could ask that $\delta_1+\cdots+\delta_n=2\pi \chi$.