text:
Q: why is foursquare api not returning contact information for a venue? One of our testers found this issue:
This foursquare venue
  https://foursquare.com/v/whole-foods-market/4a38676cf964a520f49e1fe3
When returned as a result of this url query
  https://api.foursquare.com/v2/venues/search?ll=32.747837,--17158101&radius=250&intent=checkin  [some more parameters including secret key]
Produces a result JSON string which includes the venue, but the array of contact data is completely empty.  The foursquare page for the venue lists the twitter contact and URL contact fields, but the JSON looks like this:
{"id":"4a38676cf964a520f49e1fe3","name":"Whole Foods Market","contact":{},"location"  [more data]
Other venues returned by the search typically have the contact data.  I noticed that this one venue does not have a phone number specified.  Could the API be triggering off of that and null'ing out the entire contact list?
UPDATE:  Here is the complete URL request, with the exception of the ID and KEY values
https://api.foursquare.com/v2/venues/search?ll=32.747837,-117.158101&radius=250&intent=checkin&limit=50&v=20120502&client_secret=XXX&client_id=YYY&categoryId=4bf58dd8d48988d1f9941735,4bf58dd8d48988d118951735,4d4b7105d754a06374d81259,4d4b7105d754a06376d81259

A: There's one of two scenarios: (1) the venue has a twitter name associated with it or (2) the chain that the venue belongs to has a twitter name associated with it. In the case of (2), you'll find the twitter name in the page user object associated with the venue. Foursquare looks for the venue twitter name first, then falls back on the chain twitter name when rendering the user-facing venue page.


text:
Q: C# "How to get a list of match letters words through suggest & append while entering some letters in the datagridview cell? When i type the letter G it gives me the list of words that are starting from G. e.g Gas, Grill.
I want to you use the code in my program that can list all the words that have letter G. (You can say match anywhere in the list). Hope i have cleared my query.
Thanking you in anticipation for your kind help.
private void dataGridView1_EditingControlShowing_1(object sender, DataGridViewEditingControlShowingEventArgs e)
{
    if (dataGridView1.CurrentCell.ColumnIndex == 0)
    {
        int currentRow = dataGridView1.CurrentRow.Index;
        TextBox tb1 = e.Control as TextBox;
        OleDbCommand cmd1 = new OleDbCommand("SELECT [AccName] FROM AccLevel3  WHERE AccName LIKE '" + tb1.Text + "%'", conn);

        conn.Open();
        OleDbDataReader reader = cmd1.ExecuteReader();
        AutoCompleteStringCollection AccountCol = new AutoCompleteStringCollection();

        if (reader.HasRows == true)
        {
            while (reader.Read())
            {
                AccountCol.Add(reader["AccName"].ToString());
            }
        }
        else
        {
            MessageBox.Show("Data not Found");
        }
        conn.Close();
        reader.Close();

        if (tb1 != null)
        {
            tb1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
            tb1.AutoCompleteCustomSource = AccountCol;
            tb1.AutoCompleteSource = AutoCompleteSource.CustomSource;
        }

        e.Control.KeyPress -= new KeyPressEventHandler(Column1_KeyPress);
        if (dataGridView1.CurrentCell.ColumnIndex == 2) //Desired Column
        {
            TextBox tb = e.Control as TextBox;
            if (tb != null)
            {
                tb.KeyPress += new KeyPressEventHandler(Column1_KeyPress);
            }

        }

    }
}

A: Add an extra wildcard to your query to match a suibstring in any position:
... WHERE AccName LIKE '%" + tb1.Text + "%'" ...

redpajama_set_name: RedPajamaStackExchange


text:
Q: Custom 404 error page generates 403 IIS 6.1 - Custom Error pages.
The web site is defined as www.url.com/mysite.  Custom error pages have been defined for mysite.  404 and 500.100.
I can redirect to /mysite/500.htm and /mysite/400.htm.
I can set 500.100 to redirect to /global/500.htm and this works.
When I redirect 404 to /global/404.htm I get a 403 access denied error.  (I also tried redirecting 404 to /global/500.htm just to make sure it was not file-specific rights.)
Directory browsing is enabled.
The page works if you browse directly to it.
Checked the iis log file for oddities.
Can anyone offer an explanation that might lead me in the right direction?


text:
Q: Is this a sound implementation of a signup function?
*

*Are the async and await in the right places given this arrow function.

*What about the const at the start? Is that okay?

*Flow of the function as well as it's compartmentalization. (I put it in a different file, and upon submitting a form in my signup component, it will be called)

*Should I save the results of this function in a variable in my signup component and then evaluate it there to see what to do next?

Helpful info:
I am doing form validation with Yup prior to submitting the form. So all that is being returned from the server is "email taken" or "successful registration".
Thank you!
/*
  File: src/utils/authentication.js
  Author: jreyes
  Date: 01-26-2021
*/

/** Register new user */
const signupAuth = async () => {
  await fetch('http://localhost:8080/signup', {
    method: 'POST',
    mode: 'cors',
    credentials: 'omit',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      email,
      password,
      firstname,
      lastname
    })
  })
  .then(response => {
    if (!response.ok) {
      throw new Error('Please check your network.');
    }
    return response.json();
  })
  .then(data => {
    console.log('Success:', data);
  })
  .catch((error) => {
    console.error('Error:', error);
  });
};

export { signupAuth };

A: you should try to do something like that:
export const signupAuth = (email, password, firstname, lastname) => {
  return fetch('http://localhost:8080/signup', {
    method: 'POST',
    mode: 'cors',
    credentials: 'omit',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      email,
      password,
      firstname,
      lastname
    })
  })
};

and after :
import { signupAuth } from "./file";

signupAuth(email, password, firstname, lastname)
  .then(response => {

  })
  .catch(error => {

  });

// or this way
try {
 const response = await signupAuth(email, password, firstname, lastname);
 // do you stuff here
} catch (error) {
 // handle error here
}


text:
Q: How to solve this set of PDE equations? I am trying to solve a set of PDE equations with parameters of v[z],q[z],T[z,t,r]. Below is my test code where I tried the method of parametricNDSolve but to no avail.
ClearAll["Global`*"] ;
equ = With[{v = v@z, q = q@z, T = T @@ {z, t, r}, p = 1/(1 + T@@ {z, t, r}^(-3/2)),
A = NIntegrate[p*Exp[-q*r^2] r, {r, 0, \[Infinity]}],  B = NIntegrate[p*Exp[-2 q*r^2] r, {r, 0, \[Infinity]}]},
{-v D[q, z] + q*D[v, z] == -q^2*v*A,
-v*D[q, z] + 2 q*D[v, z] == -4*q^2*v*B,
D[T + (p + 1) v^2 Exp[-2 q r^2], t] + 1/r D[r*p*v^2 Exp[-2 q r^2], r] + D[p*v^2 Exp[-2 q r^2],z] == p*v^2 Exp[-2 q r^2]}]

ic = {v[0] == 1, q[0] == 1, T[0, 0, 0] == 1}
{vsol,qsol,Tsol}=ParametricNDSolveValue[{equ, ic}, {v, q, T}, {z, 0, 10}, {t, r}]

Can anyone help me out? Thanks.

A: Here is my attempt, based on the code you provided. I first replaced the formula you had for p directly in the set of equations, as it depended on T[z,t,r].
As pointed out by @Daniel Huber, you should use Integrate in A and B, with the assumption that $q>0$ for convergence.
Following the answer in this question, you should be able to solve your set of equations assuming q and v also depend on (z,t,r), not just on z.
Since you don't have any parameter, I use NDSolveValue instead of ParameterNDSolveValue. You will have some warning messages, but NDSolve will go through and give you some interpolating function, that you can visualise with SliceContourPlot3D.
Please, tell me if this can help you.
Cheers
ClearAll["Global`*"];
equ = With[{v = v @@ {z, t, r}, q = q @@ {z, t, r}, T = T @@ {z, t, r},
   A = Integrate[r*Exp[-q[z, t, r]*r^2]/(1 + T[z, t, r]^(-3/2)), {r, 0, Infinity},
      Assumptions -> q[z, t, r] > 0], B = Integrate[r*Exp[-2 q[z, t, r]*r^2]/(1 + T[z, t, r]^(-3/2)), {r, 0, Infinity}, Assumptions -> q[z, t, r] > 0]}, {-v D[q, z] +
     q*D[v, z] == -q^2*v*A, -v*D[q, z] + 2 q*D[v, z] == -4*q^2*v*B,
   D[T + (1/(1 + T^(-3/2)) + 1) v^2 Exp[-2 q r^2], t] +
     1/r D[r*(1/(1 + T^(-3/2)))*v^2 Exp[-2 q r^2], r] +
     D[(1/(1 + T^(-3/2)))*v^2 Exp[-2 q r^2], z] == (1/(1 + T^(-3/2)))*
     v^2 Exp[-2 q r^2]}]
ic = {v[0, t, r] == 1, q[0, t, r] == 1, T[0, t, r] == 1}
{vsol, qsol, Tsol} =  NDSolveValue[{equ, ic}, {v, q, T}, {z, 0, 10}, {t, 0, 10}, {r, 0.1,10}]
SliceContourPlot3D[vsol[z, t, r], "ZStackedPlanes", {z, 0, 10}, {t, 0, 10}, {r, 0.1,10}]


text:
Q: Problems with openvpn on ubuntu 22.04 I'm trying to set up openvpn on the server using this guide:
https://www.digitalocean.com/community/tutorials/how-to-set-up-and-configure-an-openvpn-server-on-ubuntu-22-04
I got to step 10, but I can't start the openvpn service:
serv_ivan@964889-cd87180:~$ sudo systemctl -f enable openvpn-server@server.service
[sudo] password for serv_ivan:
serv_ivan@964889-cd87180:~$ sudo systemctl start openvpn-server@server.service
serv_ivan@964889-cd87180:~$ sudo systemctl status openvpn-server@server.service
● openvpn-server@server.service - OpenVPN service for server
     Loaded: loaded (/lib/systemd/system/openvpn-server@.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Mon 2022-08-01 21:33:03 MSK; 3s ago
       Docs: man:openvpn(8)
             https://community.openvpn.net/openvpn/wiki/Openvpn24ManPage
             https://community.openvpn.net/openvpn/wiki/HOWTO
    Process: 1256469 ExecStart=/usr/sbin/openvpn --status /run/openvpn-server/status-server.log --status-version 2 --suppress-timestamps --config server.conf (code=exited, status=1/FAILURE)
   Main PID: 1256469 (code=exited, status=1/FAILURE)
     Status: "Pre-connection initialization successful"
        CPU: 24ms

Aug 01 21:33:03 964889-cd87180.tmweb.ru systemd[1]: openvpn-server@server.service: Main process exited, code=exited, status=1/FAILURE
Aug 01 21:33:03 964889-cd87180.tmweb.ru systemd[1]: openvpn-server@server.service: Failed with result 'exit-code'.
serv_ivan@964889-cd87180:~$

I searched the Internet for an answer, but did not find it.
log:
serv_ivan@964889-cd87180:~$ sudo tail -n 20 /var/log/syslog
Aug  1 21:36:47 964889-cd87180 systemd[1]: Stopped OpenVPN connection to server.
Aug  1 21:36:47 964889-cd87180 systemd[1]: Starting OpenVPN connection to server...
Aug  1 21:36:47 964889-cd87180 ovpn-server[1257478]: Options error: In [CMD-LINE]:1: Error opening configuration file: /etc/openvpn/server.conf
Aug  1 21:36:47 964889-cd87180 ovpn-server[1257478]: Use --help for more information.
Aug  1 21:36:47 964889-cd87180 systemd[1]: openvpn@server.service: Main process exited, code=exited, status=1/FAILURE
Aug  1 21:36:47 964889-cd87180 systemd[1]: openvpn@server.service: Failed with result 'exit-code'.
Aug  1 21:36:47 964889-cd87180 systemd[1]: Failed to start OpenVPN connection to server.
Aug  1 21:36:48 964889-cd87180 systemd[1]: openvpn-server@server.service: Scheduled restart job, restart counter is at 1733.
Aug  1 21:36:48 964889-cd87180 systemd[1]: Stopped OpenVPN service for server.
Aug  1 21:36:48 964889-cd87180 systemd[1]: Starting OpenVPN service for server...
Aug  1 21:36:48 964889-cd87180 systemd[1]: Started OpenVPN service for server.
Aug  1 21:36:48 964889-cd87180 networkd-dispatcher[1030209]: WARNING:Unknown index 49326 seen, reloading interface list
Aug  1 21:36:48 964889-cd87180 systemd-networkd[1214783]: tun1: Link UP
Aug  1 21:36:48 964889-cd87180 systemd-networkd[1214783]: tun1: Gained carrier
Aug  1 21:36:48 964889-cd87180 systemd-networkd[1214783]: tun1: Gained IPv6LL
Aug  1 21:36:48 964889-cd87180 systemd-udevd[1257483]: Using default interface naming scheme 'v249'.
Aug  1 21:36:48 964889-cd87180 systemd-networkd[1214783]: tun1: Link DOWN
Aug  1 21:36:48 964889-cd87180 systemd-networkd[1214783]: tun1: Lost carrier
Aug  1 21:36:48 964889-cd87180 systemd[1]: openvpn-server@server.service: Main process exited, code=exited, status=1/FAILURE
Aug  1 21:36:48 964889-cd87180 systemd[1]: openvpn-server@server.service: Failed with result 'exit-code'.
serv_ivan@964889-cd87180:~$

cat server.config:
#################################################
# Sample OpenVPN 2.0 config file for            #
# multi-client server.                          #
#                                               #
# This file is for the server side              #
# of a many-clients <-> one-server              #
# OpenVPN configuration.                        #
#                                               #
# OpenVPN also supports                         #
# single-machine <-> single-machine             #
# configurations (See the Examples page         #
# on the web site for more info).               #
#                                               #
# This config should work on Windows            #
# or Linux/BSD systems.  Remember on            #
# Windows to quote pathnames and use            #
# double backslashes, e.g.:                     #
# "C:\\Program Files\\OpenVPN\\config\\foo.key" #
#                                               #
# Comments are preceded with '#' or ';'         #
#################################################

# Which local IP address should OpenVPN
# listen on? (optional)
;local 94.228.120.106

# Which TCP/UDP port should OpenVPN listen on?
# If you want to run multiple OpenVPN instances
# on the same machine, use a different port
# number for each one.  You will need to
# open up this port on your firewall.
port 1194

# TCP or UDP server?
;proto tcp
proto udp

# "dev tun" will create a routed IP tunnel,
# "dev tap" will create an ethernet tunnel.
# Use "dev tap0" if you are ethernet bridging
# and have precreated a tap0 virtual interface
# and bridged it with your ethernet interface.
# If you want to control access policies
# over the VPN, you must create firewall
# rules for the the TUN/TAP interface.
# On non-Windows systems, you can give
# an explicit unit number, such as tun0.
# On Windows, use "dev-node" for this.
# On most systems, the VPN will not function
# unless you partially or fully disable
# the firewall for the TUN/TAP interface.
;dev tap
dev tun

# Windows needs the TAP-Win32 adapter name
# from the Network Connections panel if you
# have more than one.  On XP SP2 or higher,
# you may need to selectively disable the
# Windows firewall for the TAP adapter.
# Non-Windows systems usually don't need this.
;dev-node MyTap

# SSL/TLS root certificate (ca), certificate
# (cert), and private key (key).  Each client
# and the server must have their own cert and
# key file.  The server and all clients will
# use the same ca file.
#
# See the "easy-rsa" directory for a series
# of scripts for generating RSA certificates
# and private keys.  Remember to use
# a unique Common Name for the server
# and each of the client certificates.
#
# Any X509 key management system can be used.
# OpenVPN can also use a PKCS #12 formatted key file
# (see "pkcs12" directive in man page).
ca ca.crt
cert server.crt
key server.key  # This file should be kept secret

# Diffie hellman parameters.
# Generate your own with:
#   openssl dhparam -out dh2048.pem 2048
;dh dh2048.pem
dh none

# Network topology
# Should be subnet (addressing via IP)
# unless Windows clients v2.0.9 and lower have to
# be supported (then net30, i.e. a /30 per client)
# Defaults to net30 (not recommended)
;topology subnet

# Configure server mode and supply a VPN subnet
# for OpenVPN to draw client addresses from.
# The server will take 10.8.0.1 for itself,
# the rest will be made available to clients.
# Each client will be able to reach the server
# on 10.8.0.1. Comment this line out if you are
# ethernet bridging. See the man page for more info.
server 10.8.0.0 255.255.255.0

# Maintain a record of client <-> virtual IP address
# associations in this file.  If OpenVPN goes down or
# is restarted, reconnecting clients can be assigned
# the same virtual IP address from the pool that was
# previously assigned.
ifconfig-pool-persist /var/log/openvpn/ipp.txt

# Configure server mode for ethernet bridging.
# You must first use your OS's bridging capability
# to bridge the TAP interface with the ethernet
# NIC interface.  Then you must manually set the
# IP/netmask on the bridge interface, here we
# assume 10.8.0.4/255.255.255.0.  Finally we
# must set aside an IP range in this subnet
# (start=10.8.0.50 end=10.8.0.100) to allocate
# to connecting clients.  Leave this line commented
# out unless you are ethernet bridging.
;server-bridge 10.8.0.4 255.255.255.0 10.8.0.50 10.8.0.100

# Configure server mode for ethernet bridging
# using a DHCP-proxy, where clients talk
# to the OpenVPN server-side DHCP server
# to receive their IP address allocation
# and DNS server addresses.  You must first use
# your OS's bridging capability to bridge the TAP
# interface with the ethernet NIC interface.
# Note: this mode only works on clients (such as
# Windows), where the client-side TAP adapter is
# bound to a DHCP client.
;server-bridge

# Push routes to the client to allow it
# to reach other private subnets behind
# the server.  Remember that these
# private subnets will also need
# to know to route the OpenVPN client
# address pool (10.8.0.0/255.255.255.0)
# back to the OpenVPN server.
;push "route 192.168.10.0 255.255.255.0"
;push "route 192.168.20.0 255.255.255.0"

# To assign specific IP addresses to specific
# clients or if a connecting client has a private
# subnet behind it that should also have VPN access,
# use the subdirectory "ccd" for client-specific
# configuration files (see man page for more info).

# EXAMPLE: Suppose the client
# having the certificate common name "Thelonious"
# also has a small subnet behind his connecting
# machine, such as 192.168.40.128/255.255.255.248.
# First, uncomment out these lines:
;client-config-dir ccd
;route 192.168.40.128 255.255.255.248
# Then create a file ccd/Thelonious with this line:
#   iroute 192.168.40.128 255.255.255.248
# This will allow Thelonious' private subnet to
# access the VPN.  This example will only work
# if you are routing, not bridging, i.e. you are
# using "dev tun" and "server" directives.

# EXAMPLE: Suppose you want to give
# Thelonious a fixed VPN IP address of 10.9.0.1.
# First uncomment out these lines:
;client-config-dir ccd
;route 10.9.0.0 255.255.255.252
# Then add this line to ccd/Thelonious:
#   ifconfig-push 10.9.0.1 10.9.0.2

# Suppose that you want to enable different
# firewall access policies for different groups
# of clients.  There are two methods:
# (1) Run multiple OpenVPN daemons, one for each
#     group, and firewall the TUN/TAP interface
#     for each group/daemon appropriately.
# (2) (Advanced) Create a script to dynamically
#     modify the firewall in response to access
#     from different clients.  See man
#     page for more info on learn-address script.
;learn-address ./script

# If enabled, this directive will configure
# all clients to redirect their default
# network gateway through the VPN, causing
# all IP traffic such as web browsing and
# and DNS lookups to go through the VPN
# (The OpenVPN server machine may need to NAT
# or bridge the TUN/TAP interface to the internet
# in order for this to work properly).
;push "redirect-gateway def1 bypass-dhcp"

# Certain Windows-specific network settings
# can be pushed to clients, such as DNS
# or WINS server addresses.  CAVEAT:
# http://openvpn.net/faq.html#dhcpcaveats
# The addresses below refer to the public
# DNS servers provided by opendns.com.
;push "dhcp-option DNS 208.67.222.222"
;push "dhcp-option DNS 208.67.220.220"

# Uncomment this directive to allow different
# clients to be able to "see" each other.
# By default, clients will only see the server.
# To force clients to only see the server, you
# will also need to appropriately firewall the
# server's TUN/TAP interface.
;client-to-client

# Uncomment this directive if multiple clients
# might connect with the same certificate/key
# files or common names.  This is recommended
# only for testing purposes.  For production use,
# each client should have its own certificate/key
# pair.
#
# IF YOU HAVE NOT GENERATED INDIVIDUAL
# CERTIFICATE/KEY PAIRS FOR EACH CLIENT,
# EACH HAVING ITS OWN UNIQUE "COMMON NAME",
# UNCOMMENT THIS LINE OUT.
;duplicate-cn

# The keepalive directive causes ping-like
# messages to be sent back and forth over
# the link so that each side knows when
# the other side has gone down.
# Ping every 10 seconds, assume that remote
# peer is down if no ping received during
# a 120 second time period.
keepalive 10 120

# For extra security beyond that provided
# by SSL/TLS, create an "HMAC firewall"
# to help block DoS attacks and UDP port flooding.
#
# Generate with:
#   openvpn --genkey tls-auth ta.key
#
# The server and each client must have
# a copy of this key.
# The second parameter should be '0'
# on the server and '1' on the clients.
;tls-auth ta.key 0 # This file is secret
tls-crypt ta.key

# Select a cryptographic cipher.
# This config item must be copied to
# the client config file as well.
# Note that v2.4 client/server will automatically
# negotiate AES-256-GCM in TLS mode.
# See also the ncp-cipher option in the manpage
;cipher AES-256-CBC
cipher AES-256-GCM
auth SHA256

# Enable compression on the VPN link and push the
# option to the client (v2.4+ only, for earlier
# versions see below)
;compress lz4-v2
;push "compress lz4-v2"

# For compression compatible with older clients use comp-lzo
# If you enable it here, you must also
# enable it in the client config file.
;comp-lzo

# The maximum number of concurrently connected
# clients we want to allow.
;max-clients 100

# It's a good idea to reduce the OpenVPN
# daemon's privileges after initialization.
#
# You can uncomment this out on
# non-Windows systems.
user nobody
group nobody

# The persist options will try to avoid
# accessing certain resources on restart
# that may no longer be accessible because
# of the privilege downgrade.
persist-key
persist-tun

# Output a short status file showing
# current connections, truncated
# and rewritten every minute.
status /var/log/openvpn/openvpn-status.log

# By default, log messages will go to the syslog (or
# on Windows, if running as a service, they will go to
# the "\Program Files\OpenVPN\log" directory).
# Use log or log-append to override this default.
# "log" will truncate the log file on OpenVPN startup,
# while "log-append" will append to it.  Use one
# or the other (but not both).
log         /var/log/openvpn/openvpn.log
;log-append  /var/log/openvpn/openvpn.log

# Set the appropriate level of log
# file verbosity.
#
# 0 is silent, except for fatal errors
# 4 is reasonable for general usage
# 5 and 6 can help to debug connection problems
# 9 is extremely verbose
verb 3

# Silence repeating messages.  At most 20
# sequential messages of the same message
# category will be output to the log.
;mute 20

# Notify the client that when the server restarts so it
# can automatically reconnect.
explicit-exit-notify 1

#mode server

Also I noticed that openvpn can't open the file from the path:
ovpn-server[1257478]: Options error: In [CMD-LINE]:1: Error opening configuration file: /etc/openvpn/server.conf
But the fact is that I do not have this file along this path. Here is its absolute path:
/etc/openvpn/server/server.conf
But if I move the file to a higher directory, I get this error:
serv_ivan@964889-cd87180:/etc/openvpn$ sudo systemctl restart  openvpn-server@server.service
Job for openvpn-server@server.service failed because the control process exited with error code.
See "systemctl status openvpn-server@server.service" and "journalctl -xeu openvpn-server@server.service" for details.
serv_ivan@964889-cd87180:/etc/openvpn$ sudo tail /var/log/syslog
Aug  2 15:17:17 964889-cd87180 systemd[1]: openvpn@server.service: Failed with result 'exit-code'.
Aug  2 15:17:17 964889-cd87180 systemd[1]: Failed to start OpenVPN connection to server.
Aug  2 15:17:18 964889-cd87180 systemd[1]: openvpn-server@server.service: Scheduled restart job, restart counter is at 13907.
Aug  2 15:17:18 964889-cd87180 systemd[1]: Stopped OpenVPN service for server.
Aug  2 15:17:18 964889-cd87180 systemd[1]: Starting OpenVPN service for server...
Aug  2 15:17:18 964889-cd87180 openvpn[1521409]: Options error: In [CMD-LINE]:1: Error opening configuration file: server.conf
Aug  2 15:17:18 964889-cd87180 openvpn[1521409]: Use --help for more information.
Aug  2 15:17:18 964889-cd87180 systemd[1]: openvpn-server@server.service: Main process exited, code=exited, status=1/FAILURE
Aug  2 15:17:18 964889-cd87180 systemd[1]: openvpn-server@server.service: Failed with result 'exit-code'.
Aug  2 15:17:18 964889-cd87180 systemd[1]: Failed to start OpenVPN service for server.
serv_ivan@964889-cd87180:/etc/openvpn$

I tried to change the path to the working directory, but it didn't work:
serv_ivan@964889-cd87180:/etc/openvpn$ cat /usr/lib/systemd/system/openvpn-server@.service
[Unit]
Description=OpenVPN service for %I
After=network-online.target
Wants=network-online.target
Documentation=man:openvpn(8)
Documentation=https://community.openvpn.net/openvpn/wiki/Openvpn24ManPage
Documentation=https://community.openvpn.net/openvpn/wiki/HOWTO

[Service]
Type=notify
PrivateTmp=true
#WorkingDirectory=/etc/openvpn/server
WorkingDirectory=/etc/openvpn
ExecStart=/usr/sbin/openvpn --status %t/openvpn-server/status-%i.log --status-version 2 --suppress-timestamps --config %i.conf
CapabilityBoundingSet=CAP_IPC_LOCK CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW CAP_SETGID CAP_SETUID CAP_SYS_CHROOT CAP_DAC_OVERRIDE CAP_AUDIT_WRITE
LimitNPROC=10
DeviceAllow=/dev/null rw
DeviceAllow=/dev/net/tun rw
ProtectSystem=true
ProtectHome=true
KillMode=process
RestartSec=5s
Restart=on-failure

[Install]
WantedBy=multi-user.target
serv_ivan@964889-cd87180:/etc/openvpn$

serv_ivan@964889-cd87180:/etc/openvpn$ sudo mv server/server.conf ./
serv_ivan@964889-cd87180:/etc/openvpn$ ls
client  server  server.conf  update-resolv-conf
serv_ivan@964889-cd87180:/etc/openvpn$ sudo systemctl restart  openvpn-server@server.service
Warning: The unit file, source configuration file or drop-ins of openvpn-server@server.service changed on disk. Run 'systemctl daemon-reload' to reload units.
Job for openvpn-server@server.service failed because the control process exited with error code.
See "systemctl status openvpn-server@server.service" and "journalctl -xeu openvpn-server@server.service" for details.

serv_ivan@964889-cd87180:/etc/openvpn$ sudo systemctl -f enable openvpn-server@server.service
serv_ivan@964889-cd87180:/etc/openvpn$ sudo systemctl start openvpn-server@server.service
Job for openvpn-server@server.service failed because the control process exited with error code.
See "systemctl status openvpn-server@server.service" and "journalctl -xeu openvpn-server@server.service" for details.
serv_ivan@964889-cd87180:/etc/openvpn$ sudo systemctl status openvpn-server@server.service
● openvpn-server@server.service - OpenVPN service for server
     Loaded: loaded (/lib/systemd/system/openvpn-server@.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Tue 2022-08-02 16:14:59 MSK; 3s ago
       Docs: man:openvpn(8)
             https://community.openvpn.net/openvpn/wiki/Openvpn24ManPage
             https://community.openvpn.net/openvpn/wiki/HOWTO
    Process: 1534787 ExecStart=/usr/sbin/openvpn --status /run/openvpn-server/status-server.log --status-version 2 --suppress-timestamps --config server.conf (code=exited, status=1/FAILURE)
   Main PID: 1534787 (code=exited, status=1/FAILURE)
        CPU: 14ms

Aug 02 16:14:59 964889-cd87180.tmweb.ru systemd[1]: openvpn-server@server.service: Main process exited, code=exited, status=1/FAILURE
Aug 02 16:14:59 964889-cd87180.tmweb.ru systemd[1]: openvpn-server@server.service: Failed with result 'exit-code'.
Aug 02 16:14:59 964889-cd87180.tmweb.ru systemd[1]: Failed to start OpenVPN service for server.
serv_ivan@964889-cd87180:/etc/openvpn$

log:
serv_ivan@964889-cd87180:/etc/openvpn$ sudo systemctl restart openvpn-server@server.service
Job for openvpn-server@server.service failed because the control process exited with error code.
See "systemctl status openvpn-server@server.service" and "journalctl -xeu openvpn-server@server.service" for details.
serv_ivan@964889-cd87180:/etc/openvpn$ sudo tail -n 30 /var/log/syslog
Aug  2 17:53:54 964889-cd87180 systemd[1]: Failed to start OpenVPN service for server.
Aug  2 17:53:54 964889-cd87180 systemd[1]: openvpn@server.service: Scheduled restart job, restart counter is at 15243.
Aug  2 17:53:54 964889-cd87180 systemd[1]: Stopped OpenVPN connection to server.
Aug  2 17:53:54 964889-cd87180 systemd[1]: Starting OpenVPN connection to server...
Aug  2 17:53:54 964889-cd87180 systemd[1]: openvpn@server.service: Main process exited, code=exited, status=1/FAILURE
Aug  2 17:53:54 964889-cd87180 systemd[1]: openvpn@server.service: Failed with result 'exit-code'.
Aug  2 17:53:54 964889-cd87180 systemd[1]: Failed to start OpenVPN connection to server.
Aug  2 17:53:59 964889-cd87180 systemd[1]: openvpn-server@server.service: Scheduled restart job, restart counter is at 15708.
Aug  2 17:53:59 964889-cd87180 systemd[1]: Stopped OpenVPN service for server.
Aug  2 17:53:59 964889-cd87180 systemd[1]: Starting OpenVPN service for server...
Aug  2 17:53:59 964889-cd87180 systemd[1]: openvpn-server@server.service: Main process exited, code=exited, status=1/FAILURE
Aug  2 17:53:59 964889-cd87180 systemd[1]: openvpn-server@server.service: Failed with result 'exit-code'.
Aug  2 17:53:59 964889-cd87180 systemd[1]: Failed to start OpenVPN service for server.
Aug  2 17:54:00 964889-cd87180 systemd[1]: openvpn@server.service: Scheduled restart job, restart counter is at 15244.
Aug  2 17:54:00 964889-cd87180 systemd[1]: Stopped OpenVPN connection to server.
Aug  2 17:54:00 964889-cd87180 systemd[1]: Starting OpenVPN connection to server...
Aug  2 17:54:00 964889-cd87180 systemd[1]: openvpn@server.service: Main process exited, code=exited, status=1/FAILURE
Aug  2 17:54:00 964889-cd87180 systemd[1]: openvpn@server.service: Failed with result 'exit-code'.
Aug  2 17:54:00 964889-cd87180 systemd[1]: Failed to start OpenVPN connection to server.
Aug  2 17:54:01 964889-cd87180 systemd[1]: Stopped OpenVPN service for server.
Aug  2 17:54:01 964889-cd87180 systemd[1]: Starting OpenVPN service for server...
Aug  2 17:54:01 964889-cd87180 systemd[1]: openvpn-server@server.service: Main process exited, code=exited, status=1/FAILURE
Aug  2 17:54:01 964889-cd87180 systemd[1]: openvpn-server@server.service: Failed with result 'exit-code'.
Aug  2 17:54:01 964889-cd87180 systemd[1]: Failed to start OpenVPN service for server.
Aug  2 17:54:05 964889-cd87180 systemd[1]: openvpn@server.service: Scheduled restart job, restart counter is at 15245.
Aug  2 17:54:05 964889-cd87180 systemd[1]: Stopped OpenVPN connection to server.
Aug  2 17:54:05 964889-cd87180 systemd[1]: Starting OpenVPN connection to server...
Aug  2 17:54:05 964889-cd87180 systemd[1]: openvpn@server.service: Main process exited, code=exited, status=1/FAILURE
Aug  2 17:54:05 964889-cd87180 systemd[1]: openvpn@server.service: Failed with result 'exit-code'.
Aug  2 17:54:05 964889-cd87180 systemd[1]: Failed to start OpenVPN connection to server.
serv_ivan@964889-cd87180:/etc/openvpn$

A: I found this solution. It's for CentOS, not Ubuntu, but it could work. It says

Copy config here: /etc/openvpn and change path to files in config to correct.

I'm not sure where you are supposed to "change path", it could be the WorkingDirectory in the service file (/usr/lib/systemd/system/openvpn-server@.service).
You already tried putting the config file into /etc/openvpn/, so maybe you just need to adjust the service file too.
Note: I think it's not enough to copy just the server.conf. I think the other files (eg. ca.crt) are needed too, because they are referenced by the server.conf.
Is there an error in that guide?
However, this workaround shouldn't be necessary. I created a fresh Ubuntu 22.04 installation in a VM and followed the guide until step 10. I have no separate CA Server, but this shouldn't make a difference for the current problem.
Now guess what? In step 10 the server started without any errors. This doesn't solve your problem. But at least now you know that this guide is probably correct, and the problem is caused by something else.
Directory and file permissions
You said that everything is in order with access rights. Just to be sure, i'll write down the permission of my working setup:

*

*The directories /etc/, /etc/openvpn/ and /etc/openvpn/server/ are owned by root:root and chmod'ed to 755.

*The files in /etc/openvpn/server/ are owned by root:root and chmod'ed to 600, just the server.conf is set to 644.

A: In my case when nginx starts first caused vpn error
if you are using nginx as proxy reverse for your vpn clients, do the following:
sudo su
#stop open vpn and nginx
systemctl stop openvpn
systemctl stop nginx

#re-start openvpn first
systemctl start openvpn
systemctl status openvpn

#finally restart your nginx service
systemctl start nginx
systemctl status nginx


text:
Q: NotReadablePropertyException while using projection on EclipseLink I have the following problem with using Spring Data on EclipseLink - I use projections in order to get selected properties of the objects in database. I have an entity named "Campaign":
@Entity
@Table(name = "campaign")
public class Campaign implements Serializable {

    @Id
    @NotNull
    private String id;
    @NotNull
    private CampaignState state = CampaignState.NEW;

    // getters and setters...

}

CampaignState is some enum. Then, I added the following projection:
public interface CampaignStateView {
    CampaignState getState();
}

...which I use in my repository:
public interface CampaignRepository extends
        JpaRepository<Campaign, String>,
        QuerydslPredicateExecutor<Campaign> {

    @Query("SELECT DISTINCT c.state AS state FROM Campaign c")
    List<CampaignStateView> findDistinctStates();
}

I use this repository in my service:
@ApplicationScoped
public class CampaignDataService {

    private CampaignRepository campaignRepository;

    // for CDI proxy
    public CampaignDataService() {
    }

    @Inject
    public CampaignDataService(CampaignRepository campaignRepository) {
        this.campaignRepository = campaignRepository;
    }

    public Collection<CampaignState> findStates() {
        return campaignRepository.findDistinctStates().stream()
                .map(CampaignStateView::getState)
                .collect(Collectors.toList());
    }

}

But, unfortunately, when I call a method findStates() from the service, I get the following exception:
Caused by: org.springframework.beans.NotReadablePropertyException: Invalid property 'state' of bean class [campaign.CampaignState]: Could not find field for property during fallback access!
     at org.springframework.data.util.DirectFieldAccessFallbackBeanWrapper.getPropertyValue(DirectFieldAccessFallbackBeanWrapper.java:58)
     at org.springframework.data.projection.PropertyAccessingMethodInterceptor.invoke(PropertyAccessingMethodInterceptor.java:73)
     at org.springframework.data.projection.ProjectingMethodInterceptor.invoke(ProjectingMethodInterceptor.java:64)
     at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
     at org.springframework.data.projection.ProxyProjectionFactory$TargetAwareMethodInterceptor.invoke(ProxyProjectionFactory.java:245)
     at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
     at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59)
     at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
     at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
     at com.sun.proxy.$Proxy301.getState(Unknown Source)
     at campaign.CampaignDataService$$Lambda$491.000000006DCDF7C0.apply(Unknown Source)
     at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:204)
     at java.util.Vector$VectorSpliterator.forEachRemaining(Vector.java:1451)
     at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:523)
     at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:513)
     at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:719)
     at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:245)
     at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:510)
     at campaign.CampaignDataService.findStates(CampaignDataService.java:153)
     ... 118 more

I get this error only on EclipseLink - on Hibernate everything works fine...

A: The exception is thrown when the Object (CampaignState) will be null. Please verify if you are having valid values for it.
As per the code and Line where the error is being thrown in DirectFieldAccessFallbackBeanWrapper.Java class :
@Override
public Object getPropertyValue(String propertyName) {
    try {
        return super.getPropertyValue(propertyName);
    } catch (NotReadablePropertyException e) {
        Field field = findField(getWrappedClass(), propertyName);
        if (field == null) {
            throw new NotReadablePropertyException(getWrappedClass(), propertyName, "Could not find field for property during fallback access!");
        }
        makeAccessible(field);
        return getField(field, getWrappedInstance());
    }
}

The NotReadablePropertyException will be thrown if field is null.
Most probably the value coming from campaignRepository.findDistinctStates() is null.


text:
Q: Flash CS5 Actionscript 3.0 Using a movie clip as a button with linking So I have an animated button in the form of a movie clip that I want to be able to use as a link. The movie clip is animated on mouse over and mouse off using a script I found online, and that works perfectly. However, when I try to create a simple actionscript command to also have the movie clip act as a link, I get the following error thrown at me:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at PheV3_fla::MainTimeline/frame185()

All of the tutorials I found online use the "button" type for linking as opposed to a movie clip, which seems to work fine, but I need this to be a movie clip for the animation. Here is the code I'm using:
import flash.events.MouseEvent
import flash.net.URLRequest

MixesButtonTop.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage_2);

function fl_ClickToGoToWebPage_2(event:MouseEvent):void
{
    navigateToURL(new URLRequest("http://www.adobe.com"), "_blank");
}

Do I need to reference one of the symbols inside the movie clip button itself or something? I'm very new to all this so if I missed anything please let me know, thanks so much for the help!

A: You should give your button an instance name under the properties tab, and then reference to it by that name, and not by how it is called in the library. To do that you need

*

*Select the button instance on the Stage.

*Select Window > Properties, and enter a name in the Instance Name box.

So for example you set instance name MixesButtonTop. Then you should declare a variable in your code like this:
var buttonMC:MovieClip = MixesButtonTop;

And that should fix your problem.

A: If your button exists in the timeline, you need to give it an instance name (see the response of jfgi). By this instance name you can reference it in your code. It is not necessary to assign it to a variable (in contrast to what jfgi wrote) - however assigning it to a variable and adding the type (:MovieClip) will help you with code-hinting if you are working with Flash IDE, otherwise the IDE cannot figure out what type the symbol is. Note: the name of the symbol in the library is a 'Class name' (Linkage). You cannot use the class name to command and INSTANCE of the class. You need to assign it to a variable/give it an instance name in the properties window. If you manually place a symbol from the library to the stage and you want to control it, you 'always' need to add an instance name. ('always'... as there are other ways to retrieve the reference, e.g. getChildAt, etc...)
I had to post this as an answer, it was too long for a comment.


text:
Q: Change zero to ones in vector if surrounded by less than five consecutive zeros I have a vector of 0s and 1s and want to identify the indices where a string of 0s is surrounded by 1s. If the number of 0s between the 1s is lower or equal than 5, I want to change these zeros to 1s.
Here is an example:
> x <- c(0,0,0,1,1,1,0,0,0,1,1,0,0,0,0,0,0,1,1,1,1)

In positions 7,8, and 9, I have only three zeros, and thus these need to be changed to 1. The other zeros are more than 5, and thus need not to be changed.
The resulting vector should look like this:
> x_converted <- c(0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1)

I am doing this with a for loop and if else statement, but I am sure there must be a faster way to do this.
Thank you.

A: You can use rle() to get the runs. Then just change it based on the length of the run, excluding first run by looking at cumprod().
x_rle <- rle(x)

x_0 <- cumprod(x_rle$values == 0)
x_rev_0 <- rev(cumprod(rev(x_rle$values) == 0))

x_rle$values <- ifelse(
  x_rle$lengths > 5 | x_0 | x_rev_0,
  x_rle$values,
  1
)

rep(x_rle$values, x_rle$lengths)
#>  [1] 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1

A: A possible solution with rle which does not change shorts sequences of zero's at the beginning or end of x:
# create the run length encoding
r <- rle(x)

# create an index of which zero's should be changed
i <- r$values == 0 & r$lengths < 5 &
  c(tail(r$values, -1) == 1, FALSE) &
  c(FALSE, head(r$values, -1) == 1)

# set the appropriate values to 1
r$values[i] <- 1

# use the inverse of rle to recreate the vector
inverse.rle(r)

which gives:
[1] 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1

A: The rle() (run-length-encoding) function makes this pretty easy.
x <- c(0,0,0,1,1,1,0,0,0,1,1,0,0,0,0,0,0,1,1,1,1)
r <- rle(x)
## modify values appropriately
r$values[r$values==0 & r$lengths<=5] <- 1
## convert back to full vector
x_new <- rep(r$values, r$lengths)
## [1] 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1

However, this still needs a little bit of adjustment for literal edge cases — this has converted the initial run of 3 zeros to 1. Perhaps
n <- length(r$values)
rv_int <- r$values[2:(n-1)]
rl_int <- r$lengths[2:(n-1)]
rv_int[rv_int == 0 &
       rl_int <= 5] <- 1
x_new <- rep(c(r$values[1],  rv_int, r$values[n]),
             c(r$lengths[1], rl_int, r$lengths[n]))

A: With data.table::rleid: rleid creates run-length type group id, which are used as grouping factor in ave. ave then performs a function over the groups defined by r.
r <- data.table::rleid(x)
# [1] 1 1 1 2 2 2 3 3 3 4 4 5 5 5 5 5 5 6 6 6 6
sub <- !r %in% c(1, max(r))

x[sub] <- ave(x[sub], r[sub], FUN = function(x) ifelse(length(x) <= 3 & x == 0, 1, x))
# [1] 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1

A: A different approach, based on converting x to a string and then back to a numeric vector:
library(tidyverse)

x <- c(0,0,0,1,1,1,0,0,0,1,1,0,0,0,0,0,0,1,1,1,1)

x %>% str_c(collapse = "") %>%
  str_replace_all("(?<=1)0{1,5}(?=1)", \(x) str_dup("1", nchar(x))) %>%
  str_split("") %>% flatten %>% as.numeric

#>  [1] 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1

Or with purrr::walk and rle:
library(purrr)

x <- c(0,0,0,1,1,1,0,0,0,1,1,0,0,0,0,0,0,1,1,1,1)

z <- rle(x)

walk(1:(length(z$values)-3),
  ~ if (all(z$values[.x:(.x+2)] == c(1,0,1)) & z$lengths[.x+1] <= 5)
     z$values[.x+1] <<- 1)

inverse.rle(z)

#>  [1] 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1


text:
Q: insert cumulative values between non-existed dates: Suppose Tom placed two orders on Monday and Friday. But I want to figure out an efficient way to insert no-purchase data for Tue,Wed,Thu, which are not existed in my data so I can calculate cumulative total spending for every day for Tom.
My current code is to create an massive user-date(full date,from 2010-2011); merge them with existed data by full merge; fill in missing value; calculate cumsum.
user<-c("Tom","Tom","Jim","Jim")
order_time<-c("2018-01-01", "2018-01-04", "2018-01-02","2018-01-04")
total_spending<-c(20,80,50,60)
dt<-data.frame(user,order_time,total_spending)

> dt
  user order_time total_spending
1  Tom 2018-01-01             20
2  Tom 2018-01-04             80
3  Jim 2018-01-02             50
4  Jim 2018-01-04             60

Desired output
user order_time total_spending cumulative_spending
1  Tom 2018-01-01             20                  20
2  Tom 2018-01-02              0                  20
3  Tom 2018-01-03              0                  20
4  Tom 2018-01-04             80                 100
5  Jim 2018-01-02             50                  50
6  Jim 2018-01-03              0                  50
7  Jim 2018-01-04             60                 110

A: You can use complete with seq.Date:
dt %>%
  mutate(order_time = as.Date(order_time)) %>%
  group_by(user) %>%
  complete(order_time =seq.Date(min(order_time), max(order_time), by="day")) %>%
  replace_na(list(total_spending = 0)) %>%
  mutate(cumulative_spending = cumsum(total_spending))

Output:
# A tibble: 7 x 4
# Groups:   user [2]
  user  order_time total_spending cumulative_spending
  <fct> <date>              <dbl>               <dbl>
1 Jim   2018-01-02            50.                 50.
2 Jim   2018-01-03             0.                 50.
3 Jim   2018-01-04            60.                110.
4 Tom   2018-01-01            20.                 20.
5 Tom   2018-01-02             0.                 20.
6 Tom   2018-01-03             0.                 20.
7 Tom   2018-01-04            80.                100.


text:
Q: Error accessing Geometry column from Azure SQL in Azure Function I have an Azure Function that accesses an Azure SQL database. The 42nd column in the database is of the Geography datatype (this is where the problem lies).
Here is the code I am running:
// var datatable = DataTable();
// Filled 'datatable' from a database query

string json = Newtonsoft.Json.JsonConvert.SerializeObject(dataTable, Newtonsoft.Json.Formatting.Indented);
return new HttpResponseMessage(HttpStatusCode.OK)
{
    Content = new StringContent(json, Encoding.UTF8, "application/json")
};

And I am getting this error message:

Exception while executing function: Functions.GetRepeaterDetails.
  Microsoft.Azure.WebJobs.Script: One or more errors occurred.
  System.Data: DataReader.GetFieldType(42) returned null.

I've done several hours' worth of searching and trying what others have claimed to work, but none have fixed my scenario.
I read this on another forum:

Be aware that your sample will work, but what won't work is a web
  application that retrieves geometry from SQL Azure, because SQL Azure
  is currently running Denali (SQL Server 2012) at compatibility level
  100; hence it will return instances of the 10.0 spatial types and the
  web role will throw an exception when trying to cast them to 11.0.

Some things I've tried:

*

*Added Microsoft.SqlServer.Types v14.0.314.76 to project.json (also tried several other versions.

*Added HashFoo.SqlServer.SpatialTypes v10.0.0 to project.json

*Changed the Azure SQL Server compatibility level to 110.

Even though I can see that the server is installing the appropriate references via Nuget, the error message has remained the same.

A: I don't know exactly which assembly to load to make that work, but you can sidestep the issue by converting that column to WKT using the .ToString() function in your query.
Since you're formatting the results a JSON, that's probably what you want anyway.
eg
select ...., geo_location.ToString() geo_location, . . .
from some_table

You can also just have SQL Server Return Query Results as JSON


text:
Q: How to avoid 'any' and provide correct type in typescript code? My task is to improve the current TypeScript, avoiding using any type at the same time. The thing is that sometimes it is pretty hard to understand what should be there instead as part of the code is a legacy code.
Could you please give me any tips how to look for the proper types in the cases that are not that obvious (besides obviously hovering over some things)?
What would be the best way to investigate this payload thing and X,Y,Z?
I know any is okay when used with some 3rd party libraries etc. but what about these cases for example? How should I avoid any in cases like HOC when testing the type of the thing is much harder?
export default ({ classes, label, payload }: Props): JSX.Element => (
  <div className={classes.background}>
    <Typography className={classes.label} variant="subtitle2">
      {label} - {payload.find((item) => item.dataKey === 'value')?.value || '-'}
    </Typography>
  </div>
);

interface Props {
  classes: Partial<ClassNameMap>;
  label: string;
  payload: any;
}

import React, { useEffect } from 'react';

export default (WrappedComponent: React.ComponentType) => ({ X, Y, Z }): JSX.Element => {
  useEffect(() => {
    if (!X.length) {
      Y();
    }
  }, [X, Y, Z]);

  return (
    <WrappedComponent />
  );

};

A: This technical debt kind of work is always a bit of a slog. But it will help you hone your skills with TypeScript.
Looking at your first snippet above, what I would do is look at how that function uses that prop. You can see that it uses a find method, so this is a good indicator that it is an array type. Furthermore, the array seems to contain values called item that have a dataKey, which gives you a starting point to find what exactly an item is. Assuming somewhere in your codebase there is an Item interface or type, you can import that type and define the payload as Item[].
The second example is a lot more difficult. Maybe this is X, Y and Z coordinates. Or maybe it is just badly named. The only way to identify this would be to search the codebase for the usages of that component and go from there.


text:
Q: Not Able To Add To Array In "C" I have a program meant to calculate prime numbers of a specific number then I have to put it into an array in order to do some math to those numbers; however, I'm running into an issue where I am not able to put the prime numbers collected into an array.
Current Code
#include <stdio.h>
#include "pairs.h"
#define SIZE 1000

int main(){
    int n, m, count, i=0, res = 0;
    char prime[SIZE];

    scanf("%d %d", &n, &m);

    // while(count >= 1){
    //     // count = getchar();
    //     // prime[i++] = count;
    for(count = n; count >= 2; count--){
        if(primed(count) == 0){
            prime[i++] = count;
        }

    }
    printf("%s",prime);
    return 0;

}

int primed(int num){
    int primes;
    for(primes = 2; primes<=num/2; primes++){
        if (num % primes != 0){
            continue;
        }
        else{
            return 1;
        }
    }
    return 0;
}

I am hoping to add the numbers collected in the for-loop to an array

A: Well, your code works, the problem is that you are not printing the array well, try this code for printing the array which has to the same type of the elements you want to put in, so int prime[SIZE]:
int j;
for(j = 0; j < i; j++)
    printf("%d ", prime[j]);
printf("\n");

Note that the numbers will be in reverse order as you are starting the calculation from the last element, so if you input 10 you will have:
7 5 3 2

The %s you are using in order to print the array is used to print strings (char arrays terminated with the character '\0'). If you want to print every other type of array you must use a cycle and print every element.


text:
Q: Can't generate apk project that make with react native in android studio I have made a project with react native. now I want to generate an apk. but there isn't any generated icon as below picture and also there isn't exist Gradle script at the root of my project.

I think the Gradle script does not in the root project, is this the problem with Gradle?

A: Open android folder in android studio, you will see Gradle, libraries and can build apk, also if you want to generate a release apk you can do it with this command in android folder directory ./gradlew assembleRelease or gradlew assembleRelease

A: Run npx react-native run-android --variant=release from the android folder.
You can find the apk in:
'project_name'/android/app/build/outputs/apk/release


text:
Q: On clicking first radio button, automatically open radio button inside of that div I have list of packages. All of them are radio buttons. When clicked, i get list of price options who are also radio button, but only first price option, others are normal buttons.
When i click on package radio button, i need first price option also checked and active, so it can show some values inside of it. Others needs to be closed.

<input class="col-sm-1" id="id_radio26"
         type="radio" value="26" name="radio"> Paket 1

Credits: 20

Duration: 2min

$200/Month

                          Price Option:  86

                                            <input class="price_option" type="radio"
                                                   value="86"
                                                   name="price_option" checked="checked">

                                                        Values

                                                            Vrednost 31

                                                            <input type="hidden"
                                                                   name="value-86[]"
                                                                   value="Vrednost 31">

                                                            Vrednost 32

                                                            <input type="hidden"
                                                                   name="value-86[]"
                                                                   value="Vrednost 32">

                                            <button class="price_option" type="button"
                                                    name="price_option" value="91">
                                                Alternative Payment
                                            </button>

                                                        Values

                                                            assd

                                                            <input type="hidden"
                                                                   name="value-91[]"
                                                                   value="assd">

                                                            asdasd

                                                            <input type="hidden"
                                                                   name="value-91[]"
                                                                   value="asdasd">

This is my script for now:
        /*Radio buttons */
    $('div[id^="package"]').hide();

    $('body').on('click', 'input[id^="id_radio"]', function () {
        $('div[id^="package"]').hide();
        $('#package' + $(this).val()).show();
        console.log($(this).val());

    });

    $('div[id^="price_option_div"]').hide();

    $('body').on('click', '.price_option', function () {
        $('div[id^="price_option_div_"]').hide();
        $("#price_option_div_" + $(this).val()).show();
        console.log($(this).val());
    });

A: I assume that u cant change your HTML Code and add some Classes. Therefore you could use something like this:

/* Radio buttons */

    // set variables
    var $packages = $('div[id^="package"]'),
        $priceOptions = $('div[id^="price_option_div"]'),
        priceOptionNr;

    // hide stuff
    $packages.hide();
    $priceOptions.hide();

    $('input[id^="id_radio"]').on('click', function () {
        // hide stuff
        $packages.hide();
        $priceOptions.hide();

        // safe price option value
        priceOptionNr = $('#package' + $(this).val())
            .find('.price_option').val();

        // show specific price option + connected div
        $('#package' + $(this).val()).show()
          .find('#price_option_div_' + priceOptionNr).show();
    });

    $('.price_option').on('click', function () {
        $priceOptions.hide();
        $("#price_option_div_" + $(this).val()).show();
    });

<input class="col-sm-1" id="id_radio26" type="radio" value="26" name="radio"> Paket 1

Credits: 20

Duration: 2min

$200/Month

    Price Option:  86
     <input class="price_option" type="radio" value="86" name="price_option" checked="checked">

 Values

                         Vrednost 31
 <input type="hidden" name="value-86[]" value="Vrednost 31">

                         Vrednost 32
 <input type="hidden" name="value-86[]" value="Vrednost 32">

     <button class="price_option" type="button" name="price_option" value="91"> Alternative Payment</button>

                            Values

                         assd
 <input type="hidden" name="value-91[]" value="assd">

                         asdasd
 <input type="hidden" name="value-91[]" value="asdasd">


text:
Q: How to display Image from folder using ASP.NET MVC I create entity outside my Project
this is solution Explorer
My entity Post
[Table("Post")]
public partial class Post
{
    public int PostID { get; set; }

    [Required]
    [StringLength(256)]
    public string Title { get; set; }

    [StringLength(256)]
    public string Description { get; set; }

    [StringLength(256)]
    public string Picture { get; set; }

    public int CategoryID { get; set; }

    [StringLength(10)]
    public string ViewNumber { get; set; }

    public int UserID { get; set; }

    public DateTime CreateDate { get; set; }

    public int LikeNumber { get; set; }

    public int? CommentID { get; set; }
}

My Post Controller
[HttpPost]
    public ActionResult UpPost(Post model, HttpPostedFileBase txtImg)
    {
            var db = new ShareImageDbContext();

                if (ModelState.IsValid)
            {
            if (txtImg != null)
            {
                txtImg.SaveAs(HttpContext.Server.MapPath("~/Images/")
                                                      + txtImg.FileName);
                var post = new Post();
                post.PostID = model.PostID;
                post.Title = model.Title;
                post.Description = model.Description;
                post.CategoryID = model.CategoryID;
                var userSession = new UserLogin();
                userSession = (UserLogin)Session[ShareImage.Common.CommonConstants.USER_SESSION];
                post.UserID = userSession.UserID;
                post.CreateDate = DateTime.Now;
                post.Picture = txtImg.FileName;
                db.Posts.Add(post);
                db.SaveChanges();

                    return RedirectToAction("Index", "Homeuser");
                }

                    else
            {
                ModelState.AddModelError("", "Đăng ảnh thất bại!");
            }
        }
        return View(txtImg);
        }

My Post Database
I inserted some post
I want to display all Post on View. And I call Model as below.
@model IEnumerable<Model.EF.Post>

and I call foreach
@foreach (var item in Model)

but it has an error:

Object reference not set to an instance of an object.

I can display my image in Images folder as code following, but I want to show more attribute of Post table such as Title, Discription, CreateDate...
@foreach(var imgPath in Directory.GetFiles(Server.MapPath("~/Images")))
{
   var img = new FileInfo(imgPath);

}

Please guide me how to fix it, Thanks!

A: In your view use String.IsNullOrWhiteSpace for strings and
<img src="<%= ResolveUrl(item.Picture) %>" alt="" /> for images
Problem caused because somewhere you do not set or create object. You have reference that has null value. It raises in view or controller. It will be nice if you provide your error message.


text:
Q: Date() constructor is rendering my page completely blank When I'm using the built-in Date() constructor it's rendering my page completely blank
Current Output
Expected Output
import './ExpenseItem.css';

function ExpenseItem() {
 const expenseDate = new Date(2022, 1, 1)

  return (

{expenseDate}

Car Insurance

$269.64

  );
}

export default ExpenseItem;

A: This is because you are trying to render a Date as a React child and Objects are not valid as a React child (the reason behind your blank screen).
Change your code to be like:
const expenseDate = new Date(2022, 1, 1).toLocaleString();

In this way you will have a string instead, that is a valid React child.
Check the documentation on how to change your date-to-string format:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString

A: ** Because Date is an object and you cant render object as child**
// toDateString() will convert it into sting.
const expenseDate = new Date(2022, 1, 1).toDateString();


text:
Q: Entity Framework varchar To nVarchar I have a column in the database whose datatype is varchar and when I issue a command using Linq as in the following example:
context.x.columnName=="someValue", the generated query uses nVarchar. I understand that Entity Framework uses nVarchar for strings. I tried to use the solution to decorate the column in the entity class with TypeName="varchar" and it works in the above scenario.
[Column(TypeName="varchar")]
public string ColumnName{get;set;}

but when I tried to write the query the following way:
context.x.columnName.Contains("someValue")
the generated query still has nVarchar...I tried all the solutions provided but still having the issue. I tried setting the data type in the Map file and also tried to set IsUnicode(false), but non of them works.
Can someone please help me figure out the solution to this problem...
I really appreciate the response...


text:
Q: Using past prediction as dependent variable with slider I'm stuck on a problem that I can't solve no matter how hard I try.
Imagine that you have 3 variables as described below. The y that you want to predict has 5 observations less than a or b. What I want is: run an OLS with the last 10 obs and predict one ahead. Use this new one as the original value to predict the 12th obs and so on.
I guess I'd do this easily, but I'm in love with this functional programming wave, so I keep trying...
    library(tidyverse)
    library(slider)
    regex <- tibble(a = rnorm(10),
                    b = rnorm(10),
                    y = rnorm(10))%>% add_row(a = rnorm(5), b = rnorm(5))

        regex <- regex %>%
 mutate(Pred= lag(slide(., ~stats::predict(lm(y ~  . , .x)), .before = 10, .complete = F)%>%
 map_dbl(., last)))

Also, I don't know if I'm doing anything wrong by collect the last element of the list generated by stats::predict() and changing its position with lag... this is a smaller problem, but if anyone finds a better solution I'd be pleased to know.


text:
Q: Can you render arbitrary HTML in each cell of a YUI datatable? I want to add paginated table to a page.  It should be 2 rows by 4 columns.  Each cell contains a thumbnail image and some small links.
We're using YUI elsewhere on the project, so I'd like to use the Datatable.  All the examples I see are geared around tabular data (understandable), but my hunch is that I can rewrite the HTML of each cell using Javascript.  I don't see the callback function I should hook to rewrite the cells.
Possible?  Or am I trying to hammer in a nail with a screwdriver?  If there's a simpler way to do this with YUI I'd love to hear about it.
thanks!

A: jcooper,
To paginate a simple grid of image/text elements, I'd almost prefer to see you use the Paginator without using DataTable.  DataTable is a powerful component, but it's working hard to be a lot of things you don't need.
Carousel (http://developer.yahoo.com/yui/carousel/ ), on the other hand, seems like it's trying to be just what you want.  http://developer.yahoo.com/yui/examples/carousel/csl_imagentext.html , for example, might be a good place to start.
If that's not quite what you want, you could definitely do this with DataTable.  Just create the markup snippets you want to use for each cell, store them in an array, and follow the directions for using an array datasource and pagination.
Regards,
Eric


text:
Q: Destructuring declaration initializer of type ObjectAnimator I'm using kotlin destructuring declarations. I used it before with SpringAnimation and it worked perfectly. Now I want use it with ObjectAnimator and I get this error:

Destructuring declaration initializer of type ObjectAnimator! must have a 'component1()' function
Destructuring declaration initializer of type ObjectAnimator! must have a 'component2()' function

Here is my code:
val (xanimator, alphaanim) = findViewById<View>(R.id.imageView).let { img ->
            ObjectAnimator.ofFloat(img, "translationX", 100f).apply {
                duration = 2000
            }
            to
            ObjectAnimator.ofFloat(img, "alpha", 1.0f).apply {
                duration = 2000
            }
        }

What's wrong?

A: The issue here is that you can't start an infix call function call on a new line - the compiler essentially infers a semicolon/line ending after your first apply call. This is the same way with operators, see this issue for example.
So you need to reformat your code a bit for the to to connect, most simply like this:
val (xanimator: ObjectAnimator, alphaanim: ObjectAnimator) = findViewById<View>(R.id.imageView).let { img ->
    ObjectAnimator.ofFloat(img, "translationX", 100f).apply {
        duration = 2000
    } to
    ObjectAnimator.ofFloat(img, "alpha", 1.0f).apply {
        duration = 2000
    }
}

But for readability, maybe you could go with something like this:
val (xanimator: ObjectAnimator, alphaanim: ObjectAnimator) = findViewById<View>(R.id.imageView).let { img ->
    Pair(
            ObjectAnimator.ofFloat(img, "translationX", 100f).apply {
                duration = 2000
            },
            ObjectAnimator.ofFloat(img, "alpha", 1.0f).apply {
                duration = 2000
            }
    )
}

Or anything inbetween.


text:
Q: PLSQL: Convert CLOB to XML I have the following select:
select XMLTYPE.createXML(contents) from log_sync_calls_xmls where id=2;

This gives me the following error:

How to resolve this error?

A: createXML api accepts String/CLOB and returns XMLTYPE value.
Better use this in insert where you want to convert a CLOB data to store into xMLTYPE column.
In a SELECT statement, the outcome of the query will always be displayed in text format.
So, some older versions of Toad or PLSQL developer will have this error.
Please try this using Oracle SQLDeveloper.


text:
Q: Telerik Reporting: how to handle null dates that generate red error box on the report? A date field supplies the value for one of the textboxes on the report; here's how the textbox property page looks:
         Value       =Fields.eventdate.ToString("D")

When eventdate is null, the report displays an error box in red. What's the proper way to handle null values in this scenario?
I tried using the ternary operator in place of the above, but that causes an error:
         Value       =(Fields.evendate != null) ? : Fields.eventdate.ToString("D") : String.Empty

Is it possible to trap this null in the ItemDataBinding eventhandler associated with the textbox? It doesn't seem as though the Fields collection is accessible from there:
   private void textBox28_ItemDataBinding(object sender, EventArgs e)
    {
          Telerik.Reporting.Processing.TextBox tb = (Telerik.Reporting.Processing.TextBox) sender;
          .
          .
          .
    }

A: Got it:
private void textBox28_ItemDataBinding(object sender, EventArgs e)
{
  Telerik.Reporting.Processing.ReportItemBase item ;
  item = (Telerik.Reporting.Processing.ReportItemBase)sender;
  System.Data.DataRowView drv = (item.DataObject.RawData as System.Data.DataRowView);

  //now test the drv.Row[ colname ] for DBNull.Value

}


text:
Q: Why use SurfaceView or TextureView for custom drawing? Their Canvas isn't hardware accelerated So I'm doing a number of Canvas drawText, drawPath, drawArc, drawLine, and drawCircle for an animation...
Using SurfaceView, doing lockCanvas & unlockCanvasAndPost, eventually discover that drawing to the canvas is taking > 16ms say 1 in 20 times
Hardware draw times? 0-2 milliseconds
So why does Lunar Lander <3 SurfaceView? I don't think I could ever beat a hardware accelerated canvas vs a software decelerated canvas.


text:
Q: filtration generated by function of brownian motion Consider a filtration $F^{B_1,B_2}$ generated by two independent Brownian motions $B_1,B_2$.
Now I define $W:= a B_1 + \sqrt{1-a^2} B_2$ and consider the filtration $F^W$ generated by W.
Are $F^{B_1,B_2}$ and $F^W$ the same?

A: No, unless $a=0$ or $a=1$. The inclusion $\mathcal F_t^W\subset\mathcal F_t^B$ always holds as $W_t$ is a function of $(B_{1,t},B_{2,t})$.
However, for $a=1/\sqrt 2$, we get
$$\tag{*}
\mathbb E\left[B_{1,t}\mid \mathcal F_t^W\right]=\mathbb E\left[B_{2,t}\mid \mathcal F_t^W\right]=W_t/\sqrt 2\neq B_{1,t}
$$
hence $B_{1,t}$ is not measurable with respect to $\mathcal F_t^W$.
To see the first equality in (*), observe that $B_{1,t}-B_{2,t}$ is independent of $\mathcal F_t^W$, because for $0\leqslant s_1<\dots<s_N\leqslant t$, $B_{1,t}-B_{2,t}$ is independent of $(W_{s_1},\dots,W_{s_N})$.


text:
Q: How to use images in List-of-Values of "Select List" Items? I want to use images in the LOV (list of values) of "Select List" Items in Apex 5

Following this thread
https://community.oracle.com/thread/3969943
I can change the background color of elements of the list, adding this code to Element>Properties>Advanced>Post Text:
<script type="text/javascript">
    document.getElementById("ElementId")[3].style.backgroundColor= 'cyan';
</script>

but when trying to set an image, nothing happens
<script type="text/javascript">
    document.getElementById("ElementId")[3].style.backgroundImage= "imageUrl";
</script>

What is the right way to set the image?

A: Your code looks fine but images aren't support by IE so if this is the browser you are using this is what the problem will be. It will work in Firefox.


text:
Q: ASP.NET MVC Membership GetNumberOfUsersOnline returning incorrect value I have the following line in a Controller
ViewData["UsersOnLineNow"] = Membership.GetNumberOfUsersOnline().ToString();

I am logged in as an Administrator but the above is returning a value of 0, verified by QickWatch. I was expecting a value of 1.
I also have the following in the Controller
ViewData["RegisteredUsers"] = Membership.GetAllUsers().Count.ToString();

This is returning the correct value of 2, myself included.
Anyone else had problems in this area?

A: MSDN:

GetNumberOfUsersOnline returns the
  number of users for the current
  ApplicationName where the
  last-activity date is greater than the
  current time less the
  UserIsOnlineTimeWindow. The
  last-activity date/time stamp is
  updated to the current date and time
  when user credentials are validated by
  way of the ValidateUser or UpdateUser
  method or when a call to a GetUser
  overload that takes no parameters or
  one that uses the userIsOnline
  parameter to specify that the
  date/time stamp should be updated.

Tip: You can try setting your UserIsOnlineTimeWindow to a higher value. Default value is 15 minutes, in the following example I've set it to 60.
<membership defaultProvider="AspNetSqlMembershipProvider"
  userIsOnlineTimeWindow="60">
  <providers>
    <add name="AspNetSqlMembershipProvider"
      type="System.Web.Security.SqlMembershipProvider"
      connectionStringName="ApplicationServices"
         enablePasswordRetrieval="false"
         enablePasswordReset="true"
         requiresQuestionAndAnswer="false"
         requiresUniqueEmail="false"
         maxInvalidPasswordAttempts="5"
         minRequiredPasswordLength="6"
         minRequiredNonalphanumericCharacters="0"
         passwordAttemptWindow="10"
         applicationName="/" />
  </providers>
</membership>


text:
Q: Pycharm project files background red The issue
Note, this error is not similar to others whereby the letters themselves are in red, this is where the project files have a red background. See the attached image below

I believe that this is because it's not marked as a content root
What I've tried

*

*I've tried to set the code as "project root" but I cannot "mark directory as" on right click or within the menu

*Open the code in CLion and do the same as ^

*Deleted Pycharm and reinstalled it

*Looked in the .xml (I don't really know what I'm doing)
Related issues(?)
I've looked up other issues such as How to stop pycharm show files in project in red color? but they are largely irrelevant to me

A: The solution was to explicitly open the folder again and this makes the red background go away.
File->Open->${project folder}

A: The red background indicates that your Project doesn't know where its root directory is located.
You can set it in File > Settings > Project: <name> > Project Structure > Set Root Folder and point it at the root directory of your repository.


text:
Q: Problem calling a method from visualforce I want the User Id to be displayed in a visualforce page
 public class getUser{

   public void classGetID()
   {
     String s=UserInfo.getUserId();
   }
 }

Following is my visualforce page..
 <apex:page Controller="getUser" >

    <apex:outputText value="!classGetID"></apex:outputText>

 </apex:page>

Please guide me how do get the user ID.

A: You can use the User global variable, which would be quite straight forward
 <apex:outputText value=" {!$User.Id}"/>

A: First, You need to return the Id in your method (your method is void which means it won't return anything if you call it) - like this:
public Id classGetId()
{
    return Userinfo.getUserId();
}

Then in your page you need to call this method (your syntax is not correct) like:
<apex:outputText value="{!classGetID}"></apex:outputText>


text:
Q: what's the meaning of "groping for political relevance"
Blamed for a painful recession at home, hounded by Washington do
  deploy thousands of combat troops to Iraq and unable to resolve North
  Korea's pressing nuclear problem, President Roh is groping for
  political relevance.

what's the meaning of "groping for political relevance"?
I know 'groping' for means 'seeking for or looking for', but what is political relevance? Is it political insight or political ability?

A: President Roh has been an ineffective political leader, not being able to solve pressing problems. As such he is no longer of much value to his country and its government. He is groping for political relevance: looking for something that will make him valuable within the politics of his country.


text:
Q: TeamCity SMB deployer - artifacts to flatten folder structure My last build step in my TeamCity 9.1 project configuration uses the SMB deployer to copy files to a shared network drive (which we use to deploy the version to our users).
The copy is performed fine but the deployer somehow creates all the folders in the hierarchy leading to the bin folder. Example:
My configuration is:
Target URL:
\\theserver\thefolder

Artifacts path:
**\ProjectName\bin\Release\* => .
**\ProjectName\bin\Release\Resources\* => Resources

With this configuration, I'm expecting the files to be copied to \\theserver\thefolder\* and \\theserver\thefolder\Resources\*
However, this is the result I get instead: my files are copied to
\\theserver\thefolder\ProjectName\bin\Release\*
\\theserver\thefolder\Resources\ProjectName\bin\Release\Resources\*

How do I go with my artifacts definition so my files are copied to the proper folder? I'm having such a hard time with this syntax

A: The **\ prefix is causing the artifact path output to include the matched folder hierarchy.
You'll need to use the full path to the Project folder, also if you want to include nested directories, use the **\* at the end of the artifact path:
\path\to\ProjectName\bin\Release\**\* => .
\path\to\ProjectName\bin\Release\Resources\**\* => Resources

For more information, see the artifact path doco, specifically:

wildcard — to publish files matching Ant-like wildcard pattern (only "*" and "**" wildcards are supported). The wildcard should represent a path relative to the build checkout directory. The files will be published preserving the structure of the directories matched by the wildcard (directories matched by "static" text will not be created). That is, TeamCity will create directories starting from the first occurrence of the wildcard in the pattern.


text:
Q: Reference request for bounds of $n$-th composite Motivation
I will briefly elaborate here my motivations for asking the question. If you are not interested in it then please go to the questions.

*

*Recently during trying to understand and prove the Second Hardy-Littlewood Conjecture, I came to notice that the following slightly weak version of the conjecture,

$π(x + y) ≤ π(x) + π(y)$ for all integers $x, y ≥ 2$, where $π(x)$ denotes the prime-counting function, giving the number of prime numbers up to and including $x$.

Is equivalent to the following,

$π(x + y) ≤ π(x) + π(y)$ for all composite number $x, y ≥ 4$, where $π(x)$ denotes the prime-counting function, giving the number of prime numbers up to and including $x$.

Which in turn is equivalent to the following,

$c_m+c_n\ge c_{m+n+1}$ for all $m,n\in \mathbb{N}$ where $c_j$ denotes the $j$-th composite.

*It can be easily seen that the following results hold,

*

*If $c_n$ and $c_m$ denotes respectively the $n$-th and $m$-th composite number such that $m+n$ is even and $c_n+c_m$ is odd, then there exists a prime between $c_n$ and $c_m$

*If $c_n$ and $c_m$ denotes respectively the $n$-th and $m$-th composite number such that $m+n$ is odd and $c_n+c_m$ is even, then there exists a prime between $c_n$ and $c_m$ for all sufficiently large $m,n\in\mathbb{N}$.

*For all sufficiently $x,y\in \mathbb{R}$ either there exists a prime between $x$ and $y$ or $\pi(x)+\pi(y)>\pi(x+y)$.

*The literature regarding the bounds on $n$-th composite number seems to be very little. In fact, by online search I found no other paper (in English) than    this.
Question
Does there exist stronger bounds for the $n$-th composite than the one already given in the paper I linked above? More specifically, Does there exist stronger bounds for the $n$-th composite than what is already given in the following theorem?

For all integer $n\ge 4$ we have, $$n\left(1+\dfrac{1}{\ln n}+\dfrac{1}{\ln^2 n}\right)<c_n< n\left(1+\dfrac{1}{\ln n}+\dfrac{3}{\ln^2 n}\right)$$

If so then can someone please give some references?


text:
Q: SQL Dealing with midnight I'm dealing with (for me) huge SQL problem. I have table called "timeshifts" which as 4 columns:
id, name, from and to. Last two type is TIME.
Now: I have three timeshifts:
06:00 - 14:00
14:00 - 22:00
22:00 - 06:00
Now, I have to find correct shift for current time (which works like a charm), but I can't find a proper records that belong to current shift. IE. table called user_times contains fields with separate date and time values. According to current timeshift I have to find records that belongs to the timeshift. There is no problem for first two shifts, but third one passes midnight and that is my problem.
Here is the query that finds proper shift, event through midnight:
SELECT
  FLOOR(SUM(time_sum) / 60) AS th,
  MOD(SUM(time_sum), 60) AS tm,
  t.*
FROM
  ur_user_times ut,
  ur_timeshifts t
WHERE CURTIME() >= IF (
    t.timeshift_to < t.timeshift_from,
    0,
    ADDTIME(t.timeshift_from, "00:15")
  )
  AND CURTIME() <= ADDTIME(
    IF (
      t.timeshift_to < t.timeshift_from,
      ADDTIME(t.timeshift_from, "10:00:00"),
      t.timeshift_to
    ),
    "00:15"
  )
  AND ut.`date` BETWEEN CURDATE() - INTERVAL 1 DAY AND CURDATE()
  AND ut.`start` BETWEEN ADDTIME(t.`timeshift_from`, "-10:00:00") AND ADDTIME(t.`timeshift_to`, "-10:00:00")
  AND ut.user_id = 40

ut.start is time value that interests us.

A: Try this:
select *
from timeshifts ts,
usertimes ut
where
(ts.from < ts.to and ut.start >= ts.from and ut.start <= ts.to) OR
(ts.from > ts.to and (ut.start >= ts.from or ut.start <= ts.to))

A: A similar query was posted a few days ago:
Please see this question:
Shift wise datetime checking in sql server query


text:
Q: Capture when laptop is suspended in AIR on OSX The high level problem is that I want to know if the user is present for a given time period in the past. This can be solved when the computer is awake by tracking USER_IDLE and USER_PRESENT events.
However, I've found that when the laptop lid is closed, it does not fire the USER_IDLE event, nor does it fire USER_PRESENT when the laptop lid is opened. The laptop can be closed for hours and neither events are ever dispatched.
So how can I know if the user is present? I've looked into all sorts of events to capture the laptop being suspended, including SUSPEND, DEACTIVATE, etc, but none do what I want.
For example, I have this test code:
var logFile:File = File.documentsDirectory.resolvePath("events.log");

var app:NativeApplication = NativeApplication.nativeApplication;
app.addEventListener(Event.USER_IDLE, logEvent);
app.addEventListener(Event.USER_PRESENT, logEvent);
app.addEventListener(Event.SUSPEND, logEvent);
app.addEventListener(Event.EXITING, logEvent);
app.addEventListener(Event.ACTIVATE, logEvent);
app.addEventListener(Event.DEACTIVATE, logEvent);
app.addEventListener(InvokeEvent.INVOKE, logEvent);

logEvent(new Event("started"));

function logEvent(e:Event):void {
    var log:String = "\n" + e.type + " at " + new Date();

    var fileStream:FileStream = new FileStream();
    fileStream.open(logFile, FileMode.APPEND);
    fileStream.writeUTFBytes(log);
    fileStream.close();
}

If I run this app, change window focus away then back, close the laptop, then open the laptop, I get this output:
started at Tue Sep 1 09:29:11 GMT-0400 2015
invoke at Tue Sep 1 09:29:11 GMT-0400 2015
activate at Tue Sep 1 09:29:12 GMT-0400 2015
deactivate at Tue Sep 1 09:29:13 GMT-0400 2015
activate at Tue Sep 1 09:29:13 GMT-0400 2015
deactivate at Tue Sep 1 09:29:17 GMT-0400 2015
activate at Tue Sep 1 09:29:31 GMT-0400 2015

As you can see this doesn't seem to help me figure out if the user is present (laptop awake) or not. There are no USER_IDLE or USER_PRESENT events, and the ACTIVATE and DEACTIVATE events happen even when the user is present.
Is there any way to know if the laptop is suspended? Or to know if the user is present?

Edit: I guess that I can poll the system clock. A large jump in time would indicate waking up after being suspended for awhile. I'll try this.


text:
Q: What is difference between "extended Email notification" and "Email notification" in Jenkins I am trying to configure pipeline having email to be sent about pipeline status. For that I came across two mail configurations.
and other one is--

I didn't able to find difference between these two configurations.

A: They are two different plugins.

*

*E-mail Notification is from the plugin Mailer and allows to send a basic email.

*Extended E-mail Notification is from the plugin Email-ext and allows more customization, e.g. from the plugin's page: "when an email is sent, who should receive it, and what the email says".  This plugin also allows to set default global parameters (e.g. recipient list) so you don't have to set these parameters on each and every project.


text:
Q: Firefox does not clear memory when a refresh my Three.js based page I have been coding for an hour a web page in Three.js using Firefox as a browser. For some reason whenever I press refresh Firefox, it keeps increasing the memory. Doesn't have a garbage collector? When I see the memory from the tools, I see that only 74MB are dedicated to the web page. So the other 7000 MB are from previous sessions, I assume ???

A: You need to dispose properly the instances of Material, Geometry, WebGLRenderer and scene. Here is a well self-answered question on the topic, but the best for me (the one I use) is this one


text:
Q: How to get parameters of cron job Schedule in laravel When I run  crontab -e
* * * * * php /srv/PHP/devloper/test/artisan schedule:run company-cd=1

In Kernel.php , I have functiom
protected function schedule(Schedule $schedule)
 {
        $schedule->command('test:alertlimitedstock --company-cd=1')
                ->withoutOverlapping()
                ->cron('* * * * *');
    }

How to get company from cron command?


text:
Q: find phoneNumber regex with mongoose I am trying to build a query to find phoneNumber in MongoDB.
for example I have those number in my database:

*

*+33671974813

*+33.6.71.97.48.13

*+33 6 71 97 48 13
and I want to find them all in a query like
mobilePhone: { $regex: "+3367197", $options: "i" }

I already try that but it doesn't work:
mobilePhone: { $regex: "+3367197", $options: "i", $in: [/^\+?[\d\. ]+/] }

Do you know how to do ?
Thanks for help ;)

A: I think you should clean the database from bad formatted phones.
Also dont allow bad formatted phones to enter the database, clean them before insert.
The bellow query works in bad formated phones.
The first step is to clean the phone (keep only digits and the + symbol if in front).
And then does the match you want.
You can use the first part that cleans the phone, to clear all the database, with a pipeline update, like  updateMany({},[{"$set" ...}])
Also when you try to match you should escape the regex special characters, for example not {regex : "+33.."} but {regex : "\\+33"} like the example bellow.
For a function that does those automatically see this answer also
Query
Test code here
db.collection.aggregate([
  {
    "$set": {
      "phone": {
        "$reduce": {
          "input": {
            "$regexFindAll": {
              "input": "$phone",
              "regex": "^\\+|\\d+"
            }
          },
          "initialValue": "",
          "in": {
            "$concat": [
              "$$value",
              "$$this.match"
            ]
          }
        }
      }
    }
  },
  {
    "$match": {
      "$expr": {
        "$regexMatch": {
          "input": "$phone",
          "regex": "\\+3367197"
        }
      }
    }
  }
])

A: The .aggregate() solution is great, and will work! But afaik it will add a performance cost to your back-end query with MongoDB.
Another approach my colleague hipped me to is to use a "magic regex delimiter", in between each digit in the search value.
The delimiter: \D*

*

*\D means "matches any single character that is not a digit (same as [^0-9] )."

** means "zero or more matches"

So, if the user is searching for 123567 and the db has 123-567 then you end up looking for the regex:

*

*1\D*2\D*3\D*5\D*6\D*7\D*
That way, any other characters that appear in between digits in the DB (parentheses, dashes, etc.) are ignored with the modified regex. And no additional aggregation needs to be done.
The actual code looked like this:
new RegExp(search.replace(/\D/g, '').split('').join('\\D*'), 'i')

*

*you can see that we first replace/remove all non-digits from the search value...

Hope that helps!


text:
Q: How to calculate wifi dynamic frequency selection probability I have no idea how I can handle this question.
Let's say 802.11h AP points are spread out throughout a street.
#52, #56 ...., #140

A bus that is connected to #52 channel is travelling along that street with a constant speed.
What's probability that that bus will have to change its AP?
Thanks.

A: This almost sounds like a trick question.
The way it's written the answer is certainly 100%.
That is, unless the bus's constant speed is 0 or the AP's range is ∞.


text:
Q: Ubuntu 18.04 unable to install python3 tkinter Lubuntu 18.04 python3 version is 3.6.10
~$ python3 --version
Python 3.6.10

When trying install tkinter module, it seems to point to 3.6.9 version and failed:
~$ sudo apt-get install python3.6-tk
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'python3-tk' instead of 'python3.6-tk'
Suggested packages:
  tix python3-tk-dbg
The following NEW packages will be installed:
  python3-tk
0 to upgrade, 1 to newly install, 0 to remove and 23 not to upgrade.
Need to get 119 kB of archives.
After this operation, 1,324 kB of additional disk space will be used.
Get:1 http://au.archive.ubuntu.com/ubuntu bionic-updates/main amd64 python3-tk amd64 3.6.9-1~18.04 [119 kB]
Fetched 119 kB in 0s (599 kB/s)
(Reading database ... 481569 files and directories currently installed.)
Preparing to unpack .../python3-tk_3.6.9-1~18.04_amd64.deb ...
Unpacking python3-tk:amd64 (3.6.9-1~18.04) ...
dpkg: error processing archive /var/cache/apt/archives/python3-tk_3.6.9-1~18.04_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/python3.6/tkinter/__init__.py', which is also in package libpython3.6-stdlib:amd64 3.6.10-1+xenial1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/python3-tk_3.6.9-1~18.04_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

apt-cache:
~$ apt-cache policy libpython3.6-stdlib python3-tk
libpython3.6-stdlib:
  Installed: 3.6.10-1+xenial1
  Candidate: 3.6.10-1+xenial1
  Version table:
 *** 3.6.10-1+xenial1 100
        100 /var/lib/dpkg/status
     3.6.9-1~18.04 500
        500 http://au.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
     3.6.8-1~18.04.3 500
        500 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages
     3.6.5-3 500
        500 http://au.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
python3-tk:
  Installed: (none)
  Candidate: 3.6.9-1~18.04
  Version table:
     3.6.9-1~18.04 500
        500 http://au.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
     3.6.5-3 500
        500 http://au.archive.ubuntu.com/ubuntu bionic/main amd64 Packages

$ sudo apt-get install libpython3.6-stdlib=3.6.9-1~18.04
[sudo] password for gdhp:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libpython3.6-stdlib : Depends: libpython3.6-minimal (= 3.6.9-1~18.04) but 3.6.10-1+xenial1 is to be installed
E: Unable to correct problems, you have held broken packages.
[1]+  Done                    code .

$ sudo apt-get install python3-tk
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  tix python3-tk-dbg
The following NEW packages will be installed:
  python3-tk
0 to upgrade, 1 to newly install, 0 to remove and 23 not to upgrade.
Need to get 0 B/119 kB of archives.
After this operation, 1,324 kB of additional disk space will be used.
(Reading database ... 481569 files and directories currently installed.)
Preparing to unpack .../python3-tk_3.6.9-1~18.04_amd64.deb ...
Unpacking python3-tk:amd64 (3.6.9-1~18.04) ...
dpkg: error processing archive /var/cache/apt/archives/python3-tk_3.6.9-1~18.04_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/python3.6/tkinter/__init__.py', which is also in package libpython3.6-stdlib:amd64 3.6.10-1+xenial1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/python3-tk_3.6.9-1~18.04_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

A: So I would recommend to install packages from official Ubuntu repositories with:
sudo apt-get install libpython3.6-stdlib=3.6.9-1~18.04
sudo apt-get install python3-tk


text:
Q: Python - side effects/purity analysis tools? Are there any existing tools for side effects/purity analysis in Python, similar to http://jppa.sourceforge.net in Java?

A: I don't know of any that exist, but here are some general approaches to making one:

*

*Analysing source files as text - using regular expressions to find things that show a function definitely isn't pure - e.g. the global keyword. For practical purposes, most decently written functions that only have a return statement in the body are likely to be pure. On the other hand, if a function doesn't have a return statement, it is either useless, or impure.

*Analysing functions in a source file as code. If testing a function in isolation produces a NameError, you know that it is either impure (because it doesn't have access to variables at a higher level), or has a mistake in it (referring to a variable before it is defined or some such), however the latter case should be covered by normal testing. The inspect module's function isfunction may be useful if you want to do this.
For each function you test, if it has a relatively small domain (e.g. one input that can either be 1, 2, 3 or 4) then you could exhaustively test all possible inputs, and get a certain answer this way. If it has a limited, or finite but large domain (e.g. all the real numbers between 0 and 1000 (infinite but limited), or all the integers between -12345 and 67890) then you could try sampling a selection of inputs in that domain, and use that to get a probability of purity. However, this approach may not be very useful, as the domain of the function is unlikely to be specified, so you may only be able to check it if you wrote the function, in which case you may not need to analyse it anyway.

*Doing something clever, possibly in combination with the above techniques. For instance, making a neural network, with the input as the text of a function, and the output as the likelihood of it being pure. You could then train the network on examples of functions you know to be pure or impure, and then use it on functions of unknown purity.
Edit:
I came back to this question after someone downvoted with new knowledge! The ast module should make it relatively easy to write your own analysis tool like this, as it allows you access to the abstract syntax tree of code. It should be fairly easy to walk through this tree and see if there is anything preventing purity. This is a much better approach than analysing source files as text, and I might have a go at it at some point.
Finally, this question might also be useful, and also this one, which is basically a duplicate of this question.


text:
Q: Parse::UserCannotBeAlteredWithoutSessionError The issue started when I updated Parse SDK to Parse 1.9.4. I get this error when I try to update any object with a user object property / pointer in it.
I am using anonymous user and I am aware of the migration of session tokens.
I did follow the guide by adding ParseUser.enableRevocableSessionInBackground();
I still get the error. I even tried turning on and tuning off the revoke session setting in the parse console. Nothing works.
It works when I clear the cache and reinstall the app, but as soon as you exit the app, for some reason the tokens are removed.
Do I have to do anything else ?
Any Help will be appreciated.