text:
Q: What's the correct way to have gnuplot ignore data outside a given range? I'm collecting temperature data at ten minute intervals and plotting the last three days. Currently, I'm using xrange to limit the range of the plot. Is this the right way to do this? I'm concerned that gnuplot is internally creating a plot for all the data in the file and just showing what's in range. That could start to be a problem when I have months of data.
Here's the gnuplot code:
#!/opt/local/bin/gnuplot

# Make PNG for iPhone
set terminal pngcairo enhanced background "#000000" font "Lato-Light,20" linewidth 1 rounded size 1366,660
set output "/Users/steve/Documents/Temperature History/temperatureHistory.png"
dataFileHistory = "/Users/steve/Documents/Temperature History/Temperature History.csv"
set datafile separator ','
set xdata time
# create function to ignore first four characters of time string
# http://stackoverflow.com/questions/26793373/how-to-ignore-timezone-in-csv-data
timefmt = "%b %d %H:%M:%S %Y"
timeval(s) = strptime(timefmt, substr(s, 5, strlen(s)))

set border linetype rgb "#666666"
set boxwidth 0.25 relative
set key off
#set style fill transparent solid 1
set style fill solid 1
set style line 1 linetype rgb "#666666" lw 2 #outside
set style line 2 linetype rgb "#990099" lw 3 #bedroom
set style line 3 linetype rgb "#999900" #upstairs
set style line 4 linetype rgb "#0055DD" #downstairs
set style line 5 linetype rgb "#666666" #grid

# X Axis
endTime = time(0) - 7*60*60  #Adjust for time zone
startTime = endTime-72*60*60
set xtics 6*60*60 format "%l %p" nomirror
set xrange [startTime:endTime]

# Y Axis
set ytics format "%2.0f°" nomirror
set grid ytics linestyle 5

plot dataFileHistory using (timeval(strcol(1))):2 with lines linestyle 1, \
    dataFileHistory using (timeval(strcol(1))):3 with lines linestyle 2, \
    dataFileHistory using (timeval(strcol(1))):4 with lines linestyle 3, \
    dataFileHistory using (timeval(strcol(1))):5 with lines linestyle 4

# Make PNG for iPad
set terminal pngcairo enhanced background "#000000" font "Lato-Light,20" linewidth 1 rounded size 2048,689
set output "/Users/steve/Documents/Temperature History/temperatureHistory-iPad.png"

plot dataFileHistory using (timeval(strcol(1))):2 with lines linestyle 1, \
    dataFileHistory using (timeval(strcol(1))):3 with lines linestyle 2, \
    dataFileHistory using (timeval(strcol(1))):4 with lines linestyle 3, \
    dataFileHistory using (timeval(strcol(1))):5 with lines linestyle 4

Here's a sample of the data:
Fri Jul  3 10:20:01 2015, 75.1, 80.0, 80.0, 75.0
Fri Jul  3 10:30:01 2015, 76.1, 80.0, 80.0, 75.0
Fri Jul  3 10:40:01 2015, 77.3, 80.0, 80.0, 75.0
Fri Jul  3 10:50:01 2015, 78.5, 80.0, 80.0, 75.0
Fri Jul  3 11:00:01 2015, 79.5, 80.0, 80.0, 75.0
Fri Jul  3 11:10:01 2015, 80.2, 80.0, 80.0, 75.0
Fri Jul  3 11:20:02 2015, 80.6, 80.0, 80.0, 75.0
Fri Jul  3 11:30:01 2015, 80.6, 80.0, 80.0, 75.0
Fri Jul  3 11:40:01 2015, 81.5, 81.0, 80.0, 75.0
Fri Jul  3 11:50:01 2015, 81.2, 81.0, 80.0, 75.0
Fri Jul  3 12:00:01 2015, 82.2, 81.0, 80.0, 75.0
Fri Jul  3 12:10:00 2015, 83.3, 81.0, 81.0, 75.0
Fri Jul  3 12:20:00 2015, 83.1, 81.0, 81.0, 75.0
Fri Jul  3 12:30:00 2015, 82.9, 81.0, 81.0, 75.0
Fri Jul  3 12:40:00 2015, 83.4, 81.0, 81.0, 75.0
Fri Jul  3 12:50:00 2015, 84.2, 81.0, 81.0, 75.0
Fri Jul  3 13:00:01 2015, 84.6, 81.0, 81.0, 75.0
Fri Jul  3 13:10:00 2015, 85.4, 81.0, 82.0, 75.0
Fri Jul  3 13:20:00 2015, 86.5, 81.0, 82.0, 75.0
Fri Jul  3 13:30:00 2015, 87.5, 81.0, 82.0, 75.0
Fri Jul  3 13:40:00 2015, 89.7, 81.0, 82.0, 75.0
Fri Jul  3 13:50:00 2015, 90.5, 81.0, 82.0, 75.0
Fri Jul  3 14:00:01 2015, 91.3, 81.0, 82.0, 75.0
Fri Jul  3 14:10:01 2015, 91.9, 82.0, 83.0, 75.0
Fri Jul  3 14:20:01 2015, 92.8, 82.0, 83.0, 75.0
Fri Jul  3 14:30:01 2015, 93.5, 82.0, 83.0, 75.0
Fri Jul  3 14:40:01 2015, 93.8, 82.0, 83.0, 75.0
Fri Jul  3 14:50:01 2015, 93.6, 82.0, 83.0, 75.0
Fri Jul  3 15:00:01 2015, 94.2, 83.0, 84.0, 75.0
Fri Jul  3 15:10:01 2015, 94.5, 83.0, 84.0, 75.0
Fri Jul  3 15:20:01 2015, 94.6, 83.0, 84.0, 75.0
Fri Jul  3 15:30:01 2015, 94.6, 83.0, 84.0, 75.0
Fri Jul  3 15:40:01 2015, 94.0, 83.0, 84.0, 75.0
Fri Jul  3 15:50:01 2015, 93.3, 83.0, 84.0, 75.0
Fri Jul  3 16:00:01 2015, 92.9, 83.0, 85.0, 75.0
Fri Jul  3 16:10:01 2015, 92.6, 83.0, 85.0, 75.0
Fri Jul  3 16:20:01 2015, 92.5, 83.0, 85.0, 75.0
Fri Jul  3 16:30:01 2015, 92.0, 83.0, 85.0, 75.0
Fri Jul  3 16:40:01 2015, 91.7, 83.0, 85.0, 75.0
Fri Jul  3 16:50:01 2015, 91.2, 83.0, 85.0, 75.0
Fri Jul  3 17:00:01 2015, 89.9, 84.0, 85.0, 75.0
Fri Jul  3 17:10:01 2015, 89.6, 84.0, 85.0, 75.0
Fri Jul  3 17:20:01 2015, 89.0, 84.0, 85.0, 75.0
Fri Jul  3 17:30:01 2015, 88.8, 84.0, 85.0, 75.0
Fri Jul  3 17:40:01 2015, 87.8, 84.0, 85.0, 75.0
Fri Jul  3 17:50:01 2015, 87.6, 84.0, 85.0, 75.0
Fri Jul  3 18:00:01 2015, 86.9, 84.0, 85.0, 75.0
Fri Jul  3 18:10:01 2015, 86.7, 84.0, 85.0, 75.0
Fri Jul  3 18:20:01 2015, 86.1, 84.0, 85.0, 75.0
Fri Jul  3 18:30:01 2015, 85.7, 84.0, 85.0, 75.0
Fri Jul  3 18:40:01 2015, 85.5, 84.0, 85.0, 75.0
Fri Jul  3 18:50:01 2015, 85.1, 84.0, 85.0, 75.0
Fri Jul  3 19:00:01 2015, 84.4, 84.0, 85.0, 75.0
Fri Jul  3 19:10:01 2015, 84.2, 85.0, 85.0, 76.0
Fri Jul  3 19:20:01 2015, 83.8, 85.0, 85.0, 76.0
Fri Jul  3 19:30:01 2015, 83.4, 85.0, 85.0, 76.0
Fri Jul  3 19:40:01 2015, 82.4, 85.0, 85.0, 76.0
Fri Jul  3 19:50:01 2015, 82.2, 85.0, 85.0, 76.0
Fri Jul  3 20:00:01 2015, 81.8, 85.0, 85.0, 76.0
Fri Jul  3 20:10:01 2015, 81.3, 85.0, 85.0, 76.0
Fri Jul  3 20:20:01 2015, 80.2, 85.0, 85.0, 76.0
Fri Jul  3 20:30:01 2015, 79.7, 85.0, 85.0, 76.0
Fri Jul  3 20:40:01 2015, 79.1, 85.0, 85.0, 76.0
Fri Jul  3 20:50:01 2015, 78.8, 85.0, 85.0, 76.0
Fri Jul  3 21:00:01 2015, 77.9, 85.0, 85.0, 76.0
Fri Jul  3 21:10:01 2015, 77.3, 85.0, 85.0, 76.0
Fri Jul  3 21:20:01 2015, 77.0, 85.0, 85.0, 76.0
Fri Jul  3 21:30:01 2015, 76.4, 85.0, 85.0, 76.0
Fri Jul  3 21:40:01 2015, 75.9, 85.0, 84.0, 76.0
Fri Jul  3 21:50:01 2015, 75.5, 85.0, 84.0, 76.0
Fri Jul  3 22:00:01 2015, 75.3, 85.0, 84.0, 76.0
Fri Jul  3 22:10:01 2015, 74.9, 85.0, 84.0, 76.0
Fri Jul  3 22:20:01 2015, 74.3, 85.0, 84.0, 76.0
Fri Jul  3 22:30:01 2015, 74.0, 85.0, 84.0, 76.0
Fri Jul  3 22:40:01 2015, 73.5, 84.0, 84.0, 76.0
Fri Jul  3 22:50:01 2015, 73.3, 84.0, 84.0, 76.0
Fri Jul  3 23:00:01 2015, 73.1, 84.0, 84.0, 76.0
Fri Jul  3 23:10:01 2015, 72.7, 84.0, 84.0, 76.0
Fri Jul  3 23:20:01 2015, 72.4, 84.0, 84.0, 76.0
Fri Jul  3 23:30:01 2015, 72.2, 84.0, 84.0, 76.0
Fri Jul  3 23:40:00 2015, 71.9, 84.0, 83.0, 76.0
Fri Jul  3 23:50:00 2015, 71.4, 84.0, 83.0, 76.0
Sat Jul  4 00:00:01 2015, 71.2, 84.0, 83.0, 76.0
Sat Jul  4 00:10:00 2015, 71.0, 84.0, 83.0, 76.0
Sat Jul  4 00:20:00 2015, 70.4, 84.0, 83.0, 76.0
Sat Jul  4 00:30:00 2015, 70.1, 84.0, 83.0, 76.0
Sat Jul  4 00:40:00 2015, 69.9, 84.0, 82.0, 76.0
Sat Jul  4 00:50:00 2015, 69.7, 84.0, 82.0, 76.0
Sat Jul  4 01:00:00 2015, 69.6, 84.0, 82.0, 76.0
Sat Jul  4 01:10:01 2015, 69.3, 84.0, 82.0, 76.0
Sat Jul  4 01:20:00 2015, 69.1, 84.0, 82.0, 76.0
Sat Jul  4 01:30:01 2015, 68.9, 84.0, 82.0, 76.0
Sat Jul  4 01:40:01 2015, 68.8, 84.0, 81.0, 76.0
Sat Jul  4 01:50:01 2015, 68.5, 84.0, 81.0, 76.0
Sat Jul  4 02:00:00 2015, 68.4, 84.0, 81.0, 76.0
Sat Jul  4 02:10:00 2015, 68.3, 83.0, 81.0, 76.0
Sat Jul  4 02:20:00 2015, 68.2, 83.0, 81.0, 76.0
Sat Jul  4 02:30:00 2015, 67.9, 83.0, 81.0, 76.0
Sat Jul  4 02:40:00 2015, 67.9, 83.0, 81.0, 76.0
Sat Jul  4 02:50:01 2015, 67.9, 83.0, 81.0, 76.0
Sat Jul  4 03:00:01 2015, 67.7, 83.0, 81.0, 76.0
Sat Jul  4 03:10:00 2015, 67.6, 83.0, 81.0, 76.0
Sat Jul  4 03:20:00 2015, 67.6, 83.0, 81.0, 76.0
Sat Jul  4 03:30:01 2015, 67.4, 83.0, 81.0, 76.0
Sat Jul  4 03:40:01 2015, 67.1, 83.0, 80.0, 75.0
Sat Jul  4 03:50:01 2015, 67.0, 83.0, 80.0, 75.0
Sat Jul  4 04:00:00 2015, 66.8, 83.0, 80.0, 75.0
Sat Jul  4 04:10:00 2015, 66.7, 83.0, 80.0, 75.0
Sat Jul  4 04:20:00 2015, 66.4, 83.0, 80.0, 75.0
Sat Jul  4 04:30:01 2015, 66.3, 83.0, 80.0, 75.0
Sat Jul  4 04:40:01 2015, 66.5, 83.0, 80.0, 75.0
Sat Jul  4 04:50:01 2015, 66.2, 83.0, 80.0, 75.0
Sat Jul  4 05:00:00 2015, 65.9, 83.0, 80.0, 75.0
Sat Jul  4 05:10:00 2015, 65.9, 82.0, 80.0, 75.0
Sat Jul  4 05:20:00 2015, 65.8, 82.0, 80.0, 75.0
Sat Jul  4 05:30:01 2015, 65.9, 82.0, 80.0, 75.0
Sat Jul  4 05:40:01 2015, 65.5, 82.0, 79.0, 75.0
Sat Jul  4 05:50:01 2015, 65.5, 82.0, 79.0, 75.0
Sat Jul  4 06:00:00 2015, 65.4, 82.0, 79.0, 75.0
Sat Jul  4 06:10:00 2015, 65.3, 82.0, 79.0, 75.0
Sat Jul  4 06:20:00 2015, 65.0, 82.0, 79.0, 75.0
Sat Jul  4 06:30:00 2015, 65.1, 82.0, 79.0, 75.0
Sat Jul  4 06:40:00 2015, 64.9, 82.0, 79.0, 75.0
Sat Jul  4 06:50:01 2015, 65.2, 82.0, 79.0, 75.0
Sat Jul  4 07:00:00 2015, 65.3, 82.0, 79.0, 75.0
Sat Jul  4 07:10:00 2015, 65.3, 82.0, 79.0, 75.0
Sat Jul  4 07:20:00 2015, 65.4, 82.0, 79.0, 75.0
Sat Jul  4 07:30:00 2015, 65.7, 82.0, 79.0, 75.0
Sat Jul  4 07:40:00 2015, 65.9, 82.0, 79.0, 75.0
Sat Jul  4 07:50:01 2015, 66.3, 82.0, 79.0, 75.0
Sat Jul  4 08:00:01 2015, 66.6, 82.0, 79.0, 75.0
Sat Jul  4 08:10:01 2015, 66.9, 81.0, 79.0, 75.0
Sat Jul  4 08:20:00 2015, 67.1, 81.0, 79.0, 75.0
Sat Jul  4 08:30:00 2015, 67.2, 81.0, 79.0, 75.0
Sat Jul  4 08:40:01 2015, 67.6, 81.0, 79.0, 75.0
Sat Jul  4 08:50:01 2015, 67.8, 81.0, 79.0, 75.0
Sat Jul  4 09:00:00 2015, 68.5, 81.0, 79.0, 75.0
Sat Jul  4 09:10:00 2015, 68.8, 81.0, 79.0, 75.0
Sat Jul  4 09:20:00 2015, 69.2, 81.0, 79.0, 75.0
Sat Jul  4 09:30:00 2015, 69.9, 81.0, 79.0, 75.0
Sat Jul  4 09:40:01 2015, 71.3, 81.0, 79.0, 75.0
Sat Jul  4 09:50:00 2015, 71.9, 81.0, 79.0, 75.0
Sat Jul  4 10:00:00 2015, 72.4, 81.0, 79.0, 75.0
Sat Jul  4 10:10:00 2015, 73.0, 81.0, 79.0, 75.0
Sat Jul  4 10:20:00 2015, 74.5, 81.0, 79.0, 75.0
Sat Jul  4 10:30:00 2015, 75.6, 81.0, 79.0, 75.0
Sat Jul  4 10:40:00 2015, 76.8, 81.0, 79.0, 75.0
Sat Jul  4 10:50:00 2015, 78.2, 81.0, 79.0, 75.0
Sat Jul  4 11:00:01 2015, 80.4, 81.0, 79.0, 75.0
Sat Jul  4 11:10:00 2015, 81.7, 81.0, 80.0, 75.0
Sat Jul  4 11:20:00 2015, 83.7, 81.0, 80.0, 75.0
Sat Jul  4 11:30:00 2015, 85.6, 81.0, 80.0, 75.0
Sat Jul  4 11:40:00 2015, 86.8, 81.0, 80.0, 75.0
Sat Jul  4 11:50:00 2015, 87.1, 81.0, 80.0, 75.0
Sat Jul  4 12:00:01 2015, 87.1, 81.0, 80.0, 75.0
Sat Jul  4 12:10:00 2015, 87.8, 82.0, 80.0, 75.0
Sat Jul  4 12:20:00 2015, 87.9, 82.0, 80.0, 75.0
Sat Jul  4 12:30:00 2015, 87.4, 82.0, 80.0, 75.0
Sat Jul  4 12:40:00 2015, 87.6, 82.0, 80.0, 75.0
Sat Jul  4 12:50:00 2015, 88.0, 82.0, 81.0, 75.0
Sat Jul  4 13:00:00 2015, 89.1, 82.0, 81.0, 75.0
Sat Jul  4 13:10:03 2015, 89.3, 82.0, 81.0, 75.0
Sat Jul  4 13:20:00 2015, 89.8, 82.0, 81.0, 75.0
Sat Jul  4 13:30:00 2015, 90.9, 82.0, 81.0, 75.0
Sat Jul  4 13:40:00 2015, 92.3, 82.0, 81.0, 75.0
Sat Jul  4 13:50:00 2015, 92.6, 83.0, 82.0, 75.0
Sat Jul  4 14:00:01 2015, 93.3, 83.0, 82.0, 75.0
Sat Jul  4 14:10:01 2015, 94.3, 83.0, 82.0, 75.0
Sat Jul  4 14:20:00 2015, 94.9, 83.0, 82.0, 75.0
Sat Jul  4 14:30:00 2015, 94.2, 83.0, 82.0, 75.0
Sat Jul  4 14:40:00 2015, 94.2, 83.0, 82.0, 75.0
Sat Jul  4 14:50:00 2015, 93.9, 83.0, 82.0, 75.0
Sat Jul  4 15:00:00 2015, 92.3, 83.0, 82.0, 75.0
Sat Jul  4 15:10:01 2015, 91.8, 83.0, 82.0, 75.0
Sat Jul  4 15:20:00 2015, 91.0, 83.0, 82.0, 75.0
Sat Jul  4 15:30:00 2015, 90.5, 83.0, 82.0, 75.0
Sat Jul  4 15:40:00 2015, 89.3, 83.0, 82.0, 75.0
Sat Jul  4 15:50:00 2015, 89.1, 83.0, 82.0, 75.0
Sat Jul  4 16:00:00 2015, 88.5, 84.0, 83.0, 75.0
Sat Jul  4 16:10:00 2015, 88.0, 84.0, 83.0, 75.0
Sat Jul  4 16:20:00 2015, 87.6, 84.0, 83.0, 75.0
Sat Jul  4 16:30:00 2015, 87.4, 84.0, 83.0, 75.0
Sat Jul  4 16:40:00 2015, 87.4, 84.0, 83.0, 75.0
Sat Jul  4 16:50:00 2015, 87.5, 84.0, 83.0, 75.0
Sat Jul  4 17:00:00 2015, 87.4, 84.0, 83.0, 75.0
Sat Jul  4 17:10:00 2015, 87.4, 84.0, 83.0, 75.0
Sat Jul  4 17:20:01 2015, 87.1, 84.0, 83.0, 75.0
Sat Jul  4 17:30:00 2015, 87.2, 84.0, 83.0, 75.0
Sat Jul  4 17:40:00 2015, 86.9, 84.0, 83.0, 75.0
Sat Jul  4 17:50:00 2015, 86.6, 84.0, 83.0, 75.0
Sat Jul  4 18:00:00 2015, 86.6, 84.0, 83.0, 76.0
Sat Jul  4 18:10:00 2015, 86.3, 84.0, 83.0, 76.0
Sat Jul  4 18:20:01 2015, 86.3, 84.0, 83.0, 76.0
Sat Jul  4 18:30:00 2015, 86.0, 84.0, 83.0, 76.0
Sat Jul  4 18:40:00 2015, 85.8, 84.0, 83.0, 76.0
Sat Jul  4 18:50:00 2015, 85.6, 84.0, 83.0, 76.0
Sat Jul  4 19:00:00 2015, 85.1, 85.0, 84.0, 76.0
Sat Jul  4 19:10:00 2015, 84.8, 85.0, 84.0, 76.0
Sat Jul  4 19:20:00 2015, 84.5, 85.0, 84.0, 76.0
Sat Jul  4 19:30:01 2015, 84.1, 85.0, 84.0, 76.0
Sat Jul  4 19:40:00 2015, 83.6, 85.0, 84.0, 76.0
Sat Jul  4 19:50:00 2015, 83.1, 85.0, 84.0, 76.0
Sat Jul  4 20:00:00 2015, 82.8, 85.0, 84.0, 76.0
Sat Jul  4 20:10:00 2015, 82.2, 85.0, 84.0, 76.0
Sat Jul  4 20:20:00 2015, 81.5, 85.0, 84.0, 76.0
Sat Jul  4 20:30:01 2015, 81.2, 85.0, 84.0, 76.0
Sat Jul  4 20:40:01 2015, 80.7, 85.0, 84.0, 76.0
Sat Jul  4 20:50:00 2015, 80.1, 85.0, 84.0, 76.0
Sat Jul  4 21:00:00 2015, 79.2, 85.0, 84.0, 76.0
Sat Jul  4 21:10:00 2015, 78.7, 85.0, 84.0, 76.0
Sat Jul  4 21:20:00 2015, 78.4, 85.0, 84.0, 76.0
Sat Jul  4 21:30:01 2015, 78.0, 85.0, 84.0, 76.0
Sat Jul  4 21:40:00 2015, 77.1, 85.0, 84.0, 76.0
Sat Jul  4 21:50:00 2015, 76.7, 85.0, 84.0, 76.0
Sat Jul  4 22:00:00 2015, 76.1, 85.0, 84.0, 76.0
Sat Jul  4 22:10:00 2015, 75.8, 85.0, 84.0, 76.0
Sat Jul  4 22:20:00 2015, 75.1, 85.0, 84.0, 76.0
Sat Jul  4 22:30:02 2015, 75.0, 85.0, 84.0, 76.0
Sat Jul  4 22:40:00 2015, 74.5, 85.0, 84.0, 76.0
Sat Jul  4 22:50:00 2015, 74.3, 84.0, 83.0, 76.0
Sat Jul  4 23:00:00 2015, 73.7, 84.0, 83.0, 76.0
Sat Jul  4 23:10:01 2015, 73.4, 83.0, 82.0, 76.0
Sat Jul  4 23:20:00 2015, 73.3, 83.0, 82.0, 76.0
Sat Jul  4 23:30:00 2015, 73.0, 83.0, 82.0, 76.0
Sat Jul  4 23:40:01 2015, 72.5, 83.0, 82.0, 76.0
Sat Jul  4 23:50:00 2015, 72.2, 83.0, 81.0, 76.0
Sun Jul  5 00:00:01 2015, 71.9, 83.0, 81.0, 76.0
Sun Jul  5 00:10:00 2015, 71.7, 82.0, 82.0, 76.0
Sun Jul  5 00:20:01 2015, 71.4, 82.0, 82.0, 76.0
Sun Jul  5 00:30:00 2015, 71.2, 82.0, 82.0, 76.0
Sun Jul  5 00:40:01 2015, 71.0, 82.0, 81.0, 76.0
Sun Jul  5 00:50:00 2015, 70.7, 82.0, 81.0, 76.0
Sun Jul  5 01:00:02 2015, 70.1, 82.0, 81.0, 76.0
Sun Jul  5 01:10:01 2015, 70.0, 81.0, 80.0, 76.0
Sun Jul  5 01:20:01 2015, 69.9, 81.0, 80.0, 76.0
Sun Jul  5 01:30:01 2015, 69.7, 81.0, 80.0, 76.0
Sun Jul  5 01:40:02 2015, 69.3, 81.0, 80.0, 76.0
Sun Jul  5 01:50:01 2015, 69.2, 81.0, 80.0, 76.0
Sun Jul  5 02:00:01 2015, 69.2, 81.0, 80.0, 76.0
Sun Jul  5 02:10:00 2015, 68.8, 81.0, 80.0, 76.0
Sun Jul  5 02:20:00 2015, 68.7, 81.0, 80.0, 76.0
Sun Jul  5 02:30:01 2015, 68.6, 80.0, 80.0, 76.0
Sun Jul  5 02:40:00 2015, 68.4, 80.0, 80.0, 76.0
Sun Jul  5 02:50:02 2015, 68.1, 80.0, 80.0, 76.0
Sun Jul  5 03:00:01 2015, 67.8, 80.0, 79.0, 76.0
Sun Jul  5 03:10:01 2015, 67.7, 80.0, 79.0, 76.0
Sun Jul  5 03:20:01 2015, 67.7, 80.0, 79.0, 76.0
Sun Jul  5 03:30:00 2015, 67.6, 80.0, 79.0, 76.0
Sun Jul  5 03:40:01 2015, 67.2, 79.0, 79.0, 76.0
Sun Jul  5 03:50:01 2015, 67.4, 79.0, 79.0, 76.0
Sun Jul  5 04:00:01 2015, 66.9, 79.0, 79.0, 76.0
Sun Jul  5 04:10:01 2015, 66.8, 79.0, 78.0, 76.0
Sun Jul  5 04:20:01 2015, 66.5, 79.0, 78.0, 76.0
Sun Jul  5 04:30:01 2015, 66.6, 79.0, 78.0, 76.0
Sun Jul  5 04:40:02 2015, 66.2, 79.0, 78.0, 76.0
Sun Jul  5 04:50:01 2015, 66.4, 79.0, 78.0, 76.0
Sun Jul  5 05:00:01 2015, 65.9, 78.0, 78.0, 76.0
Sun Jul  5 05:10:02 2015, 66.1, 78.0, 78.0, 76.0
Sun Jul  5 05:20:01 2015, 65.7, 78.0, 78.0, 76.0
Sun Jul  5 05:30:01 2015, 65.6, 78.0, 78.0, 76.0
Sun Jul  5 05:40:01 2015, 65.5, 78.0, 77.0, 75.0
Sun Jul  5 05:50:01 2015, 65.4, 78.0, 78.0, 75.0
Sun Jul  5 06:00:01 2015, 65.4, 78.0, 78.0, 75.0
Sun Jul  5 06:10:01 2015, 65.1, 78.0, 77.0, 75.0
Sun Jul  5 06:20:01 2015, 65.0, 78.0, 77.0, 75.0
Sun Jul  5 06:30:01 2015, 65.1, 78.0, 77.0, 75.0
Sun Jul  5 06:40:01 2015, 65.1, 78.0, 77.0, 75.0
Sun Jul  5 06:50:01 2015, 65.1, 78.0, 77.0, 75.0
Sun Jul  5 07:00:02 2015, 65.1, 78.0, 77.0, 75.0
Sun Jul  5 07:10:01 2015, 65.3, 77.0, 77.0, 75.0
Sun Jul  5 07:20:01 2015, 65.3, 77.0, 77.0, 75.0
Sun Jul  5 07:30:01 2015, 65.2, 77.0, 77.0, 75.0
Sun Jul  5 07:40:01 2015, 65.5, 77.0, 77.0, 75.0
Sun Jul  5 07:50:01 2015, 65.7, 77.0, 77.0, 75.0
Sun Jul  5 08:00:01 2015, 65.6, 77.0, 77.0, 75.0
Sun Jul  5 08:10:01 2015, 66.0, 77.0, 77.0, 75.0
Sun Jul  5 08:20:01 2015, 66.5, 77.0, 77.0, 75.0
Sun Jul  5 08:30:01 2015, 66.8, 77.0, 77.0, 75.0
Sun Jul  5 08:40:01 2015, 67.2, 77.0, 77.0, 75.0
Sun Jul  5 08:50:01 2015, 67.6, 77.0, 77.0, 75.0
Sun Jul  5 09:00:02 2015, 68.8, 77.0, 77.0, 75.0
Sun Jul  5 09:10:01 2015, 69.4, 77.0, 77.0, 75.0
Sun Jul  5 09:20:01 2015, 69.8, 77.0, 77.0, 75.0
Sun Jul  5 09:30:02 2015, 70.7, 77.0, 77.0, 75.0
Sun Jul  5 09:40:01 2015, 72.0, 77.0, 77.0, 75.0
Sun Jul  5 09:50:01 2015, 72.7, 77.0, 77.0, 75.0
Sun Jul  5 10:00:01 2015, 73.0, 78.0, 78.0, 75.0
Sun Jul  5 10:10:01 2015, 73.7, 78.0, 78.0, 75.0
Sun Jul  5 10:20:01 2015, 74.9, 78.0, 79.0, 75.0
Sun Jul  5 10:30:01 2015, 76.4, 78.0, 79.0, 75.0
Sun Jul  5 10:40:01 2015, 77.8, 78.0, 79.0, 75.0
Sun Jul  5 10:50:01 2015, 79.3, 78.0, 79.0, 75.0
Sun Jul  5 11:00:01 2015, 81.1, 79.0, 80.0, 75.0
Sun Jul  5 11:10:01 2015, 82.4, 79.0, 80.0, 75.0
Sun Jul  5 11:20:01 2015, 84.6, 79.0, 80.0, 75.0
Sun Jul  5 11:30:01 2015, 86.2, 79.0, 80.0, 75.0
Sun Jul  5 11:40:01 2015, 89.0, 79.0, 80.0, 75.0
Sun Jul  5 11:50:01 2015, 89.7, 79.0, 80.0, 75.0
Sun Jul  5 12:00:01 2015, 89.9, 79.0, 80.0, 75.0
Sun Jul  5 12:10:01 2015, 90.1, 80.0, 82.0, 75.0
Sun Jul  5 12:20:01 2015, 90.2, 81.0, 82.0, 75.0
Sun Jul  5 12:30:02 2015, 90.0, 81.0, 82.0, 75.0
Sun Jul  5 12:40:01 2015, 89.9, 81.0, 82.0, 75.0
Sun Jul  5 12:50:01 2015, 89.9, 81.0, 83.0, 75.0
Sun Jul  5 13:00:01 2015, 90.3, 81.0, 83.0, 75.0
Sun Jul  5 13:10:02 2015, 90.9, 81.0, 83.0, 75.0
Sun Jul  5 13:20:00 2015, 91.2, 81.0, 83.0, 75.0
Sun Jul  5 13:30:01 2015, 92.1, 81.0, 83.0, 75.0
Sun Jul  5 13:40:00 2015, 93.3, 82.0, 84.0, 75.0
Sun Jul  5 13:50:00 2015, 93.8, 82.0, 84.0, 75.0
Sun Jul  5 14:00:00 2015, 94.3, 82.0, 84.0, 75.0
Sun Jul  5 14:10:00 2015, 94.9, 82.0, 85.0, 75.0
Sun Jul  5 14:20:00 2015, 96.1, 82.0, 85.0, 75.0
Sun Jul  5 14:30:00 2015, 96.0, 82.0, 85.0, 75.0
Sun Jul  5 14:40:01 2015, 96.0, 83.0, 85.0, 75.0
Sun Jul  5 14:50:00 2015, 96.3, 83.0, 85.0, 75.0
Sun Jul  5 15:00:00 2015, 96.7, 83.0, 85.0, 75.0
Sun Jul  5 15:10:00 2015, 96.5, 83.0, 86.0, 75.0
Sun Jul  5 15:20:01 2015, 96.8, 83.0, 86.0, 75.0
Sun Jul  5 15:30:00 2015, 96.7, 83.0, 86.0, 75.0
Sun Jul  5 15:40:00 2015, 95.6, 84.0, 86.0, 75.0
Sun Jul  5 15:50:00 2015, 94.9, 84.0, 86.0, 75.0
Sun Jul  5 16:00:00 2015, 94.4, 84.0, 86.0, 75.0
Sun Jul  5 16:10:00 2015, 94.1, 84.0, 86.0, 75.0
Sun Jul  5 16:20:00 2015, 93.4, 84.0, 86.0, 75.0
Sun Jul  5 16:30:01 2015, 93.0, 84.0, 86.0, 75.0
Sun Jul  5 16:40:00 2015, 92.2, 84.0, 86.0, 75.0
Sun Jul  5 16:50:00 2015, 91.7, 84.0, 86.0, 75.0
Sun Jul  5 17:00:00 2015, 90.2, 84.0, 86.0, 75.0
Sun Jul  5 17:10:00 2015, 89.8, 84.0, 86.0, 76.0
Sun Jul  5 17:20:00 2015, 89.1, 84.0, 86.0, 76.0
Sun Jul  5 17:30:01 2015, 88.7, 84.0, 86.0, 76.0
Sun Jul  5 17:40:00 2015, 87.9, 85.0, 86.0, 76.0
Sun Jul  5 17:50:00 2015, 87.5, 85.0, 86.0, 76.0
Sun Jul  5 18:00:00 2015, 86.8, 85.0, 87.0, 76.0
Sun Jul  5 18:10:00 2015, 86.3, 85.0, 87.0, 76.0
Sun Jul  5 18:20:00 2015, 85.4, 85.0, 87.0, 76.0
Sun Jul  5 18:30:01 2015, 84.9, 85.0, 87.0, 76.0
Sun Jul  5 18:40:00 2015, 84.6, 85.0, 86.0, 76.0
Sun Jul  5 18:50:00 2015, 84.4, 85.0, 87.0, 76.0
Sun Jul  5 19:00:00 2015, 83.7, 85.0, 87.0, 76.0
Sun Jul  5 19:10:00 2015, 83.5, 85.0, 86.0, 76.0
Sun Jul  5 19:20:00 2015, 83.2, 85.0, 86.0, 76.0
Sun Jul  5 19:30:00 2015, 82.7, 85.0, 86.0, 76.0
Sun Jul  5 19:40:01 2015, 81.7, 85.0, 86.0, 76.0
Sun Jul  5 19:50:00 2015, 81.4, 85.0, 86.0, 76.0
Sun Jul  5 20:00:00 2015, 80.7, 85.0, 86.0, 76.0
Sun Jul  5 20:10:00 2015, 80.1, 85.0, 86.0, 76.0
Sun Jul  5 20:20:00 2015, 79.0, 85.0, 86.0, 76.0
Sun Jul  5 20:30:00 2015, 78.4, 85.0, 86.0, 76.0
Sun Jul  5 20:40:00 2015, 78.2, 84.0, 84.0, 76.0
Sun Jul  5 20:50:00 2015, 77.5, 82.0, 84.0, 76.0
Sun Jul  5 21:00:00 2015, 76.7, 82.0, 84.0, 76.0
Sun Jul  5 21:10:01 2015, 75.9, 80.0, 83.0, 76.0
Sun Jul  5 21:20:00 2015, 75.4, 80.0, 83.0, 76.0

Here's what the plot looks like:

A: Just by setting xrange gnuplot might use at least some of the points outside of range, depending on the yrange. For instance, consider the following data:
1 2
2 3
3 4
4 5

Just plotting this with no ranges set:

Setting set xrange [1.5:*] so that the first point lies outside ignores the first point:

However, also setting the yrange will include this point even though it's out of range, e.g. set xrange [1.5:*]; set yrange [2:5]:

To properly exclude points you need to use a conditional plot telling gnuplot to ignore the point (1/0) if it's out of range:
xmin=1.5; xmax=4
set xrange [xmin:xmax]; set yrange [2:5]
plot "datafile" u ($1 >= xmin && $1 <= xmax ? $1 : 1/0):($2) w lp pt 7 not

A: Short answer:
The range set via set xrange etc. does only define the lenght of your axes. All points in the file are evaluated (you can explicitly limit this with the index or every specifiers, based on the format of you data file).
Connecting lines are by default drawn if one of the points is inside, but not if both are outside. You can influence both of this with (un)set clip one/two.

*

*unset clip one does not draw a line towards an outlying point

*unset clip two (default) does not connect two outlying points.

Switching values outside the wanted range to NaN (== 1/0) like in Miguels answer works as well, but i can hardly see why it'd be necessary.


text:
Q: Rijndael S-Box algorithm: Can someone please explain how this code calculates the multiplicative inverse? Wikipedia's explanation of the Rijndael Cipher's S-Box gives c code for calculating the S-Box.
I've been able to calculate the S-Box values using exponent and log look-up tables to calculate the multiplicative inverse, but I can't see how this code generates the same values.
I understand how the "S-Box index" (i.e. 'p') is calculated (multiplied by x+1, i.e. the generator, 0x03), and I can see how the Affine Transformation is performed, but I don't understand the part in between that "divides by x+1".

  /* divide q by x+1 */
    q ^= q << 1;
    q ^= q << 2;
    q ^= q << 4;
    q ^= q & 0x80 ? 0x09 : 0;

How does this code divide by x+1?
Where do the values 1, 2, and 4 come from?
Where does the value 0x09 come from?
I'm wondering if this is just a highly efficient but obfuscated way to divide.

A: The inverse of $x+1$ is $(x+1)^{-1} = x + x^2 + x^4 + x^5 + x^6 + x^7$, so instead of dividing by $x+1$, we multiply by $(x+1)^{-1}$.
Now, it is not that hard to multiply an arbitrary element of $\mathbb F_{256}$ with $(x+1)^{-1}$ and calculate what it will be. Let
$$a = a_0 + a_1x + a_2x^2 + a_3x^3 + a_4x^4 + a_5x^5 + a_6x^6 + a_7x^7$$
be an arbitrary element. Then:
$$\begin{align}
a(x+1)^{-1} &= a_1 + a_2 + a_3 + a_4 + a_5 + a_6 + a_7 \\
& + x \left(a_0+a_1\right)\\
&+x^2 \left(a_0+a_1+a_2\right) \\
&+x^3 \left(a_4+a_5+a_6+a_7\right) \\
&+x^4 \left(a_0+a_1+a_2+a_3+a_4\right)\\
&+x^5 \left(a_0+a_1+a_2+a_3+a_4+a_5\right)\\
&+x^6 \left(a_0+a_1+a_2+a_3+a_4+a_5+a_6\right)\\
&+x^7 \left(a_0+a_1+a_2+a_3+a_4+a_5+a_6+a_7\right)
\end{align}$$
I will skip over the details, since I did not do this by hand (but it is simple to do it by hand, just tedious). ;)
The first three lines of the code calculates $(1+x)(1+x^2)(1+x^4)q$ and also truncates the polynomial (i.e. drops all monomials with power larger than 7) after each multiplication. This will result in the element:
$$\begin{align}
q_3 &= a_0\\
&+x \left(a_0+a_1\right)\\
&+x^2 \left(a_0+a_1+a_2\right)\\
&+x^3 \left(a_0+a_1+a_2+a_3\right)\\
&+x^4 \left(a_0+a_1+a_2+a_3+a_4\right)\\
&+x^5 \left(a_0+a_1+a_2+a_3+a_4+a_5\right)\\
&+x^6 \left(a_0+a_1+a_2+a_3+a_4+a_5+a_6\right)\\
&+x^7 \left(a_0+a_1+a_2+a_3+a_4+a_5+a_6+a_7\right)
\end{align}$$
where we can note that only the cofficients for $x^0$ and $x^3$ are incorrect.
So, let's look at the last line. The last line says that if the coefficient of $x^7$ is not zero, we add $1+x^3$ to $q_3$, otherwise we do nothing.
Let's look at the case where $x^7$'s coefficient is zero. Then
$$a_0+a_1+a_2+a_3+a_4+a_5+a_6+a_7 = 0$$
which is equivalent to
$$a_0+a_1+a_2+a_3 = a_4+a_5+a_6+a_7$$
so the coefficient of $x^3$ in $q_3$ is correct. Using the same reasoning, we see that
$$a_0 = a_1+a_2+a_3+a_4+a_5+a_6+a_7$$
so the coefficient of $x^0$ in $q_3$ is correct, so we do not need to do anything.
If the coefficient of $x^7$ is not zero, i.e. it is one, we have:
$$a_0+a_1+a_2+a_3+a_4+a_5+a_6+a_7 = 1$$
we get that the coefficient of $x^0$ in $q_3$ is:
$$a_0 = 1 + a_1+a_2+a_3+a_4+a_5+a_6+a_7$$
so we need to add 1 to get the correct result. Use the same reasoning to see that we also need to add $x^3$.
This is of course a post-hoc explanation of what is happening. It would be much more interesting to have an algorithmic approach to construct these kind of code segments.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Object deleted when its member function is being executed? I have pointer object to singleton class.
Thread 1: Currently executing a member function of the above said object.
Thread 2: Deletes the above object when the object's member function is still being executed by Thread 1.
What happens to Thread 1 where the member function is being executed? Whether the execution will be stopped midway?

A: It is probably undefined behavior, unless you are extra careful.
Deleting the object while your thread accesses it in an unordered (non-synchronized, basically) manner is undefined behavior, even if you get lucky.
Accessing the members of the object (not just running a member: actually accessing a member -- calling a member function, reading a member variable, etc) after you have synchronized with the delete from the main thread is also undefined behavior.
If you carefully synchronize with the main thread, then do not access the member data nor call a different member function after that synchronization, and the main thread deletes the object after that synchronization, then you are perfectly ok.
Almost anything short of that results in undefined behavior.
While undefined behavior can do almost anything, it would be unexpected undefined behavior for this to cause the execution of the code in the member function to suddenly stop just because the object is deleted.  More likely you'd get segfaults, memory corruption, or the like.  What is worse is that in many cases, things would work "just fine".

A: You will most likely get undefined behavior. Thread 1 can get a seg fault or it may continue merrily on its way if it accesses no member data (and makes no virtual function calls) after the object's deletion. It also depends on what happens to the memory area after deletion. Is it cleared? Is it non-writable/non-readable? It's all highly implementation dependent as well dependent on the data needs of your application in terms of reusing the data area to handle other allocations.
The guidance is to never delete an object until all use of it is complete. There are some exceptions where member functions delete the object they operate on ensuring there is no more member access after the point of deletion. But other than those few cases that actually justify deletion in a member, don't do this.
In the multi-threaded environment you are describing, be absolutely certain to coordinate object lifetime with object use or you may get very difficult to debug (platform dependent and non-deterministic) behavior.

A: Short answer: You shouldn't do this... You need to make sure the object is not being used before deleting it.
In terms of what the C++ standard specifies, it's (probably) undefined behaviour - something unexpected may well happen. The basis for this is that it's undefined behaviour to use any member (function or variable) of an object after the object has been destroyed. Of course, if the member function looks like this:
void foo::func()
{
   for(;;)
   {
     // do nothing here
   }
}

then it's NOT undefined behaviour, and the thread can be left running indefinitely, without any ill effect, and the behvaiour (I believe) is well defined (it just keeps running).
Certainly thread 1's execution will definitely not stop simply because the object is being deleted. That is, unless the object actually contains a thread object for thread 1 - in which case, the destructor of the thread object may kill the thread.
In practice, if the object is deleted, it's memory is freed, and the memory may well be reused for some other object a small amount of time later. Depending on what the member function is doing, e.g, what parts of the object it's referring to, and how it's using those members, it may cause a crash, or if it does something like x++; (where x is a member variable), it will modify some memory it no longer is the owner of - and that can be quite tricky to debug, because it will appear like something is randomly changing other objects... This is definitely NOT good (and most likely, it will only happen SOMETIMES, making it really hard to spot when it goes wrong).
Nothing good can possibly come out of this.
You MUST make sure the object is not in use in any way to delete it. One way to do that is of course to have the thread object for thread 1, and kill the thread.

A: Undefined behavior is the right answer. To avoid such things consider using smart pointers, like this: http://www.boost.org/doc/libs/1_54_0/libs/smart_ptr/shared_ptr.htm or this: http://en.cppreference.com/w/cpp/memory/shared_ptr. They have reference counting mechanism that doesn't allow you to delete using object.


text:
Q: DENYed user wasn't denied - is this a parallel query processing issue? I'm experiencing with permissions in SQL Server, and followed along the lines in this tutorial:

*

*Creating a Login and a User,

*Then GRANTing the user a SELECT permission

*Testing a SELECT query while impersonating as that user

*REVERT, and then DENYing that user the SELECT permission

*Again impersonating as that user and proofing SELECT doesn't work.

On step number 5, I executed the query:
EXECUTE AS USER = 'MyDeniedUser';
GO
SELECT * FROM Products;

And to my surprise the query worked, though it shouldn't have been.
I tried executing it again several times, and it still worked.
Then, I added some random query to see if something changes (I used SELECT DB_NAME(); before the EXECUTE AS command), and now I got the expected error - the query didn't work.
What caused this behavior? (My first guess was that this is a parallel query processing issue, but the GO should've made the execution order as needed).
EDIT:
This behavior happened again. I executed:
REVERT;
GO
DROP LOGIN MyDeniedLogin;
DROP USER MyDeniedUser;
GO

Then tested to see if the MyDeniedLogin still exists - and it did. I than added some dummy command (I used SELECT CURRENT_USER; GO) after the first GO, and it worked.
EDIT2: Full original script (without the aforementioned "dummy" commands):
-- Set up a login and user
CREATE LOGIN DenyTestServerLevel WITH PASSWORD = 'DenyTest',
     CHECK_POLICY = OFF;
GO
USE NORTHWND;
GO
CREATE USER DenyTestDBLevel FROM LOGIN DenyTestServerLevel;
GO

-- Set up a role that's granted SELECT permissions to the database
CREATE ROLE GrantSelectRole;
GRANT SELECT TO GrantSelectRole;
EXEC sp_addrolemember 'GrantSelectRole','DenyTestDBLevel';
EXECUTE AS USER = 'DenyTestDBLevel';
GO
-- This should work:
SELECT * FROM Products;

-- revert back to the 'dbo' user:
REVERT;
GO
-- and deny:
DENY SELECT TO DenyTestDBLevel;
GO

EXECUTE AS USER = 'DenyTestDBLevel';
GO
-- Now this shouldn't work:
SELECT * FROM Products;

-- revert back and drop everything:
REVERT;
GO

DROP LOGIN DenyTestServerLevel;
DROP USER DenyTestDBLevel;
DROP ROLE GrantSelectRole
GO


text:
Q: "react-native run-ios" command line does not work Description
First error:
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening awesome.xcworkspace.
couple of warnings:
warning: Mapping architecture arm64 to x86_64. Ensure that this target's Architectures and Valid Architectures build settings are configured correctly for the iOS Simulator platform. (in target 'React-jsiexecutor' from project 'Pods')
warning: None of the architectures in ARCHS (i386, x86_64) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (i386, x86_64) which is not in EXCLUDED_ARCHS (x86_64). (in target 'React-jsiexecutor' from project 'Pods')
last error:
The following build commands failed:
PhaseScriptExecution [CP]\ Copy\ XCFrameworks /Users/sammie/Library/Developer/Xcode/DerivedData/awesome-fgqovmpltvmybwfboirbhkzybyqx/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/OpenSSL-Universal.build/Script-329FE3CB18B30DBF34BE47031BE8F397.sh
(1 failure)
React Native version:
OS: macOS 10.15
CPU: (6) x64 Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz
Memory: 321.19 MB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 14.17.0 - /usr/local/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 6.14.13 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.10.1 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
Android SDK:
API Levels: 30
Build Tools: 30.0.3, 31.0.0
System Images: android-29 | Android TV Intel x86 Atom, android-30 | Google APIs Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: 4.2 AI-202.7660.26.42.7351085
Xcode: 11.2/11B52 - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_292 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.1 => 17.0.1
react-native: 0.64.2 => 0.64.2
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Steps To Reproduce
What I did:
-remove react-native cli globally and reinstall it.
-delete pods and pod lock files and reinstall pods
-commented some lines in pod file
-deleted "build" directory
-...
Expected Results
react native run ios command line works properly.


text:
Q: Missing text when I print Pages 5.1 file or export to PDF I've encountered a problem whereby if I want to print a pages 5.1 file or export it to PDF, text goes missing (specifically text near superscript/subscript text). An example of this same problem can be found here however the 'solution' there doesn't work.
I'd be very grateful for any advice or solutions.


text:
Q: pthread same ID and output self_t i hope i will put my question very clear, i am programming pthread,Briefly i calculate the number of threads needed, and pass created threads to a function and back, the function does transpose on different blocks; so each thread has its own block.
To check that im sending different threads, i run pthread_t self_t, but face two problems:
that seems only one same thread is used, and that i always have warning message about the type output of selt_t, below code simplified showing main pints.
any ideas where i went wrong ?
First here struct and main:
pthread_mutex_t mutexZ;       // Mutex initialize
int array[nn][nn];

struct v
{
  int i, j; // threaded Row,Col
  int n, y; //
  int iMAX; //
};

void *transposeM(void *arg);

int main(int argc, char *argv[])
{

  int Thread_Num = 10;
  pthread_t t_ID[Thread_Num]; // the number of threads depending on # blocks

  printf("Thread_Num %d\n", Thread_Num);

  struct v *data = (struct v *) malloc(sizeof(struct v));

  int i, j; //loop varables

  //#############################################################
  printf("Matrix Initial before Transpose Done\n");
  // printing the Matrix Before any transpose if needed testing

 for (i = 0; i < nn; i++){
  for(j = 0; j< nn; j++){
    array[i][j] = i*nn + j;
    printf("%d ", array[i][j]);
   }
   printf("\n");}

  //************************************************************/
  // Initialize the mutex
  pthread_mutex_init(&mutexZ, NULL);
  pthread_attr_t attr; //Set of thread attributes
  pthread_attr_init(&attr);

  int n, y; // Loop Variables for tiling

  //************************************************************/
  //Start of loop transpose:

  int start = 0;

  for (n = 0; n < nn; n += TILE)
  {
    data->n = n; // row

    for (y = 0; y <= n; y += TILE) {
      data->y = y; // column

      printf("y Tile:%d  \n", y);
      printf("Start before:%d  \n", start);

      //Transpose the other blocks, thread created for each Block transposed

      pthread_create(&(t_ID[start]), NULL, transposeM, (void*) data); // Send the thread to the function
      pthread_join(t_ID[start], NULL);

      if (start < Thread_Num)
      {
        start = start + 1;

      }
      printf("Start after:%d  \n", start);

    } // End the Y column TileJump loop
  } // End of n Row TileJump loop
}

Modified according to the notes,
void *transposeM(void *arg)
{
  // Transposing the tiles
  struct v *data = arg;
  int i, j; //loop row and column
  int temp = 0;
  pthread_mutex_lock(&mutexZ); //lock the running thread here,so keeps block until thread that holds     mutex releases it

  pthread_t self_t; // To check the thread id - my check not Mandetory to use
  self_t = pthread_self();
  printf("Thread number Main = %u \n ", self_t); //here we used u% coz seems the pthread_t is unsigned long data type

  //*******************************************************
  //here some function to work
  //########################################################

  pthread_mutex_unlock(&mutexZ);
  pthread_exit(NULL);

  return (NULL);

} // End

A: There are two conceptual issues with your code:

*

*You pass the same reference/addrerss to each thread, making each thread work on the same data.

*You join the thread immediately after having created it. As joining block until the thread to be joined ended, this sequentialises the running of all threads.

To get around 1. created a unique instance of what data points to for each thread.
To fix 2. move the call to pthread_join() out of the loop creating the threads and put it in a 2nd loop run after creation-loop.
...

printf("Thread_Num %d\n", Thread_Num);

pthread_t t_ID[Thread_Num]; // the number of threads depending on # blocks
struct v data_ID[Thread_Num] = {0}; // define an instance of data for ech thread

...

for (n = 0; n < nn; n += TILE) //limit of row
{
  struct v * data = data_ID + start; // assign thread specific instance

  data->n = n; // row

  for (y = 0; y <= n; y += TILE) // limit of column -here removd the =n, then diagonal tile is not     transposed
  {
    ...
    pthread_create(&(t_ID[start]), NULL, transposeM, (void*) data); // Send the thread to the function
    ...
  }
} // End the Y column TileJump loop

for (;start >= 0; --start)
{
  pthread_join(t_ID[start], NULL);
}

...

Modifications to the thread function:
void *transposeM(void *arg)
{
  struct v *data = arg;

  ...

  pthread_t self = pthread_self(); // better naming

  ...

  pthread_exit(NULL); // the thread functions exits here.

  return NULL; // this is never reached, but is necessary to calm down thr compiler.
} // End


text:
Q: iOS: how to display a long text in a UIScrollView? EDITED
I have a UIScrollView, it has an ImageView at the top, under that there is a UIlabel, and under that i want to put a long text.
I tried to put a UITextView inside of a UIScrollView, but UITextView has its own scroll bar, i need to put a long text and let the UIScrollView do the scrolling not the UITextView.
How can i achieve that ?

A: I think this way is ok to do what you are trying. In my code I used UILabel and gave it a size according to String long.
and here is my code
//Add an scroll to full size frame to view
UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
//some properties of scroll
scroll.userInteractionEnabled = YES;
scroll.showsHorizontalScrollIndicator = YES;
[self.view addSubview:scroll];
//now add views into the scroll
UIImageView *myTopImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, scroll.frame.size.width, 100)];
myTopImage.image = [UIImage imageNamed:@"your_image.png"];
UIFont *myFont = [UIFont fontWithName:@"Helvetica Neue" size:30];
[scroll addSubview:myTopImage];

NSString *myText = @"your  long text here";
//calculate width if it bigger than frame's width make it multiline
int width = [self calculateWidthForText:myText forHeight:30 forFont:myFont]+2;
if (width > scroll.frame.size.width) {
    width = scroll.frame.size.width;
    //calculate height for specific width
    int height = [self calculateHeightForText:myText forWidth:scroll.frame.size.width forFont:myFont]+2;
    //change your scroll contentSize
    scroll.contentSize = CGSizeMake(self.view.frame.size.width, myTopImage.frame.size.height + height);

    //now create your label
    UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 100, width, height)];
    myLabel.numberOfLines = 0;
    myLabel.text = myText;
    myLabel.textAlignment = NSTextAlignmentLeft;
    myLabel.font = myFont;
    [scroll addSubview:myLabel];

}else {

    //if it is smaller than width give it specific height and init
    UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 100, width, 30)];
    myLabel.numberOfLines = 0;
    myLabel.text = myText;
    myLabel.textAlignment = NSTextAlignmentLeft;
    myLabel.font = myFont;
    [scroll addSubview:myLabel];

}

and here is my methods to calculate string size
- (CGFloat) calculateHeightForText:(NSString *)str forWidth:(CGFloat)width forFont:(UIFont *)font {
CGFloat result = 20.0f;
    if (str) {
        CGSize textSize = { width, 20000.0f };
        CGSize size = [str sizeWithFont:font constrainedToSize:textSize lineBreakMode:UILineBreakModeWordWrap];
        result = MAX(size.height, 20.0f);
    }
    return result;
}

- (CGFloat) calculateWidthForText:(NSString *)str forHeight:(CGFloat)height forFont:(UIFont *)font {
CGFloat result = 20.0f;
    if (str) {
        CGSize textSize = { 20000.0f, height };
        CGSize size = [str sizeWithFont:font constrainedToSize:textSize lineBreakMode:UILineBreakModeWordWrap];
        result = MAX(size.width, 20.0f);
    }
    return result;
}


text:
Q: How to alter table CREATE TABLE [dbo].[INVS_ITEM_LOCATIONS](
    [DEPARTMENT_CODE] [varchar](3) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [IM_INV_NO] [numeric](10, 0) NOT NULL,
    [LOCATION_CODE] [varchar](2) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [CURR_QTY] [numeric](10, 0) NOT NULL CONSTRAINT [DF__INVS_ITEM__CURR___1352D76D]  DEFAULT ((0)),
    [DO_QTY] [numeric](10, 0) NOT NULL CONSTRAINT [DF__INVS_ITEM__DO_QT__1446FBA6]  DEFAULT ((0)),
    [ALLOC_QTY] [numeric](10, 0) NOT NULL CONSTRAINT [DF__INVS_ITEM__ALLOC__153B1FDF]  DEFAULT ((0)),
    [YOB_QTY] [numeric](10, 0) NOT NULL CONSTRAINT [DF__INVS_ITEM__YOB_Q__162F4418]  DEFAULT ((0)),
    [FOC_QTY] [numeric](10, 0) NULL CONSTRAINT [DF__INVS_ITEM__FOC_Q__17236851]  DEFAULT ((0)),
    [USER_CREATED] [varchar](25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [DATE_CREATED] [datetime] NOT NULL,
    [USER_MODIFIED] [varchar](25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [DATE_MODIFIED] [datetime] NULL,
 CONSTRAINT [INVS_ITEM_LOCATIONS_PK] PRIMARY KEY CLUSTERED
(
    [DEPARTMENT_CODE] ASC,
    [IM_INV_NO] ASC,
    [LOCATION_CODE] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

this is my table name how can i delete primary key in im_inv_ni and location_ code
and also i should add foriegn key to im_inv_no....pls help

A: You can use the ALTER TABLE -statements. More information can be found here http://ss64.com/ora/table_a_cons.html.
The needed statements are
ALTER TABLE [dbo].INVS_ITEM_LOCATIONS DROP PRIMARY KEY;
ALTER TABLE [dbo].INVS_ITEM_LOCATIONS ADD CONSTRAINT <name of fk> FOREIGN KEY (<columns>) REFERENCES <table>(<columns>);


text:
Q: SQL The largest number of consecutive values for each value I have Tabel MatchResults
id | player_win_id
------------------
1  |    1
2  |    1
3  |    3
4  |    1
5  |    2
6  |    3
7  |    3
8  |    1
9  |    1
10 |    1

I need to find out for each player ID the highest number of consecutive victories. I use MS SQL Server.
Expected Result
PLAYER_ID | WIN_COUNT
------------------
    1     |    3
    2     |    1
    3     |    2

A: This is a type of gaps-and-islands problem.  One solution uses the difference of row numbers.  So, to get all streaks:
select player_win_id, count(*)
from (select t.*,
             row_number() over (order by id) as seqnum,
             row_number() over (partition by player_win_id order by id) as seqnum_p
      from MatchResults t
     ) t
group by player_win_id, (seqnum - seqnum_p);

Why this works is a little tricky to explain.  But if you look at the results of the subquery, you'll probably see how the difference between the row number values captures adjacent rows with the same player win id.
For the maximum, the simplest is probably just an aggregation query:
select player_win_id, max(cnt)
from (select player_win_id, count(*) as cnt
      from (select t.*,
                   row_number() over (order by id) as seqnum,
                   row_number() over (partition by player_win_id order by id) as seqnum_p
            from MatchResults t
           ) t
      group by player_win_id, (seqnum - seqnum_p)
     ) p
group by player_win_id;

A: Now I understand the previous comment. The code for my table is:
select player_win_id, max(cnt)
from (select player_win_id, count(*) as cnt
      from (select *,
                   row_number() over (order by id) as seqnum,
                   row_number() over (partition by player_win_id order by id) as seqnum_p
            from MatchResults ) t
      group by player_win_id, (seqnum - seqnum_p)
     ) p
group by player_win_id;


text:
Q: Tensorflow-gpu doesn't working with Nvidia driver 455.45 & CUDA version - 11.1 on UBUNTU 20.04 I'm trying to install the latest version of TensorFlow 2 using pip install tensorflow as of mentioned in official website. I've the latest version of Ubuntu 20.04 LTS. And my laptop has Nvidia GeForce GTX 1050ti graphics card. But when I install Nvidia driver, it only installs the latest version - 455.45 and its CUDA version - 11.1.
Then I installed cuda-toolkit 10.1 and CuDNN7.6. But still TensorFlow doesn't detect GPU on my system.
Help me to install TensorFlow on the latest version of Ubuntu and Nvidia Driver.
If you find any blogpost which shows the proper way to install it, please share it. Thank you.

A: Just simply do a clean install of CUDA (First delete all of its traces and then try to reinstall the correct version, which is 10.1).
OR:- you can install Miniconda or Anaconda on your computer and then run this command on cmd :-
conda create --name tf_gpu tensorflow-gpu
which would automatically download and install all the correct software needed to run TensorFlow on GPU.


text:
Q: SAS Grid Validation error I am getting the following error message:
"Objspawn was unable to launch the server SASApp - Workspace Server due to the server launch exceeding the specified wait time.
Failed to start the server"
This is a grid environment, and the new application servers created - (for example SASAppVS, created for the Visual Statistics use) - work fine. I am new to the grid environment. So, any help regarding this would be appreciated.
more on SAS


text:
Q: Angular binding not working properly on checkbox (webkit) I have this code:
<input type="checkbox" ng-checked="item.selected == 'yes'"  ng-click="change()">{{item.selected}}<br/>

http://jsfiddle.net/NmQXp/2/
As you can see, there are three identical checkboxes, with their checked status binded to the value of some string.  The catch is that I want to introduce an intermediate "partially selected" state to the checkboxes.  In fact what I want to do is use the checkbox to change the value from "pending" to "ongoing" and then to "done" (I'm making a ToDo list).
If you click one of them several times you can see the correct behavior in the others, but the checked status is wrong in the one you are clicking.
¿Is this a bug in Angular Binding, or am I missing something?

A: Well i tried to fix your fiddle to take care of the checked issue. The behavior was inconsistent because checkbox gets checked when mouse is clicked over it due to the default HTML behavior. I added these lines to prevent the default behavior for checkbox.
 if ($scope.item.selected == 'no') {
            $scope.item.selected = 'halfway';
            $event.preventDefault();
        }

Here is the updated fiddle.
http://jsfiddle.net/cmyworld/J27jN/


text:
Q: default destructor in a struct containing a unique_ptr causes compilation errors when using an std::map Considering the following code example, why does the definition of a default destructor cause a compilation error?
#include <iostream>
#include <memory>
#include <map>

struct Foo
{
    char c;
    std::unique_ptr<int> ptr;

    Foo(char c_, int n_) : c(c_), ptr(std::make_unique<int>(n_))
    {;}

    //~Foo() noexcept = default; // problem here, why?
};

int main()
{
    std::map<int, Foo> mp;

    mp.emplace(0, Foo{'a',40});
    mp.emplace(1, Foo{'b',23});

    for (auto &&i : mp)
        std::cout<< i.first << " : {" << i.second.c << "," << *(i.second.ptr) << "}" <<std::endl;
}

Compiler error:

error: call to implicitly-deleted copy constructor of 'Foo'

From the error message I get that there's a silent copy happening???
It is worth mentioning that the code compiles fine when using a normal pointer instead of a unique_ptr. But I do not understand why the default destructor would be a problem?

A: Because if you define a destructor yourself then the compiler will no longer generate the copy-con and the move-con for you. You can specify them as default and deleted (even though the copy con will still be implicitly deleted cause of the unique_ptr) and your code will work again:
struct Foo
{
    char c;
    std::unique_ptr<int> ptr;

    Foo(char c_, int n_) : c(c_), ptr(std::make_unique<int>(n_))
    {;}

    ~Foo() noexcept = default;
    Foo(Foo&&) = default;
};

This'll also be the case for operator=(Foo&&).


text:
Q: Why String.equals() doesn't use hashCode() equality check under the hood? Why not using hashCode() under the hood of equals() to pre-check for equality first?
Quick draft tests:
@Fork(value = 1)
@Warmup(time = 1)
@Measurement(time = 1)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Benchmark)

public class Main {

  @Param({
    "o", // differ size
    "oooooooooooooooooo1", // same size, differ last symbol
    "oooooooooooooooooo2" // same content
  })
  String string1;

  @Param({
    "oooooooooooooooooo2"
  })
  String string2;

  @Benchmark
  public void stringEquals(Blackhole bh) {
    bh.consume(string1.equals(string2));
  }

  @Benchmark
  public void myEquals(Blackhole bh) {
    bh.consume(myEquals(string1, string2));
  }

  boolean myEquals(String str1, String str2){
    if (str1.hashCode()==str2.hashCode()) {
      return str1.equals(str2);
    }
    return false;
  }
}

Results:
Benchmark                    (string1)            (string2)  Mode  Cnt   Score   Error  Units
Main.myEquals                        o  oooooooooooooooooo2  avgt    5   5.552 ± 0.094  ns/op
Main.myEquals      oooooooooooooooooo1  oooooooooooooooooo2  avgt    5   5.626 ± 0.173  ns/op
Main.myEquals      oooooooooooooooooo2  oooooooooooooooooo2  avgt    5  14.347 ± 0.234  ns/op
Main.stringEquals                    o  oooooooooooooooooo2  avgt    5   6.441 ± 1.076  ns/op
Main.stringEquals  oooooooooooooooooo1  oooooooooooooooooo2  avgt    5  13.596 ± 0.348  ns/op
Main.stringEquals  oooooooooooooooooo2  oooooooooooooooooo2  avgt    5  13.663 ± 0.126  ns/op

As you can see we got great speedup for the case of "same size, differ last symbol".
I think under the hood of String.equals() check for hashCode() equality should replace check for length() equality as it takes the same time:
  @Benchmark
  public void emptyTest(Blackhole bh) {
    bh.consume(0);
  }

  @Benchmark
  public void stringLength(Blackhole bh) {
    bh.consume(string2.length());
  }

  @Benchmark
  public void stringHashCode(Blackhole bh) {
    bh.consume(string2.hashCode());
  }

Benchmark                      (string2)  Mode  Cnt  Score   Error  Units
Main.emptyTest       oooooooooooooooooo2  avgt    5  3.702 ± 0.086  ns/op
Main.stringHashCode  oooooooooooooooooo2  avgt    5  4.832 ± 0.421  ns/op
Main.stringLength    oooooooooooooooooo2  avgt    5  5.175 ± 0.156  ns/op

PS I have a feeling my measurements method might be wrong, so any comments are welcome. Also, the hash is saved inside String and that also might produce some misleading results...
UPD1: As @AdamSiemion mentioned we need to recreate string every time a benchmarked method is called to avoid cashing of hash code:
  String str1, str2;

  @Setup(value = Level.Invocation)
  public void setup(){
    str1 = string1;
    str2 = string2;
  }

  @Benchmark
  public void stringEquals(Blackhole bh) {
    bh.consume(str1.equals(str2));
  }

  @Benchmark
  public void myEquals(Blackhole bh) {
    bh.consume(myEquals(str1, str2));
  }

Benchmark                    (string1)            (string2)  Mode  Cnt   Score   Error  Units
Main.myEquals                        o  oooooooooooooooooo2  avgt    5  29.417 ± 1.430  ns/op
Main.myEquals      oooooooooooooooooo1  oooooooooooooooooo2  avgt    5  29.635 ± 2.053  ns/op
Main.myEquals      oooooooooooooooooo2  oooooooooooooooooo2  avgt    5  37.628 ± 0.974  ns/op
Main.stringEquals                    o  oooooooooooooooooo2  avgt    5  29.905 ± 2.530  ns/op
Main.stringEquals  oooooooooooooooooo1  oooooooooooooooooo2  avgt    5  38.090 ± 2.933  ns/op
Main.stringEquals  oooooooooooooooooo2  oooooooooooooooooo2  avgt    5  36.966 ± 1.642  ns/op

So, we still have almost 30% speedup for the case of "same size, differ last symbol".
UPD2 As @DanielPryden mentioned str1 = string1 will not create new String. So we need to explicitly do so:
  @Setup(value = Level.Invocation)
  public void setup(){
    str1 = new String(string1);
    str2 = new String(string2);
  }

Benchmark                    (string1)            (string2)  Mode  Cnt   Score   Error  Units
Main.myEquals                        o  oooooooooooooooooo2  avgt    5  61.662 ± 3.068  ns/op
Main.myEquals      oooooooooooooooooo1  oooooooooooooooooo2  avgt    5  85.761 ± 7.766  ns/op
Main.myEquals      oooooooooooooooooo2  oooooooooooooooooo2  avgt    5  92.156 ± 8.851  ns/op
Main.stringEquals                    o  oooooooooooooooooo2  avgt    5  30.789 ± 0.731  ns/op
Main.stringEquals  oooooooooooooooooo1  oooooooooooooooooo2  avgt    5  38.602 ± 1.212  ns/op
Main.stringEquals  oooooooooooooooooo2  oooooooooooooooooo2  avgt    5  38.921 ± 1.816  ns/op

So, now we have what was expected: using hashCode() will always be slower then equals(). And that has a total sense (as @Carcigenicate mentioned in comments below): hashCode() need to do full traversal through char[] to produce the hash. I thought it might be some intrinsic under the hood of hashCode() that make it faster, but it has not.
Therefore, it's still possible to get some speed up of equals() if make a check for precalculated hash existence and compare them:
public boolean equals(Object anObject) {
    if (this == anObject) {
        return true;
    }
    if (anObject instanceof String) {
        String anotherString = (String)anObject;
        int n = value.length;
        if (n == anotherString.value.length
           // new code begins
            && (hash==0 || anotherString.hash==0 || hash==anotherString.hash)) {
           // new code ends
            char v1[] = value;
            char v2[] = anotherString.value;
            int i = 0;
            while (n-- != 0) {
                if (v1[i] != v2[i])
                    return false;
                i++;
            }
            return true;
        }
    }
    return false;
}

We'll get some small(?) slowdown in case of equal strings (for checking hash fields), but also will get a speedup in case of strings with the same length but different content and already precalculated hashes.
Unfortunately, I can't test it as I can't change the source code of String class.

A: Your performance tests calling hashCode() thousands of times (using jmh) do not make sense because String hash code is cached:
/** Cache the hash code for the string */
private int hash; // Default to 0

public int hashCode() {
  int h = hash;
  if (h == 0 && value.length > 0) {
    char val[] = value;

    for (int i = 0; i < value.length; i++) {
      h = 31 * h + val[i];
    }
    hash = h;
  }
  return h;
}

So once String hash code is computed, calling hashCode() has almost no cost - contrary to the majority of the Java classes which recompute the hash code every time hashCode() is called.
Usually it is equals() which is faster than hashCode() as it is usually uses a short-circuit evaluation. For example, if you have a call with 10 fields, and the values in first fields of the two provided instances differ equals() will not inspect the remaining 9 fields, while hashCode() (usually) be computed from all the 10 fields.

A: I agree that comparing the hashCode (only if already calculated) looks like it might boost up performance, as String objects are immutable.
Considerations:

*

*The boost is only for when the hashCode already exists (was already calculated). If the hashCode wasn't already calculated, calculating might take longer than comparing the chars of 2 strings. This because, when comparing, we can stop as soon as we see a difference. For example, when comparing "aaxxxxxxxxxx" to "aazzzzzzzzzzz", we can stop after the second char if the strings aren't equal. But calculating hashCode will need a traversal over all chars.

*Perhaps the writers' decision was based on stats regarding how Strings are used. They might have seen that the additional comparison of the hashCode might slow the system.
For example, if most strings are used withing hash maps/tables, than the hashCode is already compared and used. All the strings left to compare have the same hashCode, so there's no need to compare the hashCodes again.

*The hash field might be calculated in several threads simultaneously for the same object, especially if equals() uses it. This needs to be taken into consideration.

*Another consideration is the memory usage. Perhaps there's an optimization in the JVM to not use memory if an int field is zero? Once it's not zero, might it raise the memory consumption?
It would have been nice to have a way to tweak and measure this (String is final). Perhaps using some bytecode manipulation or using a different classloader...
Here's the code tweak for what was suggested (OpenJDK and Oracle look the same):
public boolean equals(Object anObject) {
    if (this == anObject) {
        return true;
    }

    if (anObject instanceof String) {
        String anotherString = (String)anObject;
        int n = value.length;
        if (n == anotherString.value.length) {

            // THE HASHCODE TWEAK
            if (hash != 0 &&
                anotherString.hash != 0 &&
                hash == anotherString.hash)
            {
                return true;
            }

            char v1[] = value;
            char v2[] = anotherString.value;
            int i = 0;
            while (n-- != 0) {
                if (v1[i] != v2[i])
                    return false;
                i++;
            }
            return true;
        }
    }
    return false;
}


text:
Q: eventResizeStop and eventDragStop callbacks dont send the right event data with fullcalendar I am using fullcalendar http://fullcalendar.io/ to create a calendar where my user can indicate his disponibilities. I am sending events' info into a hidden field. Everytime an event occurs such as clicking to delete an event, dragging an event or resizing an event, I am updating the data sent to the hidden field. I have been experiencing problems with two callbacks :
•   eventResizeStop
•   eventDragStop
Here are the two problematic callbacks in my fullcalendar.js file
eventResizeStop: function(event) {
      var all_events = $('#js-calendar').fullCalendar('clientEvents');
      console.log(all_events);
      var array_all_events = [];
      $.each(all_events, function(index, value) {
          // console.log(value.start["_d"]);
          // console.log(index);
           var day         = moment(value.start["_d"]).format('dddd');
           var start_time  = moment(value.start["_d"]).format("HH:mm");
           var end_time    = moment(value.end["_d"]).format("HH:mm");
             // var id          = value.unique_id["_i"];
             var slot        = {
                day: day,
                start_time: start_time,
                end_time: end_time,
              };
              console.log(slot)
            array_all_events.push(slot);
           // console.log(array_all_events.length);
        });

      console.log(array_all_events);
       if (array_all_events.length == 0) {
          console.log("eventresize");
          $("#dispo_array").val("");
        }
        else {
          console.log(typeof(array_all_events));
          console.log("eventresize");
          $("#dispo_array").val(JSON.stringify(array_all_events));
        }
    },

    eventDragStop: function( event ) {
      // console.log(event);
      var all_events = $('#js-calendar').fullCalendar('clientEvents');
      console.log(all_events)
      var array_all_events = [];
      $.each(all_events, function(index, value) {
          // console.log(value.start["_d"]);
          // console.log(index);
           var day         = moment(value.start["_d"]).format('dddd');
           var start_time  = moment(value.start["_d"]).format("HH:mm");
           var end_time    = moment(value.end["_d"]).format("HH:mm");
             // var id          = value.unique_id["_i"];
             var slot        = {
                day: day,
                start_time: start_time,
                end_time: end_time,
              };
            array_all_events.push(slot);
            // console.log(array_all_events.length);
        });
       if (array_all_events.length == 0) {
          console.log(array_all_events);
          $("#dispo_array").val("eventdrag");
        }
        else {
          console.log("eventdrag");
          console.log(JSON.stringify(array_all_events))
          $("#dispo_array").val(JSON.stringify(array_all_events));
        }

    },

Everytime one of these two events happen, I am collecting all the events in the calendar through  var all_events = $('#js-calendar').fullCalendar('clientEvents'); and then sending their relevant data in the right format to my hidden field.
The problem is that these callbacks are supposed to be triggered at the end of the resizing or the dragging of the event (thus the data sent should be the one relevant to the state of the events at the end of the dragging and resizing actions). However when I run my tests, I realise that the data sent to my hidden field are the one relevant to the beginning of these triggers : that is when the dragging starts and when the resizing starts. How can I fix that ?


text:
Q: Shortest distance between factors without using array, data structures or any api in java? I was asked a question to find a shortest distance between factors of a number without using arrays, any data structures or string in Java. For example if 13013 is passed to a method it should return 2, since the factors of 13013 are 1*7*11*13*13 and the shortest distance between two different number is 13-11=2, one more example if 10 is passed it should return 1, since factors of 10 are 1*2*5 and the shortest distance is (2-1) which is 1. What i found was if even number is passed it should always return 1, since 2, and 1 is always involved in the factor and (2-1)=1, if prime is passed it will be (number-1), since prime is only divisible by itself and 1, and if odd is passed mostly it is 2 Since (3-1)=2, but I am not being able to find for all numbers.
This is what I have till this point, thank you all
static int findDistance(int numberPassed)
{
    boolean isPrime=true;
    int returnValue=0;

    if(numberPassed % 2==0)
    {
        //If it is even there must be 2 and 1 as a factor therefore 2-1=1
        returnValue=1;
    }
    else
    {
        for(int i=2;i<numberPassed;i++)
        {
            if(numberPassed % i==0)
            {
                //if number is divisible by any except by 1 and itself
                //it is prime
                isPrime=false;
                break;
            }
        }
        if(isPrime && numberPassed!=1)
        {
            //If it is prime then return value should be numberPassed-1
            //since factor of prime are 1 and itself, so shortest distance
            //numberPassed-1
            returnValue=numberPassed-1;
        }
        else
        {
            //The problem is here if the number is not prime and is odd
            //since shortest distance differes now, for value divisible by 3
            //it should be 3-1=2, but there are many other cases
            returnValue=2;
        }
    }
    return returnValue;
}

A: static int findDistance(int a)
{
    //variables needed for calculation
    int temp=a;
    int fact=1;
    int distance=0;
    int shortestDistance=a;
    int lastFact=1;

    while(temp>1)
    {
        //If value is divisible by fact variable
        if(temp % fact==0)
        {
            //If last fact does not equal current fact
            if(lastFact!=fact)
            {
            distance=fact-lastFact;
            lastFact=fact;
            }
            //divide by fact
            temp=temp/fact;

            //reassign the fact to 1 so that it can start from beginning
            fact=1;

            //if distance is not zero and shortestDistance is bigger
            if(shortestDistance>distance && distance !=0)
            {
                //now the shortest distance is the distance
                shortestDistance=distance;
            }
        }

        fact++;
    }
    return shortestDistance;
}

A: public static int minDistance(int num){
        int fact1 = 1;
        int minDist = num;
        int fact2 = 0;
        for(int i=2; i<num; i++){
            if (num%i==0){
            fact2 = i;
                if((fact2-fact1)<=minDist){
                    minDist = fact2-fact1;
                    fact1 = fact2;
                }
            }
        }
    return (minDist);
}

A: public class Demo {
    public static void main(String[] args) {
        System.out.println("Result: " + minDistance(1001));
    }

    public static int minDistance(int n) {
        int minDistance = n;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                if (n % i == 0 && n % j == 0) {
                    if (i > j) {
                        int distance = i - j;
                        if (distance < minDistance) {
                            minDistance = distance;
                        }
                    }
                }
            }
        }
        return minDistance;
    }
}

Here,two for-loops are used: Outer for-loop is used to take one value at a time and calculate distance between two value(Second value is obtained from Inner for-loop) and stored in distance variable. Since minimum distance between the factors of the number will always be less than itself, so the minDistance is initialized to the number itself. If the distance is less than minDistance value then minDistance is reset to new distance value.


text:
Q: .Net core Web API who calls other external APIs I'm creating a .Net Core web API which will further call an external API.
Scenario:
In .Net Core web API, I want to make a Post request to UiPath Orchestrator API to get authentication token. Following is the link for the Request that I want to make
https://postman.uipath.rocks/#8f3b38d8-57dc-4d79-876d-0d2ff897f61a
[HttpPost]
public Task<IActionResult> GetAccessToken()
{
  //Here I want to make a Post request to the API to Authenticate
}

And response (Auth token) of this will be sent to another post request to start a process
https://postman.uipath.rocks/#738c3beb-1c19-4257-8474-841a054c4220
[HttpPost]
 public Task<IActionResult> StartProcess(string token)
 {
   //Here I want to make a Post request to the other API in which token from the previous call will be
    sent in header
 }

I have to complete it in a day or two and I can't figure out how can I achieve this.
Any help will be much appreciated.

A: If I correctly understand you want to have an endpoint, which will make two POST requests to third-party API. The first request will retrieve an Authorization Token. The second request will use the Token in its Headers to pass an authorization.
To achive this behavior, you should to have a single endpoint in your API, instead of two endpoints (as in your example above).
Also, I recommend you to have a separate class, which will responsible for communicating with your third-party API (with the postman.uipath.rocks).
So, your single endpoint to call a third-party API may looks like this:
public class Controller
{
    // another Controller's code...
    private readonly IPostmanApi postmanApi;

    public Controller(IPostmanApi postmanApi)
    {
        this.postmanApi = postmanApi;
    }

    [HttpPost]
    public async Task<IActionResult> StartPostmanProcess()
    {
        string token = await postmanApi.GetToken();
        await postmanApi.StartProcess(token);

        return Accepted();
    }

    // another Controller's code...
}

Your IPostmanApi.cs file may looks like this:
public interface IPostmanApi
{
    ///
    /// A method to get Authorization Token from Postman
    ///
    Task<string> GetToken();

    ///
    /// A method to get start a process in Postman
    ///
    ///<param name="token">Postman's authorization token</param>
    Task StartProcess(string token);
}

Your PostmanApi.cs file may looks like this:
public class PostmanApi
{
    Task<string> GetToken()
    {
        using (HttpClient client = new HttpClient())
        {
            var response = await client.PostAsync("https://postman.uipath.rocks/#8f3b38d8-57dc-4d79-876d-0d2ff897f61a");

            // Note: this code assumes that the whole response body is a string Token.
            // If the `postman.uipath.rocks` returns an JSON object, which contains a
            // Token inside some field, you may use Newtonsoft.Json library to deserialize
            // it, and then retrieve your Token from corresponding field.
            // See example here: https://stackoverflow.com/questions/24131067/deserialize-json-to-array-or-list-with-httpclient-readasasync-using-net-4-0-ta
            return await response.Content.ReadAsStringAsync();
        }
    }

    Task StartProcess(string token)
    {
        using (HttpClient client = new HttpClient())
        {
            // Note: this code assumes that the `postman.uipath.rocks` receives
            // a **Bearer** token. If it receives another kind of authentication
            // scheme, you should use it instead of "Bearer".
            client.DefaultRequestHeaders.Authorization
                         = new AuthenticationHeaderValue("Bearer", token);
            await client.PostAsync("https://postman.uipath.rocks/#738c3beb-1c19-4257-8474-841a054c4220");
    }
}

Also don't forget to register your IPostmanApi service within Startup.cs:
public void ConfigureServices(IServiceCollection services)
{
    // another code...

    services.AddScoped<IPostmanApi, PostmanApi>();
    // another code...
}

Notice:

*

*This code is not thread-safe (because an HttpClient is not thread safe). If you want it to be thread-safe, consider to use IHttpClientFactory.

Useful links:

*

*The ways of consume Rest API in .NET Core app

*https://learn.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-5.0


text:
Q: Word for Mac: How can you stop a category of Table of Authorities add an extra line after its entry? I created a few different categories only to realize I missed out one later.
Now I have an option to simply unwind all the changes I made in the text, and rename the top category to the one I should have had in the first place, and then re-mark each citations or I can go with it...
Which means, I have to rename a subsequent category, say, some of the ones numbered and not named to the category I wish. And then simply add that particular category above "all" of the table of authorities as inserted in the text previously. The problem is, it adds an extra line each time the tables are updated.
I am hoping for a solution that will not add automatically a line there.
Is there a way?


text:
Q: Minimum number of subgraphs such that every node is included? Suppose we have a graph of N nodes, and we have S subgraphs of this original graph where each subgraph contains subset of the N nodes. It is guaranteed that each node exists in at least one subgraph.
We want to know the minimum number of subgraphs X out of S such that every node of the N nodes is included at least once in at least one subgraph of the chosen X subgraphs. Is there a way to do this with efficient complexity?

A: Your problem is an instance of the Set cover problem. Set cover is NP-Hard, so there is unfortunately no way to efficiently solve this in general.

A: I have two solutions in mind which dont require you to brute force through all possible combinations, one not being too perfect, the other being less efficient.
Like stated by SaiBot, a perfect and efficient answer doesn't seem to exist.

*

*You could start once with every subgraph X and continue adding the graphs that contain the most missing nodes. Afterwards you could pick which solution needed the least subgraphs.

*You could assing each subgraph X an "independecy" value, which describes how many of his nodes are not (or rarely) contained in other subgraphs as well and combine that with method one to get a possibly more perfect solution at the cost of generating this "independency" value.

A: As said before, this is an NP-hard problem. If you like, you can approximate it to a factor of about ln(n) efficiently. This is as good an approximation factor as possible to achieve efficiently (assuming NP-hard problems are lower bound to exponential complexity).
You can do this with the Greedy set cover algorithm.
Basically, what the algorithm does is repeatedly selected the set (subgraph in your case) with most uncovered elements (verices). It repeats this until no more uncovered elements exist.


text:
Q: How to run Go program as a service I try to use https://github.com/kardianos/service library  but can't manage to get it to work.
I have the following code :
package main

import (
    "log"

    "github.com/kardianos/service"
    "github.com/reujab/wallpaper"
)

var logger service.Logger

type program struct{}

func (p *program) Start(s service.Service) error {
    // Start should not block. Do the actual work async.
    go p.run()
    return nil
}
func (p *program) run() {
    // link to whaterver image from the web
    wallpaper.SetFromURL("https://apod.nasa.gov/apod/image/1910/MilkyWaySaltFlat_Huerta_960_annotated.jpg")
}
func (p *program) Stop(s service.Service) error {
    // Stop should not block. Return with a few seconds.
    return nil
}

    func main() {
        svcConfig := &service.Config{
            Name:        "GoServiceExampleSimple",
            DisplayName: "Go Service Example",
            Description: "This is an example Go service.",
        }

        prg := &program{}
        s, err := service.New(prg, svcConfig)
        if err != nil {
            log.Fatal(err)
        }
        logger, err = s.Logger(nil)
        if err != nil {
            log.Fatal(err)
        }
        err = s.Run()
        if err != nil {
            logger.Error(err)
        }
    }

When I run the program itself, the call to wallpaper.SetFromURL() works well, but I got no services registered afterward.
What am I missing? I seems everyone uses this solution very simply and I feel even dumber.


text:
Q: Angular.js $setValidity onLoad Page
*

*Cenário:
Possuo um formulário com 3 etapas, uma jsp para cada etapa. Em uma determinada jsp existe um input text com a diretiva ng-minlength e um onChange que chama uma função que valida com o $setValidity caso o valor informado seja inválido.

*Problema:
Quando a campo é inválido e ocorre a navegação entre as etapas, ao voltar pra etapa o campo perde o status de inválido. Como solução, eu tentei validar o campo ao carregar a pagina mas ocorre erro ao executar o código a baixo pois o formulário ainda não foi carregado:
$scope.form.numeroCartao.$setValidity("valid", true);

*Pergunta:
Como validar um campo com o $setValidity ao carregar a página?

A: Ao invés de setar o valor do campo usando o value do input, carregue o valor no ng-model.
Ao invés de fazer isso:
<input type="text" ng-minlenth="10" ng-model="teste" value="${ vdo.teste }"/>

Faça isso:
<form ng-init="teste = '${ vdo.teste }';">
...
<input type="text" ng-minlenth="10" ng-model="teste"/>

Outra... não escute o evento nativo onChange do elemento, com Angular o ideal é usar a diretiva on-change, ou então criar um $watch no seu controller.


text:
Q: Is the product of ideals in an algebra an ideal? Yesterday, my professor made the following claim:
Let $K$ be a field, and let $L$ be a $K$-algebra, with ideals $A,B$. Then
$$AB = \left\{ \sum_i a_i b_i : a_i \in A, b_i \in B\right\} $$
is an ideal of $L$.
Myself and another student have tried to prove this, but we can't get anywhere without assuming that multiplication in $L$ is associative. I know that this claim is true in the context of Lie algebras, but the proof involves the Jacobi identity, which a general $K$-algebra does not have. Is this claim simply false without assuming associativity?


text:
Q: Код работает в режиме отладки, но в обычном режиме вылетает При нажатии на кнопку из БД подтягваются данные и выводятся на форму.в отладчике все как надо работает.В обычном режиме - вылет.В БД все таблицы, связи EF создал нормально.Ниже код события кнопки и модели БД
public class Backgrounds
{
    public int Id { get; set; }
    public string Name { get; set; }
    public int Price { get; set; }
    public byte[] TitleImage {get;set;}
    public byte[] Content { get; set; }
    public virtual ICollection<User> Users { get; set; }
}
 public class User
{
    public int Id { get; set; }
    public string Email { get; set; }
    public string Password { get; set; }
    public int Money { get; set; }
    public  ICollection<Servers> Servers { get; set; }
    public virtual ICollection<Backgrounds> Backgrounds { get; set; }

}

private void backgrounds_Click(object sender, RoutedEventArgs e)
        {
            var AuthorizedUser = _context.User.First(x => x.Id == UserId);
            var ListOfServers = _context.Backgrounds.Take(18).AsQueryable();
            DataList.Children.Clear();

            foreach (var it in ListOfServers)
            {
                if (AuthorizedUser.Backgrounds.FirstOrDefault(x => x.Id == it.Id)!=null)
                {
                    viewer v = new viewer();
                    v.ObjId = it.Id;
                    v.Name.Content = it.Name;
                    v.Price.Content = it.Price;
                    if (it.TitleImage != null)
                        using (MemoryStream ms = new MemoryStream(it.TitleImage))
                        {
                            var decoder = BitmapDecoder.Create(ms, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad);
                            ImageSource IS = decoder.Frames[0];
                            v.image.Source = IS;
                        }
                    v.Padding = new Thickness(5);
                    DataList.Children.Add(v);
                }
            }
        }


text:
Q: HTML2PDF : error (sometimes) when generating, but PDF generated Let me explain !
I have a magento website. I'm generating custom PDF when my user is making an order.
It works most of the time, but for some reason, sometimes, I have this error :

Undefined property: Spipu\Html2Pdf\MyPdf::$h in ...../vendor/spipu/html2pdf/src/MyPdf.php on line 670"

The line is this :
public function getH()
{
    return $this->h;
}

The class is : class MyPdf extends \TCPDF
and in TCPDF, $h is a protected variable
It's weird, knowing that my PDF is saved on my server, and I can open without getting an error..
Do you have any idea of what the problem could be ?

A: Ah ah got it !
Forgot to mention, i'm using a loop to make and attach my pdf to a mailer.
I had to put the declaration of the HTML2PDF inside the loop, not outside (that's make sense).
Hope this will help !


text:
Q: Cakephp: How to add variable value to table How can I add a variable value to table with cakephp formhelper. In my form, I allow user to input some values, but the user's ip address also add to table. I also calculate user's input before insert into database.
Should I modify controller or model in cakephp. I have a Number table with id, cybernumber, created, department, ipaddress. Thanks very much.
//Controller/NumberController.php
public function add()
{
    if ($this->request->is('post'))
    {
        $this->Number->create();
        //not working
        //$this->request->data['Number']['ipaddress'] = $this->request->clientIp();
        //not working
        //$this->Number->set('ipaddress',$this->request->clientIp());

        if ($this->Number->save($this->request->data))
        {
            $this->Session->setFlash(__('OK.'));
            return $this->redirect(array('action' => 'index'));
        }
        $this->Session->setFlash(__('Unable to add your post.'));
        }
    }
}

// Model/Number.php
<?php

class Number extends AppModel {

    public $validate = array(
        'cybernumber' => array(
            'rule' => 'isUnique',
            'message' => 'unique only'
        ),
        'department' => array(
            'rule' => 'notEmpty'
        )

    );
}

A: First in Config/core.php change: Configure::write('debug', 0); to Configure::write('debug', 1);
After
$this->Number->create();
$this->request->data['Number']['ipaddress'] = $this->request->clientIp();

Add
debug($this->request->data);

Check if the ipaddress field is there.
Try to check the type of field in your database. Maybe it is incompatible with the format of data.


text:
Q: What makes the trapdoor function in elliptic curve cryptography hard to reverse? I've been reading this article on elliptic-curve crypto and how it works:
http://arstechnica.com/security/2013/10/a-relatively-easy-to-understand-primer-on-elliptic-curve-cryptography/
In the article, they state:

It turns out that if you have two points [on an elliptic curve], an initial point "dotted" with itself n times to arrive at a final point [on the curve], finding out n when you only know the final point and the first point is hard.

It goes on to state that the only way to find out n (if you only have the first and final points, and you know the curve eqn), is to repeatedly dot the initial point until you finally have the matching final point.
I think I understand all this - but what confuses me is - if n is the private key, and the final point corresponds to the public key (which I think is the case), then doesn't it take the exact same amount of work to compute the public key from the private, as it does the private from the public (both just have to recursively dot a point on the curve)? am I misunderstanding something about what the article is saying?

A: The one-way attribute of ECC and RSA is due to the Chinese Reminder Theoreom (CRT).  A series of arithmetic divisions where only the remainder is kept (aka Modulo operation %), which results in information loss in the output.  As a result, the person with the keys takes one direct path to generate the output - and any would-be attacker has to exhaust a massive number of possible paths in order to determine what key was used to create the output. If the simple division was used instead of a modulo - then key data would be present in the output and it couldn't be used for cryptography.
If you lived in a world where you had a powerful enough computer to exhaust all possibilities - then the CRT wouldn't be useful as a cryptographic primitive.  The computers we have now a fairly powerful - so we balance the power of our modern machines with a keysize that introduces enough range of possibilities so that they cannot be exhausted in a timeframe that matters.
The CRT is a subset of the P vs NP problem set - so perhaps proving P=NP may lead to a way of undermining the oneway aspect of asymmetric cryptography. We know that there is a way to factor CRT using a quantum computer running Shor's Algorithm.  Shor's Algorithm has proven that we can defeat the so-called "trapdoor", or one-way attributes of CRT, it is still however an expensive attack to conduct.
The following lecture is my favorite description of the CRT. It shows that there are many possible solutions for one direction forcing an attacker to exhaust them all and only one solution for the other:
https://www.youtube.com/watch?v=ru7mWZJlRQg

A: EDIT: I previously stated that n is not the private key. In your example, n is either server or client private key.
How it works is that there is a starting point known to anybody.

*

*You select random integer k and do the "dotting operation" k-times. Then you send this new point to the server. (k is your private key)

*Server does the same with the starting point, but q-times and sends it to you. (q is server's private key)

*You take the point you got from server and "dot" it k-times. The final point would be the starting point "dotted" k*q-times.

*Server does the same with point it got from you. And again its final point would be the starting point "dotted" q*k-times.

That means the final point (= the starting point "dotted" k*q-times) is the shared secret since all what any attacker would know is the starting point, the starting point dotted k-times and the starting point dotted q-times. And given only those data, it's practically impossible to find the final point as a product of k*q unless any of those known.
EDIT: No, it doesn't take the same time to compute k from G = kP given known values of G (sent point) and P (starting point). More in comment section and:

*

*For rising to power, see Exponentiation by squaring.

*For ECC point multiplication, see point multiplication.


text:
Q: Hypothesis testing: test involving proportion I am comparing two diff treatments:
H0: p_t1 = p_t2
Ha: p_t1 ≠ p_t2

Treatment 1: 47030 trials, 5390 worked
Treatment 2: 340 trials, 11 worked
from scipy import stats
import numpy as np
trials = np.array([[47030, 5390], [340, 11]])
stats.chi2_contingency(trials)

p-value from above is close to zero so null hyp is rejected. What changes I need to do in my approach to say one treatment is better than other? here I have only tested that they aren't equally effective.....any leads?

A: I think, you made a mistake there:

Treatment 1: 47030 trials, 5390 worked

That means that 47030 - 5390 = 41640 did not work. For the contingency table, you need the number of "worked" and the number of "did not work", not the number of trials.
The same is true for [340, 11] which should be [329, 11].
It will not change the $p$-value a lot in this case, but still.
Once statistical significance is established you can just compare 5390/47030 with 11/340 to see, which one was larger in the sample. The statistical significance then allows you to generalize from the sample to the population.


text:
Q: string is value type or reference type? I have some confusion about string a reference type or value type, I have two variables of type string, I assign value to first variable and then assigned same variable to second variable, If i change anything on first variable value doesn't get change in second variable, as second variable is also pointing to the same location where first one does?
        string string1 = "abc";

        string string2 = string1;

        string1 = "xyz";

here string1 is holding value xyz and string2 is abc

A: Here's what's going on:
string string1 = "abc";

string1 is a reference to the string "abc" which lives on the heap somewhere.
string string2 = string1;

string2 is another reference, that just happens to point to the same place in memory as string1.  That reference was copied over to string2 when you used the assignment operator.  You now have two variables that point to the same place in memory.
string1 = "xyz";

string1 now points to a newly created string that contains "xyz".  string2 still points over to "abc", which is still reachable and won't be garbage collected.
In any case, yes; String is a reference type.


text:
Q: Accessing a website's table with a WinHTTPRequest in Excel VBA I have written code that grabs a table from a website and pulls out each cell from that table and then drops them into an excel spreadsheet. The code works flawlessly when the website loads correctly.
The issue is the website does not play nice with internet explorer, therefore the code only executes successfully about half of the time. I could write a routine that checks to see if the website loaded successfully and repeat if it did not, However I want to see if I can get it to work with a WinHTTPRequest.
The lines below are how I access the table using internet explorer based webscraping, with the last line being how i load the table into a variable.
Set IE = CreateObject("InternetExplorer.Application")
IE.navigate "https://weather.com/weather/tenday/l/12345:4:US"
IE.Visible = True

Application.Wait (Now() + TimeValue("00:02:00"))

Set doc = IE.document

Set WeatherTable = doc.getElementsByClassName("twc-table")(0)

I can load the website in question via WinHTTPRequest using the code below.
Set doc = New HTMLDocument

With CreateObject("WINHTTP.WinHTTPRequest.5.1")
    .Open "GET", "https://weather.com/weather/tenday/l/12345:4:US", False
    .send
    doc.body.innerHTML = .responseText
End With

However when I try and grab the table using the line below i get "Run-time error '438': Object doesn't support this property or method.
Set WeatherTable = doc.getElementByclassname("twc-table")(0)

Basically i need the equivalent of this line for WinHTTP webscraping.
I have looked at descending down through the html document(doc.body.all.item(1), etc) but I don't get very far before I run into errors. I have also looked at the Selenium addon, but I don't remember being able to download and install it successfully, and I am not sure if it is even still maintained for current versions of chrome / firefox.
Here is the full code that allows me to get the table via internet explorer webscraping and then drop it onto an excel spreadsheet.
Any help is appreciated.
Sub GetTable2()

Dim IE As Object
Dim doc As HTMLDocument
Dim WeatherTable As HTMLTable
Dim WeatherTableRows As HTMLTableRow
Dim HTMLTableCell As HTMLTableCell
Dim HeaderRow As Boolean

Dim RowCount As Long
Dim ColumnCount As Long

Dim i As Long

RowCount = 1
ColumnCount = 1
HeaderRow = True

Set IE = CreateObject("InternetExplorer.Application")
IE.navigate "https://weather.com/weather/tenday/l/12345:4:US"
IE.Visible = True

'Application.Wait (Now() + TimeValue("00:02:00"))

Set doc = IE.document

Set WeatherTable = doc.getElementsByClassName("twc-table")(0)

    For Each WeatherTableRows In WeatherTable.Rows
        i = 1
        For Each HTMLTableCell In WeatherTableRows.Cells
            If HeaderRow = True Then
                ThisWorkbook.Sheets("Sheet5").Cells(RowCount, ColumnCount).Value = HTMLTableCell.innerText
                ColumnCount = ColumnCount + 1
            Else
                If i = 1 Then
                    i = i + 1
                Else
                    ThisWorkbook.Sheets("Sheet5").Cells(RowCount, ColumnCount).Value = HTMLTableCell.innerText
                    ColumnCount = ColumnCount + 1
                End If
            End If
        Next HTMLTableCell
        HeaderRow = False
    ColumnCount = 1
    RowCount = RowCount + 1
    Next WeatherTableRows

IE.Quit
Set IE = Nothing
Set doc = Nothing

End Sub

A: You missed an s. It is plural as you are getting a collection of elements by className.
Set WeatherTable = doc.getElementsByClassName("twc-table")(0)

A: To make your approach slightly cleaner, you can try this way as well.
Sub FetchTabularData()
    Dim elem As Object, trow As Object, S$, R&, C&

    [B1:G1] = [{"Day","Description","High/Low","Precip","Wind","Humidity"}]

    With New WinHttp.WinHttpRequest
        .Open "GET", "https://weather.com/weather/tenday/l/12345:4:US", False
        .send
        S = .responseText
    End With

    With New HTMLDocument
        .body.innerHTML = S

        For Each elem In .querySelector(".twc-table").getElementsByTagName("tr")
            For Each trow In elem.getElementsByTagName("td")
                C = C + 1: Cells(R + 1, C) = trow.innerText
            Next trow
            C = 0: R = R + 1
        Next elem
    End With
End Sub

Reference to add:
Microsoft HTML Object Library
Microsoft WinHTTP Services, version 5.1


text:
Q: Is there a way to cast a group of columns to the same NUMBER(p,s) type so that they can be UNPIVOT in Snowflake SQL? I have a table several numeric columns all with different NUMBER(p,s) types. The table was created with a CREATE TABLE xx as (select date, SUM(x), SUM(y) from xxx GROUP BY date). It seems that snowflake decided the minimum NUMBER(precision, scale) required to store each resulting column. That resulting in different types for each column.
Now I want to UNPIVOT those columns and Snowflake will complain that SQL compilation error: The type of column 'xxxxx' conflicts with the type of other columns in the UNPIVOT list
I create this little minimal table to exemplify the problem:
create or replace temporary table temp1(id number, sales number(10,0), n_orders number(20,0)) as (
    select * from (values
           (1, 1, 2 )
           ,(2, 3, 4)
           ,(3, 5, 6)
    )
); -- imagine that temp1 was created via a select AGG1, AGG2 FROM XXX GROUP BY YYY

describe table temp1;
--
name    type    kind    null?   default primary key unique key  check   expression  comment
ID  NUMBER(38,0)    COLUMN  Y       N   N
SALES   NUMBER(10,0)    COLUMN  Y       N   N
N_ORDERS    NUMBER(20,0)    COLUMN  Y       N   N

select *
from temp1 UNPIVOT(measure_value for measure_name in (sales, n_orders)); -- won't work because SALES is NUMBER(10,0) and N_ORDERS is NUMBER(20,0)

Right now my workaround is to cast each columns with a explicit TO_NUMBER(x, 38,0) as x like so:
with t1 as (
  select
    id
    ,TO_NUMBER(sales,38,0) as sales
    ,TO_NUMBER(n_orders, 38,0) as n_orders
  from temp1
)
select * from t1 UNPIVOT(measure_value for measure_name in (sales, n_orders));

This is less than optimal because there are many columns in the actual table that I'm using.
I don't want to recreate the table (the aggregations take long to compute) so what are my options?
Is there a any other syntax that I can use to cast in bulk a list of columns?

A: Your best option is to modify the already create table (without having to rerun the costly aggregation) like so:
alter table temp1 modify
  sales set data type number(38,0)
  ,n_orders set data type number(38,0)
;

This way has two advantages:

*

*you avoid typing the column name twice for each column:  column_name set data type number(38,) instead of TO_NUMBER(column_name, 38,0) as column_name

*It's run just once, instead of having to running as a CTE before each UNPIVOT query.


text:
Q: Drawing border using R in shapefile based on dummy variable? For an analysis in R I want to create a "new" border from a shapefile. The Shapefile comes with a dummy variable (zone_dummy) indicating the regions laying east and west from the border (see example below). Now I wanted to create a geomatric path along the border of the green and red municipalities:

Here is my shapefile and below an example code:
rm(list = ls(all = TRUE))

library(maptools)
library(RColorBrewer)

area <- readShapePoly("VZ250_GEM.shp")

kreise.data<-data.frame(area@data)

zone<-data.frame(c("Weiden i.d. OPf.", "Bad Kissingen", "Schweinfurt", "    Mellrichstadt", "Brückenau", "Rhön-Grabfeld",
               "Hofheim", "Ebern",  "Haßberge", "Coburg", "Hof", "Selb", "Kulmbach",
               "Marktredwitz", "Bayreuth", "Bamberg","Staffelstein", "Lichtenfels", "Kronach",
               "Stadtsteinach", "Naila", "Münchberg", "Rehau", "Wunsiedel", "Weiden",
               "Tirschenreuth", "Kemnath", "Neustadt a.d. Waldnaab", "Bad Neustadt a.d. Saale", "Neustadt b. Coburg", "Vohenstrauß", "Nabburg",
               "Overviechtach", "Waldmünchen", "Cham", "Roding",
               "Deggendorf", "Passau", "Kötzling" ,"Viechtach", "Regen", "Bogen", "Grafenau",
               "Wolfstein", "Wegscheid", "Wunsiedel i. Fichtelgebirge", "Schwandorf", "Freyung-Grafenau"
               ))
#create dummy to mark municipalities in zone
colnames(zone)<-c("GEN_K")
zone$zone_dummy<-1
#merge with original data
kreise.data.zone<-merge(kreise.data, zone, by="GEN_K", all=T)
## Replace NA's with 0
kreise.data.zone[is.na(kreise.data.zone)] <- 0
##Merge assembled Shape-file Data Frame to Original Shapefile
area.zone<-merge(area, kreise.data.zone)
#we only care about bavaria:
bayern<-subset(area.zone, area.zone@data$NUTS1_CODE=="DE2")
#plot a map of bavaria with zone:
my.palette <- brewer.pal(n = 3, name = "Set1")
spplot(bayern, "zone_dummy", cuts = 1 , col.regions = my.palette, col="white", colorkey=FALSE)

My question is now:
How can I create a border along the zone (=sharp border marking the path along the red and green municipalities)?
The idea is to (1) create this border in the shapefile (2) estimate the distance of each municipality in Bavaria to this border.

A: Compute the intersection of both geometries (e.g. sf::st_intersection), here is some R code using the sf package:
library("dplyr")
library("sf")

zone <- c("Weiden i.d. OPf.", "Bad Kissingen", "Schweinfurt",
          "Mellrichstadt", "Brückenau", "Rhön-Grabfeld", "Hofheim", "Ebern",
          "Haßberge", "Coburg", "Hof", "Selb", "Kulmbach", "Marktredwitz",
          "Bayreuth", "Bamberg","Staffelstein", "Lichtenfels", "Kronach",
          "Stadtsteinach", "Naila", "Münchberg", "Rehau", "Wunsiedel",
          "Weiden", "Tirschenreuth", "Kemnath", "Neustadt a.d. Waldnaab",
          "Bad Neustadt a.d. Saale", "Neustadt b. Coburg", "Vohenstrauß",
          "Nabburg", "Overviechtach", "Waldmünchen", "Cham", "Roding",
          "Deggendorf", "Passau", "Kötzling" ,"Viechtach", "Regen", "Bogen",
          "Grafenau", "Wolfstein", "Wegscheid", "Wunsiedel i. Fichtelgebirge",
          "Schwandorf", "Freyung-Grafenau")

shp <- st_read("VZ250_GEM.shp") %>%
       filter(NUTS1_CODE=="DE2") %>%
       mutate(zone=factor(if_else(GEN_K %in% zone, 1, 0)))

border <- st_intersection(st_geometry(filter(shp, zone==1)),
                          st_geometry(filter(shp, zone==0)))

library("ggplot2")
ggplot() +
  geom_sf(data=shp, aes(fill=zone)) +
  geom_sf(data=border, colour="white", size=2)


text:
Q: How to make make subfolder invisible in link? What rule can I make in web.config to make this link:
https://www.example.com/en/product.asp?vare=38948

redirect to:
https://www.example.com/product.asp?vare=38948

The page works so I guess rewrite would work too.