问:
Printing a sentence, only if a Makefile rule is executed
I am customizing my Makefile for a school project.

I would like to print the following sentence but only when the .c files from my SRCS_DIR have been actually compiled.

All the .c files have been compiled successfully !

If I move the printf that you see in line 3 of the code block below to the last line, it prints the message after each .c file being compiled...
Thus, I created a COMPILED variable which I set to 0 at the beginning of my Makefile, and then I change its value to 1 during compilation (line 11 in the code block below). I tried to use the ifeq condition (line 2 in the code block below), but the sentence does not print when I do that.

```<code>$(NAME): $(LIBFT_AR) $(OBJS)
ifeq ($(COMPILED), 1)
    printf "$(GREEN)> All the .c files have been compiled successfully !$(END)\n"
endif
    printf "$(BLUE)> Creating the executable file :$(END) $@\n"
    $(CC) $(OBJS) $(LIBFT_AR) -lreadline -o $(NAME)
    printf "$(GREEN)> Executable file has been created successfully !$(END)\n"

$(OBJS_DIR):
    mkdir -p $(addprefix $(OBJS_DIR)/, $(SUBDIRS_LST))

$(OBJS_DIR)/%.o: $(SRCS_DIR)/%.c $(INCS) Makefile | $(OBJS_DIR)
override COMPILED=1
    $(CC) $(CFLAGS) -I $(INCS_DIR) -c $< -o $@
    printf "$(BLUE)> Compiling :$(END) $<\n"
</code>```

Do you have any explanation regarding this issue and/or a solution that could help me to solve the problem ?

Thank you !

答:
Makefiles are not scripting languages.  Make doesn't read the makefile and run each rule as it's read.  Make will (1) parse the entire makefile (and any included files) and build an internal graph of all the prerequisites, than (2) run recipes for targets that are outdated.  Content that is NOT IN A RECIPE is always evaluated during the first step.  Content that IS IN A RECIPE is always evaluated during the second step.

Lines that are not indented with TABs, are not in recipes (and so are evaluated during the first step).  Lines that are indented with TABs, are in recipes (and so are evaluated--which means, given to the shell to execute--during the second step).

Maybe you can now see why your attempts cannot work: the if-statements and variable assignment of COMPILED are always evaluated, during the first step, before make has decided whether or not any targets should be built.

I'm not really sure I understand your goal.  If the recipe of your executable is being invoked then it means that all your source files have been compiled: that's what a makefile does.  Maybe you are trying to make a distinction between a build where at least one source file was compiled, and a build where no source files had to be recompiled but the target (the executable) was out of date?

If that's what you want the simple way to solve your problem is with automatic variables; for example the $? automatic variable expands to the list of prerequisites that were out of date.  You can do something like:

```<code>$(NAME): $(LIBFT_AR) $(OBJS)
        test -z '$(filter %.o,$?)' || printf "$(GREEN)> All the .c files have been compiled successfully !$(END)\n"
        printf "$(BLUE)> Creating the executable file :$(END) $@\n"
        $(CC) $(OBJS) $(LIBFT_AR) -lreadline -o $(NAME)
        printf "$(GREEN)> Executable file has been created successfully !$(END)\n"
</code>```

The $(filter ...) function will expand to the list of .o files in the $? variable; if that's empty then no .o files were rebuilt.

Body:
I am customizing my Makefile for a school project.

I would like to print the following sentence but only when the .c files from my SRCS_DIR have been actually compiled.

All the .c files have been compiled successfully !

If I move the printf that you see in line 3 of the code block below to the last line, it prints the message after each .c file being compiled...
Thus, I created a COMPILED variable which I set to 0 at the beginning of my Makefile, and then I change its value to 1 during compilation (line 11 in the code block below). I tried to use the ifeq condition (line 2 in the code block below), but the sentence does not print when I do that.

$(NAME): $(LIBFT_AR) $(OBJS)
ifeq ($(COMPILED), 1)
    printf "$(GREEN)> All the .c files have been compiled successfully !$(END)\n"
endif
    printf "$(BLUE)> Creating the executable file :$(END) $@\n"
    $(CC) $(OBJS) $(LIBFT_AR) -lreadline -o $(NAME)
    printf "$(GREEN)> Executable file has been created successfully !$(END)\n"

$(OBJS_DIR):
    mkdir -p $(addprefix $(OBJS_DIR)/, $(SUBDIRS_LST))

$(OBJS_DIR)/%.o: $(SRCS_DIR)/%.c $(INCS) Makefile | $(OBJS_DIR)
override COMPILED=1
    $(CC) $(CFLAGS) -I $(INCS_DIR) -c $< -o $@
    printf "$(BLUE)> Compiling :$(END) $<\n"

Do you have any explanation regarding this issue and/or a solution that could help me to solve the problem ?

Thank you !

Body:
Makefiles are not scripting languages.  Make doesn't read the makefile and run each rule as it's read.  Make will (1) parse the entire makefile (and any included files) and build an internal graph of all the prerequisites, than (2) run recipes for targets that are outdated.  Content that is NOT IN A RECIPE is always evaluated during the first step.  Content that IS IN A RECIPE is always evaluated during the second step.

Lines that are not indented with TABs, are not in recipes (and so are evaluated during the first step).  Lines that are indented with TABs, are in recipes (and so are evaluated--which means, given to the shell to execute--during the second step).

Maybe you can now see why your attempts cannot work: the if-statements and variable assignment of COMPILED are always evaluated, during the first step, before make has decided whether or not any targets should be built.

I'm not really sure I understand your goal.  If the recipe of your executable is being invoked then it means that all your source files have been compiled: that's what a makefile does.  Maybe you are trying to make a distinction between a build where at least one source file was compiled, and a build where no source files had to be recompiled but the target (the executable) was out of date?

If that's what you want the simple way to solve your problem is with automatic variables; for example the $? automatic variable expands to the list of prerequisites that were out of date.  You can do something like:

$(NAME): $(LIBFT_AR) $(OBJS)
        test -z '$(filter %.o,$?)' || printf "$(GREEN)> All the .c files have been compiled successfully !$(END)\n"
        printf "$(BLUE)> Creating the executable file :$(END) $@\n"
        $(CC) $(OBJS) $(LIBFT_AR) -lreadline -o $(NAME)
        printf "$(GREEN)> Executable file has been created successfully !$(END)\n"

The $(filter ...) function will expand to the list of .o files in the $? variable; if that's empty then no .o files were rebuilt.


来源: stackexchange

问:
Cannot read property 'providesTags' of undefined
I'm using RTK query to get one record via api via "useGetUserQuery"

Api Call is ok because backend have result.
I use sequelize and my result send data object.
I tried to erase providestags but i have the same issue.

My front-end return this error :

```<code>rtk-query.esm.js:771 Uncaught (in promise) TypeError: Cannot read property 'providesTags' of undefined
at calculateProvidedByThunk (rtk-query.esm.js:771)
at rtk-query.esm.js:908
at redux-toolkit.esm.js:603
at produce (immer.esm.js:1)
at redux-toolkit.esm.js:602
at Array.reduce (<anonymous>)
at redux-toolkit.esm.js:581
at combination (redux.js:528)
at reducer (rtk-query.esm.js:992)
at combination (redux.js:528)
at computeNextEntry (<anonymous>:3395:21)
at recomputeStates (<anonymous>:3429:17)
at <anonymous>:3809:22
at Object.dispatch (redux.js:288)
at dispatch (<anonymous>:3856:17)
at rtk-query.esm.js:1326
...
at rtk-query.esm.js:1418
at redux-toolkit.esm.js:386
at index.js:11
at redux-toolkit.esm.js:314
at dispatch (redux.js:659)
at redux-toolkit.esm.js:1144
at step (redux-toolkit.esm.js:38)
at Object.next (redux-toolkit.esm.js:19)
at fulfilled (redux-toolkit.esm.js:72)
</code>```

My code with RTK query is here :

```<code>import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'
import Cookie from 'js-cookie';
import React from 'react';

export interface User {
   id: string
   login: string
   password: string
   fonction: string
   imageprofil: string
   ...
}
React.useLayoutEffect = React.useEffect
type UsersResponse = User[]

export const api = createApi({
    baseQuery: fetchBaseQuery({ baseUrl: 'http://localhost:8080/api/',
    prepareHeaders: (headers) => {
        const token = Cookie.get('token');
        if (token) {
            headers.set('authorization', `Bearer ${token}`)
        }
        return headers
    },

}),
 tagTypes: 'User',

endpoints: (build) => ({

getUser: build.query<User, string>({
    query: (id) => ({url:'users/'+id}),
    providesTags: 'User',
}),
}),
}),
})

 export const {
     useGetUserQuery
 } = api
</code>```

答: My mistake was: I was using the same reducerPath more than one time. (this is why you should not do ctr+c, ctr+v)

ContentLicense: CC BY-SA 4.0

Body:
I'm using RTK query to get one record via api via "useGetUserQuery"

Api Call is ok because backend have result.
I use sequelize and my result send data object.
I tried to erase providestags but i have the same issue.

My front-end return this error :

rtk-query.esm.js:771 Uncaught (in promise) TypeError: Cannot read property 'providesTags' of undefined
at calculateProvidedByThunk (rtk-query.esm.js:771)
at rtk-query.esm.js:908
at redux-toolkit.esm.js:603
at produce (immer.esm.js:1)
at redux-toolkit.esm.js:602
at Array.reduce (<anonymous>)
at redux-toolkit.esm.js:581
at combination (redux.js:528)
at reducer (rtk-query.esm.js:992)
at combination (redux.js:528)
at computeNextEntry (<anonymous>:3395:21)
at recomputeStates (<anonymous>:3429:17)
at <anonymous>:3809:22
at Object.dispatch (redux.js:288)
at dispatch (<anonymous>:3856:17)
at rtk-query.esm.js:1326
...
at rtk-query.esm.js:1418
at redux-toolkit.esm.js:386
at index.js:11
at redux-toolkit.esm.js:314
at dispatch (redux.js:659)
at redux-toolkit.esm.js:1144
at step (redux-toolkit.esm.js:38)
at Object.next (redux-toolkit.esm.js:19)
at fulfilled (redux-toolkit.esm.js:72)

My code with RTK query is here :

import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'
import Cookie from 'js-cookie';
import React from 'react';

export interface User {
   id: string
   login: string
   password: string
   fonction: string
   imageprofil: string
   ...
}
React.useLayoutEffect = React.useEffect
type UsersResponse = User[]

export const api = createApi({
    baseQuery: fetchBaseQuery({ baseUrl: 'http://localhost:8080/api/',
    prepareHeaders: (headers) => {
        const token = Cookie.get('token');
        if (token) {
            headers.set('authorization', `Bearer ${token}`)
        }
        return headers
    },

}),
 tagTypes: 'User',

endpoints: (build) => ({

getUser: build.query<User, string>({
    query: (id) => ({url:'users/'+id}),
    providesTags: 'User',
}),
}),
}),
})

 export const {
     useGetUserQuery
 } = api


问:
Expo Stuck on Splash Screen
I recently my expo version and my app will now no longer work. I've even tried reverting my app's codebase to a previous commit before I made the changes to my packages. I don't get any errors, instead the app "boots" up and is stuck on the default expo splash screen.

update: Minimal reproducible example: https://github.com/atb-brown/expo-issue

update: A freshly initiated app seems to work: https://github.com/atb-brown/expo-issue/tree/expo-init

```<code>$ expo --version
5.0.3
</code>```

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@expo/vector-icons": "^12.0.0",
    "@react-native-async-storage/async-storage": "~1.15.0",
    "@react-navigation/bottom-tabs": "^6.0.5",
    "@react-navigation/native": "^6.0.2",
    "@react-navigation/native-stack": "^6.1.0",
    "@types/uuid": "^8.3.4",
    "ansi-regex": "^6.0.1",
    "eslint-config-prettier": "^8.3.0",
    "expo": "^44.0.0",
    "expo-asset": "~8.4.6",
    "expo-constants": "~13.0.1",
    "expo-font": "~10.0.4",
    "expo-linking": "~3.0.0",
    "expo-splash-screen": "~0.14.1",
    "expo-status-bar": "~1.2.0",
    "expo-web-browser": "~10.1.0",
    "node-notifier": "^10.0.1",
    "react": "17.0.1",
    "react-dom": "17.0.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-44.0.0.tar.gz",
    "react-native-gesture-handler": "~2.1.0",
    "react-native-get-random-values": "~1.7.0",
    "react-native-reanimated": "~2.3.1",
    "react-native-safe-area-context": "3.3.2",
    "react-native-screens": "~3.10.1",
    "react-native-web": "0.17.1",
    "reflect-metadata": "^0.1.13",
    "uuid": "^8.3.2"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@testing-library/jest-native": "^4.0.4",
    "@testing-library/react-hooks": "^7.0.2",
    "@testing-library/react-native": "^9.0.0",
    "@types/react": "~17.0.21",
    "@types/react-native": "~0.64.12",
    "@typescript-eslint/eslint-plugin": "^5.11.0",
    "@typescript-eslint/parser": "^5.11.0",
    "eslint": "^8.8.0",
    "eslint-config-google": "^0.14.0",
    "eslint-plugin-react": "^7.26.0",
    "eslint-plugin-react-hooks": "^4.3.0",
    "jest": "^26.6.3",
    "jest-expo": "^44.0.0",
    "prettier": "^2.4.1",
    "typescript": "~4.3.5",
    "yarn-audit-fix": "^9.0.10"
  },
  "resolutions": {
    "uuid": "^8.3.2"
  },
  "private": true
}
```

The Expo Go app on my android is version 2.23.2.

This is the screen that my app gets stuck on:

There are no errors in the console that I can see. What could possibly be going wrong here?

答:
It turns out that the issue in my case was that I was resolving the uuid package.

  "resolutions": {
    "uuid": "^8.3.2"
  }
```

Removing uuid from my resolutions fixed my issue, although I still don't know precisely what was going wrong, but clearly Expo needed something from a different version of a uuid package.

Title: Expo Stuck on Splash Screen

Body:
I recently my expo version and my app will now no longer work. I've even tried reverting my app's codebase to a previous commit before I made the changes to my packages. I don't get any errors, instead the app "boots" up and is stuck on the default expo splash screen.

update: Minimal reproducible example: https://github.com/atb-brown/expo-issue

update: A freshly initiated app seems to work: https://github.com/atb-brown/expo-issue/tree/expo-init

$ expo --version
5.0.3

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@expo/vector-icons": "^12.0.0",
    "@react-native-async-storage/async-storage": "~1.15.0",
    "@react-navigation/bottom-tabs": "^6.0.5",
    "@react-navigation/native": "^6.0.2",
    "@react-navigation/native-stack": "^6.1.0",
    "@types/uuid": "^8.3.4",
    "ansi-regex": "^6.0.1",
    "eslint-config-prettier": "^8.3.0",
    "expo": "^44.0.0",
    "expo-asset": "~8.4.6",
    "expo-constants": "~13.0.1",
    "expo-font": "~10.0.4",
    "expo-linking": "~3.0.0",
    "expo-splash-screen": "~0.14.1",
    "expo-status-bar": "~1.2.0",
    "expo-web-browser": "~10.1.0",
    "node-notifier": "^10.0.1",
    "react": "17.0.1",
    "react-dom": "17.0.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-44.0.0.tar.gz",
    "react-native-gesture-handler": "~2.1.0",
    "react-native-get-random-values": "~1.7.0",
    "react-native-reanimated": "~2.3.1",
    "react-native-safe-area-context": "3.3.2",
    "react-native-screens": "~3.10.1",
    "react-native-web": "0.17.1",
    "reflect-metadata": "^0.1.13",
    "uuid": "^8.3.2"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@testing-library/jest-native": "^4.0.4",
    "@testing-library/react-hooks": "^7.0.2",
    "@testing-library/react-native": "^9.0.0",
    "@types/react": "~17.0.21",
    "@types/react-native": "~0.64.12",
    "@typescript-eslint/eslint-plugin": "^5.11.0",
    "@typescript-eslint/parser": "^5.11.0",
    "eslint": "^8.8.0",
    "eslint-config-google": "^0.14.0",
    "eslint-plugin-react": "^7.26.0",
    "eslint-plugin-react-hooks": "^4.3.0",
    "jest": "^26.6.3",
    "jest-expo": "^44.0.0",
    "prettier": "^2.4.1",
    "typescript": "~4.3.5",
    "yarn-audit-fix": "^9.0.10"
  },
  "resolutions": {
    "uuid": "^8.3.2"
  },
  "private": true
}

The Expo Go app on my android is version 2.23.2.

This is the screen that my app gets stuck on:

There are no errors in the console that I can see. What could possibly be going wrong here?

Body:
It turns out that the issue in my case was that I was resolving the uuid package.

  "resolutions": {
    "uuid": "^8.3.2"
  }

Removing uuid from my resolutions fixed my issue, although I still don't know precisely what was going wrong, but clearly Expo needed something from a different version of a uuid package.


问:
Unable to update batchtimeout in orderer configuration?
I have created a network of fabric and it running fine. I want to update the oderer configuration such as batchtimeout in running network. I have followed this tutorial to update the channel configuration at runtime. This tutorial works for adding a new org. But when i am updating orderer configuration then i am getting error as

Error: got unexpected status: BAD_REQUEST -- error applying config
  update to existing channel 'mychannel': error authorizing update:
  error validating DeltaSet: policy for [Value]
  /Channel/Orderer/BatchTimeout not satisfied: implicit policy
  evaluation failed - 0 sub-policies were satisfied, but this policy
  requires 1 of the 'Admins' sub-policies to be satisfied

I sigining the envelope.pb file from all the org admins such as org1 and org2. Kindly help me with this.

Note: I have used fabric-samples first-network for this.

EDIT:
I have signed pb file with org1 and org2.I have also signed it with orderer by exporting below variables

```<code>CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/users/Admin\@example.com/msp/

CORE_PEER_ADDRESS=orderer.example.com:7050

CORE_PEER_LOCALMSPID=OrdererMSP

CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt
</code>```

Logs

```<code>11-28 09:13:57.207 UTC [policies] Manager -> DEBU cc4 Manager Channel/Orderer looking up path []
2019-11-28 09:13:57.207 UTC [policies] Manager -> DEBU cc5 Manager Channel/Orderer has managers OrdererOrg
2019-11-28 09:13:57.207 UTC [policies] Evaluate -> DEBU cc6 == Evaluating *policies.implicitMetaPolicy Policy /Channel/Orderer/Admins ==
2019-11-28 09:13:57.207 UTC [policies] Evaluate -> DEBU cc7 This is an implicit meta policy, it will trigger other policy evaluations, whose failures may be benign
2019-11-28 09:13:57.207 UTC [policies] Evaluate -> DEBU cc8 == Evaluating *cauthdsl.policy Policy /Channel/Orderer/OrdererOrg/Admins ==
2019-11-28 09:13:57.207 UTC [cauthdsl] deduplicate -> WARN cc9 De-duplicating identity [OrdererMSP95598fd8d4ea9aa73dad2aee5bc32375d01e3ed9da0a25c2f64ae1067af7ac74] at index 1 in signature set
2019-11-28 09:13:57.207 UTC [cauthdsl] deduplicate -> WARN cca De-duplicating identity [OrdererMSP95598fd8d4ea9aa73dad2aee5bc32375d01e3ed9da0a25c2f64ae1067af7ac74] at index 2 in signature set
2019-11-28 09:13:57.208 UTC [cauthdsl] func1 -> DEBU ccb 0xc000c99ef0 gate 1574932437208001961 evaluation starts
2019-11-28 09:13:57.208 UTC [cauthdsl] func2 -> DEBU ccc 0xc000c99ef0 signed by 0 principal evaluation starts (used [false false false])
2019-11-28 09:13:57.208 UTC [cauthdsl] func2 -> DEBU ccd 0xc000c99ef0 processing identity 0 with bytes of a1f390
2019-11-28 09:13:57.208 UTC [msp] satisfiesPrincipalInternalV143 -> DEBU cce Checking if identity has been named explicitly as an admin for OrdererMSP
2019-11-28 09:13:57.208 UTC [msp] satisfiesPrincipalInternalV143 -> DEBU ccf Checking if identity carries the admin ou for OrdererMSP
2019-11-28 09:13:57.208 UTC [msp] Validate -> DEBU cd0 MSP OrdererMSP validating identity
2019-11-28 09:13:57.208 UTC [msp] getCertificationChain -> DEBU cd1 MSP OrdererMSP getting certification chain
2019-11-28 09:13:57.208 UTC [msp] hasOURole -> DEBU cd2 MSP OrdererMSP checking if the identity is a client
2019-11-28 09:13:57.208 UTC [msp] getCertificationChain -> DEBU cd3 MSP OrdererMSP getting certification chain
2019-11-28 09:13:57.208 UTC [cauthdsl] func2 -> DEBU cd4 0xc000c99ef0 identity 0 does not satisfy principal: The identity is not an admin under this MSP [OrdererMSP]: The identity does not contain OU [ADMIN], MSP: [OrdererMSP]
2019-11-28 09:13:57.208 UTC [cauthdsl] func2 -> DEBU cd5 0xc000c99ef0 principal evaluation fails
2019-11-28 09:13:57.208 UTC [cauthdsl] func1 -> DEBU cd6 0xc000c99ef0 gate 1574932437208001961 evaluation fails
2019-11-28 09:13:57.208 UTC [policies] Evaluate -> DEBU cd7 Signature set did not satisfy policy /Channel/Orderer/OrdererOrg/Admins
2019-11-28 09:13:57.208 UTC [policies] Evaluate -> DEBU cd8 == Done Evaluating *cauthdsl.policy Policy /Channel/Orderer/OrdererOrg/Admins
2019-11-28 09:13:57.208 UTC [policies] func1 -> DEBU cd9 Evaluation Failed: Only 0 policies were satisfied, but needed 1 of [ OrdererOrg/Admins ]
2019-11-28 09:13:57.208 UTC [policies] Evaluate -> DEBU cda Signature set did not satisfy policy /Channel/Orderer/Admins
2019-11-28 09:13:57.208 UTC [policies] Evaluate -> DEBU cdb == Done Evaluating *policies.implicitMetaPolicy Policy /Channel/Orderer/Admins
2019-11-28 09:13:57.208 UTC [orderer.common.broadcast] ProcessMessage -> WARN cdc [channel: mychannel] Rejecting broadcast of config message from 172.25.0.7:42570 because of error: error applying config update to existing channel 'mychannel': error authorizing update: error validating DeltaSet: policy for [Value]  /Channel/Orderer/BatchTimeout not satisfied: implicit policy evaluation failed - 0 sub-policies were satisfied, but this policy requires 1 of the 'Admins' sub-policies to be satisfied
2019-11-28 09:13:57.208 UTC [orderer.common.server] func1 -> DEBU cdd Closing Broadcast stream
2019-11-28 09:13:57.208 UTC [comm.grpc.server] 1 -> INFO cde streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Broadcast grpc.peer_address=172.25.0.7:42570 grpc.code=OK grpc.call_duration=1.864323ms
2019-11-28 09:13:57.209 UTC [grpc] warningf -> DEBU cdf transport: http2Server.HandleStreams failed to read frame: read tcp 172.25.0.3:7050->172.25.0.7:42570: read: connection reset by peer
2019-11-28 09:13:57.209 UTC [grpc] infof -> DEBU ce0 transport: loopyWriter.run returning. connection error: desc = "transport is closing"
2019-11-28 09:13:57.209 UTC [grpc] infof -> DEBU ce1 transport: loopyWriter.run returning. connection error: desc = "transport is closing"
2019-11-28 09:13:57.209 UTC [common.deliver] Handle -> WARN ce2 Error reading from 172.25.0.7:42568: rpc error: code = Canceled desc = context canceled
2019-11-28 09:13:57.209 UTC [orderer.common.server] func1 -> DEBU ce3 Closing Deliver stream
2019-11-28 09:13:57.209 UTC [comm.grpc.server] 1 -> INFO ce4 streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Deliver grpc.peer_address=172.25.0.7:42568 error="rpc error: code = Canceled desc = context canceled" grpc.code=Canceled grpc.call_duration=4.921585ms
</code>```

Updated env

```<code>CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt
    CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
    CORE_PEER_LOCALMSPID=OrdererMSP
    CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
    CORE_PEER_TLS_ENABLED=true
    CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/users/Admin@example.com/msp/
    CORE_PEER_ID=cli
    CORE_PEER_ADDRESS=orderer.example.com:7050
</code>```

答:
Try this:

Export orderer organization environment:
```<code>export CH_NAME=<your-channel>
export CORE_PEER_LOCALMSPID="OrdererMSP"
export CORE_PEER_MSPCONFIGPATH=<ca-client-path>/organizations/ordererOrganizations/orderer.com/users/admin@orderer.com/msp/    <OR>    <your-orderer-admin-msp-path>
export ORDERER_CONTAINER=localhost:7050
export ORDERER_CA=../../ca/fabric-ca-client/organizations/ordererOrganizations/orderer.com/msp/tlscacerts/<your-tls-cert>.pem    <OR>        <your-orderer-tlscert-path>
export FABRIC_CFG_PATH=../../peers/<your-org-peer>
</code>```

Sign-in using the signconfigtx tool:
```<code>peer channel signconfigtx -f <your-enveloped-config>.pb
</code>```

Try to send the config update again:
```<code>peer channel update -f <your-enveloped-config>.pb -c $CH_NAME -o $ORDERER_CONTAINER --tls --cafile $TLS_ROOT_CA
</code>```

Body:
I have created a network of fabric and it running fine. I want to update the oderer configuration such as batchtimeout in running network. I have followed this tutorial to update the channel configuration at runtime. This tutorial works for adding a new org. But when i am updating orderer configuration then i am getting error as

Error: got unexpected status: BAD_REQUEST -- error applying config
  update to existing channel 'mychannel': error authorizing update:
  error validating DeltaSet: policy for [Value]
  /Channel/Orderer/BatchTimeout not satisfied: implicit policy
  evaluation failed - 0 sub-policies were satisfied, but this policy
  requires 1 of the 'Admins' sub-policies to be satisfied

I sigining the envelope.pb file from all the org admins such as org1 and org2. Kindly help me with this.

Note: I have used fabric-samples first-network for this.

EDIT:
I have signed pb file with org1 and org2.I have also signed it with orderer by exporting below variables

CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/users/Admin\@example.com/msp/

CORE_PEER_ADDRESS=orderer.example.com:7050

CORE_PEER_LOCALMSPID=OrdererMSP

CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt

Logs

11-28 09:13:57.207 UTC [policies] Manager -> DEBU cc4 Manager Channel/Orderer looking up path []
2019-11-28 09:13:57.207 UTC [policies] Manager -> DEBU cc5 Manager Channel/Orderer has managers OrdererOrg
2019-11-28 09:13:57.207 UTC [policies] Evaluate -> DEBU cc6 == Evaluating *policies.implicitMetaPolicy Policy /Channel/Orderer/Admins ==
2019-11-28 09:13:57.207 UTC [policies] Evaluate -> DEBU cc7 This is an implicit meta policy, it will trigger other policy evaluations, whose failures may be benign
2019-11-28 09:13:57.207 UTC [policies] Evaluate -> DEBU cc8 == Evaluating *cauthdsl.policy Policy /Channel/Orderer/OrdererOrg/Admins ==
2019-11-28 09:13:57.207 UTC [cauthdsl] deduplicate -> WARN cc9 De-duplicating identity [OrdererMSP95598fd8d4ea9aa73dad2aee5bc32375d01e3ed9da0a25c2f64ae1067af7ac74] at index 1 in signature set
2019-11-28 09:13:57.207 UTC [cauthdsl] deduplicate -> WARN cca De-duplicating identity [OrdererMSP95598fd8d4ea9aa73dad2aee5bc32375d01e3ed9da0a25c2f64ae1067af7ac74] at index 2 in signature set
2019-11-28 09:13:57.208 UTC [cauthdsl] func1 -> DEBU ccb 0xc000c99ef0 gate 1574932437208001961 evaluation starts
2019-11-28 09:13:57.208 UTC [cauthdsl] func2 -> DEBU ccc 0xc000c99ef0 signed by 0 principal evaluation starts (used [false false false])
2019-11-28 09:13:57.208 UTC [cauthdsl] func2 -> DEBU ccd 0xc000c99ef0 processing identity 0 with bytes of a1f390
2019-11-28 09:13:57.208 UTC [msp] satisfiesPrincipalInternalV143 -> DEBU cce Checking if identity has been named explicitly as an admin for OrdererMSP
2019-11-28 09:13:57.208 UTC [msp] satisfiesPrincipalInternalV143 -> DEBU ccf Checking if identity carries the admin ou for OrdererMSP
2019-11-28 09:13:57.208 UTC [msp] Validate -> DEBU cd0 MSP OrdererMSP validating identity
2019-11-28 09:13:57.208 UTC [msp] getCertificationChain -> DEBU cd1 MSP OrdererMSP getting certification chain
2019-11-28 09:13:57.208 UTC [msp] hasOURole -> DEBU cd2 MSP OrdererMSP checking if the identity is a client
2019-11-28 09:13:57.208 UTC [msp] getCertificationChain -> DEBU cd3 MSP OrdererMSP getting certification chain
2019-11-28 09:13:57.208 UTC [cauthdsl] func2 -> DEBU cd4 0xc000c99ef0 identity 0 does not satisfy principal: The identity is not an admin under this MSP [OrdererMSP]: The identity does not contain OU [ADMIN], MSP: [OrdererMSP]
2019-11-28 09:13:57.208 UTC [cauthdsl] func2 -> DEBU cd5 0xc000c99ef0 principal evaluation fails
2019-11-28 09:13:57.208 UTC [cauthdsl] func1 -> DEBU cd6 0xc000c99ef0 gate 1574932437208001961 evaluation fails
2019-11-28 09:13:57.208 UTC [policies] Evaluate -> DEBU cd7 Signature set did not satisfy policy /Channel/Orderer/OrdererOrg/Admins
2019-11-28 09:13:57.208 UTC [policies] Evaluate -> DEBU cd8 == Done Evaluating *cauthdsl.policy Policy /Channel/Orderer/OrdererOrg/Admins
2019-11-28 09:13:57.208 UTC [policies] func1 -> DEBU cd9 Evaluation Failed: Only 0 policies were satisfied, but needed 1 of [ OrdererOrg/Admins ]
2019-11-28 09:13:57.208 UTC [policies] Evaluate -> DEBU cda Signature set did not satisfy policy /Channel/Orderer/Admins
2019-11-28 09:13:57.208 UTC [policies] Evaluate -> DEBU cdb == Done Evaluating *policies.implicitMetaPolicy Policy /Channel/Orderer/Admins
2019-11-28 09:13:57.208 UTC [orderer.common.broadcast] ProcessMessage -> WARN cdc [channel: mychannel] Rejecting broadcast of config message from 172.25.0.7:42570 because of error: error applying config update to existing channel 'mychannel': error authorizing update: error validating DeltaSet: policy for [Value]  /Channel/Orderer/BatchTimeout not satisfied: implicit policy evaluation failed - 0 sub-policies were satisfied, but this policy requires 1 of the 'Admins' sub-policies to be satisfied
2019-11-28 09:13:57.208 UTC [orderer.common.server] func1 -> DEBU cdd Closing Broadcast stream
2019-11-28 09:13:57.208 UTC [comm.grpc.server] 1 -> INFO cde streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Broadcast grpc.peer_address=172.25.0.7:42570 grpc.code=OK grpc.call_duration=1.864323ms
2019-11-28 09:13:57.209 UTC [grpc] warningf -> DEBU cdf transport: http2Server.HandleStreams failed to read frame: read tcp 172.25.0.3:7050->172.25.0.7:42570: read: connection reset by peer
2019-11-28 09:13:57.209 UTC [grpc] infof -> DEBU ce0 transport: loopyWriter.run returning. connection error: desc = "transport is closing"
2019-11-28 09:13:57.209 UTC [grpc] infof -> DEBU ce1 transport: loopyWriter.run returning. connection error: desc = "transport is closing"
2019-11-28 09:13:57.209 UTC [common.deliver] Handle -> WARN ce2 Error reading from 172.25.0.7:42568: rpc error: code = Canceled desc = context canceled
2019-11-28 09:13:57.209 UTC [orderer.common.server] func1 -> DEBU ce3 Closing Deliver stream
2019-11-28 09:13:57.209 UTC [comm.grpc.server] 1 -> INFO ce4 streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Deliver grpc.peer_address=172.25.0.7:42568 error="rpc error: code = Canceled desc = context canceled" grpc.code=Canceled grpc.call_duration=4.921585ms

Updated env

CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt
    CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
    CORE_PEER_LOCALMSPID=OrdererMSP
    CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
    CORE_PEER_TLS_ENABLED=true
    CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/users/Admin@example.com/msp/
    CORE_PEER_ID=cli
    CORE_PEER_ADDRESS=orderer.example.com:7050

Body:
Try this:

Export orderer organization environment:

export CH_NAME=<your-channel>
export CORE_PEER_LOCALMSPID="OrdererMSP"
export CORE_PEER_MSPCONFIGPATH=<ca-client-path>/organizations/ordererOrganizations/orderer.com/users/admin@orderer.com/msp/    <OR>    <your-orderer-admin-msp-path>
export ORDERER_CONTAINER=localhost:7050
export ORDERER_CA=../../ca/fabric-ca-client/organizations/ordererOrganizations/orderer.com/msp/tlscacerts/<your-tls-cert>.pem    <OR>        <your-orderer-tlscert-path>
export FABRIC_CFG_PATH=../../peers/<your-org-peer>

Sign-in using the signconfigtx tool:

peer channel signconfigtx -f <your-enveloped-config>.pb

Try to send the config update again:

peer channel update -f <your-enveloped-config>.pb -c $CH_NAME -o $ORDERER_CONTAINER --tls --cafile $TLS_ROOT_CA


问:
Problem in strong tag when Parsing Html in swift 5
Hi i have a problem when im parsing a Html to NSAtributtedString in a UILabel.
The problem is in the strong text, the result is too bold (I guess when parsing the font is changed to "GibsonBold" and I need GibsonSemibold, or even change from Regular to Medium. I tried change tag to  or implement an style, but the result is always the same. Also I tried several extensions but I came out whit the same result.

This is the html String:

```<code>"<p>First text <strong> this text should be at lest Semibold</strong>. Final text.</p>"
</code>```

Im using this two extension to parsing:

```<code>extension UIColor {
    var hexString:String? {
        if let components = self.cgColor.components {
            let r = components[0]
            let g = components[1]
            let b = components[2]
            return  String(format: "%02X%02X%02X", (Int)(r * 255), (Int)(g * 255), (Int)(b * 255))
        }
        return nil
    }
}

extension String {
    var html2Attributed: NSAttributedString? {
        do {
            guard let data = data(using: String.Encoding.utf8) else {
                return nil
            }
            return try NSAttributedString(data: data,
                                          options: [.documentType: NSAttributedString.DocumentType.html,
                                                    .characterEncoding: String.Encoding.utf8.rawValue],
                                          documentAttributes: nil)
        } catch {
            print("error: ", error)
            return nil
        }
    }

    var htmlAttributed: (NSAttributedString?, NSDictionary?) {
        do {
            guard let data = data(using: String.Encoding.utf8) else {
                return (nil, nil)
            }

            var dict:NSDictionary?
            dict = NSMutableDictionary()

            return try (NSAttributedString(data: data,
                                          options: [.documentType: NSAttributedString.DocumentType.html,
                                                    .characterEncoding: String.Encoding.utf8.rawValue],
                                          documentAttributes: &dict), dict)
        } catch {
            print("error: ", error)
            return (nil, nil)
        }
    }

    func htmlAttributed(using font: UIFont, color: UIColor, lineHeight: CGFloat) -> NSAttributedString? {
        do {
            let htmlCSSString = "<style>" +
                "html *" +
                "{" +
                "font-size: \(font.pointSize * 0.75)pt !important;" +
                "color: #\(color.hexString!) !important;" +
                "font-family: \(font.familyName), Helvetica !important;" +
                "line-height: \(lineHeight * 0.06) !important;" +
                "}</style> \(self)"

            guard let data = htmlCSSString.data(using: String.Encoding.utf8) else {
                return nil
            }

            return try NSAttributedString(data: data,
                                          options: [.documentType: NSAttributedString.DocumentType.html,
                                                    .characterEncoding: String.Encoding.utf8.rawValue],
                                          documentAttributes: nil)
        } catch {
            print("error: ", error)
            return nil
        }
    }
}
</code>```

And the implementation in label:

```<code>descriptionLabelText.attributedText = description.htmlAttributed(using: UIFont.gibsonRegular.withAdjustedSize(16),
                                                                    color: .greyscale800,
                                                                    lineHeight: 20.adjusted)
</code>```

答:
Currently all the css styling only defines the font to use and the font size, not really the style (bold, italic, regular etc) or the weights (normal, bold, light etc) so these tags pick up the default styles of the  tag.

I created the following HTML

```<code>let htmlString
            = "<p>Normal text <strong> Strong set to 600 font weight </strong>. <b> Bold set to italic style </b>"
</code>```

And then I use your code like this

```<code>label.attributedText = htmlString.htmlAttributed(using: UIFont(name: "Gibson-Regular",
                                                               size: 16)!,
                                                 color: .red,
                                                 lineHeight: 20)
</code>```

This gives me the following result as you probably see now

If you added all the fonts (Gibson regular, bold, italic) to your file system properly, you can add specific styles in your CSS.

Small changes to your func htmlAttributed

```<code>func htmlAttributed(using font: UIFont,
                    color: UIColor,
                    lineHeight: CGFloat) -> NSAttributedString? {
    do {
        let htmlCSSString = "<style>" +
            "html *" +
            "{" +
            "font-size: \(font.pointSize * 0.75)pt !important;" +
            "color: #\(color.hexString!) !important;" +
            "font-family: \(font.familyName), Helvetica !important;" +
            "line-height: \(lineHeight * 0.06) !important;" +
            "}" +

            // customize bold
            "b" +
            "{" +
            "font-size: \(font.pointSize * 0.75)pt !important;" +
            "font-style: italic;" + // I set bold to be italic
            "font-family: \(font.familyName), Helvetica !important;" +
            "line-height: \(lineHeight * 0.06) !important;" +
            "}" +

            // customize strong font weight
            // https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight
            "strong" +
            "{" +
            "font-size: \(font.pointSize * 0.75)pt !important;" +
            "font-weight: 600;" + // customize weight to what you want
            "font-family: \(font.familyName), Helvetica !important;" +
            "line-height: \(lineHeight * 0.06) !important;" +
            "}" +

            "}</style> \(self)"

        guard let data = htmlCSSString.data(using: String.Encoding.utf8) else {
            return nil
        }

        return try NSAttributedString(data: data,
                                      options: [.documentType: NSAttributedString.DocumentType.html,
                                                .characterEncoding: String.Encoding.utf8.rawValue],
                                      documentAttributes: nil)
    } catch {
        print("error: ", error)
        return nil
    }
}
</code>```

With this change you will see some changes to the weight of the strong tag and I made the b tag render as italics

Finally, as far as I know, you cannot set the weight to Semi Bold so if you want to use the Semi Bold font, you have explicitly set this as the font you want to use.

So you can customize the strong tag:

// I set font family to Gibson italic for example
// You can set it to semi bold font
"strong" +
"{" +
"font-size: \(font.pointSize * 0.75)pt !important;" +
"font-family: \(UIFont(name: "Gibson-Italic", size: 16)!), Helvetica !important;" +
"line-height: \(lineHeight * 0.06) !important;" +
"}" +

```

I think this should give you some ideas on how to customize to suit your solution

Body:
Hi i have a problem when im parsing a Html to NSAtributtedString in a UILabel.
The problem is in the strong text, the result is too bold (I guess when parsing the font is changed to "GibsonBold" and I need GibsonSemibold, or even change from Regular to Medium. I tried change tag to  or implement an style, but the result is always the same. Also I tried several extensions but I came out whit the same result.

This is the html String:

"
First text  this text should be at lest Semibold. Final text.
"

Im using this two extension to parsing:

extension UIColor {
    var hexString:String? {
        if let components = self.cgColor.components {
            let r = components[0]
            let g = components[1]
            let b = components[2]
            return  String(format: "%02X%02X%02X", (Int)(r * 255), (Int)(g * 255), (Int)(b * 255))
        }
        return nil
    }
}

extension String {
    var html2Attributed: NSAttributedString? {
        do {
            guard let data = data(using: String.Encoding.utf8) else {
                return nil
            }
            return try NSAttributedString(data: data,
                                          options: [.documentType: NSAttributedString.DocumentType.html,
                                                    .characterEncoding: String.Encoding.utf8.rawValue],
                                          documentAttributes: nil)
        } catch {
            print("error: ", error)
            return nil
        }
    }

    var htmlAttributed: (NSAttributedString?, NSDictionary?) {
        do {
            guard let data = data(using: String.Encoding.utf8) else {
                return (nil, nil)
            }

            var dict:NSDictionary?
            dict = NSMutableDictionary()

            return try (NSAttributedString(data: data,
                                          options: [.documentType: NSAttributedString.DocumentType.html,
                                                    .characterEncoding: String.Encoding.utf8.rawValue],
                                          documentAttributes: &dict), dict)
        } catch {
            print("error: ", error)
            return (nil, nil)
        }
    }

    func htmlAttributed(using font: UIFont, color: UIColor, lineHeight: CGFloat) -> NSAttributedString? {
        do {
            let htmlCSSString = " \(self)"

            guard let data = htmlCSSString.data(using: String.Encoding.utf8) else {
                return nil
            }

            return try NSAttributedString(data: data,
                                          options: [.documentType: NSAttributedString.DocumentType.html,
                                                    .characterEncoding: String.Encoding.utf8.rawValue],
                                          documentAttributes: nil)
        } catch {
            print("error: ", error)
            return nil
        }
    }
}

And the implementation in label:

descriptionLabelText.attributedText = description.htmlAttributed(using: UIFont.gibsonRegular.withAdjustedSize(16),
                                                                    color: .greyscale800,
                                                                    lineHeight: 20.adjusted)

Body:
Currently all the css styling only defines the font to use and the font size, not really the style (bold, italic, regular etc) or the weights (normal, bold, light etc) so these tags pick up the default styles of the  tag.

I created the following HTML

let htmlString
            = "<p>Normal text <strong> Strong set to 600 font weight </strong>. <b> Bold set to italic style </b>"

And then I use your code like this

label.attributedText = htmlString.htmlAttributed(using: UIFont(name: "Gibson-Regular",
                                                               size: 16)!,
                                                 color: .red,
                                                 lineHeight: 20)

This gives me the following result as you probably see now

If you added all the fonts (Gibson regular, bold, italic) to your file system properly, you can add specific styles in your CSS.

Small changes to your func htmlAttributed

func htmlAttributed(using font: UIFont,
                    color: UIColor,
                    lineHeight: CGFloat) -> NSAttributedString? {
    do {
        let htmlCSSString = "<style>" +
            "html *" +
            "{" +
            "font-size: \(font.pointSize * 0.75)pt !important;" +
            "color: #\(color.hexString!) !important;" +
            "font-family: \(font.familyName), Helvetica !important;" +
            "line-height: \(lineHeight * 0.06) !important;" +
            "}" +

            // customize bold
            "b" +
            "{" +
            "font-size: \(font.pointSize * 0.75)pt !important;" +
            "font-style: italic;" + // I set bold to be italic
            "font-family: \(font.familyName), Helvetica !important;" +
            "line-height: \(lineHeight * 0.06) !important;" +
            "}" +

            // customize strong font weight
            // https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight
            "strong" +
            "{" +
            "font-size: \(font.pointSize * 0.75)pt !important;" +
            "font-weight: 600;" + // customize weight to what you want
            "font-family: \(font.familyName), Helvetica !important;" +
            "line-height: \(lineHeight * 0.06) !important;" +
            "}" +

            "}</style> \(self)"

        guard let data = htmlCSSString.data(using: String.Encoding.utf8) else {
            return nil
        }

        return try NSAttributedString(data: data,
                                      options: [.documentType: NSAttributedString.DocumentType.html,
                                                .characterEncoding: String.Encoding.utf8.rawValue],
                                      documentAttributes: nil)
    } catch {
        print("error: ", error)
        return nil
    }
}

With this change you will see some changes to the weight of the strong tag and I made the b tag render as italics

Finally, as far as I know, you cannot set the weight to Semi Bold so if you want to use the Semi Bold font, you have explicitly set this as the font you want to use.

So you can customize the strong tag:

// I set font family to Gibson italic for example
// You can set it to semi bold font
"strong" +
"{" +
"font-size: \(font.pointSize * 0.75)pt !important;" +
"font-family: \(UIFont(name: "Gibson-Italic", size: 16)!), Helvetica !important;" +
"line-height: \(lineHeight * 0.06) !important;" +
"}" +

I think this should give you some ideas on how to customize to suit your solution


问:
Unable to override the connection timeout value in JMeter
I tried to set the deafult connection and response timeout values to 120000 milliseconds (120 seconds) both for the request default and individual requests, but the test still fails if it takes more than 20 seconds. It runs for few threads for say 300, but does not run for more, say 400.

I also tried changing the timeout values in jmeter properties file, but still the results were same

Does anyone know how to change the timeout values? enter image description here
enter image description here
enter image description here

答:
I don't think it's JMeter timeouts, as far as I can see maximum response time is 21 seconds so most probably it's the system under test which has the timeout on its side, some form of logic that terminates connections after 21 seconds.

So check the sever-side settings.

Also given you cannot reproduce it using lower number of threads I would say that the system under test gets overloaded so you can do the following:

Check logs for any suspicious entries

Ensure that there is enough headroom to operate in terms of CPU, RAM, Network, Disk, Swap, etc. If no better solution is there already you can use JMeter PerfMon Plugin

Check database logs in terms of heaviest and slowest queries

If there is an APM or a profiler tool connected to the application look into its output to see what is under the hood of requests which take > 20 seconds.


问:
create an int column after dividing a column by a number in pandas
Assume that I have a panda data frame with a column that holds seconds.

I want to create a new column that holds minutes. so I divide the sec column by 60. The problem that I have is that min column is not an integer anymore. How can I make it an integer?

I have this code:

```<code>alldata['min']=alldata['sec']/60
</code>```

I tried this, but it did not work:

```<code>alldata['min']=int(alldata['sec']/60)
</code>```

I am getting this error:

```<code>TypeError: cannot convert the series to <class 'int'>
</code>```

I tried this:

```<code>alldata["min"] = pd.to_numeric(alldata["min"], downcast='integer')
</code>```

but I still have float values in min column.

How can have integer values for min? (Just drop the value to its floor value)

答:
You can use .astype() to convert dataframe columns to different types. In your case use the following line:

```<code>alldata['min']= (alldata['sec']/60).astype("int")
</code>```

DocPage

Body:
Assume that I have a panda data frame with a column that holds seconds.

I want to create a new column that holds minutes. so I divide the sec column by 60. The problem that I have is that min column is not an integer anymore. How can I make it an integer?

I have this code:

alldata['min']=alldata['sec']/60

I tried this, but it did not work:

alldata['min']=int(alldata['sec']/60)

I am getting this error:

TypeError: cannot convert the series to <class 'int'>

I tried this:

alldata["min"] = pd.to_numeric(alldata["min"], downcast='integer')

but I still have float values in min column.

How can have integer values for min? (Just drop the value to its floor value)

Body:
You can use .astype() to convert dataframe columns to different types. In your case use the following line:

alldata['min']= (alldata['sec']/60).astype("int")

DocPage


问:
Cannot GET / http://localhost:8080/ for rxjs local setup
Trying to setup my local server in order to run rxjs code

Package.json

```<code> {
      "name": "rxjs",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "start": "webpack-dev-server --mode development"

      },
      "keywords": [],
      "author": "",
      "license": "ISC",
      "dependencies": {
        "rxjs": "^7.5.4",
        "ts-loader": "^9.2.6",
        "typescript": "^4.5.5",
        "webpack": "^5.68.0",
        "webpack-dev-server": "^4.7.4"
      },
      "devDependencies": {
        "webpack-cli": "^4.9.2"
      }
    }
</code>```

ts config.json

```<code>{
    "compilerOptions": {
      "outDir": "./dist/",
      "sourceMap": true,
      "noImplicitAny": true,
      "module": "es6",
      "moduleResolution": "node",
      "target": "es6",
      "allowJs": true,
      "lib": [
        "es2017",
        "dom"
      ]
    }
}
</code>```

webpack.config.js

```<code>const path = require('path');
module.exports = {
    entry: './src/index.ts',
    devtool: 'inline-source-map',
    module: {
      rules: [
        {
          test: /\.tsx?$/,
          use: 'ts-loader',
          exclude: /node_modules/
        }
      ]
    },
    devServer: {
        historyApiFallback: true,
      },
    resolve: {
      extensions: [ '.tsx', '.ts', '.js' ]
    },
    output: {
      filename: 'bundle.js',
      path: path.resolve(__dirname, 'dist')
    }
};
</code>```

Index.html

```<code><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>RxJS Demo</title>
    <style>
        body { font-family: 'Arial'; background: lightgray }
        ul { list-style-type: none; padding: 20px; }
        li { padding: 15px; background: lightcoral; margin-bottom: 10px; }
    </style>
</head>
<body>
    <h1>RxJS Demo</h1>
    <div>
        <ul id="list"></ul>
    </div>
    <script src="/bundle.js"></script>
</body>
</html>
</code>```

index.ts

```<code>import * as RX from "rxjs";

console.log("hai",RX)
</code>```

Here is my file structure

I tried npm run start and getting this

答:
It looks like you haven't configured a port for the DevServer. The default is "auto".

You'll probably want to change your we pack.config.js devServer section to include

port: 8080

Body:
Trying to setup my local server in order to run rxjs code

Package.json

 {
      "name": "rxjs",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "start": "webpack-dev-server --mode development"

      },
      "keywords": [],
      "author": "",
      "license": "ISC",
      "dependencies": {
        "rxjs": "^7.5.4",
        "ts-loader": "^9.2.6",
        "typescript": "^4.5.5",
        "webpack": "^5.68.0",
        "webpack-dev-server": "^4.7.4"
      },
      "devDependencies": {
        "webpack-cli": "^4.9.2"
      }
    }

ts config.json

{
    "compilerOptions": {
      "outDir": "./dist/",
      "sourceMap": true,
      "noImplicitAny": true,
      "module": "es6",
      "moduleResolution": "node",
      "target": "es6",
      "allowJs": true,
      "lib": [
        "es2017",
        "dom"
      ]
    }
}

webpack.config.js

const path = require('path');
module.exports = {
    entry: './src/index.ts',
    devtool: 'inline-source-map',
    module: {
      rules: [
        {
          test: /\.tsx?$/,
          use: 'ts-loader',
          exclude: /node_modules/
        }
      ]
    },
    devServer: {
        historyApiFallback: true,
      },
    resolve: {
      extensions: [ '.tsx', '.ts', '.js' ]
    },
    output: {
      filename: 'bundle.js',
      path: path.resolve(__dirname, 'dist')
    }
};

Index.html

<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>RxJS Demo</title>

RxJS Demo

index.ts

import * as RX from "rxjs";

console.log("hai",RX)

Here is my file structure

I tried npm run start and getting this


问:
JavaScript Object planned output does't match
End of the code is:

```<code>console.log ("Name: " + pete.fullname() + "\tAge:" + pete.age);
console.log ("Name: " + cara.fullname() + "\tAge:" + cara.age);
console.log (cara.firstname + "is" + (cara.age - pete.age) + " year older than " + pete.firstname);
</code>```

I wrote it:

```<code>pete = {
firstname: "Pete",
lastname: "Programmer",
age: 20
};
var cara = {
firstname: "Cara",
lastname: "Coder",
age: 30,
};
pete.fullname = function (){
console.log (pete.firstname + pete.lastname)
};
cara.fullname = function () {
console.log (cara.firstname +
cara.lastname)
};

console.log ("Name: " + pete.fullname() + "\tAge:" + pete.age);
console.log ("Name: " + cara.fullname() + "\tAge:" + cara.age);
console.log (cara.firstname + "is" + (cara.age - pete.age) + " year older than " + pete.firstname);
</code>```

Planned output:

```<code>Name: Pete Programmer   Age:20 Name:
Cara Coder  Age:32
Cara is 12 years older than Pete
</code>```

Don't understand why I have this output:

```<code>PeteProgrammer
Name: undefined Age:20
CaraCoder
Name: undefined Age:30
Cara is 10 years older than Pete
</code>```

答:
In pete.fullname() and cara.fullname() functions you're doing console.log() instead of return. The code:

pete = {
firstname: "Pete",
lastname: "Programmer",
age: 20
};
var cara = {
firstname: "Cara",
lastname: "Coder",
age: 30,
};
pete.fullname = function (){
return pete.firstname + pete.lastname
}
cara.fullname = function () {
return cara.firstname +
cara.lastname
};

console.log ("Name: " + pete.fullname() + "\tAge:" + pete.age);
console.log ("Name: " + cara.fullname() + "\tAge:" + cara.age);
console.log (cara.firstname + " is " + (cara.age - pete.age) + " year older than " + pete.firstname);
```

Body:
End of the code is:

console.log ("Name: " + pete.fullname() + "\tAge:" + pete.age);
console.log ("Name: " + cara.fullname() + "\tAge:" + cara.age);
console.log (cara.firstname + "is" + (cara.age - pete.age) + " year older than " + pete.firstname);

I wrote it:

pete = {
firstname: "Pete",
lastname: "Programmer",
age: 20
};
var cara = {
firstname: "Cara",
lastname: "Coder",
age: 30,
};
pete.fullname = function (){
console.log (pete.firstname + pete.lastname)
};
cara.fullname = function () {
console.log (cara.firstname +
cara.lastname)
};

console.log ("Name: " + pete.fullname() + "\tAge:" + pete.age);
console.log ("Name: " + cara.fullname() + "\tAge:" + cara.age);
console.log (cara.firstname + "is" + (cara.age - pete.age) + " year older than " + pete.firstname);

Planned output:

Name: Pete Programmer   Age:20 Name:
Cara Coder  Age:32
Cara is 12 years older than Pete

Don't understand why I have this output:

PeteProgrammer
Name: undefined Age:20
CaraCoder
Name: undefined Age:30
Cara is 10 years older than Pete


问:
In C#, how do i create an object within a method and add it to a list of other objects?
I have a program in which i would like to call an "Add" method from the main scope, which sends a new empty object to a Class method.

Within the method i assign the values i pass to the object, assign the values to the 'new' object and add the initialised object to a list.
The created list is outside of the method but still within the same class the method is in.

Is there a way to do this? I have a code snippet which might help you understand what i'm talking about..

Thank you!

```<code>public Kayttajat addToList(Kayttajat objects)
{

    //Adds the name
    Console.WriteLine("Käyttäjän nimi: ");
    string input = Console.ReadLine();

    //Adds a decimal amount of money
    Console.WriteLine("Käyttäjän rahasumma: ");
    decimal input2 = Convert.ToDecimal(Console.ReadLine());

    //Adds a PIN code
    Console.WriteLine("Käyttäjän pin: ");
    int input3 = Convert.ToInt16(Console.ReadLine();

    //Adds to the list outside of the scope
    KayttajaLista.Add(objects(input, input2, input3));

}
</code>```

and then i call this method from the main scope..

Class.AddToList(new objects());

答:
One of the tenets of OOP is data encapsulation. Somewhat simplified, this means that an object owns its data, and only that object should modify it.

This means that ideally, you want the function that modifies the list in the same object that contains it:

```<code>using System;
using System.Collections.Generic;

record User {
    public string Name { get; init; } = default!;
    // Add more info fields here
}

class Users {
    private readonly List<User> UserList = new List<User>();

    public void AddNew() {

        Console.WriteLine("Käyttäjän nimi: ");
        string name = Console.ReadLine();

        // Add more things

        UserList.Add(new User() {
            Name = name,
            // More stuff ...
        });
    }
}

class Program {
    public static void Main() {
        var users = new Users();
        // Add five users
        for (var i = 0;i < 5; i++ ) {
            users.AddNew();
        }
    }
}

</code>```

But in the event that you cant do it in this way a list is passed by reference, so it can be manipulated right there in the function.

Here's a complete program to show this:

```<code>using System;
using System.Collections.Generic;

record User {
    public string Name { get; init; } = default!;
    // Add more info fields here
}

class SomeOtherClass {
    public void AddNew(List<User> users) {

        Console.WriteLine("Käyttäjän nimi: ");
        string name = Console.ReadLine();

        // Add more things

        users.Add(new User() {
            Name = name,
            // More stuff ...
        });
    }

}

class Program {
    public static void Main() {

        var other = new SomeOtherClass();

        List<User> userList = new List<User>();

        // Add five users
        for (var i = 0;i < 5; i++ ) {
            other.AddNew(userList);
        }

    }
}
</code>```

Body:
I have a program in which i would like to call an "Add" method from the main scope, which sends a new empty object to a Class method.

Within the method i assign the values i pass to the object, assign the values to the 'new' object and add the initialised object to a list.
The created list is outside of the method but still within the same class the method is in.

Is there a way to do this? I have a code snippet which might help you understand what i'm talking about..

Thank you!

public Kayttajat addToList(Kayttajat objects)
{

    //Adds the name
    Console.WriteLine("Käyttäjän nimi: ");
    string input = Console.ReadLine();

    //Adds a decimal amount of money
    Console.WriteLine("Käyttäjän rahasumma: ");
    decimal input2 = Convert.ToDecimal(Console.ReadLine());

    //Adds a PIN code
    Console.WriteLine("Käyttäjän pin: ");
    int input3 = Convert.ToInt16(Console.ReadLine();

    //Adds to the list outside of the scope
    KayttajaLista.Add(objects(input, input2, input3));

}

and then i call this method from the main scope..

Class.AddToList(new objects());

Body:
One of the tenets of OOP is data encapsulation. Somewhat simplified, this means that an object owns its data, and only that object should modify it.

This means that ideally, you want the function that modifies the list in the same object that contains it:

using System;
using System.Collections.Generic;

record User {
    public string Name { get; init; } = default!;
    // Add more info fields here
}

class Users {
    private readonly List<User> UserList = new List<User>();

    public void AddNew() {

        Console.WriteLine("Käyttäjän nimi: ");
        string name = Console.ReadLine();

        // Add more things

        UserList.Add(new User() {
            Name = name,
            // More stuff ...
        });
    }
}

class Program {
    public static void Main() {
        var users = new Users();
        // Add five users
        for (var i = 0;i < 5; i++ ) {
            users.AddNew();
        }
    }
}

But in the event that you cant do it in this way a list is passed by reference, so it can be manipulated right there in the function.

Here's a complete program to show this:

using System;
using System.Collections.Generic;

record User {
    public string Name { get; init; } = default!;
    // Add more info fields here
}

class SomeOtherClass {
    public void AddNew(List<User> users) {

        Console.WriteLine("Käyttäjän nimi: ");
        string name = Console.ReadLine();

        // Add more things

        users.Add(new User() {
            Name = name,
            // More stuff ...
        });
    }

}

class Program {
    public static void Main() {

        var other = new SomeOtherClass();

        List<User> userList = new List<User>();

        // Add five users
        for (var i = 0;i < 5; i++ ) {
            other.AddNew(userList);
        }

    }
}


问:
What is the best way to integrate TFS version control
Working on implementing TFS throughout our organization.  It is easy to integrate with .NET projects and any platform that uses Eclipse or a derivative of Eclipse for editing.

What's the best way to use TFS version control with Xcode (now that I find out we need to write some iPhone apps)?

答:
Xcode integration is something that we at Teamprise have been looking into a lot. One of the main problems for us is that Apple does not provide a version control API that we can hook into to add a new version control system to Xcode - for integrated version control it is either the systems that Apple provide access to or nothing at the moment.

That said, we do have a number of customers who develop in Xcode for TFS.  They either use Teamprise Explorer (which is a standalone GUI client to TFS compiled as a Universal Binary) or they have macros inside Xcode that perform basic check-out and get operations in-conjunction with the TFS command line (tf).  It's obviously not the ideal experience but acceptable for them.  The stand-alone GUI has the advantage that you can do all the work item tracking stuff there as well and integrate this with your check-ins.

Sorry if this is a very "marketing" type answer - just trying to let you know what our current customers do with Xcode.  If you want more details around the macro approach then let me know.

Hope that helps,

Martin.

OwnerDisplayName: Jason

ContentLicense: CC BY-SA 3.0

OwnerDisplayName: Martin


问:
Classic ASP crash course
I'm a C# and PHP developer. At work, I just got some classic ASP stuff dumped in my lap. I only need to make edits for a few weeks so I don't want to have to learn too much about legacy stuff I'll never touch again. However, I do need to be able to do my job for this duration.

How can I get a good crash course in ASP? I need to get good-enough at it very quickly. What sites/books/resources would best fit this need?

答:
realistically, classic ASP is just VBScript + a couple of libraries that handle web interaction.

The fastest way is here:

http://msdn.microsoft.com/en-us/library/d1wf56tt.aspx

understand the basics of VBScript  (it's relatively tiny)

then understand the basic objects of classic ASP

Request
Response
Server
Session
Application
ASPError

OwnerDisplayName: Dinah

ContentLicense: CC BY-SA 2.5

Title: Classic ASP crash course

OwnerDisplayName: NoCarrier


问:
Changing the href on gplus & facebook buttons using javascript
My website is [link-removed] and when you change the page from the main menu it uses ajax to load the main content div, this means the social buttons on the right are still pointing to the original page you landed on, how can I update them along with the page content?

I have tried

```<code>$('.sidebar g\\:like').attr("href", x);
$('.sidebar fb\\:like').attr("href", x);
</code>```

But doesn't seem to work

Any ideas? I am surprised I couldn't find a somebody with a similar problem...

答:
It would be easier to dump than iframe and re-add it for the facebook like portion:

```<code>$('#social fb').remove(); //fb seems to create a fb:like element... wierd

$('#social').append(
    '<iframe src="http://www.facebook.com/plugins/like.php?href="' + url + '"
    scrolling="no" frameborder="0"
    style="border:none; width:450px; height:80px"></iframe>');
</code>```

and do the same with the G+

```<code>$('#social [id*=plusone]').remove();
</code>```

Body:
My website is [link-removed] and when you change the page from the main menu it uses ajax to load the main content div, this means the social buttons on the right are still pointing to the original page you landed on, how can I update them along with the page content?

I have tried

$('.sidebar g\\:like').attr("href", x);
$('.sidebar fb\\:like').attr("href", x);

But doesn't seem to work

Any ideas? I am surprised I couldn't find a somebody with a similar problem...

Body:
It would be easier to dump than iframe and re-add it for the facebook like portion:

$('#social fb').remove(); //fb seems to create a fb:like element... wierd

$('#social').append(
    '<iframe src="http://www.facebook.com/plugins/like.php?href="' + url + '"
    scrolling="no" frameborder="0"
    style="border:none; width:450px; height:80px"></iframe>');

and do the same with the G+

$('#social [id*=plusone]').remove();


问:
jquery - Updating and clearing textarea not working when content edited
Can someone please support with the code snippet. There are li items. The button "update" updates the textarea content with defined text (data-text). The text area has 2 buttons that copy and clear the textarea content. What doesn't work is when the text in the textarea is edited: Neither do the "update" buttons work nor the clear button. The "copy" button still works. What needs to be changed in the code?

jQuery(function ($) {

        $('.area_update').click(function () {
            var my_var = $(this).data('text');
            $('#area').html(my_var);
            document.querySelector("textarea").select();
            document.execCommand('copy');
        });

    });

 jQuery(function ($) {

        $('#clear_area').click(function () {
            $('#area').empty();
        });
    });

  document.querySelector("#copy-btn").onclick = function () {
        document.querySelector("textarea").select();
        document.execCommand('copy');
    };```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<ul>
    <li>aaa<input type="button" class="area_update" data-text="zzz" value="update" /></li>
    <li>bbb<input type="button" class="area_update" data-text="yyy" value="update" /></li>
    <li>ccc<input type="button" class="area_update" data-text="xxx" value="update" /></li>
</ul>

<textarea id='area' name='editor'>test</textarea>
<button id="copy-btn">Copy</button>
<button id="clear_area">Clear</button></code>```

答:
The issue is because you're using html() and empty() to set the value of the textarea. As it's a form control you should use val() instead.

Also note that you're using an odd mix of native and jQuery methods. If you've loaded jQuery in to the page you may as well use it. Also note that you only need a single jQuery document.ready handler; all your code can go within that.

jQuery($ => {
  let $textarea = $('#area');

  $('.area_update').on('click', e => {
    var my_var = $(e.currentTarget).data('text');
    $textarea.val(my_var).select();
    document.execCommand('copy'); // are you sure you want to copy the value in the 'update' command?
  });

  $('#clear_area').on('click', () => {
    $textarea.val('');
  });

  $('#copy-btn').on('click', () => {
    $textarea.select();
    document.execCommand('copy');
  });
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<ul>
  <li>aaa <input type="button" class="area_update" data-text="zzz" value="update" /></li>
  <li>bbb <input type="button" class="area_update" data-text="yyy" value="update" /></li>
  <li>ccc <input type="button" class="area_update" data-text="xxx" value="update" /></li>
</ul>

<textarea id="area" name="editor">test</textarea>
<button id="copy-btn">Copy</button>
<button id="clear_area">Clear</button></code>```

Body:
Can someone please support with the code snippet. There are li items. The button "update" updates the textarea content with defined text (data-text). The text area has 2 buttons that copy and clear the textarea content. What doesn't work is when the text in the textarea is edited: Neither do the "update" buttons work nor the clear button. The "copy" button still works. What needs to be changed in the code?

jQuery(function ($) {

        $('.area_update').click(function () {
            var my_var = $(this).data('text');
            $('#area').html(my_var);
            document.querySelector("textarea").select();
            document.execCommand('copy');
        });

    });

 jQuery(function ($) {

        $('#clear_area').click(function () {
            $('#area').empty();
        });
    });

  document.querySelector("#copy-btn").onclick = function () {
        document.querySelector("textarea").select();
        document.execCommand('copy');
    };

aaa<input type="button" class="area_update" data-text="zzz" value="update" />

bbb<input type="button" class="area_update" data-text="yyy" value="update" />

ccc<input type="button" class="area_update" data-text="xxx" value="update" />

<textarea id='area' name='editor'>test</textarea>
<button id="copy-btn">Copy</button>
<button id="clear_area">Clear</button>

Body:
The issue is because you're using html() and empty() to set the value of the textarea. As it's a form control you should use val() instead.

Also note that you're using an odd mix of native and jQuery methods. If you've loaded jQuery in to the page you may as well use it. Also note that you only need a single jQuery document.ready handler; all your code can go within that.

jQuery($ => {
  let $textarea = $('#area');

  $('.area_update').on('click', e => {
    var my_var = $(e.currentTarget).data('text');
    $textarea.val(my_var).select();
    document.execCommand('copy'); // are you sure you want to copy the value in the 'update' command?
  });

  $('#clear_area').on('click', () => {
    $textarea.val('');
  });

  $('#copy-btn').on('click', () => {
    $textarea.select();
    document.execCommand('copy');
  });
});

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<ul>
  <li>aaa <input type="button" class="area_update" data-text="zzz" value="update" /></li>
  <li>bbb <input type="button" class="area_update" data-text="yyy" value="update" /></li>
  <li>ccc <input type="button" class="area_update" data-text="xxx" value="update" /></li>
</ul>

<textarea id="area" name="editor">test</textarea>
<button id="copy-btn">Copy</button>
<button id="clear_area">Clear</button>


问:
what is the jenkins job-dsl snippet for generating allure report in freestylejob
I am trying to generate job using jenkins JOB-DSL and i am unable to find a way to trigger allure report as publisher in freestylejob

```<code>job('ci') {

publishers {

    allure([includeProperties: false, jdk: '', results: [[path: 'Result']]])

}

}
</code>```

I even tried to search on https://jenkinsci.github.io/job-dsl-plugin  also tried on https://job-dsl.herokuapp.com/ for getting this work. but no luck.
But getting the following error:

```<code>  javaposse.jobdsl.dsl.DslScriptException: (script, line 5) No signature of
  method: javaposse.jobdsl.dsl.helpers.publisher.PublisherContext.allure()
  is applicable for argument types: (java.util.LinkedHashMap) values:
  [[includeProperties:false, jdk:, results:[[path:Result]]]]
  Possible solutions: mailer(java.lang.String), use([Ljava.lang.Object;),
  asType(java.lang.Class)
  at javaposse.jobdsl.dsl.AbstractDslScriptLoader.runScriptEngine(AbstractDslScriptLoader.groovy:112)
at javaposse.jobdsl.dsl.AbstractDslScriptLoader$_runScripts_closure1.doCall(AbstractDslScriptLoader.groovy:59)
at javaposse.jobdsl.dsl.AbstractDslScriptLoader.runScripts(AbstractDslScriptLoader.groovy:46)
at javaposse.jobdsl.dsl.AbstractDslScriptLoader$runScripts$0.callCurrent(Unknown Source)
at javaposse.jobdsl.dsl.AbstractDslScriptLoader.runScript(AbstractDslScriptLoader.groovy:85)
at javaposse.jobdsl.dsl.AbstractDslScriptLoader$runScript.call(Unknown Source)
at com.sheehan.jobdsl.DslScriptExecutor.execute(DslScriptExecutor.groovy:27)
at com.sheehan.jobdsl.ScriptExecutor$execute.call(Unknown Source)
at Ratpack$_run_closure1$_closure3$_closure7$_closure8.doCall(Ratpack.groovy:32)
at com.sun.proxy.$Proxy10.execute(Unknown Source)
at ratpack.exec.internal.DefaultPromise$1.success(DefaultPromise.java:42)
at ratpack.exec.Promise.lambda$null$9(Promise.java:304)
at ratpack.exec.Downstream$1.success(Downstream.java:73)
at ratpack.exec.Promise.lambda$null$9(Promise.java:304)
at ratpack.exec.Downstream$1.success(Downstream.java:73)
at ratpack.exec.internal.DefaultExecution$2.lambda$success$1(DefaultExecution.java:161)
at ratpack.exec.internal.DefaultExecution$SingleEventExecStream.exec(DefaultExecution.java:419)
at ratpack.exec.internal.DefaultExecution.exec(DefaultExecution.java:246)
at ratpack.exec.internal.DefaultExecution.intercept(DefaultExecution.java:240)
at ratpack.exec.internal.DefaultExecution.drain(DefaultExecution.java:220)
at ratpack.exec.internal.DefaultExecution.access$100(DefaultExecution.java:45)
at ratpack.exec.internal.DefaultExecution$SingleEventExecStream.resume(DefaultExecution.java:452)
at ratpack.exec.internal.DefaultExecution$2.success(DefaultExecution.java:161)
at ratpack.server.internal.RequestBody.complete(RequestBody.java:125)
at ratpack.server.internal.RequestBody.add(RequestBody.java:76)
at ratpack.server.internal.NettyHandlerAdapter.channelRead(NettyHandlerAdapter.java:84)
at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:83)
at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:163)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:155)
at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:83)
at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:163)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:155)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111)
at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:83)
at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:163)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:155)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:276)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:263)
at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:83)
at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:163)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:155)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:950)
at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:818)
at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:338)
at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:254)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:742)
at ratpack.exec.internal.DefaultExecController$ExecControllerBindingThreadFactory.lambda$newThread$0(DefaultExecController.java:113)
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
Caused by: groovy.lang.MissingMethodException: No signature of method: javaposse.jobdsl.dsl.helpers.publisher.PublisherContext.allure() is applicable for argument types: (java.util.LinkedHashMap) values: [[includeProperties:false, jdk:, results:[[path:Result]]]]
 Possible solutions: mailer(java.lang.String), use([Ljava.lang.Object;), asType(java.lang.Class)
at javaposse.jobdsl.dsl.AbstractExtensibleContext.methodMissing(AbstractExtensibleContext.groovy:19)
at javaposse.jobdsl.dsl.AbstractContext.invokeMethod(AbstractContext.groovy)
at script$_run_closure1$_closure2.doCall(script:5)
at script$_run_closure1$_closure2.doCall(script)
at javaposse.jobdsl.dsl.ContextHelper.executeInContext(ContextHelper.groovy:16)
at javaposse.jobdsl.dsl.ContextHelper$executeInContext.call(Unknown Source)
at javaposse.jobdsl.dsl.ContextHelper$executeInContext.call(Unknown Source)
at javaposse.jobdsl.dsl.Job.publishers(Job.groovy:628)
at script$_run_closure1.doCall(script:3)
at javaposse.jobdsl.dsl.JobParent.processItem(JobParent.groovy:104)
at javaposse.jobdsl.dsl.JobParent.freeStyleJob(JobParent.groovy:46)
at javaposse.jobdsl.dsl.JobParent$freeStyleJob$0.callCurrent(Unknown Source)
at javaposse.jobdsl.dsl.JobParent$freeStyleJob$0.callCurrent(Unknown Source)
at javaposse.jobdsl.dsl.JobParent.job(JobParent.groovy:38)
at javaposse.jobdsl.dsl.DslFactory$job.callCurrent(Unknown Source)
at script.run(script:1)
at script$run.call(Unknown Source)
at script$run.call(Unknown Source)
at javaposse.jobdsl.dsl.AbstractDslScriptLoader.runScript(AbstractDslScriptLoader.groovy:132)
at javaposse.jobdsl.dsl.AbstractDslScriptLoader.runScriptEngine(AbstractDslScriptLoader.groovy:106)
... 49 more
</code>```

Can some one give me any snippet for allure?

答:
To be able to use Allure with the Job DSL I had to add the allure-jenkins-plugin to my build.gradle as follows:

```<code>dependencies {
  testPlugins 'ru.yandex.qatools.allure:allure-jenkins-plugin:2.30.2'
}
</code>```

Note: what can help is making sure Allure is available on your Jenkins, which you can check by going to https://url-of-your-jenkins.org/plugin/job-dsl/api-viewer/index.html and looking for "allure".

Hope this helps anyone who struggled with the error!

Body:
I am trying to generate job using jenkins JOB-DSL and i am unable to find a way to trigger allure report as publisher in freestylejob

job('ci') {

publishers {

    allure([includeProperties: false, jdk: '', results: [[path: 'Result']]])

}

}

I even tried to search on https://jenkinsci.github.io/job-dsl-plugin  also tried on https://job-dsl.herokuapp.com/ for getting this work. but no luck.
But getting the following error:

  javaposse.jobdsl.dsl.DslScriptException: (script, line 5) No signature of
  method: javaposse.jobdsl.dsl.helpers.publisher.PublisherContext.allure()
  is applicable for argument types: (java.util.LinkedHashMap) values:
  [[includeProperties:false, jdk:, results:[[path:Result]]]]
  Possible solutions: mailer(java.lang.String), use([Ljava.lang.Object;),
  asType(java.lang.Class)
  at javaposse.jobdsl.dsl.AbstractDslScriptLoader.runScriptEngine(AbstractDslScriptLoader.groovy:112)
at javaposse.jobdsl.dsl.AbstractDslScriptLoader$_runScripts_closure1.doCall(AbstractDslScriptLoader.groovy:59)
at javaposse.jobdsl.dsl.AbstractDslScriptLoader.runScripts(AbstractDslScriptLoader.groovy:46)
at javaposse.jobdsl.dsl.AbstractDslScriptLoader$runScripts$0.callCurrent(Unknown Source)
at javaposse.jobdsl.dsl.AbstractDslScriptLoader.runScript(AbstractDslScriptLoader.groovy:85)
at javaposse.jobdsl.dsl.AbstractDslScriptLoader$runScript.call(Unknown Source)
at com.sheehan.jobdsl.DslScriptExecutor.execute(DslScriptExecutor.groovy:27)
at com.sheehan.jobdsl.ScriptExecutor$execute.call(Unknown Source)
at Ratpack$_run_closure1$_closure3$_closure7$_closure8.doCall(Ratpack.groovy:32)
at com.sun.proxy.$Proxy10.execute(Unknown Source)
at ratpack.exec.internal.DefaultPromise$1.success(DefaultPromise.java:42)
at ratpack.exec.Promise.lambda$null$9(Promise.java:304)
at ratpack.exec.Downstream$1.success(Downstream.java:73)
at ratpack.exec.Promise.lambda$null$9(Promise.java:304)
at ratpack.exec.Downstream$1.success(Downstream.java:73)
at ratpack.exec.internal.DefaultExecution$2.lambda$success$1(DefaultExecution.java:161)
at ratpack.exec.internal.DefaultExecution$SingleEventExecStream.exec(DefaultExecution.java:419)
at ratpack.exec.internal.DefaultExecution.exec(DefaultExecution.java:246)
at ratpack.exec.internal.DefaultExecution.intercept(DefaultExecution.java:240)
at ratpack.exec.internal.DefaultExecution.drain(DefaultExecution.java:220)
at ratpack.exec.internal.DefaultExecution.access$100(DefaultExecution.java:45)
at ratpack.exec.internal.DefaultExecution$SingleEventExecStream.resume(DefaultExecution.java:452)
at ratpack.exec.internal.DefaultExecution$2.success(DefaultExecution.java:161)
at ratpack.server.internal.RequestBody.complete(RequestBody.java:125)
at ratpack.server.internal.RequestBody.add(RequestBody.java:76)
at ratpack.server.internal.NettyHandlerAdapter.channelRead(NettyHandlerAdapter.java:84)
at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:83)
at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:163)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:155)
at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:83)
at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:163)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:155)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111)
at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:83)
at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:163)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:155)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:276)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:263)
at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:83)
at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:163)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:155)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:950)
at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:818)
at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:338)
at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:254)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:742)
at ratpack.exec.internal.DefaultExecController$ExecControllerBindingThreadFactory.lambda$newThread$0(DefaultExecController.java:113)
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
Caused by: groovy.lang.MissingMethodException: No signature of method: javaposse.jobdsl.dsl.helpers.publisher.PublisherContext.allure() is applicable for argument types: (java.util.LinkedHashMap) values: [[includeProperties:false, jdk:, results:[[path:Result]]]]
 Possible solutions: mailer(java.lang.String), use([Ljava.lang.Object;), asType(java.lang.Class)
at javaposse.jobdsl.dsl.AbstractExtensibleContext.methodMissing(AbstractExtensibleContext.groovy:19)
at javaposse.jobdsl.dsl.AbstractContext.invokeMethod(AbstractContext.groovy)
at script$_run_closure1$_closure2.doCall(script:5)
at script$_run_closure1$_closure2.doCall(script)
at javaposse.jobdsl.dsl.ContextHelper.executeInContext(ContextHelper.groovy:16)
at javaposse.jobdsl.dsl.ContextHelper$executeInContext.call(Unknown Source)
at javaposse.jobdsl.dsl.ContextHelper$executeInContext.call(Unknown Source)
at javaposse.jobdsl.dsl.Job.publishers(Job.groovy:628)
at script$_run_closure1.doCall(script:3)
at javaposse.jobdsl.dsl.JobParent.processItem(JobParent.groovy:104)
at javaposse.jobdsl.dsl.JobParent.freeStyleJob(JobParent.groovy:46)
at javaposse.jobdsl.dsl.JobParent$freeStyleJob$0.callCurrent(Unknown Source)
at javaposse.jobdsl.dsl.JobParent$freeStyleJob$0.callCurrent(Unknown Source)
at javaposse.jobdsl.dsl.JobParent.job(JobParent.groovy:38)
at javaposse.jobdsl.dsl.DslFactory$job.callCurrent(Unknown Source)
at script.run(script:1)
at script$run.call(Unknown Source)
at script$run.call(Unknown Source)
at javaposse.jobdsl.dsl.AbstractDslScriptLoader.runScript(AbstractDslScriptLoader.groovy:132)
at javaposse.jobdsl.dsl.AbstractDslScriptLoader.runScriptEngine(AbstractDslScriptLoader.groovy:106)
... 49 more

Can some one give me any snippet for allure?

Body:
To be able to use Allure with the Job DSL I had to add the allure-jenkins-plugin to my build.gradle as follows:

dependencies {
  testPlugins 'ru.yandex.qatools.allure:allure-jenkins-plugin:2.30.2'
}

Note: what can help is making sure Allure is available on your Jenkins, which you can check by going to https://url-of-your-jenkins.org/plugin/job-dsl/api-viewer/index.html and looking for "allure".

Hope this helps anyone who struggled with the error!


问:
How to determine if some name refers to a module without actually importing it in python?
I'm aware of two python functions that can be used to determine if some name refers to a module:
pkgutil.find_loader(fullname)
and pkgutil.resolve_name(name). The first method returns a loader if the input is an importable module name. The second option returns an object whose type can be inspected to determine if it's a module. However, in both of these cases the module in question actually gets imported to python - something I do not wish to happen. Is there a way to determine if a name refers to a module (package) without actually importing it?</p>

答:
If a module is either a .py file, or a directory containing init.py in one of sys.path directories then below function may help:

```<code>def ismodule(fn):
    for i in sys.path:
        if os.path.isfile(os.path.join(i, fn) + '.py'): return (True, i)
        if os.path.isfile(os.path.join(i, fn, '__init__.py')): return (True,  os.path.join(i, fn))
    return (False, None)
</code>```

version below covers sub-modules:

```<code>def ismodule(fn):
    fnm = fn.split('.')[0]
    for i in sys.path:
        if os.path.isfile(os.path.join(i, fnm) + '.py'): return (True, i, fnm)
        if os.path.isfile(os.path.join(i, fnm, '__init__.py')): return (True,  os.path.join(i, fnm), fnm)
    return (False, None, fnm)
</code>```

Body:
If a module is either a .py file, or a directory containing init.py in one of sys.path directories then below function may help:

def ismodule(fn):
    for i in sys.path:
        if os.path.isfile(os.path.join(i, fn) + '.py'): return (True, i)
        if os.path.isfile(os.path.join(i, fn, '__init__.py')): return (True,  os.path.join(i, fn))
    return (False, None)

version below covers sub-modules:

def ismodule(fn):
    fnm = fn.split('.')[0]
    for i in sys.path:
        if os.path.isfile(os.path.join(i, fnm) + '.py'): return (True, i, fnm)
        if os.path.isfile(os.path.join(i, fnm, '__init__.py')): return (True,  os.path.join(i, fnm), fnm)
    return (False, None, fnm)


问:
How to reload a page using JavaScript
How can I reload the page using JavaScript?

I need a method that works in all browsers.

答:
The Javascript reload() method is used to reload the current document or URL. The javascript location.reload(true) method work just like reload button in your browser. By default, the JS reload() method reloads the page from the cache, however you may force it to reload the page from the server side by setting the forceGet parameter to true: location. reload(true).
Source: https://www.coderepublics.com/JavaScript/javascript-location-reload-true.php

What about Depricated?
It is only the reload with forcedReload which is now deprecated. But to avoid depricated error you can use location.reload() without the forceReload flag.

Title: How to reload a page using JavaScript


问:
Java typewriter effect
Hello I want to have a typewrite effect on the screen where every few seconds a letter appear after the previous one. I was thinking about having a string with all the text I want to write and every second I would take the first char of that string, remove it and then add it to a different string. For example:

```<code>  String text = "hello world";
  String onscreenText = "";
</code>```

Then onscreenText would have "h" in it and text would have everything but the "h" in it and so on. How can I remove the first char from a string and add it to the next string?

答:
Check this out I am using this</p>
```<code>class TypingBot extends Thread{
    String textToAnimate;
    int delayInMilliSeconds;
    public TypingBot(String s, int delayInMilliSeconds){
        this.textToAnimate = s;
        this.delayInMilliSeconds = delayInMilliSeconds;
    }
    @Override
    public void run(){
        for (int i = 0 ; i < textToAnimate.length() ; i++){
            System.out.print(textToAnimate.charAt(i));
            try{
                Thread.sleep(delayInMilliSeconds);
            }
            catch (Exception e){
                System.out.println(e);
            }
        }
    }
}

public class TypingAnimation {
    public static void startAnimation(String textToAnimate, int waitForMillis){
        TypingBot typingBot = new TypingBot(textToAnimate, waitForMillis);
        typingBot.isDaemon();
        typingBot.start();

        Thread currentThread = Thread.currentThread();
        try{
            currentThread.join(waitForMillis);
        }
        catch (Exception e){
            System.out.println(e);
        }
    }
    public static void main(String[] args){
        startAnimation("Krishna Wadhwani Is The Best Programmer", 500);
    }
}

</code>```

Title: Java typewriter effect

Body:
Hello I want to have a typewrite effect on the screen where every few seconds a letter appear after the previous one. I was thinking about having a string with all the text I want to write and every second I would take the first char of that string, remove it and then add it to a different string. For example:

  String text = "hello world";
  String onscreenText = "";

Then onscreenText would have "h" in it and text would have everything but the "h" in it and so on. How can I remove the first char from a string and add it to the next string?

Body:
Check this out I am using this

class TypingBot extends Thread{
    String textToAnimate;
    int delayInMilliSeconds;
    public TypingBot(String s, int delayInMilliSeconds){
        this.textToAnimate = s;
        this.delayInMilliSeconds = delayInMilliSeconds;
    }
    @Override
    public void run(){
        for (int i = 0 ; i < textToAnimate.length() ; i++){
            System.out.print(textToAnimate.charAt(i));
            try{
                Thread.sleep(delayInMilliSeconds);
            }
            catch (Exception e){
                System.out.println(e);
            }
        }
    }
}

public class TypingAnimation {
    public static void startAnimation(String textToAnimate, int waitForMillis){
        TypingBot typingBot = new TypingBot(textToAnimate, waitForMillis);
        typingBot.isDaemon();
        typingBot.start();

        Thread currentThread = Thread.currentThread();
        try{
            currentThread.join(waitForMillis);
        }
        catch (Exception e){
            System.out.println(e);
        }
    }
    public static void main(String[] args){
        startAnimation("Krishna Wadhwani Is The Best Programmer", 500);
    }
}


问:
Vuetify 3 change event in v-select
I am testing Vuetify 3 (npm:@vuetify/nightly@next) v-select and try to get change event. However, my handler function is not called. This is my code:

TS:

```<code>export default defineComponent({

  setup() {

    function onLanguageChange(a: any) {
      console.log(a);
    }
    const items = ['Русский', 'English'];

    return {onLanguageChange, items}
  }
});
</code>```

Vue

```<code> <v-select
    prepend-icon="mdi-web"
    :items="items"
    label="Lang"
    @change="onLanguageChange"
  ></v-select>
</code>```

And this is what I get in console when I focus select and change its value.

Could anyone say, if this is a bug or something is wrong with my code (and how to fix it)?

答:
v-select's event list does not include the change event. It only has one event: update:modelValue.

Use the update:modelValue event instead:

<v-select @update:modelValue="onLanguageChange">
```
<p>demo 1</p>
<p>Or use a <code>v-model</code> with a watcher:</p>
<pre class="lang-html prettyprint-override"><code><v-select v-model="lang">...</v-select>
</code>```

import { ref, watch } from 'vue'

export default {
  setup() {
    const lang = ref()
    watch(lang, (newValue) => console.log('new lang', newValue))
    return { lang }
  }
}
```

demo 2

Title: Vuetify 3 change event in v-select

Body:
I am testing Vuetify 3 (npm:@vuetify/nightly@next) v-select and try to get change event. However, my handler function is not called. This is my code:

TS:

export default defineComponent({

  setup() {

    function onLanguageChange(a: any) {
      console.log(a);
    }
    const items = ['Русский', 'English'];

    return {onLanguageChange, items}
  }
});

Vue

 <v-select
    prepend-icon="mdi-web"
    :items="items"
    label="Lang"
    @change="onLanguageChange"
  ></v-select>

And this is what I get in console when I focus select and change its value.

Could anyone say, if this is a bug or something is wrong with my code (and how to fix it)?

Body:
v-select's event list does not include the change event. It only has one event: update:modelValue.

Use the update:modelValue event instead:

<v-select @update:modelValue="onLanguageChange">

demo 1

Or use a v-model with a watcher:

<v-select v-model="lang">...</v-select>

import { ref, watch } from 'vue'

export default {
  setup() {
    const lang = ref()
    watch(lang, (newValue) => console.log('new lang', newValue))
    return { lang }
  }
}

demo 2