text:
Q: Extract residuals from an XGBoost regression as a single raster In R, using the caret and xgboost packages and this tutorial, I am running an XGBoost regression (XGBR) and I want to extract the residuals of the XGBR. I hyper-tuned the model using the caret package and then, using the 'best' model parameters I used the xgboost package to perform the regression.
My dataset has the ntl, pop, tirs, agbh variables stored in data.frame (ntl is the dependent variable while the other three are the independent). Assuming that my XGBR model is called m and my data.frame is called block.data, I did:
library(caret)
library(terra)
library(xgboost)
library(doParallel)
library(dplyr)
library(ggplot2)
library(glue)
library(ModelMetrics)
library(readr)

wd = "path/"

block.data = read.csv(paste0(wd, "block.data.csv"))

block.data = subset(block.data, select = c(ntl, tirs, pop, agbh))

set.seed(1123)

samp <- sample(nrow(block.data), 0.80 * nrow(block.data))

train <- block.data[samp, ]
train_x <- as.matrix(select(train, -ntl))
train_y <- train$ntl

test <- block.data[-samp, ]
test_x <- select(test, -ntl)
test_y <- test$ntl

no_cores <- detectCores() - 1
cl = makePSOCKcluster(no_cores)
registerDoParallel(cl)

# default model
grid_default <- expand.grid(
  nrounds = 100,
  max_depth = 6,
  eta = 0.3,
  gamma = 0,
  colsample_bytree = 1,
  min_child_weight = 1,
  subsample = 1
)

train_control <- caret::trainControl(
  method = "none",
  verboseIter = FALSE, # no training log
  allowParallel = TRUE # FALSE for reproducible results
)

xgb_base <- caret::train(
  x = train_x,
  y = train_y,
  trControl = train_control,
  tuneGrid = grid_default,
  method = "xgbTree",
  verbose = TRUE
)

# hyperparameter tuning
# setting up the maximum number of trees
nrounds <- 1000

# note to start nrounds from 200, as smaller learning rates result in errors so
# big with lower starting points that they'll mess the scales
tune_grid <- expand.grid(
  nrounds = seq(from = 200, to = nrounds, by = 50),
  eta = c(0.025, 0.05, 0.1, 0.3),
  max_depth = c(2, 3, 4, 5, 6),
  gamma = 0,
  colsample_bytree = 1,
  min_child_weight = 1,
  subsample = 1
)

tune_control <- caret::trainControl(
  method = "cv", # cross-validation
  number = 3, # with n folds
  #index = createFolds(tr_treated$Id_clean), # fix the folds
  verboseIter = FALSE, # no training log
  allowParallel = TRUE # FALSE for reproducible results
)

xgb_tune <- caret::train(
  x = train_x,
  y = train_y,
  trControl = tune_control,
  tuneGrid = tune_grid,
  method = "xgbTree",
  verbose = TRUE
)

tuneplot <- function(x, probs = .90) {
  ggplot(x) +
    coord_cartesian(ylim = c(quantile(x$results$RMSE, probs = probs), min(x$results$RMSE))) +
    theme_bw()
}

tuneplot(xgb_tune)

xgb_tune$bestTune

# find maximum depth
tune_grid2 <- expand.grid(
  nrounds = seq(from = 50, to = nrounds, by = 50),
  eta = xgb_tune$bestTune$eta,
  max_depth = ifelse(xgb_tune$bestTune$max_depth == 2,
                     c(xgb_tune$bestTune$max_depth:4),
                     xgb_tune$bestTune$max_depth - 1:xgb_tune$bestTune$max_depth + 1),
  gamma = 0,
  colsample_bytree = 1,
  min_child_weight = c(1, 2, 3),
  subsample = 1
)

xgb_tune2 <- caret::train(
  x = train_x,
  y = train_y,
  trControl = tune_control,
  tuneGrid = tune_grid2,
  method = "xgbTree",
  verbose = TRUE
)

tuneplot(xgb_tune2)

xgb_tune2$bestTune

# different values for row and column sampling
tune_grid3 <- expand.grid(
  nrounds = seq(from = 50, to = nrounds, by = 50),
  eta = xgb_tune$bestTune$eta,
  max_depth = xgb_tune2$bestTune$max_depth,
  gamma = 0,
  colsample_bytree = c(0.4, 0.6, 0.8, 1.0),
  min_child_weight = xgb_tune2$bestTune$min_child_weight,
  subsample = c(0.5, 0.75, 1.0)
)

xgb_tune3 <- caret::train(
  x = train_x,
  y = train_y,
  trControl = tune_control,
  tuneGrid = tune_grid3,
  method = "xgbTree",
  verbose = TRUE
)

tuneplot(xgb_tune3, probs = .95)

xgb_tune3$bestTune

set.seed(57)
omp_set_num_threads(2) # caret parallel processing threads

# gamma
tune_grid4 <- expand.grid(
  nrounds = seq(from = 50, to = nrounds, by = 50),
  eta = xgb_tune$bestTune$eta,
  max_depth = xgb_tune2$bestTune$max_depth,
  gamma = c(0, 0.05, 0.1, 0.5, 0.7, 0.9, 1.0),
  colsample_bytree = xgb_tune3$bestTune$colsample_bytree,
  min_child_weight = xgb_tune2$bestTune$min_child_weight,
  subsample = xgb_tune3$bestTune$subsample
)

xgb_tune4 <- caret::train(
  x = train_x,
  y = train_y,
  trControl = tune_control,
  tuneGrid = tune_grid4,
  method = "xgbTree",
  verbose = TRUE
)

tuneplot(xgb_tune4)

xgb_tune4$bestTune

# Reducing the Learning Rate
tune_grid5 <- expand.grid(
  nrounds = seq(from = 100, to = 10000, by = 100),
  eta = c(0.01, 0.015, 0.025, 0.05, 0.1),
  max_depth = xgb_tune2$bestTune$max_depth,
  gamma = xgb_tune4$bestTune$gamma,
  colsample_bytree = xgb_tune3$bestTune$colsample_bytree,
  min_child_weight = xgb_tune2$bestTune$min_child_weight,
  subsample = xgb_tune3$bestTune$subsample
)

xgb_tune5 <- caret::train(
  x = train_x,
  y = train_y,
  trControl = tune_control,
  tuneGrid = tune_grid5,
  method = "xgbTree",
  verbose = TRUE
)

tuneplot(xgb_tune5)

xgb_tune5$bestTune

# Fitting the Model
(final_grid <- expand.grid(
  nrounds = xgb_tune5$bestTune$nrounds,
  eta = xgb_tune5$bestTune$eta,
  max_depth = xgb_tune5$bestTune$max_depth,
  gamma = xgb_tune5$bestTune$gamma,
  colsample_bytree = xgb_tune5$bestTune$colsample_bytree,
  min_child_weight = xgb_tune5$bestTune$min_child_weight,
  subsample = xgb_tune5$bestTune$subsample
))

(xgb_model <- caret::train(
  x = train_x,
  y = train_y,
  trControl = train_control,
  tuneGrid = final_grid,
  method = "xgbTree",
  verbose = TRUE
))

stopCluster(cl)

# apply model to the whole data set using xgboost
xgb_m <- xgb.DMatrix(data = data.matrix(block.data), label = block.data$ntl)

m = xgb.train(data = xgb_m,
            max.depth = xgb_tune5$bestTune$max_depth,
            # watchlist = watchlist,
            nrounds = xgb_tune5$bestTune$nrounds,
            min_child_weight = xgb_tune5$bestTune$min_child_weight,
            subsample = xgb_tune5$bestTune$subsample,
            eta = xgb_tune5$bestTune$eta,
            gamma = xgb_tune5$bestTune$gamma,
            colsample_bytree = xgb_tune5$bestTune$colsample_bytree,
            objective = "reg:squarederror")

m

# export xgb residuals
xgb_resids = predict(m, xgb_m, na.rm = TRUE)

sb = c(ntl, pop_res, tirs_res, agbh_res)

xgb_resids = sb$ntl - xgb_resids
plot(xgb_resids)

The plot looks like this:

Obviously, I am doing something very wrong. How can I export the residuals of an XGBR as a single raster?
Here is a very small sample of my dataset:
block.data = structure(list(x = c(11880750L, 11879250L, 11879750L, 11880250L,
11880750L, 11881250L, 11879250L, 11879750L, 11880250L, 11880750L,
11881250L, 11878750L, 11879250L, 11879750L, 11880250L, 11880750L,
11881250L, 11879250L, 11879750L, 11880250L, 11880750L, 11881250L,
11881750L, 11882250L, 11879250L, 11879750L, 11880250L, 11880750L,
11881250L, 11881750L, 11882250L, 11882750L, 11879250L, 11879750L
), y = c(1802250L, 1801750L, 1801750L, 1801750L, 1801750L, 1801750L,
1801250L, 1801250L, 1801250L, 1801250L, 1801250L, 1800750L, 1800750L,
1800750L, 1800750L, 1800750L, 1800750L, 1800250L, 1800250L, 1800250L,
1800250L, 1800250L, 1800250L, 1800250L, 1799750L, 1799750L, 1799750L,
1799750L, 1799750L, 1799750L, 1799750L, 1799750L, 1799250L, 1799250L
), ntl = c(18.7969169616699, 25.7222957611084, 23.4188251495361,
25.4322757720947, 16.4593601226807, 12.7868213653564, 30.9337253570557,
29.865758895874, 30.4080600738525, 29.5479888916016, 24.3493347167969,
35.2427635192871, 38.989933013916, 34.6536979675293, 29.4607238769531,
30.7469024658203, 34.3946380615234, 42.8660278320312, 34.7930717468262,
30.9516315460205, 32.20654296875, 39.999755859375, 46.6002235412598,
38.6480979919434, 60.5214920043945, 33.1799964904785, 31.8498134613037,
30.9209423065186, 32.2269744873047, 53.7062034606934, 45.5225944519043,
38.3570976257324, 123.040382385254, 73.0528182983398), pop = c(19.6407718658447,
610.009216308594, 654.812622070312, 426.475830078125, 66.3839492797852,
10.6471328735352, 443.848846435547, 602.677429199219, 488.478454589844,
387.470947265625, 58.2341117858887, 413.888488769531, 315.057678222656,
354.082946777344, 602.827758789062, 463.518829345703, 296.713928222656,
923.920593261719, 434.436645507812, 799.562927246094, 404.709564208984,
265.043304443359, 366.697235107422, 399.851684570312, 952.2314453125,
870.356994628906, 673.406616210938, 493.521606445312, 273.841888427734,
371.428619384766, 383.057830810547, 320.986755371094, 991.131225585938,
1148.87768554688), tirs = c(39.7242431640625, 44.9583969116211,
41.4048385620117, 42.6056709289551, 40.0976028442383, 38.7490005493164,
44.2747650146484, 43.5645370483398, 41.6180191040039, 40.3799781799316,
38.8664817810059, 44.9089202880859, 44.414306640625, 44.560977935791,
43.1288986206055, 40.9315185546875, 38.8918418884277, 46.3063850402832,
45.5805702209473, 44.9196586608887, 42.2495613098145, 39.3051452636719,
38.7914810180664, 38.6069412231445, 44.6782455444336, 46.4024772644043,
44.4720573425293, 41.7361183166504, 42.3378067016602, 41.0018348693848,
39.3579216003418, 41.6303863525391, 43.8207550048828, 46.0460357666016
), agbh = c(3.32185006141663, 4.98925733566284, 4.35699367523193,
4.94798421859741, 3.14325952529907, 2.93211793899536, 4.52736520767212,
4.99723243713379, 5.13944292068481, 3.92965626716614, 3.43465113639832,
3.55617475509644, 3.4659411907196, 5.24469566345215, 5.36995029449463,
4.61549234390259, 4.82002925872803, 4.20452928543091, 4.71502685546875,
5.20452785491943, 5.05676746368408, 5.9952244758606, 6.16778612136841,
4.69053316116333, 2.62325501441956, 4.74775457382202, 4.93133020401001,
5.02366256713867, 5.74016952514648, 6.28353786468506, 4.67424774169922,
4.56812858581543, 1.88153350353241, 4.31531000137329)), class = "data.frame", row.names = c(NA,
-34L))

My raster layer:
r = new("RasterBrick", file = new(".RasterFile", name = "", datanotation = "FLT4S",
    byteorder = "little", nodatavalue = -Inf, NAchanged = FALSE,
    nbands = 1L, bandorder = "BIL", offset = 0L, toptobottom = TRUE,
    blockrows = 0L, blockcols = 0L, driver = "", open = FALSE),
    data = new(".MultipleRasterData", values = structure(c(NA,
    NA, NA, NA, 18.7969169616699, NA, NA, NA, NA, NA, 25.7222957611084,
    23.4188251495361, 25.4322757720947, 16.4593601226807, 12.7868213653564,
    NA, NA, NA, NA, 30.9337253570557, 29.865758895874, 30.4080600738525,
    29.5479888916016, 24.3493347167969, NA, NA, NA, 35.2427635192871,
    38.989933013916, 34.6536979675293, 29.4607238769531, 30.7469024658203,
    34.3946380615234, NA, NA, NA, NA, 42.8660278320312, 34.7930717468262,
    30.9516315460205, 32.20654296875, 39.999755859375, 46.6002235412598,
    38.6480979919434, NA, NA, 60.5214920043945, 33.1799964904785,
    31.8498134613037, 30.9209423065186, 32.2269744873047, 53.7062034606934,
    45.5225944519043, 38.3570976257324, NA, 123.040382385254,
    73.0528182983398, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    19.6407718658447, NA, NA, NA, NA, NA, 610.009216308594, 654.812622070312,
    426.475830078125, 66.3839492797852, 10.6471328735352, NA,
    NA, NA, NA, 443.848846435547, 602.677429199219, 488.478454589844,
    387.470947265625, 58.2341117858887, NA, NA, NA, 413.888488769531,
    315.057678222656, 354.082946777344, 602.827758789062, 463.518829345703,
    296.713928222656, NA, NA, NA, NA, 923.920593261719, 434.436645507812,
    799.562927246094, 404.709564208984, 265.043304443359, 366.697235107422,
    399.851684570312, NA, NA, 952.2314453125, 870.356994628906,
    673.406616210938, 493.521606445312, 273.841888427734, 371.428619384766,
    383.057830810547, 320.986755371094, NA, 991.131225585938,
    1148.87768554688, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    39.7242431640625, NA, NA, NA, NA, NA, 44.9583969116211, 41.4048385620117,
    42.6056709289551, 40.0976028442383, 38.7490005493164, NA,
    NA, NA, NA, 44.2747650146484, 43.5645370483398, 41.6180191040039,
    40.3799781799316, 38.8664817810059, NA, NA, NA, 44.9089202880859,
    44.414306640625, 44.560977935791, 43.1288986206055, 40.9315185546875,
    38.8918418884277, NA, NA, NA, NA, 46.3063850402832, 45.5805702209473,
    44.9196586608887, 42.2495613098145, 39.3051452636719, 38.7914810180664,
    38.6069412231445, NA, NA, 44.6782455444336, 46.4024772644043,
    44.4720573425293, 41.7361183166504, 42.3378067016602, 41.0018348693848,
    39.3579216003418, 41.6303863525391, NA, 43.8207550048828,
    46.0460357666016, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    3.32185006141663, NA, NA, NA, NA, NA, 4.98925733566284, 4.35699367523193,
    4.94798421859741, 3.14325952529907, 2.93211793899536, NA,
    NA, NA, NA, 4.52736520767212, 4.99723243713379, 5.13944292068481,
    3.92965626716614, 3.43465113639832, NA, NA, NA, 3.55617475509644,
    3.4659411907196, 5.24469566345215, 5.36995029449463, 4.61549234390259,
    4.82002925872803, NA, NA, NA, NA, 4.20452928543091, 4.71502685546875,
    5.20452785491943, 5.05676746368408, 5.9952244758606, 6.16778612136841,
    4.69053316116333, NA, NA, 2.62325501441956, 4.74775457382202,
    4.93133020401001, 5.02366256713867, 5.74016952514648, 6.28353786468506,
    4.67424774169922, 4.56812858581543, NA, 1.88153350353241,
    4.31531000137329, NA, NA, NA, NA, NA, NA), .Dim = c(63L,
    4L)), offset = 0, gain = 1, inmemory = TRUE, fromdisk = FALSE,
        nlayers = 4L, dropped = NULL, isfactor = c(FALSE, FALSE,
        FALSE, FALSE), attributes = list(), haveminmax = TRUE,
        min = c(12.7868213653564, 10.6471328735352, 38.6069412231445,
        1.88153350353241), max = c(123.040382385254, 1148.87768554688,
        46.4024772644043, 6.28353786468506), unit = "", names = c("ntl",
        "pop", "tirs", "agbh")), legend = new(".RasterLegend",
        type = character(0), values = logical(0), color = logical(0),
        names = logical(0), colortable = logical(0)), title = character(0),
    extent = new("Extent", xmin = 11878500, xmax = 11883000,
        ymin = 1799000, ymax = 1802500), rotated = FALSE, rotation = new(".Rotation",
        geotrans = numeric(0), transfun = function ()
        NULL), ncols = 9L, nrows = 7L, crs = new("CRS", projargs = NA_character_),
    srs = character(0), history = list(), z = list())

A: I found this solution:
d <- tibble(pred = predict(f, newdata = xs)
, obs = mtcars$mpg) %>%
mutate(resid = pred - obs,
resid_sq = resid^2)

and then I cbind the d with the coordinates from my raster data and I create the residuals raster.


text:
Q: Vue+PHP+render, возможно ли? Всех приветствую!
Есть сайт, написанный на PHP. У него есть страница каталога, где настроено все SEO.
Ради ускорения появилась идея написать рендер страницы на Vue, но при этом оставить и серверную часть.

Появились вопросы:
1) Можно использовать vue cli с однофайловыми компонентами, генерируя index.php страницу вместо index.html.
2) Будет ли скрипт vue выполняться на готовом html коде, который отдаст php файл? я понимаю, что в теории нет, но нужно мнение знающих людей
3) Есть ли способ еще лучше это все организовать?

A: Сам спросил, сам и отвечу:
1) Не желательно!
НО можно просто генерировать через webpack готовый bundle. Настройки webpack'а:
{
    "name": <your-project-name>,
    "scripts": {
        "watch": "webpack -w",
        "build": "webpack"
    },
    "devDependencies": {
        "vue-loader": "^15.7.1",
        "vue-template-compiler": "^2.6.10",
        "webpack": "^4.41.1",
        "webpack-cli": "^3.3.9"
    },
    "dependencies": {
        "vue": "^2.6.10"
    }
}

2) Теория подтвердилась, при загрузке страницы vue инициализирует рендеринг по виртуальному дому. При рендеринге, умная система понимает, что дом не изменен, и вставлять (обновлять) ничего не надо.
След если у нас есть готовый html с сервера, то vue инициализируется без обновления реального DOM дерева
3) Тут уже дело каждого, под какие задачи он использует vue

redpajama_set_name: RedPajamaStackExchange


text:
Q: AWS network Load Balancer CloudFormation IP In my CloudFormation template I created elastic IP and network load balancer.
There is no problem during creating:
  Subnet1a:
    Type: AWS::EC2::Subnet
    Properties:
      VpcId:
        Ref: VPC
    AvailabilityZone: 'eu-west-1a'
    CidrBlock:
      Ref: 042SubnetCidr
    MapPublicIpOnLaunch: true

  LoadBalancerElasticIP:
    Type: AWS::EC2::EIP

  LoadBalancer:
    Type: AWS::ElasticLoadBalancingV2::LoadBalancer
    Properties:
      IpAddressType: ipv4
      Name: network-loadbalancer
      Scheme: internet-facing
      Subnets:
       - Ref: Subnet1a
    Type: network

Listeners and Target Groups are created separately and also are working with LB without elastic IP.
Now I'm trying to assign this elastic IP to load balancer, by chaning Subnets to SubnetMappings property, but it's gaving me error: "LoadBalancer   CREATE_FAILED   Property SubnetId cannot be empty."
  LoadBalancer:
    Type: AWS::ElasticLoadBalancingV2::LoadBalancer
    Properties:
      IpAddressType: ipv4
      Name: network-loadbalancer
      Scheme: internet-facing
      SubnetMappings:
        - AllocationId: !Ref LoadBalancerElasticIP
        - SubnetId: !Ref Subnet1a
    Type: network

I've been trying different solutions for a while. Can't see what's wrong. Any ideas? Should I create network interface? And Assign eip to interface then interface to load balancer?

A: Based on the documentation of AWS::ElasticLoadBalancingV2::LoadBalancer the expected value of SubnetMappings is List of SubnetMapping but you are passing two lists. You should change it to the following:
  LoadBalancer:
    Type: AWS::ElasticLoadBalancingV2::LoadBalancer
    Properties:
      IpAddressType: ipv4
      Name: network-loadbalancer
      Scheme: internet-facing
      SubnetMappings:
        - AllocationId: !Ref LoadBalancerElasticIP
          SubnetId: !Ref Subnet1a


text:
Q: Perl - undefined subroutine I have the following Perl code:
use Email::Sender::Simple;
use IO::Socket::SSL;

IO::Socket::SSL::set_defaults(SSL_verify_mode => SSL_VERIFY_NONE);

Email::Sender::Simple::sendmail($email, { transport => $transport });

When I run it I get this error:
Undefined subroutine &Email::Sender::Simple::sendmail called at script.pl line 73.

If I change the code to have the following, then it works:
use Email::Sender::Simple qw(sendmail);

sendmail($email, { transport => $transport });

Can someone explain why I had to change the code for sendmail, while I did NOT have to change the code for set_defaults to look like:
use IO::Socket::SSL qw(set_defaults);

set_defaults(SSL_verify_mode => SSL_VERIFY_NONE);

A: Take a look at the code Email/Sendmail/Simple.pm. There is no sendmail subroutine in that program. Instead, if you look at the header, you'll see:
use Sub::Exporter -setup => {
  exports => {
    sendmail        => Sub::Exporter::Util::curry_class('send'),
    try_to_sendmail => Sub::Exporter::Util::curry_class('try_to_send'),
  },
};

I'm not familiar with Sub::Exporter, but I did notice this description.

The biggest benefit of Sub::Exporter over existing exporters (including the ubiquitous Exporter.pm) is its ability to build new coderefs for export, rather than to simply export code identical to that found in the exporting package.

Oh...
So, the purpose of using Sub::Exporter is to export subroutine names that aren't subroutines in your package.
If you're interested, you can read the tutorial of Sub::Exporter, but it appears it has the ability to export subroutines under different names.
Thus, Email::Sender::Simple::sendmail isn't a subroutine, but that sendmail can still be exported.


text:
Q: Pig - How to use a nested for loop in pig to get the list of elements inside a tuple? I have an intermediate pig structure like
(A, B, (n. no Cs))
example:
(a1,b1, (c11,c12))
(a2,b2, (c21))
(a3,b3, (c31,c32, c33))

Now, I want the data in format
(a1, b1, c11)
(a1, b2, c12)
(a2, b2, c21) etc.

How do I go about doing it?
Essentially I want the size of the tuples, and then use this size for running a nested for loop.

A: Can you try the below approach?
input
a1      b1      (c11,c12)
a2      b2      (c21)
a3      b3      (c31,c32,c33)

PigScript:
A = LOAD 'input' AS(f1,f2,T:(f3:chararray));
B = FOREACH A GENERATE f1,f2,FLATTEN(T);
C = FOREACH B GENERATE f1,f2,FLATTEN(TOKENIZE(T::f3));
DUMP C;

Output:
(a1,b1,c11)
(a1,b1,c12)
(a2,b2,c21)
(a3,b3,c31)
(a3,b3,c32)
(a3,b3,c33)


text:
Q: Button spacing on UIToolbar I am having a problem with the spacing of my button on my UIToolbar look at this images:
Here is my current out put it's a UIButton on a UIBarButtonItem and it's not the desired spacing that i am trying to do, i just set it on its nib file and they can't get any closer to each other.

and here is the output that i want.

Do you how can i set the spacing? by code or by its nib file?
thanks in advance!

A: NSMutableArray *baritem =[NSMutableArray array];
[baritem addObject:return_button];
[baritem addObject:SYSBARBUTTON(UIBarButtonSystemItemFlexibleSpace, nil)];
[baritem addObject:preview];
[baritem addObject:SYSBARBUTTON(UIBarButtonSystemItemFlexibleSpace, nil)];
[baritem addObject:play_button];
[baritem addObject:SYSBARBUTTON(UIBarButtonSystemItemFlexibleSpace, nil)];
[baritem addObject:next];
[baritem addObject:SYSBARBUTTON(UIBarButtonSystemItemFlexibleSpace, nil)];

#define SYSBARBUTTON(ITEM, SELECTOR) [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:ITEM target:self action:SELECTOR] autorelease]

by this i am setting space

A: If you are using .xib file then you can use "Flexible space bar button Item or fixed space bar button item"
by using these between your toolbar items you can assign the space between them..
Its pretty handy and works good


text:
Q: Binding a Tekton Workspace directory to a VolumeMount We have a Tekton pipeline from which we want to run our ReadyAPI test suites. We're using the official image from SmartBear (https://hub.docker.com/r/smartbear/ready-api-soapui-testrunner).
The image requires that you bind the /project folder in the container to the host directory where the ReadyAPI test project is located. In our case, our test project is located in the Tekton Workspace directory common-workspace/application-foo/tests/application-foo-readyapi-project.xml.
When running the container image locally (with docker run), I would just add an argument -v="common-workspace/application-foo/tests/":/project. I can't figure out how to do this mapping in a Tekton Task. Here is the entire Task definition:
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: run-readyapi-tests
spec:
  workspaces:
    - name: source
  steps:
    - name: run-test-suite
      image: image-registry.openshift-image-registry.svc:5000/cicd/ready-api-soapui-testrunner:3.20.0
      volumeMounts:
        - name: readyapi-project
          mountPath: /project
      env:
        - name: LICENSE_SERVER
          value: "a.b.c.d:1234"
        - name: COMMAND_LINE
          value: "/project/application-foo-readyapi-project.xml"
  volumes:
    - name: readyapi-project
      [some binding mechanism here]

Looking at the official docs on volume binding
with hostPath (https://kubernetes.io/docs/concepts/storage/volumes/#hostpath), I was hoping I could do something like this, but this doesn't work for some reason:
  volumes:
    - name: readyapi-project
      hostPath:
        path: common-workspace/application-foo/tests

So how can I bind volumeMounts to actual directories on the host? Any clues?
Update:
When looking at the pods in OpenShift, this Task has a CreateContainerError status. In the Events view, this is the error message that is displayed: "Error: failed to mkdir common-workspace/application-foo/tests: mkdir common-workspace: operation not permitted"
I don't understand why it tries to create the common-workspace folder, since it already exists. I have verified that the entire path exists when using the emptyDir volume type, and then running ls /workspace/source/common-workspace/application-foo/tests. This prints out the test project's XML file.

A: Try this:
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: run-readyapi-tests
spec:
  workspaces:
    - name: source
      mountPath: /project
  steps:
    - name: run-test-suite
      image: image-registry.openshift-image-registry.svc:5000/cicd/ready-api-soapui-testrunner:3.20.0
      env:
        - name: LICENSE_SERVER
          value: "a.b.c.d:1234"
        - name: COMMAND_LINE
          value: "/project/application-foo-readyapi-project.xml"

You can set arbitrary mountPaths for your Tasks workspaces. The default being to mount them into /workspace/${name}.
You don't need the volumeMounts from your initial post. You could use it, if you had some volumes defined some place, but since you're only using workspaces here: they would be automatically mounted in all steps container from your Task.


text:
Q: ##[error]Project file(s) matching the specified pattern were not found I am having problems with a build pipeline.

The agent pools is hosted VS2017
The YAML is
pool:
  vmImage: 'VS2017-Win2016'

variables:
  buildConfiguration: 'Debug'

steps:
- task: DotNetCoreInstaller@0
  displayName: 'Use .NET Core sdk 2.1.5'
  inputs:
    version: 2.1.403

- task: DotNetCoreCLI@2
  displayName: Restore
  inputs:
    command: restore

    projects: '**/Api*.csproj'

#Your build pipeline references an undefined variable named 'Parameters.projects'. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references the 'BuildConfiguration' variable, which you've selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971
- task: DotNetCoreCLI@2
  displayName: Build
  inputs:
    projects: '$(Parameters.projects)'

    arguments: '--configuration $(BuildConfiguration)'

#Your build pipeline references an undefined variable named 'Parameters.projects'. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references the 'BuildConfiguration' variable, which you've selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971

- task: DotNetCoreCLI@2
  displayName: Publish
  inputs:
    command: publish

    publishWebProjects: false

    projects: '$(Parameters.projects)'

    arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)'

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'

When it runs, the build task has the following log
2018-10-29T18:28:43.7087338Z ##[section]Starting: Build
2018-10-29T18:28:43.7093502Z ==============================================================================
2018-10-29T18:28:43.7093580Z Task         : .NET Core
2018-10-29T18:28:43.7093785Z Description  : Build, test, package, or publish a dotnet application, or run a custom dotnet command. For package commands, supports NuGet.org and authenticated feeds like Package Management and MyGet.
2018-10-29T18:28:43.7093818Z Version      : 2.141.0
2018-10-29T18:28:43.7093864Z Author       : Microsoft Corporation
2018-10-29T18:28:43.7093895Z Help         : [More Information](https://go.microsoft.com/fwlink/?linkid=832194)
2018-10-29T18:28:43.7093925Z ==============================================================================
2018-10-29T18:28:44.4833128Z [command]C:\Windows\system32\chcp.com 65001
2018-10-29T18:28:44.4926077Z Active code page: 65001
2018-10-29T18:28:45.1965225Z ##[error]Project file(s) matching the specified pattern were not found.
2018-10-29T18:28:45.2037015Z ##[section]Finishing: Build

I note that the log refers to 2.141.0  where as I am restoring the latest SDK 2.1.403  Why would that be? Could it be that the hosted VS2017 agent does not support the latest version of .netcore?
[Update]
I added a variable for Parameters.projects

However the build task has an error still.
2018-10-29T21:07:38.6774331Z ##[section]Starting: Build
2018-10-29T21:07:38.6781540Z ==============================================================================
2018-10-29T21:07:38.6781632Z Task         : .NET Core
2018-10-29T21:07:38.6781676Z Description  : Build, test, package, or publish a dotnet application, or run a custom dotnet command. For package commands, supports NuGet.org and authenticated feeds like Package Management and MyGet.
2018-10-29T21:07:38.6781762Z Version      : 2.141.0
2018-10-29T21:07:38.6781807Z Author       : Microsoft Corporation
2018-10-29T21:07:38.6781853Z Help         : [More Information](https://go.microsoft.com/fwlink/?linkid=832194)
2018-10-29T21:07:38.6781915Z ==============================================================================
2018-10-29T21:07:39.5030735Z [command]C:\Windows\system32\chcp.com 65001
2018-10-29T21:07:39.5157531Z Active code page: 65001
2018-10-29T21:07:39.5840366Z ##[error]Project file(s) matching the specified pattern were not found.
2018-10-29T21:07:39.5916864Z ##[section]Finishing: Build

A: You need to define in the build task which .csproj files you want to build.
In your case, the definition is in a variable $(Parameters.projects).
- task: DotNetCoreCLI@2
  displayName: Build
  inputs:
    projects: '$(Parameters.projects)'

    arguments: '--configuration $(BuildConfiguration)'

You can replace this variable in your .csproj (e.g. **/*.csproj for all .csproj files in all subfolders):
- task: DotNetCoreCLI@2
  displayName: Build
  inputs:
    projects: '**/*.csproj'

    arguments: '--configuration $(BuildConfiguration)'

Or go to the variables tab and add the Parameters.projects variable:

A: Posting just in case this helps anyone in the future
I had my vmImage set as ubuntu with the following set:
projects: '**\*.csproj'

The backslash was throwing things off, I had to switch to the following:
projects: '**/*.csproj'

I copied from a guide that was assuming Windows. Subtle enough, it took me a while to notice

A: I am trying to build and publish a multiproject solution in dotnet core.
The solution structure is:
sampleTest.API
      sampleTest.API.csproj
sampleTest.Data
      sampleTest.Data.csproj
sampleTest.Identity
      sampleTest.Identity.csproj
sampleTest.Web
      sampleTest.Web.csproj
sampleTest.sln

Now, I just want to build the sampleTest.API dotnet core project. I just need to define in the build task, the path to the project as shown below.
The yaml file for build task for the pipeline in Azure Deveops is shown below:
steps:
- task: DotNetCoreCLI@2
  displayName: Build
  inputs:
    projects: 'sampleTest.API/*.csproj'
    arguments: '--configuration $(BuildConfiguration)'

If we need to build based on searching for all the 'cs.proj' files - we do
projects: '**/*.csproj'

Sample build task using the classic Editor in Azure Devops is shown below:


text:
Q: AltBeacon api return empty collection while ranging beacons I am trying to range beacons and I am doing exactly what it is written here:
http://altbeacon.github.io/android-beacon-library/samples.html
didRangeBeaconsInRegion method is firing but always with empty collection.
I have installed "locate" by altbeacon and it located 3 beacons.
this is my code: am I missing something?
public  class BeaconSingletone implements BeaconConsumer {

    private static BeaconSingletone instance;

    private final org.altbeacon.beacon.BeaconManager beaconManager2;
    private  ArrayList<BeaconThin> listNearBeacons = new ArrayList<>();

    BeaconRegion region = new BeaconRegion("ranged region",
                              UUID.fromString("B9407F30-F5F8-466E-AFF9-25556B57FE6D"), null, null);

    private List<EventInterface> listeners = new ArrayList<EventInterface>();

    private BeaconSingletone()
    {

        beaconManager2 = org.altbeacon.beacon.BeaconManager.getInstanceForApplication(ar_activity.get());
        // To detect proprietary beacons, you must add a line like below corresponding to your beacon
        // type.  Do a web search for "setBeaconLayout" to get the proper expression.
         beaconManager2.getBeaconParsers().add(new BeaconParser().
                setBeaconLayout("m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"));
        beaconManager2.bind(this);

    public static BeaconSingletone getInstance() {
        if(instance == null) {
            instance = new BeaconSingletone();
        }
        return instance;
    }
    private void showNotification(Region region, final List<Beacon> list) {
        listNearBeacons.clear();
        listNearBeacons.add(new BeaconThin(3514,7580,-1));
        for (Iterator<EventInterface> i = listeners.iterator(); i.hasNext(); ) {
            EventInterface item = i.next();
            //item.NewBeaconFound(list.get(0).getMajor(),list.get(0).getMinor(),Utils.computeAccuracy(list.get(0)));
            item.NewBeaconsFound(listNearBeacons);
        }
        return;

    }

    @Override
    public void onBeaconServiceConnect() {
        beaconManager2.addRangeNotifier(new RangeNotifier() {
            @Override
            public void didRangeBeaconsInRegion(Collection<org.altbeacon.beacon.Beacon> beacons, org.altbeacon.beacon.Region region) {
                if (beacons.size() > 0) {
                    Log.i("BeaconManager", "The first beacon I see is about "+beacons.iterator().next().getDistance()+" meters away.");
                }
            }
        });
        try {
            beaconManager2.startRangingBeaconsInRegion(new org.altbeacon.beacon.Region("mybeacons", null, null, null));
        } catch (RemoteException e) {    }{

    }

    }

    @Override
    public Context getApplicationContext() {
        return ar_activity.get();
    }

    @Override
    public void unbindService(ServiceConnection serviceConnection) {
        ar_activity.get().unbindService(serviceConnection);
    }

    @Override
    public boolean bindService(Intent intent, ServiceConnection serviceConnection, int i) {
        return ar_activity.get().bindService(intent, serviceConnection, i);
    }
}

A: You need to add a beacon layout for the beacon type you are using (iBeacon?). Replace this line:
beaconManager2.getBeaconParsers().add(new BeaconParser().
                setBeaconLayout("m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"));
With the proper layout from here:
https://beaconlayout.wordpress.com


text:
Q: Compiling an individual kernel module (Debian/Ubuntu) I need to modify the ELF loader's kernel implementation of an Ubuntu 14.04 distribution. Having downloaded the sources using:
sudo apt-get source linux-image-$(uname -r)

I ran the configuration script:
make config

in the root source tree. After a seemingly endless sequence of input requests, the script created the .config file needed to build the kernel(or a set of modules). The kernel version I am using is linux-3.13.0 and has the following source tree layout:
$ ls
arch   COPYING  crypto         Documentation  dropped.txt  FileSystemMakefile  fs       init  Kbuild   kernel  MAINTAINERS  mm   README          samples  security   sound  ubuntu  virt
block  CREDITS  debian.master  drivers        elf.dat      firmware            include  ipc   Kconfig  lib     Makefile     net  REPORTING-BUGS  scripts  shortcuts  tools  usr

The ELF loader is located in /path/to/source/fs/binfmt_elf.c. Following this question,in order to compile an individual module it is sufficient to run
make /path/to/module/directory

In this case that would be:
make ./path/to/source/fs

The compilation is quite lengthy; it takes about twenty minutes(on a virtual machine) and the output is written(by default) in the same directory in which the module is located. I've found the object files by running:
find . -name "*.o"

in /path/to/source/fs. Filtering by name the ELF loader can be located by running:
find . -name "*elf*.o"

In the current sources it is written(by default) in:
/path/to/source/fs/binfmt_elf.o

Having gone through this tutorial, I've noticed that kernel modules have the naming convention [module_name].ko in order to distinguish them from user space object files.
My question is how can I insert the new(modified) ELF loader into the kernel given that the current ELF loader is present(as unloading it may prevent binaries from being executed)?
Edit #1:
Running lsmod gives:
$ lsmod
Module                  Size  Used by
nls_utf8               12557  1
isofs                  39835  1
vboxsf                 39690  0
snd_intel8x0           38153  2
snd_ac97_codec        130285  1 snd_intel8x0
ac97_bus               12730  1 snd_ac97_codec
snd_pcm               102099  2 snd_ac97_codec,snd_intel8x0
snd_page_alloc         18710  2 snd_intel8x0,snd_pcm
snd_seq_midi           13324  0
snd_seq_midi_event     14899  1 snd_seq_midi
rfcomm                 69160  0
snd_rawmidi            30144  1 snd_seq_midi
bnep                   19624  2
bluetooth             391196  10 bnep,rfcomm
snd_seq                61560  2 snd_seq_midi_event,snd_seq_midi
snd_seq_device         14497  3 snd_seq,snd_rawmidi,snd_seq_midi
snd_timer              29482  2 snd_pcm,snd_seq
joydev                 17381  0
snd                    69238  12 snd_ac97_codec,snd_intel8x0,snd_timer,snd_pcm,snd_seq,snd_rawmidi,snd_seq_device,snd_seq_midi
serio_raw              13462  0
vboxguest             248441  7 vboxsf
i2c_piix4              22155  0
soundcore              12680  1 snd
mac_hid                13205  0
parport_pc             32701  0
ppdev                  17671  0
vboxvideo              12658  0
drm                   303102  1 vboxvideo
lp                     17759  0
parport                42348  3 lp,ppdev,parport_pc
hid_generic            12548  0
usbhid                 52570  0
hid                   106148  2 hid_generic,usbhid
psmouse               106678  0
ahci                   25819  2
libahci                32560  1 ahci
e1000                 145174  0

Which module needs to be compiled as a LKM in order to include the ELF loader. By default the loader is built into the base kernel.

A: Try this:
How do I build a single in-tree kernel module?
Alternatively, the way I normally do this is something like the following.  This is from memory and may or may not work for you.  It also builds all the modules.
Install current kernel source:
apt-get source linux-image-$(uname -r)
cd /usr/src/linux-$(uname -r)
cp /boot/config-$(uname -r) .
make menuconfig
... enable the device

then...
make modules
make modules_install
reboot

Some devices need to be added the module name to /etc/modules if it doesn't get automatically loaded.


text:
Q: In Angular 9, can I store a property in a place where all components can reference? I'm using Angular 9.  I have this in most of my components' ...
import { DeviceDetectorService } from 'ngx-device-detector';
...

export class FirstComponent implements OnChanges, OnInit {
    ...

  isMobile: boolean = false;

  constructor(private deviceService: DeviceDetectorService) { }

  ngOnInit(): void {
    this.isMobile = this.deviceService.isMobile();
  }

and then in the components themselves I have
<mat-table *ngIf="isMobile" #table [dataSource]="dataSource">
...
</mat-table>

<mat-table *ngIf="!isMobile" #table [dataSource]="dataSource">
...
</mat-table>

My question is, is there a more efficient way of doing this, in other words, can I place the "isMobile" property in one place and have all my components reference that place instead of defining it in each of my components?


text:
Q: Pinterest button on page tab app in Facebook Can anyone answer this ?
Trying to get Pinterest button onto a facebook page tab app for an image to be pinned. With the documentation at pinterest, its based on an actual link in the code. Since I do not know the page tab url for the app, is there any other way round this ?
Thanks

A: Why don't you know the page tab URL? Unless I'm missing something in the question, wouldn't it be something along the lines of...
https://www.facebook.com/cocacola/app_161193133389
...where "cocacola" is the page name and "161193133389" is the app ID?
And if THAT doesn't work for some reason, you could capture the URL with window.location.href, no?


text:
Q: Pyspark: Comparing two different dataframes by looping through a reference list to create a flag I have 2 tables like below:
Table1: This shows the items that were bought by ppl in areas
PersonID    Item_Code   Item_Name   Area_code
5000        ABC-000     Item1       12345
5000        ABC-001     Item2       12345
5000        ABC-002     Item3       12345
5000        ABC-003     Item4       12345
5000        ABC-004     Item5       12345
5001        AAB-001     Item11      10000
5001        AAB-002     Item12      10000
5001        AAB-003     Item13      10000
5001        AAB-004     Item14      10000
5001        AAB-005     Item15      10000

Table 2: This has the list of all items that is available in that area.
Item_Code   Area_code
ABC-000     12345
ABC-001     12345
ABC-002     12345
ABC-003     12345
ABC-004     12345
AAB-001     10000
AAB-002     10000
AAB-003     10000
AAB-004     10000
AAB-005     10000

I'm trying to create a test to use table 2 as the master list (for count of items by area) and see if I'm getting the same (item code by area and count). So the end result should be whether the count of items by area match or not.
I can get the count by querying like this in Pyspark:
(df.filter((df.area_code == "12345")).groupBy('Item_count').count().count())

But I'm not sure how to create a function to compare these 2 tables using a large list of area codes. But the pseudo code is something like:
area_code_sample_list == [12345, 10000]

for i in area_code_sample_list:
  cnt1 = (df.filter((df.area_code == "i")).groupBy('Item_count').count().count())
  cnt2 = (df2.filter((df2.area_code == "i")).groupBy('Item_count').count().count())
  # compare cnt1 and cnt2 and create flag

A: Since it is spark, we can unleash the power of joins. What you can do is :

*

*Group by and count on Item_code and Area_code on Table 1 and get a dataframe (df_1)
df_1 = df_tb1.groupby(["Item_code", "Area_code"]).count()

*Similarly on Table 2 and get another dataframe (df_2)
df_2 = df_tb2.groupby(["Item_code", "Area_code"]).count()

*Do an outer join df_1 and df_2 on Item_code and Area_code
df_join = df_1.join(df_2, (df_1.Item_code == df_2.Item_code) & (df_1.Area_code == df_2.Area_code), how="outer").fillna(0)

*Compare the counts.


text:
Q: Unknown column in 'where clause' while using detachedcriteria with collections property I have 3 tables : BookInfo, AuthorInfo and BookAuthors
BookInfo has one to many relationship with BookAuthors.
Mapping in BookInfo.hbm.xml :
<set name="bookAuthorsesByBookId" inverse="true">
    <key>
        <column name="book_id" not-null="true"/>
    </key>
    <one-to-many not-found="ignore" class="com.pojo.hibernate.BookAuthors"/>
</set>

BookAuthors contain bookInfo and authorInfo.
Mapping in BookAuthors.hbm.xml :
<composite-id mapped="true" class="com.pojo.hibernate.BookAuthors">
    <key-many-to-one name="bookInfoByBookId" class="com.pojo.hibernate.BookInfo" column="book_id"/>
    <key-many-to-one name="authorInfoByAuthorId" class="com.pojo.hibernate.AuthorInfo" column="author_id"/>
</composite-id>

And, relationship between AuthorInfo and BookAuthors is one-to-many,too.
Mapping in AuthorInfo.hbm.xml :
<set name="bookAuthorsesByAuthorId" inverse="true">
    <key>
        <column name="author_id" not-null="true"/>
    </key>
    <one-to-many not-found="ignore" class="com.pojo.hibernate.BookAuthors"/>
</set>

Now, i'm trying to get all books which has author name = "authorname" using detachedcriteria like this :
DetachedCriteria detachedCriteria = DetachedCriteria.forClass(BookInfo.class,"bookInfo");
detachedCriteria.createAlias("bookInfo.bookAuthorsesByBookId","bookAuthorses");
detachedCriteria.createAlias("bookAuthorses.authorInfoByAuthorId", "authorInfo");

detachedCriteria.add(Restrictions.like("authorInfo.authorName", searchQuery, MatchMode.ANYWHERE));

hibernateTemplate.findByCriteria(detachedCriteria);

But, it generates an error.
Summarized error :
org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; SQL [select this_.book_id as book1_7_2_,....]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query
Caused by: org.hibernate.exception.SQLGrammarException: could not execute query
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'authorinfo2_.author_name' in 'where clause'

and the query it generates is :
select this_.book_id as book1_7_2_, ... from book.book_info this_
inner join book.book_authors authors1_ on this_.book_id=authors1_.book_id
where (author2_.author_name like ?)

Full Query : *
SELECT this_.book_id              AS book1_7_2_,
   this_.isbn_10              AS isbn2_7_2_,
   this_.isbn_13              AS isbn3_7_2_,
   this_.book_title           AS book4_7_2_,
   this_.book_subtitle        AS book5_7_2_,
   this_.book_description     AS book6_7_2_,
   this_.no_of_pages          AS no7_7_2_,
   this_.book_mrp             AS book8_7_2_,
   this_.book_language        AS book9_7_2_,
   this_.book_format          AS book10_7_2_,
   this_.book_img_url         AS book11_7_2_,
   this_.publishing_date      AS publishing12_7_2_,
   this_.verified             AS verified7_2_,
   this_.publisher_id         AS publisher14_7_2_,
   publisher3_.publisher_id   AS publisher1_19_0_,
   publisher3_.publisher_name AS publisher2_19_0_,
   bookauthor1_.book_id       AS book1_5_1_,
   bookauthor1_.author_id     AS author2_5_1_
FROM   book.book_info this_
   INNER JOIN book.publisher_info publisher3_
           ON this_.publisher_id = publisher3_.publisher_id
   INNER JOIN book.book_authors bookauthor1_
           ON this_.book_id = bookauthor1_.book_id
WHERE  ( ( this_.book_title LIKE ?
        OR authorinfo2_.author_name LIKE ?
        OR publisher3_.publisher_name LIKE ?
        OR this_.isbn_10 LIKE ?
        OR this_.isbn_13 LIKE ? )
     AND 1 = 1 )


text:
Q: JSP : Different view result MVC1 and MVC2 in my project. Why is it? I made a some page using MVC2. But it can't display all data that model component called.
So I try to make page using MVC1. It worked.
I wonder why 2 pages are different. Why It is?
// This is the view - MVC1(bottom in photo - AdminMemberList.jsp), MVC(top in photo - AdminMemberList.do)

// This is the result of model output data(in console) - same MVC1 and MVC2
Member [id=aaaa, point=50, birthday=1923-01-01, email=dwd@google.com]
Member [id=admin, point=40, birthday=1999-01-03, email=ks@nad.com]
Member [id=bbbb, point=20, birthday=1454-09-03, email=bbb]
Member [id=bbbbbb, point=10, birthday=1970-01-01, email=bb@bd.com]
Member [id=david, point=10, birthday=1990-12-30, email=dkakd@gmd.com]
Member [id=davidhong, point=10, birthday=1967-03-09, email=hong@dsd.com]
Member [id=happy, point=30, birthday=1983-03-02, email=gg@gg.com]
Member [id=imyourman, point=10, birthday=1978-02-02, email=kakd@ddl.com]
Member [id=kaaf, point=10, birthday=1978-07-03, email=akd@em]
Member [id=solomon, point=10, birthday=1989-09-12, email=solomon@gmail.com]
Member [id=sunny, point=10, birthday=1985-04-02,email=akdfjl@em.com]
Member [id=xxxxxx, point=10, birthday=1982-01-01, email=del@do.com]

//   AdminMemberList.jsp - This is view component : MVC1 & MVC2 same

    <jsp:include page="ConnectDB.jsp"/>
    <jsp:include page="CommonTopmenu.jsp" flush="false"/>

Member Info

                <button type="button" id="ajaxDeleteMemberData" class="btn btn-sm btn-primary">Remove</button>
                <button type="button" id="ajaxUpdateMemberData" class="btn btn-sm btn-primary">Update</button>
                Total : ${countMember} people

                            <input type="checkbox" id="changeChecking" name="changeChecking">
                            ID	 Point
                            Birthday	 Email	 Regdate	 Password

                    <c:forEach items="${articleList}" var="article">

                            <input type="checkbox" class="tr_check" name="check2">
                            ${article.id}
                            <input type="number" class="point" name="${article.id}" min="0" max="300" step="10"
                                        value="${article.point}"/>
                            ${article.birthday}
                            ${article.email}
                            ${article.regdate}
                            <input type="text" name="${article.id}" value="${article.password}"/>
                                <input type="button" class="btnChange" name="${article.id}" value="Edit">

                    </c:forEach>

// AdminMemberListAction.do - This is the model component : MVC2
public class AdminMemberListAction implements CommandAction {

    @Override
    public String requestPro(HttpServletRequest request,
            HttpServletResponse response) throws Throwable {

            List<Board> list = null;
            int countMember =0;
            String res="orm/mybatis/config.xml";
            try{
                InputStream is = Resources.getResourceAsStream(res);
                SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(is);
                SqlSession sqlSession = factory.openSession();

                list = sqlSession.selectList("getMemberList");
                sqlSession.close();
            }catch(IOException ie){
                System.out.println(ie.getMessage());
            }
            countMember = list.size();

            for (int i = 0; i < list.size(); i++) {
                System.out.println(list.get(i));
            }

            request.setAttribute("articleList", list);
            request.setAttribute("countMember", countMember);

        return "AdminMemberList.jsp";
        }
 }

// ConnectDB.jsp - This is the model component : MVC1
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ page import="java.sql.*" %>
    <%@ page import="java.util.*" %>
<%
    try {
        String driverName = "org.mariadb.jdbc.Driver";
        String url = "jdbc:mariadb://localhost:3306/team";
        ResultSet rs = null;

        Class.forName(driverName);
        Connection con = DriverManager.getConnection(url,"id","password");
        Statement stmt = con.createStatement();
        String sql = "SELECT * from member";
        rs = stmt.executeQuery(sql);

        ArrayList<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();
        HashMap<String, Object> hm = new HashMap<String, Object>();

        while(rs.next()){
            hm = new HashMap<String, Object>();
            hm.put("id", rs.getString("id"));
            hm.put("point", rs.getString("point"));
            hm.put("birthday", rs.getString("birthday"));
            hm.put("email", rs.getString("email"));
            list.add(hm);
        }

        request.setAttribute("articleList", list);
        con.close();
    }catch (Exception e) {
        out.println("Oracle Database Connection Something Problem.
");
        out.println(e.getMessage());
        e.printStackTrace();
    }
%>


text:
Q: Conditionally, and inline, add a property to an object, in a type safe way The objective
The objective is to create an object while conditionally adding properties. The following rules apply:

*

*it is not allowed to end up with the optional property set to
undefined.

*this must be done inline (so e.g. no loops / .reduce etc
to construct the object)

Two scenarios
Consider the following code:
interface User {
  readonly firstName: string
  readonly lastName: string
}
interface ParitalUser {
  readonly firstName?: string
  readonly lastName?: string
}

const updateLastName = false

// SCENARIO 1
// create a user and conditionally add a name property
const partialUserA: ParitalUser = {
  ...(updateLastName ? { lastName: 'Doe' } : {}),
}

// i want the following assertion pass (so 'userA' should not have a property 'name' if addName is false)
console.assert(!('lastName' in partialUserA))

// but this is not type safe:
const partialUserB: ParitalUser = {
  ...(Math.random() < 0.5 ? { lastName: 'Doe' } : {}),
  ...(Math.random() < 0.5 ? { age: 21 } : {}), // should be an error, but isn't!
}

// SCENARIO 2
// i know I can do this
const partialUserC: ParitalUser = {
  lastName: updateLastName ? 'Doe' : undefined,
}

// this is type safe:
const partialUserB: ParitalUser = {
  lastName: updateLastName ? 'Doe' : undefined,
  age: Math.random() < 0.5 ? 21 : undefined, // is an error (as it should be)
}

// but the this assertion doesn't pass anymore
console.assert(!('lastName' in partialUserC))

(playground, to play around with, can be found here)
The problem

*

*SCENARIO 1 leads to an object without a property lastName, but it is not type safe

*SCENARIO 2 is type safe, but it leads to an object with an undefined property lastName (see rule 1)

But why?
Consider the following code:
const userToUpdate: User = {
  firstName: 'Frank',
  lastName: 'Smith',
}

const userA: User = {
  ...userToUpdate,
  ...partialUserA,
}
// becomes { firstName: 'Frank', lastName: 'Smith' }

const userC: User = {
  ...userToUpdate,
  ...partialUserC,
}
// becomes { firstName: 'Frank', lastName: undefined }

(playground, to play around with, can be found here)
The intended use of all of this is to construct partial objects which represent properties that need to be updated.
userC, which was 'updated' using an object containing an undefined property, gets this property incorrectly overwritten. userA is constructed properly using partialUserA but this was not (see above) a type safe operation.


text:
Q: Multiple property file How to handle multiple property files in spring with placeholderconfigurer?
I have an application context in Common project with following bean entry:
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:database.properties" />
</bean>
And in Service layer project I have another application context file with this bean entry:
<beans:bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<beans:property name="location" value="classpath:kestrel.properties" />
</beans:bean>
The entries in property file are like :
database proprties:
URL= xxx
USERNAME = xxx
PWD = xxx
kestrel.properties:
mediacast.url = xxx
With these setting, when I start my tomcat server I get expection like:
Could not resolve placeholder 'mediacast.url' from kestrel.properties - property file.
Thanks in advance for any help!

A: On my application, I do that:
<bean id="envPropertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <value>one/path/to/file</value>
            <value>another/path/to/file</value>
        </list>
    </property>
</bean>


text:
Q: How to resotore outlined form Html canvas using GDI+ we have a web patiner project use browser (js) draw something, like image, text etc. and restore by GDI+ to export a image to print. every think looks like well, except outlined text:
In web application we use HTML5 CanvasRenderingContext2D 'fillText' and 'strokeText'.
In winform we use GDI+ like this:
                g.SmoothingMode = SmoothingMode.AntiAlias;
                g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
                g.CompositingQuality = CompositingQuality.HighQuality;
                g.InterpolationMode = InterpolationMode.HighQualityBilinear;

             using (var newFont = new Font(family, emSize, this.FontStyle, GraphicsUnit.Pixel))
                    {
                        using (GraphicsPath path =
                       GetStringPath(this.Text, g.DpiY, new PointF(0, 0),
                       newFont,
                       StringFormat.GenericTypographic))
                        {
                            var bounds = path.GetBounds();

                            if (this.OutlineWidth > 0)
                            {
                                //scale stroke。
                                float strokeWidth = this.OutlineWidth * (emSize / this.FontSize);
                                using (Pen p = new Pen(this.OutlineColor, strokeWidth))
                                {
                                    g.DrawPath(p, path);
                                }
                            }

                            if (this.FontColor != Color.Transparent)
                            {
                                using (Brush b = new SolidBrush(this.FontColor))
                                {
                                    g.FillPath(b, path);
                                }
                            }
                        }
                    }
                }

but result have some diffrent:
this is generated by canvas to toDataUrl
this is generated by GDI+
how to smooth gdi path? please help! sorry for my bad English! thanks.


text:
Q: Eloquent update and limit I could not figure out how can i use both update and limit methods in laravel eloquent orm.
$affectedRows = Promo::where('used','=',0)
    ->update(array('user_id' => Auth::user()->id))
    ->limit(1); // Call to a member function limit() on a non-object
    //->take(1); // Call to a member function take() on a non-object

I tried both limit and take methods.
I want to do only one result will be update.
But i think, i can not use limit or take methods on update.
Is there any way to update only one row via eloquent?

Add :
Eloquent ORM
$affectedRows = Promo::where('user_id','=',DB::raw('null'))->take(1)
        ->update(
            array(
                'user_id'       => Auth::user()->id,
                'created_ip'    =>Request::getClientIp(),
                'created_at'    => new DateTime,
                'updated_at'    => new DateTime
            )
        );

Query Builder
$affectedRows = DB::table('promos')->whereNull('user_id')
    ->take(1)
    ->update(array(
        'user_id'       => Auth::user()->id,
        'created_ip'    =>Request::getClientIp(),
        'created_at'    => new DateTime,
        'updated_at'    => new DateTime
    ));

These two codes did not add limit param to the query
Output:
update `promos` set `user_id` = '1', `created_ip` = '127.0.0.1', `created_at` = '2013-06-04 14:09:53', `updated_at` = '2013-06-04 14:09:53' where `user_id` = null

A: Talking about laravel 5 (not sure about L4), depends on db engine.
MySQL supports limit for update so it works, here is the laravel code that do that:
https://github.com/laravel/framework/blob/5.4/src/Illuminate/Database/Query/Grammars/MySqlGrammar.php#L129
so, first ->limit(1) and then ->update([fields]);
DB::table('table')
    ->where('field', 'value')
    ->limit(1)
    ->update(['field', 'new value']);

A: I used raw query. There is no method limit/take for update and delete queries on both eloquent and query builder. Use
DB::update(DB::raw("UPDATE query"));

like this.

A: I have not tried it but the Laravel 4 logic makes me think this syntax would work :
$affectedRows = Promo::where('used','=',0)
    ->limit(1)
    ->update(array('user_id' => Auth::user()->id));


text:
Q: Do we really want to call it "meta" for the non-technical SE sites? I'm sure everyone on SO and the other tech-oriented SE sites is comfortable with "meta" as the label describing the meta sites. But for non-technical sites (like cooking), is this clear enough? I don't think "meta" is a word that "normal" people use all that often.
(Worse yet, on Cooking.SE it almost looks like it says "meat").
Should this be changed to "help" or "support" (or something else) instead?

A: I agree with the comments by justkt and Downvoter. "meta" is not a technical term, so this is a non-problem. Seasoned Advice does kind of prime the mind for reading "meat" instead of "meta," but I don't think that special case is enough of a problem to justify breaking standardization with the rest of the SE network. It's certainly not enough to justify changing the word across all the sites.
To answer your title question: Yes, we want to call it "meta" for all the sites, regardless of topic.

A: As the StackExchange network expands outside the boundaries of techinical audience, I think this may become a valid issue.   (See my comment to the OP for more details)
While the meta/meat issue on Cooking is an isolated and unfortunate, yet funny, coincidence, I do think we could use a more widely understood word for non-tech SE sites (or all SE sites).
I'm also thinking 'Help' or 'Support' could work.
Update #1: As @David Thornley points out in the comments, 'Help' and 'Support' do not quite say the right thing, which I somewhat agree with.   I just don't have any other suggestion myself.
Update #2: How about Shog9's suggestion of 'Feedback'?

A: It isn't "Help" - that would be resources on how to use the site.  It isn't "Support" - that would be how to get in touch with the site's admin people.
"Meta" is not a computer-specific word.  It's not a real widespread word, but I don't know of one that would work.
Besides, if they're curious, they can always click on it and see.  The Web really does support finding things out by exploration.

A: I'm not sure I know a alternate choice that has the right semantics.

*

*admin though more or less correct is presumably a little intimidating for plain vanilla users

*help might imply "cooking help" or "instructions for use" rather than "policy, and problems"

*...nothing else is coming to mind right off

Added: The more I think about it, the more I feel that "meta" really is the right word. But it is also a word that is recognized by a relatively small subset of the population (and not the educated, but rather those who like to "think about thinking" (to be, well, meta about it)), and used by a smaller group still.
"Help & Support" has been proposed, and that is not bad, but maybe policy & support  would be better. I really am worried that "help" is going to bring a lot of people with "How do I make links?" type questions when we would rather that most of them find the formatting help page.

A: Copying my answer from a few comments on https://blog.stackoverflow.com/2010/07/new-per-site-metas/

"I think a more accessible term for the wide audiences you're aiming for would be 'main site'"

Not a bad idea — "parent" vs. "main". Some say "meta" is too geeky but I don't agree with that. I could possibly support "parent" though. I worry though that "meta" and "main" look way too similar as links.

as you move away from more technical sites to the great unwashed of the interwebs, the term 'meta' might not be so well understood

I'm ok with doing a tiny bit of education about what meta is, since we have to educate people about how the Q&A format is supposed to work anyway. (or deprogram them from Yahoo! Answers, I guess)

A: Yes, we do.
Mostly because it's more apt than any of the alternatives suggested here or any others that I can think of.
Is it a descriptions that'll be clear to all users?  Nope, although the tech vs. non-tech issue is a red herring, I think.   But at least "meta" is highly accurate if you know the term.  Unlike, say "feedback," which much of meta is not, and makes me expect to get a pre-addressed email to the team.  Or "help", which I'd expect to take me to something more like the FAQs.
The challenge we're facing is that meta is actually the... rightest word (unlike "rightest", which, well... isn't).
On the beta sites, we could potentially put some verbiage on the right where the under-construction-y stuff is, something like, "Have a question ABOUT the site?  Visit Meta."
At the end of the day, if the person we're worried about is actually looking for something like meta, and they find the links up top (no one's suggesting they're too well hidden, just that the diction will prevent them from picking the right one), they'll almost certainly wind up at the FAQ.  Which will quickly advise them of where they should go if they have a question ABOUT the site.


text:
Q: Fundamental group as topological group Background
Let $(X,x)$ be a pointed topological space. Then the fundamental group $\pi_1(X,x)$ becomes a topological space: Endow the set of maps $S^1 \to X$ with the compact-open topology, endow the subset of maps mapping $1 \to x$ with the subspace topology, and finally use the quotient topology on $\pi_1(X,x)$. This topology is relevant in some situations. A very interesting paper dealing with this topology is:

[1] Daniel K. Biss, A Generalized Approach to the Fundamental Group, The American Mathematical Monthly, Vol. 107

You can find this online. This is somehow an introduction to

[2] Daniel K. Biss, The topological fundamental group and generalized covering spaces , Topology and its Applications, Vol. 124

Question
How can we prove that $\pi_1(X,x)$ is a topological group? Clearly the inversion map $\pi_1(X,x) \to \pi_1(X,x)$ is continuous, since $S^1 \to S^1, z \mapsto \overline{z}$ is continuous and induces this map. But I don't know how to attack the continuity of the multiplication. It's not hard to see that the multiplication on $map((S^1,1),(X,x))$ is continuous, since it is induced by a fold map $S^1 \to S^1 + S^1$. In order to carry this over to $\pi_1(X,x)$, there are at least two problems which I encounter:

*

*The quotient map $map((S^1,1),(X,x)) \to \pi_1(X,x)$ may be not open.

*The product of the quotient maps $map((S^1,1),(X,x))^2 \to \pi_1(X,x)^2$ may be not a quotient map.

In [1] it is claimed that $\pi_1(X,x)$ is always a topological group, and this should be proven in [2], but I have no acecss to [2].
An example that products of quotient maps don't have to be quotient maps can be found here. Remark however that this is true in the category of compactly generated spaces.

A: Andrew's answer is right, but I'll just throw in a few comments since "topological" homotopy invariants are of great interest to me. Here Paul Fabel has shown that $\pi_{1}^{top}$ on the Hawaiian earring is not a topological group. It turns out that multiplication can fail to be continuous even for some reasonably nice spaces (like locally simply connected planar continua). This and a nice connection with free topological groups appears in a manuscript I just posted on arXiv (perhaps shameless self-promotion...but I'll post the link when it becomes available).
This quotient map mistake has appeared many places in the literature, even in an appendix by Peter May from the 70's who described the topological fundamental groupoid (giving each hom-set the quotient topology of fixed endpoint Moore path spaces). The same false assertion that products of quotient maps are again quotient maps was also used to "show" the higher topological homotopy groups are topological groups.
With this quotient topology, the topological fundamental group(oid) is discrete on spaces that have universal covers (are path connected, locally path connected, and semi-locally simple connected). When it is non-discrete, this topology is often difficult to deal with. After all...there are going to be many homotopic loops that we identify in the quotient but which "look nothing alike" in the space.
While we don't always have a topological group, we're not completely out of luck. $\pi_{1}^{top}(X)$ is always a quasitopological group in the following sense:
definition: A quasitopological group is a group $G$ with topology such that inversion is continuous and multiplication $G\times G\rightarrow G$ is continuous in each variable.
A basic theory of these objects can be found in "Topological Groups and Related Structures" some of which you can get on google books.
Edit: The topological fundamental group and free topological groups is the new paper I mentioned. It is a bit denser than the one from Andrew's answer but if anyone is interested enough to read it, I'd greatly appreciate any comments, suggestions, or corrections.

A: Update: A bit of a digital paper chase led me, via David Robert's thesis (note that in the latest version, it is Chapter 5, section 2 that is most relevant), to this paper on the arXiv.  The last sentence of the abstract is:

These hoop earring spaces provide a simple class of counterexamples to the claim that $\pi_{1}^{top}$ is a functor to the category of topological groups.

I recommend reading this article.
(Added later: In case it's not clear, the author of that paper is Jeremy Brazas who added an answer afterwards, so if you vote for my answer, you should definitely vote for his!)

Original Answer: These were my initial thoughts before I found the references above.  These were what made me sufficiently intrigued to do the paper chase and find the above-mentioned thesis and article.
The proof given in the second paper (by Biss) that is mentioned in the question is short enough that I think it reasonable to copy it out here.  I shan't copy out the obvious diagram so need to establish some notation first:

*

*$m \colon \pi_1^{Top}(X,x) \times \pi_1^{Top}(X,x) \to \pi_1^{Top}(X,x)$ is the multiplication map in question

*$p \colon \operatorname{Hom}((S^1,1),(X,x)) \to \pi_1^{Top}(X,x)$ is the quotient map

*$\overline{m} \colon \operatorname{Hom}((S^1,1),(X,x)) \times \operatorname{Hom}((S^1,1),(X,x)) \to \operatorname{Hom}((S^1,1),(X,x))$ is the "upstairs" multiplication map.  (It's a tilde in the original, but that isn't displaying correctly for me so I daren't use it.)

The proof then proceeds:

To show that $m$ is continuous, it suffices to show that $\overline{m}$ is continuous, for then if $U \subset \pi_1^{Top}(X,x)$ is open, $(p \times p)^{-1} m^{-1}(U) = \overline{m}^{-1}p^{-1}(U)$ is open, but by the definition of a quotient map, $(p \times p)^{-1} m^{-1}(U)$ is open if and only if $m^{-1}(U)$ is.

There then follows a proof that $\overline{m}$ is continuous, a fact that I trust does not need proving.
Comments on your comments:

*

*We don't need the quotient map to be open since we are only ever dealing with preimage sets.  It is certainly not always true that if $q \colon X \to Y$ is a quotient that $q(U)$ is open in $Y$ for every open $U$ in $X$.  But it is true by definition that $q^{-1}(U)$ is open in $X$ if and only if $U$ is open in $Y$.  This is because the topology on $Y$ is precisely that to make this true.  So since we are only dealing with sets of the form $(p \times p)^{-1}(A)$ then the assertion is valid assuming that $p \times p$ is a quotient map.

*Here, I find myself worried.  A quick back-of-envelope check seems to show that one can't simply assume that the product of quotients is again a quotient in Top (a counterexample eludes me as I don't have Counterexamples in Topology to hand and I'm too used to dealing with "nice" spaces).  It may be the case that for Hom-spaces then there's some magic that can be done (though such is not mentioned in the paper); but again the best that I can do on the back of an envelope is observe that (modulo some basepoint mess) by construction $\operatorname{Hom}((S^1,1),(X,x)) \times \operatorname{Hom}((S^1,1),(X,x))$ quotients to $\pi_1^{Top}((X,x) \times (X,x))$.  But to proceed, one would need to know that $\pi_1^{Top}$ was a product-preserving functor.  This is morally the same as saying that it is representable - which looks good since we have an obvious representing object $S^1$!  However, this can't be made into a proper argument since although we have a representing object, we don't have an enriched Hom-functor $hTop \times hTop \to Top$ which to evaluate at $S^1$.
So I would look for a counterexample to the product of quotients being a quotient, and see where that leads you.  Either you'll find a proper counterexample to the proposition in question, or you'll see why in this special case, such a counterexample could not occur.
(Of course, I may well be missing something obvious!)

A: The fundamental groupOID of any path-connected, locally path-connected and semi-locally simply connected space is again a topological groupoid  (now you don't need to be pointed). The topologized fundamental group at $x \in X$ is now just the stablizer group of $x$ which inherits a topology from the arrow space of the groupoid. There is some on this in n-lab. Look under the heading "Topologizing the fundamental groupoid" in http://ncatlab.org/nlab/show/fundamental+groupoid.

A: What has not been said is that if $X$ is path connected and has a universal cover, then the fundamental groupoid $\pi_1(X)$ can be given a topology so that the source map $s:\pi_1 (X) \to X$  is a bundle over $X$ with fibre over $x \in X$ the universal cover of $X$ based at $x$: see Chapter 10 of Topology and Groupoids. This has been known for a long time.

A: Let $X$ be a topological space and let $a$ be a point of $X$.
There are three interesting topologies on $\pi_1(X,a)$: the quotient
topology of the topology of compact convergence, and two other one which
you'll let me call admissible and adequate.
In all three topologies, the classes of open normal subgroups coincide;
moreover they are simultaneously Hausdorff (or not).
1) As observed, the topology of compact convergence is not a group topology,
although the multiplication is separately continuous.
2) Say a subgroup $H$ of $\pi_1(X,a)$ is admissible if, any $b\in X$
has a neighborhood $V$ such that forany path class $\gamma\in\pi(X,a,b)$ (fundamental groupoid) and any loop $c$ in $V$ based at $b$,
$\gamma c \gamma^{-1}$ belongs to $H$.
There is a unique group topology on $\pi_1(X,a)$ such that the normal admissible
subgroups form a basis of neighborhoods of the identity. For this topology, the open subgroups are the admissible subgroups.
If $X$ is locally arcwise connected, then a subgroup is admissible if and only if
it is the stabilizer of a point above $a$ in a covering of $X$.
The admissible topology is coarser than the topology of compact convergence,
and may be strictly coarser.
3) Let us say that a subgroup $H$ of $\pi_1(X,a)$ is adequate if, for any $b\in X$
and any path class $\gamma\in\pi(X,a,b)$, there exists a neighborhood $V$ of $b$
such that for any loop $c$ in $V$ based at $b$
$\gamma c \gamma^{-1}$ belongs to $H$. (Note the switch in the order of quantifiers.)
There exists a unique group topology on $\pi_1(X,a)$ for which adequate subgroups form a basis of open subgroups.
This topology is finer (and possibly strictly finer) than the topology of compact convergence. However if $X$ is locally arwise connected, both topologies have the same open subgroups.


text:
Q: Hibernate outer join with null "base/root" entity I have a simple Parent->Child relationship in hibernate; some children do not have a parent.
I want to make a query, using an outer join, in hibernate, which brings a list of Parent entities.
The query itself is simple enough; my problem is that I want to also bring those children that do not have a parent.
What happens is that because I'm making the query on the Parent entity (I need to), and the Parent entity is null, no children are fetched.
What I want to see instead are Parent entities, with all their fields null, but with non-null children.
Do you know if this can be done in hibernate?


text:
Q: Rake task sending email newsletters failing when using Heroku Scheduler addon I have a rake task set up to fire once per day on a Rails app. It checks which users need a newsletter sent, then prepares the newsletter and sends it using SendGrid starter-level addon via DelayedJob queue.
When I run this rake job from the command line with heroku run rake my_job it works, and the newsletters get sent out. When I leave it to the Heroku Scheduler addon to run, the newsletters don't get sent. The script runs ok (I add the details of each newsletter sent to a table), but the emails are not sent, and do not remain in the DelayedJob queue when I check it out.
How can I go about debugging this? The scheduled job uses exact same rake my_job syntax. I am running 1 web dyno and 1 worker dyno 24/7.


text:
Q: How can I add force to an object relative to a game objects local position Long story short, I'd like to projectile an egg in the chickens local -Y direction. I know how to add force to an object via AddForce (rb.AddForce(Vector3.Forward) etc...) but super stumped on how to add force to an object in local space, I feel like I'm really overthinking how to do this!
I've attached a gif for further context, hopefully this helps in what I'm trying to achieve here.

A: You get the local axis of a transform in WorldSpace coordinates via the Transform component. In your case you want Transform.up
rb.AddForce( - chicken.transform.up * force);

A: I would like to say that you can use:
rb.AddForce(-chicken.transform.right * force);

This can make an object move left or remove the negative sign to make it go right.


text:
Q: Call JSON wcf service via jQuery I have question according calling json wcf methods from aspx page with jQuery.
This is my test method:
    [ServiceContract]
    public interface IEParcelService
    {
        [OperationContract]
        [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped,
        UriTemplate = "Test")]
        Response<string> Test();
    }

  [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
  public class EParcelServiceImpl : IEParcelService
  {
    public Response<string> Test()
    {
      return WebServiceHelper.Execute(() => "Test Message");
    }
  }

This service deployed to IIS.
When I call this method from Chrome: http://localhost/TestService/ServiceImpl.svc/Test
Everything is ok and I can see the result. But when I call it from jQuery
I have error: NETWORK_ERR: XMLHttpRequest Exception 101. I try to find solution in Google.
But the result was not successful. How I can solve it?
jQuery call:
<script language="javascript">
  $().ready(function () {
            $("#myButt").click(function () {

                $.ajax({
                    cache: false,
                    async: false,
                    type: "GET",
                    url: "http://localhost/EParselService/EParcelServiceImpl.svc/Test",
                    contentType: "application/json",
                    dataType: "json",
                  success: function (data, textStatus){
                                alert('successCallBack called');
                                alert(data);
                                alert(textStatus);
                         },
                   error: function (XMLHttpRequest, textStatus, errorThrown) {
                            alert('errorCallBack called');
                            alert('textStatus = ' + textStatus + '/nerrorThrown = ' + errorThrown);
                        }
                 });
                alert('Done!');
            });
        });
</script>

<input type="button" value="Get values from server" id="myButt" />

A: So it's a same-origin issue. (see here)
For a XMLHttpRequest the resource has to be on the exact same domain as the page requesting it. This is to prevent XSS (see here) atacks. If you want to use a resource from a different domain you'll have to use something like jsonp. (see here) For a good tutorial how to do this with WCF.


text:
Q: Author and department column wise other details row wise I want following output while using IEEEtran class.
                                        Title
        Author 1                        Author 2              Author 3
        Department 1                    Department 2          Department 3
                                Institution/university
                                mail1,mail2,mail3,mail4

A: \documentclass[conference]{IEEEtran}

\title{Sample paper}

\author{\IEEEauthorblockN{author 1\\ Department 1}%
  %\IEEEauthorblockA{}
  \and
  \IEEEauthorblockN{author 2\\ Department 2}
  \IEEEauthorblockA{Institution/university \\
                     mail1,mail2,mail3,mail4} \and
  \IEEEauthorblockN{author 3\\ Department 3}
  %\IEEEauthorblockA{}
}

\begin{document}

\maketitle

\end{document}


text:
Q: Why do LC filters have 40 dB/decade ripple attenuation at high frequencies? I am taking an online course on power electronics in which I encountered the following concept which I couldn't understand.
The instructor had the following comment about the following grid interface input filters:

*

*The filter in Fig.1 will have high losses at low frequencies, but its advantage is that at high frequencies the current ripples are attenuated at 40 dB/decade.

*The filter in Fig.2 will have low losses at low frequencies, but its drawback is that at high frequencies the current ripples are attenuated at only 20 dB.

*The filter in Fig.3 is the best of both worlds, because it doesn't dissipate much loss in low frequencies, and it has 40 dB/decade ripple attenuation at high frequencies.

I understand the loss part, but I don't get how the instructor concluded that attenuation is 40 dB/decade for fig.1.
I made this graphical representation of the impedance Bode plot:

If my Bode plot is correct, then at high frequencies, only 20dB/decade will be attenuated. What did I do wrong?

A:
I understand the loss part, but I don't get how the instructor concluded that attenuation is 40 dB/decade for fig.1.

I made this graphical representation of the impedance Bode plot:

Use gain bode plot rather than impedance bode plot to see where that 40dB/dec attenuation comes from. If you write the gain transfer function of the 1st circuit you'll see that it'll be in the following form:
$$
H(s) = \frac{\omega_n^2}{s^2+2\zeta\omega_ns+\omega_n^2}
$$
This transfer function has a double pole at \$\omega_n=1/\sqrt{L_f C_f}\$ which is called natural frequency or resonance frequency. A single pole brings -20 dB/dec (i.e. an attenuation of 20 dB/dec), so a double one does -40dB/dec.

A: The Bode plot is incorrect.
LC filters are second order filters. Second order filters have 40 dB/decade attenuation.
First order filters, such as RC filters have 20 dB/decade attenuation.


text:
Q: Equation involving the logarithm Find the set of values of $k$ satisfying this equation for only one real root of $x.$
$$ \log(kx) = 2 \log(x+2)$$
I think that for the sake of satisfying the domain restriction:

*

*$ k \cdot x > 0 $

*$x+2 > 0$

*$ k \cdot x = (x+2)^2$

*$ b^2-2ac = 0$.

I am not sure what to do from here.

A:
Find the set of values of $k$ satisfying
    \begin{align}  \log(kx) &= 2
  \log(x+2) \tag{1}\label{1}
  \end{align}
  for only one real root of $x$.

Equation
\begin{align}
k \cdot x &= (x+2)^2
\tag{2}\label{2}
\end{align}
follows from \eqref{1}
and can be transformed as
\begin{align}
(x+2)^2 -kx&=0
\\
(x+2)^2 -k(x+2)+2k&=0
\end{align}
with the roots
\begin{align}
x+2&=\tfrac12\,k\pm\tfrac12\sqrt{k^2-8k}
\tag{3}\label{3}
.
\end{align}
The domain restrictions
\begin{align}
kx&>0
\tag{4}\label{4}
,\\
x+2&>0
\tag{5}\label{5}
\end{align}
suggest that we need to consider two cases:
\begin{align}
\text{Case 1. }\quad
k&>0,\quad x>0
\tag{6}\label{6}
,\\
\text{Case 2. }\quad
k&<0,\quad x\in(-2,0)
\tag{7}\label{7}
.
\end{align}
In the first case
there is only one value ($k=8$) that is useful for \eqref{1}.
In the second case,
when $k<0,\quad x\in(-2,0)$,
since the left-hand side of \eqref{3}
is positive,
we need to check,
for which values of negative $k$
\begin{align}
x+2&=\tfrac12\,k+\tfrac12\sqrt{k^2-8k}
\tag{8}\label{8}
\end{align}
holds.
From equation \eqref{8} and condition \eqref{7},
\begin{align}
0&<\tfrac12\,k+\tfrac12\sqrt{k^2-8k}
<2
\tag{9}\label{9}
\end{align}
Let $\kappa=-k$, $\kappa>0$. Then
condition
\begin{align}
0&<-\tfrac12\,\kappa+\tfrac12\sqrt{\kappa^2+8\kappa}
\end{align}
always holds for any $\kappa>0$, that is,
for any $k<0$.
Next, consider
\begin{align}
-\tfrac12\,\kappa+\tfrac12\,\kappa\,\sqrt{1+\frac8\kappa}
<2
,\\
-\kappa+\kappa\,\sqrt{1+\frac8\kappa}
<4
,\\
\kappa\,\sqrt{1+\frac8\kappa}
<4+\kappa
,\\
\kappa^2+8\kappa
<16+8\kappa+\kappa^2
,
\end{align}
which also holds for all $\kappa>0$, that is, for all $k<0$
.
Summarizing,
the answer is:
\begin{align}
k\in(-\infty,0)\cup\{8\}
.
\end{align}
Illustration for the Case 1:

Illustration for the Case 2:

A: *

*$k⋅x>0$

*$x+2>0$

*$k⋅x=(x+2)^2$

*$b^2−2ac=0$

I am not sure what to do from here.

Well first thing is to correct 4.) $b^2-2ac = 0$ to $b^2 - 4ac=0$ (the $2$ was incorrect; it should be $4$) and then to write it in terms of $kx = (x+2)^2$
$kx = (x+2)^2$
$x^2 + (4-k)x + 4 = 0$ so $a = 1; b=4-k; c = 4$
so

*$(4-k)^2 - 16 = 0$.

Now just find the only values of $k$ where the following four are all true.

*

*$k⋅x>0$

*$x+2>0$

*$k⋅x=(x+2)^2$

*$(4-k)^2 - 16 = 0$

==== answer follows ======
So $(4-k)^2 = 16$
$4-k = \pm 4$
$k = 0, 8$.

*

*$kx > 0$

But if $k = 0$ then $k*x =0$.  So $k =0$ is impossible.  So $k = 8$.

*$kx = 8x = (x + 2)^2$

$8x = x^2 + 4x + 4$
$x^2 - 4x + 4 = 0$
$(x-2)^2 =0$ so
$x = 2$

*$x + 2 = 2+ 2=4 > 0$

Yep.  That's fine.
So $k=8$ is the only value of $k$ which gives a single solution ($x =2$).
(If $k > 8$ then there will be two solutions and 4) fails (is greater than zero).  If $0< k < 8$ then 4) fails (is less than 0) and 3) has no solution.  If $k=0$ then 4) and 3) pass and there is a single solution to 3) but 1) and 2) fail so there is no overall solution.  If $k < 0$ then 4) fails (is greater than 0) and there are two solutions to 3) but 1) and 2) fail and there are no overall solution.)


text:
Q: Getting connection time out error for local repository As we know that Ubuntu 12.10(Quantal) is at EOL. So all the package repositories are moved to http://old-releases.ubuntu.com/ubuntu.
I can access all the packages from that url.
Now I have set up some packages on my private server. For building my local repository I referred following links
https://help.ubuntu.com/community/CreateAuthenticatedReposito and
http://www.hiddentao.com/archives/2011/06/27/setting-up-a-simple-ubuntu-apt-repository/
Also made the changes in the sources.list file.
But when I do sudo apt-get update or sudo apt-get install my_package then I get following error
Could not connect to XXXXX.XXXX.com. - connect (110: Connection timed out)

How can I resolve this error. Is there port issue (like I have to open port or is there any firewall issue) or is there any other issue.


text:
Q: Advice on how to improve the efficiency of a stored procedure using lots of joins I have a stored procedure that is returning search results for items in a database grouped by customers who own them.
The user performing the search is restricted as to what items they can see by the category permissions and entity permissions.
The user category permissions are passed in on the @CategoryPermissions parameter and are filtered against the tariff the customer is on.
Items are associated with entities (via a number of combinations of BusinessID and PIN, SubID, AccountNumber or GroupSubID)
Users have to attest to these entities and to be able to see the items. What they have attested to is passed into the stored procedure as the @EntityPermissions.
The results will also indicate if the user has already viewed the item before via the ReadStatus table
The stored procedure also has the option filter by 'read' flag which can be in 3 states

*

*return all items

*only unread items or

*only read items.

The read status table will only contain a row where the item has been read, or 'marked as unread' so I am using an EXISTS and NOT EXISTS to filter by the @Read flag.
We will only return the top number of rows specified in the @RecordLimit parameter, but we need to return the total number of items found. This is being done by a COUNT(*) OVER() as ResultCount, and by loading the results into a temporary table we can select that value and output it as 'TotalCount'
Is there any way to alter this stored procedure to be more efficient? If I could avoid using a temporary table, or the EXIST and NOT EXISTS extra query on the read status table it would improve the execution time. Any advice would be welcomed!
Here is the stored procedure source:
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[uspMetaDataSearchItems]
(
    @TariffNames varchar(8000),
    @Category varchar(8000),
    @SearchText varchar(50) = null,
    @SupervisorName varchar(50) = null,
    @StartDate datetime = null,
    @EndDate datetime = null,
    @SortByColumn varchar(50) = null,
    @RecordLimit int,
    @StatusCheck bit,
    @ExpirationCheck bit,
    @CategoryPermissions CategoryPermissionTableType READONLY,
    @ApplyCategoryPermissions BIT = 0,
    @EntityPermissions EntityPermissionTableType READONLY,
    @ApplyEntityPermissions BIT = 0,
    @ExpirationStartDate datetime = null,
    @ExpirationEndDate datetime = null,
    @Read BIT = null,
    @UserID INT = null
)
AS
BEGIN

    SET NOCOUNT ON

    DECLARE @tblTariffs AS TABLE(TariffName varchar(50))
    IF (@TariffNames IS NOT NULL)
        INSERT INTO @tblTariffs
        SELECT split.a.value('.', 'VARCHAR(100)')
        FROM   (SELECT Cast ('<M>' + Replace(@TariffNames, ',', '</M><M>') +             '</M>'
            AS XML
            ) AS String
        ) AS A
        CROSS apply string.nodes ('/M') AS Split(a)

    DECLARE @tblCategory AS TABLE(Category varchar(50))
    IF (@Category IS NOT NULL)
        INSERT INTO @tblCategory
        SELECT split.a.value('.', 'VARCHAR(100)')
        FROM   (SELECT Cast ('<M>' + Replace(@Category, ',', '</M><M>') +'</M>'
        AS XML
                ) AS String
        ) AS A
    CROSS apply string.nodes ('/M') AS Split(a)

    SELECT @StartDate = ISNULL(@StartDate,CONVERT(datetime,'1970-01-01')),
        @EndDate = ISNULL(@EndDate,CONVERT(datetime,'2100-01-01'))

    IF @SortByColumn IS NULL OR @SortByColumn NOT IN ('last_item_received', 'tariff', 'customer_last_name')
        SET @SortByColumn = 'customer_last_name'

SELECT 'CustomerRecords' As "RecordSetName"

DECLARE @tmp table(member_id varchar(50), Customer_first_name varchar(50),Customer_last_name varchar(50),date_of_birth varchar(50),tariff varchar(50),customer_supervisors_name varchar(50), number_of_Items int, read_item_count int, last_item_received datetime, ResultCount INT);

INSERT INTO @tmp
SELECT TOP (@RecordLimit)
    md.[CustomerMemberID] AS member_id,
    md.[CustomerFirstName] AS Customer_first_name,
    md.[CustomerLastName] AS Customer_last_name,
    md.CustomerDateOfBirth AS date_of_birth,
    md.[TariffName] AS tariff,
    MIN(ISNULL(SupervisorName,'')) as 'customer_supervisors_name',
    Count(DISTINCT md.ItemID) as 'number_of_items',
    -- Read Item Count is only available if a UserID is provided
    ISNULL(COUNT(DISTINCT (CASE WHEN rs.ReadIND <> 0 THEN md.ItemID END)), 0) as 'read_item_count',
    Max(md.CreatedDTM) as 'last_item_received',
    COUNT(*) OVER() as ResultCount
FROM [dbo].[tblMetaData] AS md WITH (NOLOCK)
--Join To Get Read Item Count
LEFT OUTER JOIN [dbo].[tblReadStatus] as [rs] WITH (NOLOCK) on md.ItemID = rs.ItemID and rs.UserID = @UserID
-- Apply permissions
LEFT JOIN @CategoryPermissions cp ON md.TariffName = cp.TariffName AND md.ItemCategory = cp.ItemCategory
LEFT JOIN [dbo].[tblEntityPermissionLink] as pl WITH (NOLOCK) on md.ItemID = pl.ItemID
LEFT JOIN @EntityPermissions pp ON md.TariffName = pp.TariffName AND pl.BusinessId = pp.BusinessId AND (pl.PIN = pp.PIN OR pl.SubID = pp.SubID OR pl.AccountNumber = pp.AccountNumber OR pl.GroupSubID = pp.GroupSubID)
-- Other filters
WHERE [md].[CreatedDTM] BETWEEN @StartDate AND @EndDate
AND [ItemExpiryDTM] BETWEEN ISNULL(@ExpirationStartDate,CONVERT(datetime,'1970-01-01')) AND ISNULL(@ExpirationEndDate,CONVERT(datetime,'2100-01-01'))
AND md.[ItemType] = 'Customer Item'

-- Apply read filter for user - Only filter if a UserID is supplied. @Read IS NULL (Return all items), @Read = 0 (Return only unread items), @Read = 1 (Return only read items)
AND (@UserID IS NULL OR (
        @Read IS NULL OR (
            (@Read=1 AND EXISTS (SELECT [rs].[ItemID] FROM [dbo].[tblReadStatus] AS [rs] WITH (NOLOCK) WHERE [rs].[ReadIND]=1 AND [rs].[ItemID] = [md].[ItemID] AND [rs].[UserID] = @UserID))
            OR
            (@Read=0 AND NOT EXISTS (SELECT [rs].[ItemID] FROM [dbo].[tblReadStatus] AS [rs] WITH (NOLOCK) WHERE [rs].[ReadIND]=1 AND [rs].[ItemID] = [md].[ItemID] AND [rs].[UserID] = @UserID))
        )
        ))
    AND ((@SupervisorName IS NULL) OR md.SupervisorName = @SupervisorName)
    AND ((@SearchText IS NULL) OR (md.CustomerLastName LIKE @SearchText + '%'))
    AND ((@ExpirationCheck IS NULL) OR (md.[ItemExpiryDTM] > GetDate()))
    AND ((@Category IS NULL) OR (md.ItemCategory IN (SELECT Category FROM @tblCategory)))
    AND ((@TariffNames IS NULL) OR (md.TariffName IN (SELECT TariffName FROM @tblTariffs)))

    -- Permissions
    AND (@ApplyCategoryPermissions = 0 OR cp.ItemCategory IS NOT NULL)
    AND (@ApplyEntityPermissions = 0 OR (pp.GroupSubID IS NOT NULL OR pp.AccountNumber IS NOT NULL OR pp.PIN IS NOT NULL OR pp.SubID IS NOT NULL))
    GROUP BY md.CustomerMemberID,md.CustomerFirstName,md.CustomerLastName,md.TariffName,md.CustomerDateOfBirth
    ORDER BY
        (CASE ISNULL(@SortByColumn,'')
            WHEN 'last_item_received' THEN Max(md.CreatedDTM)
        END) DESC,
        (CASE ISNULL(@SortByColumn,'')
            WHEN 'tariff' THEN md.[TariffName]
            WHEN 'customer_last_name' THEN md.[CustomerLastName]
        END) ASC

    -- Return the top results data set
    SELECT * FROM @tmp

    -- Return the total row count
    IF EXISTS (SELECT top 1 ResultCount from @tmp)
        SELECT TOP 1 ResultCount AS 'TotalCount' FROM @tmp
    ELSE
        SELECT 0 AS 'TotalCount'

    SET NOCOUNT OFF

    SELECT '' As "RecordSetName"

END

GO

A: This is a "kitchen sink" query, for which SQL Server MVP Aaron Bertrand has a good video on how to optimize using dynamic SQL and a detailed post here.
A few points to get you started on the performance of your query:

*

*Use dynamic SQL to simplify the @Read criteria and subsequent lookup in tblReadStatus. I'm guessing that this is going to be your main performance gain.

*tblMetaData would benefit from having an index on (ItemType, CreatedDTM, ItemID) INCLUDE (TariffName, ItemCategory, SupervisorName, CustomerLastName, ItemExpiryDTM, CustomerMemberID, CustomerFirstName, CustomerLastName, CustomerDateOfBirth). If this table is large, a good index makes a huge performance difference. A clustered index (as opposed to non-clustered), obviously, won't need INCLUDE columns, just the indexed ones.

*If you haven't done so already, put clustered indexes on the key column(s) of your table-type variables (you can define PRIMARY KEY CLUSTERED when you're creating the table type).

*Unique index on tblEntityPermissionLink (ItemID) INCLUDE (BusinessID, PIN, SubID, AccountNumber, GroupSubID)

*Unique index on tblReadStatus (UserID, ItemID) INCLUDE (ReadIND)

*Really consider if those WITH (NOLOCK) are any good to you. This is not neccessarily performance-related, rather a best-practices note because they can cause you a lot of problems with regards to dirty reads.


text:
Q: HTML content extraction using Diffbot Can someone help me I want to extract html data from http://www.quranexplorer.com/Hadith/English/Index.html. I have found a service that does exactly that http://diffbot.com/dev/docs/ they support data extraction via a simple api, the problem it that I have a large number of url that needs that needs to be processed. The link below http://test.deen-ul-islam.org/html/h.js
I need to create  a script that that follows the url then using the api generate the json format of the html data (the apis from the site allows batch requests check website docs)
Please note diffbot only allows 10000 free request per month so I need a way to save the progress and be able to pick up where I left off.
Here is an example I created using php.
$token = "dfoidjhku";// example token
$url = "http://www.quranexplorer.com/Hadith/English/Hadith/bukhari/001.001.006.html";
$geturl="http://www.diffbot.com/api/article?tags=1&token=".$token."&url=".$url;
$json = file_get_contents($geturl);
$data = json_decode($json, TRUE);
echo $article_title=$data['title'];
echo $article_author=$data['author'];
echo $article_date=$data['date'];
echo nl2br($article_text=$data['text']);
$article_tags=$data['tags'];
foreach($article_tags as $result) {
    echo $result, '<br>';
}

I don't mind if the tool is in javascript or php  I just need a way to get the html data in json format.

A: John from Diffbot here. Note: not a developer, but know enough to write hacky code to do simple things.
You have a list of links -- it should be straightforward to iterate through those, making a call to us for each.
Here's a Python script that does such: https://gist.github.com/johndavi/5545375
I used a quick search regex in Sublime Text to pull out the links from the JS file.
To truncate this, just cut out some of the links, then run it. It will take a while as I'm not using the Batch API.
If you need to improve or change this, best seek out a stronger developer directly. Diffbot is a dev-friendly tool.