text:
Q: I am looking for project id on GitHub similar to project id on GitLab Is there a way to check for project id on GitHub similar to GitLab? I searched all settings but did not find the project id. Wondering if it's permissions that are causing me not to see the properties or there is no project id in GitHub.
Really appreciate your help and thanks in advance.

A: I'm not sure how it is organized on GitLab, but GitHub Actions are created not per project but per repository, so maybe this will work for you. You can find variables from github context here where - github.repository gives you:

The owner and repository name. For example, Codertocat/Hello-World

A: Each Github repository has an ID and many other fields you can obtain by consuming the Github API.
As explained on the link above, you can use the following service:

To get all kind of datas about the repository:

{
  "id": 1296269,
  "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
  "name": "Hello-World",
  "full_name": "octocat/Hello-World",
  "owner": {
    "login": "octocat",
    "id": 1,
    "node_id": "MDQ6VXNlcjE=",
    "avatar_url": "https://github.com/images/error/octocat_happy.gif",
    "gravatar_id": "",
    "url": "https://api.github.com/users/octocat",
    "html_url": "https://github.com/octocat",
    "followers_url": "https://api.github.com/users/octocat/followers",
    "following_url": "https://api.github.com/users/octocat/following{/other_user}",
    "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
    "organizations_url": "https://api.github.com/users/octocat/orgs",
    "repos_url": "https://api.github.com/users/octocat/repos",
    "events_url": "https://api.github.com/users/octocat/events{/privacy}",
    "received_events_url": "https://api.github.com/users/octocat/received_events",
    "type": "User",
    "site_admin": false
  },
  "private": false,
  "html_url": "https://github.com/octocat/Hello-World",
  "description": "This your first repo!",
  "fork": false,
  "url": "https://api.github.com/repos/octocat/Hello-World",
  "archive_url": "https://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}",
  "assignees_url": "https://api.github.com/repos/octocat/Hello-World/assignees{/user}",
  "blobs_url": "https://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}",
  "branches_url": "https://api.github.com/repos/octocat/Hello-World/branches{/branch}",
  "collaborators_url": "https://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}",
  "comments_url": "https://api.github.com/repos/octocat/Hello-World/comments{/number}",
  "commits_url": "https://api.github.com/repos/octocat/Hello-World/commits{/sha}",
  "compare_url": "https://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}",
  "contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/{+path}",
  "contributors_url": "https://api.github.com/repos/octocat/Hello-World/contributors",
  "deployments_url": "https://api.github.com/repos/octocat/Hello-World/deployments",
  "downloads_url": "https://api.github.com/repos/octocat/Hello-World/downloads",
  "events_url": "https://api.github.com/repos/octocat/Hello-World/events",
  "forks_url": "https://api.github.com/repos/octocat/Hello-World/forks",
  "git_commits_url": "https://api.github.com/repos/octocat/Hello-World/git/commits{/sha}",
  "git_refs_url": "https://api.github.com/repos/octocat/Hello-World/git/refs{/sha}",
  "git_tags_url": "https://api.github.com/repos/octocat/Hello-World/git/tags{/sha}",
  "git_url": "git:github.com/octocat/Hello-World.git",
  "issue_comment_url": "https://api.github.com/repos/octocat/Hello-World/issues/comments{/number}",
  "issue_events_url": "https://api.github.com/repos/octocat/Hello-World/issues/events{/number}",
  "issues_url": "https://api.github.com/repos/octocat/Hello-World/issues{/number}",
  "keys_url": "https://api.github.com/repos/octocat/Hello-World/keys{/key_id}",
  "labels_url": "https://api.github.com/repos/octocat/Hello-World/labels{/name}",
  "languages_url": "https://api.github.com/repos/octocat/Hello-World/languages",
  "merges_url": "https://api.github.com/repos/octocat/Hello-World/merges",
  "milestones_url": "https://api.github.com/repos/octocat/Hello-World/milestones{/number}",
  "notifications_url": "https://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}",
  "pulls_url": "https://api.github.com/repos/octocat/Hello-World/pulls{/number}",
  "releases_url": "https://api.github.com/repos/octocat/Hello-World/releases{/id}",
  "ssh_url": "git@github.com:octocat/Hello-World.git",
  "stargazers_url": "https://api.github.com/repos/octocat/Hello-World/stargazers",
  "statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/{sha}",
  "subscribers_url": "https://api.github.com/repos/octocat/Hello-World/subscribers",
  "subscription_url": "https://api.github.com/repos/octocat/Hello-World/subscription",
  "tags_url": "https://api.github.com/repos/octocat/Hello-World/tags",
  "teams_url": "https://api.github.com/repos/octocat/Hello-World/teams",
  "trees_url": "https://api.github.com/repos/octocat/Hello-World/git/trees{/sha}",
  "clone_url": "https://github.com/octocat/Hello-World.git",
  "mirror_url": "git:git.example.com/octocat/Hello-World",
  "hooks_url": "https://api.github.com/repos/octocat/Hello-World/hooks",
  "svn_url": "https://svn.github.com/octocat/Hello-World",
  "homepage": "https://github.com",
  "language": null,
  "forks_count": 9,
  "forks": 9,
  "stargazers_count": 80,
  "watchers_count": 80,
  "watchers": 80,
  "size": 108,
  "default_branch": "master",
  "open_issues_count": 0,
  "open_issues": 0,
  "is_template": false,
  "topics": [
    "octocat",
    "atom",
    "electron",
    "api"
  ],
  "has_issues": true,
  "has_projects": true,
  "has_wiki": true,
  "has_pages": false,
  "has_downloads": true,
  "archived": false,
  "disabled": false,
  "visibility": "public",
  "pushed_at": "2011-01-26T19:06:43Z",
  "created_at": "2011-01-26T19:01:12Z",
  "updated_at": "2011-01-26T19:14:43Z",
  "permissions": {
    "pull": true,
    "push": false,
    "admin": false
  },
  "allow_rebase_merge": true,
  "template_repository": {
    "id": 1296269,
    "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
    "name": "Hello-World-Template",
    "full_name": "octocat/Hello-World-Template",
    "owner": {
      "login": "octocat",
      "id": 1,
      "node_id": "MDQ6VXNlcjE=",
      "avatar_url": "https://github.com/images/error/octocat_happy.gif",
      "gravatar_id": "",
      "url": "https://api.github.com/users/octocat",
      "html_url": "https://github.com/octocat",
      "followers_url": "https://api.github.com/users/octocat/followers",
      "following_url": "https://api.github.com/users/octocat/following{/other_user}",
      "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
      "organizations_url": "https://api.github.com/users/octocat/orgs",
      "repos_url": "https://api.github.com/users/octocat/repos",
      "events_url": "https://api.github.com/users/octocat/events{/privacy}",
      "received_events_url": "https://api.github.com/users/octocat/received_events",
      "type": "User",
      "site_admin": false
    },
    "private": false,
    "html_url": "https://github.com/octocat/Hello-World-Template",
    "description": "This your first repo!",
    "fork": false,
    "url": "https://api.github.com/repos/octocat/Hello-World-Template",
    "archive_url": "https://api.github.com/repos/octocat/Hello-World-Template/{archive_format}{/ref}",
    "assignees_url": "https://api.github.com/repos/octocat/Hello-World-Template/assignees{/user}",
    "blobs_url": "https://api.github.com/repos/octocat/Hello-World-Template/git/blobs{/sha}",
    "branches_url": "https://api.github.com/repos/octocat/Hello-World-Template/branches{/branch}",
    "collaborators_url": "https://api.github.com/repos/octocat/Hello-World-Template/collaborators{/collaborator}",
    "comments_url": "https://api.github.com/repos/octocat/Hello-World-Template/comments{/number}",
    "commits_url": "https://api.github.com/repos/octocat/Hello-World-Template/commits{/sha}",
    "compare_url": "https://api.github.com/repos/octocat/Hello-World-Template/compare/{base}...{head}",
    "contents_url": "https://api.github.com/repos/octocat/Hello-World-Template/contents/{+path}",
    "contributors_url": "https://api.github.com/repos/octocat/Hello-World-Template/contributors",
    "deployments_url": "https://api.github.com/repos/octocat/Hello-World-Template/deployments",
    "downloads_url": "https://api.github.com/repos/octocat/Hello-World-Template/downloads",
    "events_url": "https://api.github.com/repos/octocat/Hello-World-Template/events",
    "forks_url": "https://api.github.com/repos/octocat/Hello-World-Template/forks",
    "git_commits_url": "https://api.github.com/repos/octocat/Hello-World-Template/git/commits{/sha}",
    "git_refs_url": "https://api.github.com/repos/octocat/Hello-World-Template/git/refs{/sha}",
    "git_tags_url": "https://api.github.com/repos/octocat/Hello-World-Template/git/tags{/sha}",
    "git_url": "git:github.com/octocat/Hello-World-Template.git",
    "issue_comment_url": "https://api.github.com/repos/octocat/Hello-World-Template/issues/comments{/number}",
    "issue_events_url": "https://api.github.com/repos/octocat/Hello-World-Template/issues/events{/number}",
    "issues_url": "https://api.github.com/repos/octocat/Hello-World-Template/issues{/number}",
    "keys_url": "https://api.github.com/repos/octocat/Hello-World-Template/keys{/key_id}",
    "labels_url": "https://api.github.com/repos/octocat/Hello-World-Template/labels{/name}",
    "languages_url": "https://api.github.com/repos/octocat/Hello-World-Template/languages",
    "merges_url": "https://api.github.com/repos/octocat/Hello-World-Template/merges",
    "milestones_url": "https://api.github.com/repos/octocat/Hello-World-Template/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/octocat/Hello-World-Template/notifications{?since,all,participating}",
    "pulls_url": "https://api.github.com/repos/octocat/Hello-World-Template/pulls{/number}",
    "releases_url": "https://api.github.com/repos/octocat/Hello-World-Template/releases{/id}",
    "ssh_url": "git@github.com:octocat/Hello-World-Template.git",
    "stargazers_url": "https://api.github.com/repos/octocat/Hello-World-Template/stargazers",
    "statuses_url": "https://api.github.com/repos/octocat/Hello-World-Template/statuses/{sha}",
    "subscribers_url": "https://api.github.com/repos/octocat/Hello-World-Template/subscribers",
    "subscription_url": "https://api.github.com/repos/octocat/Hello-World-Template/subscription",
    "tags_url": "https://api.github.com/repos/octocat/Hello-World-Template/tags",
    "teams_url": "https://api.github.com/repos/octocat/Hello-World-Template/teams",
    "trees_url": "https://api.github.com/repos/octocat/Hello-World-Template/git/trees{/sha}",
    "clone_url": "https://github.com/octocat/Hello-World-Template.git",
    "mirror_url": "git:git.example.com/octocat/Hello-World-Template",
    "hooks_url": "https://api.github.com/repos/octocat/Hello-World-Template/hooks",
    "svn_url": "https://svn.github.com/octocat/Hello-World-Template",
    "homepage": "https://github.com",
    "language": null,
    "forks": 9,
    "forks_count": 9,
    "stargazers_count": 80,
    "watchers_count": 80,
    "watchers": 80,
    "size": 108,
    "default_branch": "master",
    "open_issues": 0,
    "open_issues_count": 0,
    "is_template": true,
    "license": {
      "key": "mit",
      "name": "MIT License",
      "url": "https://api.github.com/licenses/mit",
      "spdx_id": "MIT",
      "node_id": "MDc6TGljZW5zZW1pdA==",
      "html_url": "https://api.github.com/licenses/mit"
    },
    "topics": [
      "octocat",
      "atom",
      "electron",
      "api"
    ],
    "has_issues": true,
    "has_projects": true,
    "has_wiki": true,
    "has_pages": false,
    "has_downloads": true,
    "archived": false,
    "disabled": false,
    "visibility": "public",
    "pushed_at": "2011-01-26T19:06:43Z",
    "created_at": "2011-01-26T19:01:12Z",
    "updated_at": "2011-01-26T19:14:43Z",
    "permissions": {
      "admin": false,
      "push": false,
      "pull": true
    },
    "allow_rebase_merge": true,
    "temp_clone_token": "ABTLWHOULUVAXGTRYU7OC2876QJ2O",
    "allow_squash_merge": true,
    "delete_branch_on_merge": true,
    "allow_merge_commit": true,
    "subscribers_count": 42,
    "network_count": 0
  },
  "temp_clone_token": "ABTLWHOULUVAXGTRYU7OC2876QJ2O",
  "allow_squash_merge": true,
  "delete_branch_on_merge": true,
  "allow_merge_commit": true,
  "subscribers_count": 42,
  "network_count": 0,
  "license": {
    "key": "mit",
    "name": "MIT License",
    "spdx_id": "MIT",
    "url": "https://api.github.com/licenses/mit",
    "node_id": "MDc6TGljZW5zZW1pdA=="
  },
  "organization": {
    "login": "octocat",
    "id": 1,
    "node_id": "MDQ6VXNlcjE=",
    "avatar_url": "https://github.com/images/error/octocat_happy.gif",
    "gravatar_id": "",
    "url": "https://api.github.com/users/octocat",
    "html_url": "https://github.com/octocat",
    "followers_url": "https://api.github.com/users/octocat/followers",
    "following_url": "https://api.github.com/users/octocat/following{/other_user}",
    "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
    "organizations_url": "https://api.github.com/users/octocat/orgs",
    "repos_url": "https://api.github.com/users/octocat/repos",
    "events_url": "https://api.github.com/users/octocat/events{/privacy}",
    "received_events_url": "https://api.github.com/users/octocat/received_events",
    "type": "Organization",
    "site_admin": false
  },
  "parent": {
    "id": 1296269,
    "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
    "name": "Hello-World",
    "full_name": "octocat/Hello-World",
    "owner": {
      "login": "octocat",
      "id": 1,
      "node_id": "MDQ6VXNlcjE=",
      "avatar_url": "https://github.com/images/error/octocat_happy.gif",
      "gravatar_id": "",
      "url": "https://api.github.com/users/octocat",
      "html_url": "https://github.com/octocat",
      "followers_url": "https://api.github.com/users/octocat/followers",
      "following_url": "https://api.github.com/users/octocat/following{/other_user}",
      "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
      "organizations_url": "https://api.github.com/users/octocat/orgs",
      "repos_url": "https://api.github.com/users/octocat/repos",
      "events_url": "https://api.github.com/users/octocat/events{/privacy}",
      "received_events_url": "https://api.github.com/users/octocat/received_events",
      "type": "User",
      "site_admin": false
    },
    "private": false,
    "html_url": "https://github.com/octocat/Hello-World",
    "description": "This your first repo!",
    "fork": false,
    "url": "https://api.github.com/repos/octocat/Hello-World",
    "archive_url": "https://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}",
    "assignees_url": "https://api.github.com/repos/octocat/Hello-World/assignees{/user}",
    "blobs_url": "https://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}",
    "branches_url": "https://api.github.com/repos/octocat/Hello-World/branches{/branch}",
    "collaborators_url": "https://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}",
    "comments_url": "https://api.github.com/repos/octocat/Hello-World/comments{/number}",
    "commits_url": "https://api.github.com/repos/octocat/Hello-World/commits{/sha}",
    "compare_url": "https://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}",
    "contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/{+path}",
    "contributors_url": "https://api.github.com/repos/octocat/Hello-World/contributors",
    "deployments_url": "https://api.github.com/repos/octocat/Hello-World/deployments",
    "downloads_url": "https://api.github.com/repos/octocat/Hello-World/downloads",
    "events_url": "https://api.github.com/repos/octocat/Hello-World/events",
    "forks_url": "https://api.github.com/repos/octocat/Hello-World/forks",
    "git_commits_url": "https://api.github.com/repos/octocat/Hello-World/git/commits{/sha}",
    "git_refs_url": "https://api.github.com/repos/octocat/Hello-World/git/refs{/sha}",
    "git_tags_url": "https://api.github.com/repos/octocat/Hello-World/git/tags{/sha}",
    "git_url": "git:github.com/octocat/Hello-World.git",
    "issue_comment_url": "https://api.github.com/repos/octocat/Hello-World/issues/comments{/number}",
    "issue_events_url": "https://api.github.com/repos/octocat/Hello-World/issues/events{/number}",
    "issues_url": "https://api.github.com/repos/octocat/Hello-World/issues{/number}",
    "keys_url": "https://api.github.com/repos/octocat/Hello-World/keys{/key_id}",
    "labels_url": "https://api.github.com/repos/octocat/Hello-World/labels{/name}",
    "languages_url": "https://api.github.com/repos/octocat/Hello-World/languages",
    "merges_url": "https://api.github.com/repos/octocat/Hello-World/merges",
    "milestones_url": "https://api.github.com/repos/octocat/Hello-World/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}",
    "pulls_url": "https://api.github.com/repos/octocat/Hello-World/pulls{/number}",
    "releases_url": "https://api.github.com/repos/octocat/Hello-World/releases{/id}",
    "ssh_url": "git@github.com:octocat/Hello-World.git",
    "stargazers_url": "https://api.github.com/repos/octocat/Hello-World/stargazers",
    "statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/{sha}",
    "subscribers_url": "https://api.github.com/repos/octocat/Hello-World/subscribers",
    "subscription_url": "https://api.github.com/repos/octocat/Hello-World/subscription",
    "tags_url": "https://api.github.com/repos/octocat/Hello-World/tags",
    "teams_url": "https://api.github.com/repos/octocat/Hello-World/teams",
    "trees_url": "https://api.github.com/repos/octocat/Hello-World/git/trees{/sha}",
    "clone_url": "https://github.com/octocat/Hello-World.git",
    "mirror_url": "git:git.example.com/octocat/Hello-World",
    "hooks_url": "https://api.github.com/repos/octocat/Hello-World/hooks",
    "svn_url": "https://svn.github.com/octocat/Hello-World",
    "homepage": "https://github.com",
    "language": null,
    "forks_count": 9,
    "stargazers_count": 80,
    "watchers_count": 80,
    "size": 108,
    "default_branch": "master",
    "open_issues_count": 0,
    "is_template": true,
    "topics": [
      "octocat",
      "atom",
      "electron",
      "api"
    ],
    "has_issues": true,
    "has_projects": true,
    "has_wiki": true,
    "has_pages": false,
    "has_downloads": true,
    "archived": false,
    "disabled": false,
    "visibility": "public",
    "pushed_at": "2011-01-26T19:06:43Z",
    "created_at": "2011-01-26T19:01:12Z",
    "updated_at": "2011-01-26T19:14:43Z",
    "permissions": {
      "admin": false,
      "push": false,
      "pull": true
    },
    "allow_rebase_merge": true,
    "temp_clone_token": "ABTLWHOULUVAXGTRYU7OC2876QJ2O",
    "allow_squash_merge": true,
    "delete_branch_on_merge": true,
    "allow_merge_commit": true,
    "subscribers_count": 42,
    "network_count": 0,
    "license": {
      "key": "mit",
      "name": "MIT License",
      "url": "https://api.github.com/licenses/mit",
      "spdx_id": "MIT",
      "node_id": "MDc6TGljZW5zZW1pdA==",
      "html_url": "https://api.github.com/licenses/mit"
    },
    "forks": 1,
    "open_issues": 1,
    "watchers": 1
  },
  "source": {
    "id": 1296269,
    "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
    "name": "Hello-World",
    "full_name": "octocat/Hello-World",
    "owner": {
      "login": "octocat",
      "id": 1,
      "node_id": "MDQ6VXNlcjE=",
      "avatar_url": "https://github.com/images/error/octocat_happy.gif",
      "gravatar_id": "",
      "url": "https://api.github.com/users/octocat",
      "html_url": "https://github.com/octocat",
      "followers_url": "https://api.github.com/users/octocat/followers",
      "following_url": "https://api.github.com/users/octocat/following{/other_user}",
      "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
      "organizations_url": "https://api.github.com/users/octocat/orgs",
      "repos_url": "https://api.github.com/users/octocat/repos",
      "events_url": "https://api.github.com/users/octocat/events{/privacy}",
      "received_events_url": "https://api.github.com/users/octocat/received_events",
      "type": "User",
      "site_admin": false
    },
    "private": false,
    "html_url": "https://github.com/octocat/Hello-World",
    "description": "This your first repo!",
    "fork": false,
    "url": "https://api.github.com/repos/octocat/Hello-World",
    "archive_url": "https://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}",
    "assignees_url": "https://api.github.com/repos/octocat/Hello-World/assignees{/user}",
    "blobs_url": "https://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}",
    "branches_url": "https://api.github.com/repos/octocat/Hello-World/branches{/branch}",
    "collaborators_url": "https://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}",
    "comments_url": "https://api.github.com/repos/octocat/Hello-World/comments{/number}",
    "commits_url": "https://api.github.com/repos/octocat/Hello-World/commits{/sha}",
    "compare_url": "https://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}",
    "contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/{+path}",
    "contributors_url": "https://api.github.com/repos/octocat/Hello-World/contributors",
    "deployments_url": "https://api.github.com/repos/octocat/Hello-World/deployments",
    "downloads_url": "https://api.github.com/repos/octocat/Hello-World/downloads",
    "events_url": "https://api.github.com/repos/octocat/Hello-World/events",
    "forks_url": "https://api.github.com/repos/octocat/Hello-World/forks",
    "git_commits_url": "https://api.github.com/repos/octocat/Hello-World/git/commits{/sha}",
    "git_refs_url": "https://api.github.com/repos/octocat/Hello-World/git/refs{/sha}",
    "git_tags_url": "https://api.github.com/repos/octocat/Hello-World/git/tags{/sha}",
    "git_url": "git:github.com/octocat/Hello-World.git",
    "issue_comment_url": "https://api.github.com/repos/octocat/Hello-World/issues/comments{/number}",
    "issue_events_url": "https://api.github.com/repos/octocat/Hello-World/issues/events{/number}",
    "issues_url": "https://api.github.com/repos/octocat/Hello-World/issues{/number}",
    "keys_url": "https://api.github.com/repos/octocat/Hello-World/keys{/key_id}",
    "labels_url": "https://api.github.com/repos/octocat/Hello-World/labels{/name}",
    "languages_url": "https://api.github.com/repos/octocat/Hello-World/languages",
    "merges_url": "https://api.github.com/repos/octocat/Hello-World/merges",
    "milestones_url": "https://api.github.com/repos/octocat/Hello-World/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}",
    "pulls_url": "https://api.github.com/repos/octocat/Hello-World/pulls{/number}",
    "releases_url": "https://api.github.com/repos/octocat/Hello-World/releases{/id}",
    "ssh_url": "git@github.com:octocat/Hello-World.git",
    "stargazers_url": "https://api.github.com/repos/octocat/Hello-World/stargazers",
    "statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/{sha}",
    "subscribers_url": "https://api.github.com/repos/octocat/Hello-World/subscribers",
    "subscription_url": "https://api.github.com/repos/octocat/Hello-World/subscription",
    "tags_url": "https://api.github.com/repos/octocat/Hello-World/tags",
    "teams_url": "https://api.github.com/repos/octocat/Hello-World/teams",
    "trees_url": "https://api.github.com/repos/octocat/Hello-World/git/trees{/sha}",
    "clone_url": "https://github.com/octocat/Hello-World.git",
    "mirror_url": "git:git.example.com/octocat/Hello-World",
    "hooks_url": "https://api.github.com/repos/octocat/Hello-World/hooks",
    "svn_url": "https://svn.github.com/octocat/Hello-World",
    "homepage": "https://github.com",
    "language": null,
    "forks_count": 9,
    "stargazers_count": 80,
    "watchers_count": 80,
    "size": 108,
    "default_branch": "master",
    "open_issues_count": 0,
    "is_template": true,
    "topics": [
      "octocat",
      "atom",
      "electron",
      "api"
    ],
    "has_issues": true,
    "has_projects": true,
    "has_wiki": true,
    "has_pages": false,
    "has_downloads": true,
    "archived": false,
    "disabled": false,
    "visibility": "public",
    "pushed_at": "2011-01-26T19:06:43Z",
    "created_at": "2011-01-26T19:01:12Z",
    "updated_at": "2011-01-26T19:14:43Z",
    "permissions": {
      "admin": false,
      "push": false,
      "pull": true
    },
    "allow_rebase_merge": true,
    "temp_clone_token": "ABTLWHOULUVAXGTRYU7OC2876QJ2O",
    "allow_squash_merge": true,
    "delete_branch_on_merge": true,
    "allow_merge_commit": true,
    "subscribers_count": 42,
    "network_count": 0,
    "license": {
      "key": "mit",
      "name": "MIT License",
      "url": "https://api.github.com/licenses/mit",
      "spdx_id": "MIT",
      "node_id": "MDc6TGljZW5zZW1pdA==",
      "html_url": "https://api.github.com/licenses/mit"
    },
    "forks": 1,
    "open_issues": 1,
    "watchers": 1
  }
}

If the repository is public, you won't need any permission to access those datas.
Now the repository is private, you'll need to use your PAT in the request headers to get access to them.


text:
Q: Exception could not catch from calllbacked function I am calling a login function using firebase authentication and checking the custom user claim. If not, then throw the exception. I could not catch the exception in caller function. May I know why?
const handleLogin = async (data) => {
console.log(data);
setIsSubmitting(true);
auth
  .login(data.email, data.password)
  .then((res) => {
    navigate(from, { replace: true });
  })
  .catch((error) => {
    console.log(error.message);
    const message = auth.mapAuthCodeToMessage(error.code);
    setLoginError(message ?? error.message);
  })
  .finally(() => {
    mounted.current && setIsSubmitting(false);
  });
};

firebase authentication
async function login(email, password) {
return signInWithEmailAndPassword(auth, email, password).then(
  async function (res) {
    const currentUser = getAuth().currentUser;
    if (currentUser) {
      currentUser.getIdTokenResult().then(async function (idTokenResult) {
        if (idTokenResult.claims.role == "ADMIN") {
          await signIn(idTokenResult.token);
        } else {
          throw new Error("You role is not authorised!");
        }
      });
    }
  }
);
}

A: Because you're not returning the promise here:
async function login(email, password) {
return signInWithEmailAndPassword(auth, email, password).then(
  async function (res) {
    const currentUser = getAuth().currentUser;
    if (currentUser) {
      currentUser.getIdTokenResult().then(async function (idTokenResult) { // ***
        if (idTokenResult.claims.role == "ADMIN") {                        // ***
          await signIn(idTokenResult.token);                               // ***
        } else {                                                           // ***
          throw new Error("You role is not authorised!");                  // ***
        }                                                                  // ***
      });                                                                  // ***
    }
  }
);
}

You need to return that promise for the caller to know about the rejection.
But there's a more fundamental issue: You're not making any use of the fact you're using async functions. There's no point to an async function that doesn't have any await in it. In general, don't mix async functions with explicit promise callbacks, it's much too easy to make mistakes like not returning the promise. Instead, use await.
Here's a translation of those functions using await (note: it may not be perfect, it's meant to guide you in the right direction, but naturally I can't run it nor do I know your context, so adjust as necessary):
const handleLogin = async (data) => {
    console.log(data);
    setIsSubmitting(true);
    try {
        await auth.login(data.email, data.password);
        navigate(from, { replace: true });
    } catch (error) {
        console.log(error.message);
        const message = auth.mapAuthCodeToMessage(error.code);
        setLoginError(message ?? error.message);
    } finally {
        if (mounted.current) {
            setIsSubmitting(false);
        }
    }
};

async function login(email, password) {
    const res = await signInWithEmailAndPassword(auth, email, password);
    const currentUser = getAuth().currentUser;
    if (currentUser) {
        const idTokenResult = await currentUser.getIdTokenResult();
        if (idTokenResult.claims.role == "ADMIN") {
            await signIn(idTokenResult.token);
        } else {
            throw new Error("You role is not authorised!");
        }
    }
};

redpajama_set_name: RedPajamaStackExchange


text:
Q: Enable CSP on 404 page with CI4 I have turned Content Security Policy on in my App.php config file which works fine across all pages of my site. Except I am running a security scanner which detects that on 404 pages it isn't running.
Is there a setting in Codeigniter 4 I need to turn on so that CSP is enabled on 404 pages?

A: It turns out if you define your own 404 handler then this problem is automatically resolved.
The solution is to therefore adjust the following in your Config\Routes.php
$routes->set404Override('\App\Controllers\Site::error404');
Then in your controller create a 404 handling function (I called mine error404). However what is strange is you must echo your view and not return it. Not quite sure why but that fixed my problem.


text: Q: В базе данных phpMyadmin datetime отображается нулями 0:00:00 .Как сделать так,чтобы выводилось реальное время? В базе данных phpMyadmin datetime отображается нулями 0:00:00 .Как сделать так,чтобы выводилось реальное время?если выставляю в таблице timespawn дата и время выводятся,но с отставанием в 7 часов.


text:
Q: Prevent tcpreplay blocking Mininet Python API cmds I need to execute multiple different commands to replay pcaps into my network.
The first pcap is over 100 seconds, I need to play it and then immediately play other pcaps.
My problem is, when I execute this line in my python code:
h2.cmd('tcpreplay --intf1=h2-eth0 BenignTest.pcap 10.0.0.1')

The program waits for this 100 second pcap to finish before continuing.  I need the program to continue as soon as it sends that command.
Is there a way to make tcpreplay non-blocking like this?

A: Turns out it is as simple as adding & to the end of the command.
h2.cmd('tcpreplay --intf1=h2-eth0 BenignTest.pcap 10.0.0.1 &')

& sends the command to the background and frees up the terminal being used.
https://bashitout.com/2013/05/18/Ampersands-on-the-command-line.html


text:
Q: Qt 5 Unknown module(s) in QT: uitools I just started to use Qt today and I don't know if I did something wrong when I installed it but I can't use QFormBuilder.
Linux Xubuntu 64b
what I did:

*

*I clone this repo : git@gitorious.org:qt/qt5.git

*init_repository >> ./configure >> make >> sudo make install

*I downloaded qt-creator http://qt-project.org/downloads#qt-creator

*I created a new project and when I try to include QFormBuilder he tell me that he doesn't know this file.

So, I saw somewhere someone who says that I need to add QT += uitools to the project file, but now when I try to use qmake,  I am getting Unknown module(s) in QT: uitools.
Sorry for my english and thank you for your help.

A: If you get
Project ERROR: Unknown module(s) in QT: designer

you are missing qttools5-dev package.

A: To add to the answer by @svlasov, on RHEL or CentOS based systems (7.x or 8.x, etc.) you need to install:
yum install qt5-qttools-devel

Depending on the project you are building, you may also need to install qt5-qttools-static.

A: Have you actually read the documentation?
It writes this at the beginning:

The QFormBuilder class is used to dynamically construct user interfaces from UI files at run-time. More...
Header:   #include
qmake:    QT += designer
Inherits: QAbstractFormBuilder.

So, just follow that and put this into your qmake project file:
QT += designer

or you can invoke qmake like this:
qmake QT += designer

Of course, you need to make sure that you have the designer installed properly for this. You will need to install a package like libqt5designer5 on your Ubuntu, or if you had installed Qt manually, you will need to install the designer manually as well.
I am not that familiar with Ubuntu. You may need to install some corresponding development package as well. Either way, the point is that the library and headers need to be installed properly on your system which you seem to lack when getting Project ERROR: Unknown module(s) in QT: designer after either of the aforementioned solutions.

A: Read the documentation, it says to add the designer module to the .pro file:

QT += designer


text:
Q: Uncaught TypeError: Cannot read property 'mData' of undefined i followed this
for enabling multiple tables(on same page) using DataTables plugin.
for manual tables it work but for dynamic created tables it shows the following error:

Uncaught TypeError: Cannot read property 'mData' of undefined

my page srcipt:
 $(document).ready(function() {
         $('table.datatable').dataTable( {
            'bSort': false,
            'aoColumns': [
                  { sWidth: "45%", bSearchable: false, bSortable: false },
                  { sWidth: "45%", bSearchable: false, bSortable: false },
                  { sWidth: "10%", bSearchable: false, bSortable: false }
            ],
            "scrollY":        "200px",
            "scrollCollapse": false,
            "info":           true,
            "paging":         true
        } );
    } );

my HTML first table:

              Issue
              Product
              Qty
             Paid
             Balance
             Total

            May 20, 2015
            Normal Sim
            1000
            Rs18,893.00
            Rs131,107.00
            Rs150,000.00

            voice/7?invoice_type=1">May 20, 2015
            Nokia 3310
            10000
            Rs2,520,000.00
            Rs12,480,000.00
            Rs15,000,000.00

            May 20, 2015
            Nokia 3310
            1000
            Rs404,000.00
            Rs1,096,000.00
            Rs1,500,000.00

second table:

            Issue
            Paid
            Comments

            May 20, 2015, 5:15 pm
            Rs 15,000.00

            May 20, 2015, 5:15 pm
            Rs 12.00

            May 20, 2015, 5:15 pm
            Rs 123.00

            May 20, 2015, 5:15 pm
            Rs 123.00

any idea how to fix?
Note: i also read this Unanswered Question, same error but mine is different criteria therefore it is not a duplicate.

A: If your aaData is an array of array e.g [["col11","col12","col13"],["col21","col22","col23"]],
then only your above code will work else it will expect an mdata attribute to set to the col value e.g., aaData=[{col1:"col1val",col2:"col2val",col3:"col3val"}],
Map aoColumns-
so in aoColumns :[{mdata:"col1"}]

Do this -
$(document).ready(function() {
         $('#p_history').dataTable( {
            'bSort': false,
            'aoColumns': [
                  { sWidth: "45%", bSearchable: false, bSortable: false },
                  { sWidth: "45%", bSearchable: false, bSortable: false },
                  { sWidth: "10%", bSearchable: false, bSortable: false },
                  //match the number of columns here for table1
            ],
            "scrollY":        "200px",
            "scrollCollapse": false,
            "info":           true,
            "paging":         true
        } );

//Now for another table
         $('#secondTableId').dataTable( {
            'bSort': false,
            'aoColumns': [
                  { sWidth: "45%", bSearchable: false, bSortable: false },
                  { sWidth: "45%", bSearchable: false, bSortable: false },
                  { sWidth: "10%", bSearchable: false, bSortable: false },
                  //match the number of columns here for table2
            ],
            "scrollY":        "200px",
            "scrollCollapse": false,
            "info":           true,
            "paging":         true
        } );
    } );

A: CAUSE
You are trying to initialize multiple table with the same options, the most important one is aoColumns, array holding column definitions. Your aoColumns array holds 3 items only, however the number of columns differ in each tables, that is why you receive an error.
From the manual:

aoColumns: If specified, then the length of this array must be equal
  to the number of columns in the original HTML table. Use 'null' where
  you wish to use only the default values and automatically detected
  options.

SOLUTION
You need to assign unique id to the first table and initialize each table separately as shown below.

$(document).ready(function() {
   $('#table_first').dataTable( {
       'bSort': false,
       'aoColumns': [
             { sWidth: "15%", bSearchable: false, bSortable: false },
             { sWidth: "15%", bSearchable: false, bSortable: false },
             { sWidth: "15%", bSearchable: false, bSortable: false },
             { sWidth: "15%", bSearchable: false, bSortable: false },
             { sWidth: "15%", bSearchable: false, bSortable: false },
             { sWidth: "15%", bSearchable: false, bSortable: false },
       ],
       "scrollY":        "200px",
       "scrollCollapse": false,
       "info":           true,
       "paging":         true
   });

    $('#p_history').dataTable( {
       'bSort': false,
       'aoColumns': [
             { sWidth: "45%", bSearchable: false, bSortable: false },
             { sWidth: "45%", bSearchable: false, bSortable: false },
             { sWidth: "10%", bSearchable: false, bSortable: false }
       ],
       "scrollY":        "200px",
       "scrollCollapse": false,
       "info":           true,
       "paging":         true
   } );

} );

<link href="//cdn.datatables.net/1.10.7/css/jquery.dataTables.css" rel="stylesheet"/>

              Issue
              Product
              Qty
             Paid
             Balance
             Total

            May 20, 2015
            Normal Sim
            1000
            Rs18,893.00
            Rs131,107.00
            Rs150,000.00

            voice/7?invoice_type=1">May 20, 2015
            Nokia 3310
            10000
            Rs2,520,000.00
            Rs12,480,000.00
            Rs15,000,000.00

            May 20, 2015
            Nokia 3310
            1000
            Rs404,000.00
            Rs1,096,000.00
            Rs1,500,000.00

            Issue
            Paid
            Comments

            May 20, 2015, 5:15 pm
            Rs 15,000.00

            May 20, 2015, 5:15 pm
            Rs 12.00

            May 20, 2015, 5:15 pm
            Rs 123.00

            May 20, 2015, 5:15 pm
            Rs 123.00

LINKS
See jQuery DataTables: Common JavaScript console errors for more information on this and other common console errors.

A: As stated in the DataTables usage guide, you need to have both thead and tbody sections declared in your table to get the plugin work correctly.
This thing has also been discussed here at SO before, so some Googling or SO search might be a good thing next time.

A: I got the this error while I was using id names like k_something_1.
I solved it by 'renaming' it to ksomething1.


text:
Q: Is it okay to use App Tamer to force apps such as Microsoft Word, to "App Nap?" One (of the many) things which has always annoyed me about Microsoft Word 2016 (and indeed, pretty much all others apps in the Microsoft Office suite) is its inability to keep the background CPU usage to zero. When using Apple's Pages, Numbers, and Keynote, the CPU usage of each of the apps decreases to zero after you switch to another app. However, the apps in the Microsoft suite seem to use around half a percent of CPU on my laptop (which sometimes even spikes).
I recently found out about a cool app called App Tamer which seems like it can force an application to nap. As a matter of fact, one of the default rules seems to do this when you install App Tamer!
Now, I'm wondering if there are any unforeseen disadvantages of doing this. Does Microsoft cause this constant background CPU usage because essential (such as auto recover?) processes are taking place, or is it just a byproduct of sloppy, unoptimized coding? To be fair with the auto recovery example, however, I have empirically found it to be quite unreliable (unfortunately in the hard way).


text:
Q: Get the top row after order by in Oracle Subquery I have a table student(id, name, department, age, score). I want to find the youngest student who has the highest(among the youngest students) score of each department. In SQL Server, I can use following SQL.
select * from student s1
where s1.id in
(select s2.id from student s2
where s2.department = s1.department order by age asc, score desc top 1).

However, in Oracle, you cannot use the order by clause in subquery and there is no limit/top like keyword. I have to join the student table with itself two times to query the result. In oracle, I use following SQL.
select s1.* from student s1,
(select s2.department, s2.age, max(s2.score) as max_score from student s2,
(select s3.department, min(s3.age) as min_age from student s3 group by s3.department) tmp1 where
s2.department = tmp1.department and s2.age = tmp1.min_age group by s2.department, s2.age) tmp2
where s1.department =tmp2.department and s1.age = tmp2.age and s1.score=tmp2.max_score

Does anyone have any idea to simplify the above SQL for oracle.

A: In addition to Bharat's answer, it is possible to do this using ORDER BY in the sub-query in Oracle (as point out by Jeffrey Kemp):
SELECT *
FROM   student s1
WHERE  s1.id IN (SELECT id
                 FROM   (SELECT   id, ROWNUM AS rn
                         FROM     student s2
                         WHERE    s1.department = s2.department
                         ORDER BY age ASC, score DESC)
                 WHERE  rn = 1);

If you use this method, you may be tempted to remove the sub-query and just use rownum = 1. This would result in the incorrect result as the sort would be applied after the criteria (you'd get 1 row that was sorted, not one row from the sorted set).

A: try this one
select * from
  (SELECT id, name, department, age, score,
  ROW_NUMBER() OVER (partition by department order by age desc, score asc) srlno
  FROM student)
where srlno = 1;

A: In addition to Allan's answer, this works fine too:
select *
from (SELECT *
  FROM student
  order by age asc,
           score desc)
where rownum = 1;

A: select to_char(job_trigger_time,'mm-dd-yyyy') ,job_status from
(select * from kdyer.job_instances ji INNER JOIN kdyer.job_param_values pm
on((ji.job_id = pm.job_id) and (ji.job_spec_id = '10003') and (pm.param_value='21692') )
order by ji.job_trigger_time desc)
where rownum<'2'


text:
Q: Android data binding error? I tried to use the me.tatarka.bindingcollectionadapter:bindingcollectionadapter library after I added it to gradle :
compile 'me.tatarka.bindingcollectionadapter:bindingcollectionadapter:1.3.0'
compile 'me.tatarka.bindingcollectionadapter:bindingcollectionadapter-recyclerview:1.3.0'

I used it in the xml file like this:
<layout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    >
    <data>
        <variable name="viewModel" type="com.example.ViewModel"/>
        <import type="me.tatarka.bindingcollectionadapter.LayoutManagers" />
    </data>

    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_toStartOf="@+id/recycler"
        app:layoutManager="@{LayoutManagers.linear()}"

        app:items="@{viewModel.items}"
        app:itemView="@{viewModel.itemView}"/>
</RelativeLayout>
</layout>

  Identifiers must have user defined types from the XML file. LayoutManagers is missing it file
    ****\ data binding error ****

Could someone help me?
Thanks.

A: Data must be a children of layout
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
    <data>
        <variable name="viewModel" type="com.example.ViewModel"/>
        <import type="me.tatarka.bindingcollectionadapter.LayoutManagers" />
    </data>

   <!-- Rest of your layout -->
</layout>


text:
Q: Have 4 fields on a adf page. How to refresh their values from database one after the other based on use selection I have an Oracle ADF page with 4 fields in the below order.

*

*radio button (select one). Always populate the radio selection from values in database.

*drop down list (select one): Empty by default. Pull the value from database based on radio button selection on 1.

*drop down list (select one): Empty by default. Pull the values from database based on drop selection made on 2.

*drop down list (select one): Empty by default. Pull the values from database based on drop selection made on 3.
I need to pass the values selected in 2, 3, 4 to a view/query in the model and retrieve a list and display it on a new page.
I have generated the entity and view objects in JDeveloper. How do I develop the above logic.
Any help on this is highly appreciated.


text:
Q: button load from xib via loadNibNamed() never called Another problem arrived me. I have a view covering my hole screen. In it a webView for showing a youTube video and a button for closing. The view is load via loadNibNamed() and no matter what I'm doing, my IBAction never called by pressing that button.
I tried to make an IBAction via storyboard, also via addTarget to a buttonoutlet. Both never called. My button is reachable when I click it, it show the default touchanimation. Also printing the button outlet in viewDidLoad() says <UIButton: 0x17d25430; frame = (15 8; 39 30); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x17d25ae0>> so it is not nil.
My Layout looks like the following.

*

*MainScreen: UIViewController, UITableViewDelegate, UITableViewDataSource, UIWebViewDelegate{}

*

*In one of mainScreens tableView is a customCell named videoViewCell implemented with:

let cell = NSBundle.mainBundle().loadNibNamed("VideoViewCell", owner: self, options: nil)!.first as! VideoViewCell
videoViewCell: UITableViewCell , UITableViewDelegate, UITableViewDataSource {}  has:
weak var delegate: ActivityDetailVideoCellDelegate?

...

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    delegate?.selectedCellAtIndex(indexPath.row)
}

...

protocol ActivityDetailVideoCellDelegate: class {
    func selectedCellAtIndex(index: Int)
}

My mainScreen class has:
extension MainScreen: ActivityDetailVideoCellDelegate {
func selectedCellAtIndex(index: Int) {

    let youtubeLink: String = "http://www.youtube.com/embed/\(selectedVideo)"
    let youtubePopup = YouTubePopUpController()

    youtubePopup.view.frame = self.view.bounds
    youtubePopup.view.alpha = 0
    youtubePopup.view.transform = CGAffineTransformMakeScale(1.3, 1.3)

    let code: String = "<iframe width=\(youtubePopup.webView.bounds.width) height=\(youtubePopup.webView.bounds.height) src=\(youtubeLink) frameborder=0 allowfullscreen></iframe> <style>body { margin: 0; padding: 0; }</style>"

    youtubePopup.webView.loadHTMLString(code, baseURL: nil)

    self.view.addSubview(youtubePopup.view)

    UIView.animateWithDuration(0.25, animations: { () -> Void in
        youtubePopup.view.alpha = 1
        youtubePopup.view.transform = CGAffineTransformMakeScale(1, 1)
    })
}

}
YouTubePopUpController: UIViewController:
@IBOutlet weak var backgroundView: UIView!
@IBOutlet weak var webView: UIWebView!
@IBOutlet weak var closeButton: UIButton!

override func viewDidLoad() {
    super.viewDidLoad()

    print(closeButton)

    closeButton.addTarget(self, action: #selector(self.closeButtonClicked(_:)), forControlEvents: .TouchUpInside)
}

@IBAction func closeButtonClicked(sender: AnyObject) {
    print("close clicked")

    UIView.animateWithDuration(0.25, animations: { () -> Void in
        self.view.transform = CGAffineTransformMakeScale(1.3, 1.3)
        self.view.alpha = 0
    }) { (finished) -> Void in
        self.view.removeFromSuperview()
    }
}

my xib:

A: Finally solved my Problem by writing the @IBAction func closeButtonClicked(sender: AnyObject) {} inside my MainScreenViewController an adding Target inside func selectedCellAtIndex(index: Int) {} to call my youtubePopUp inside closeButtonClicked I made it global:
@IBAction func closeButtonClicked(sender: AnyObject) {
    print("close clicked")

    youtubePopup!.webView.loadHTMLString("about:blank", baseURL: nil)
    youtubePopup!.webView.mediaPlaybackRequiresUserAction = false

    UIView.animateWithDuration(0.25, animations: { () -> Void in
        self.youtubePopup!.view.transform = CGAffineTransformMakeScale(1.3, 1.3)
        self.youtubePopup!.view.alpha = 0
    }) { (finished) -> Void in
        self.youtubePopup!.view.removeFromSuperview()
    }

}


text:
Q: Show a button after a time Hi sorry I'm really new to this and I need help.
I'm trying to get a button to appear after say 8 secs.
I want the app to open on a title screen then after 8 secs show a enter button to move on.
I've set up the screens and everything with the button already there but that's not what I want.
Can someone please help?? I'm using Objective C in Xcode 7.2 and for iPhone ( remember I'm really new lol).
Thanks

A: You can either use a Timer approach or a dispatch one, but timer is mostly made for repetition, so I'll go with dispatch :
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 8 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
    self.myButton.hidden = FALSE;
});

The first parameter looks weird, but let's explain it with the doc :

The dispatch_time() function returns a milestone relative to an
  existing milestone after adding offset nanoseconds.  If the base parameter maps internally to a wall clock, then the returned value is relative to the wall clock.  Otherwise, if base is DISPATCH_TIME_NOW, then the the current time of the default host clock is used.

NSEC_PER_SEC represents the number of nanosecond in a second (1000000000), so you just have to multiply it by 8 and got your 8 seconds, that you add to current time represented by DISPATCH_TIME_NOW.

A: You need to follow the steps
1) When viewIs Displayed on the screen you need to set the timer to add button on screen.
2) You detect the view displayed in ViewWillAppear in the ViewController.
3) In viewWillAppear Add the following method with the selector which will be get executed after 10 Sec
[self performSelector:@selector(displaybutton:) withObject:request afterDelay:10.0];

4) In displaybutton method write code to display button Or if you have set image in StoryBoard set the button.hidden = No in this method

A: Set your button property hidden in Interface builder and call this method in your viewWillAppear
-(void) viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self performSelector:@selector(showButton) withObject:nil afterDelay:8.0];
}

- (void)showButton{

        [UIView animateWithDuration:0.5 delay:1.0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                self.startButton.hidden = NO;
            }completion:^(BOOL finished){
                NSLog(@"Done!");
        }];
}


text:
Q: Using AJAX to add results to the bottom of a page I have some code that iterates through some database results and displays them, as such...
Note: article item.php just echoes the results with some formatting.
 <ul class="post-column">
                            <?php
                            foreach ($data as $lineitem):
                            $type = $lineitem['type'];
                            if($type == "article"){
                               require('php/articleitem.php');
                            }

                            endforeach;
                            ?>
                        </ul>

When I get to the bottom of the page, I want to do an AJAX DB call to get further results...
if ($(window).scrollTop() >= $(document).height() - $(window).height() - 700) {
        startpoint = startpoint + 10;

        processing = true;

        $.ajax({
            url: "AJAX/moritems.php",
            type: "post",
            async: false,
            //this is where we define the data that we will send
            data: {
                startpoint: startpoint,
            },
            success: function (data) {

            },
        });
        processing = false;
    }

I want to then use the DB results to display more data below the data I've already displayed on the screen, but because I've displayed the result thus far in PHP, how would I do that? Would I have to use AJAX to load a new php page with results, then use javascript to add it to the existing page at the bottom of the results?

A: The answer is yes. Example:
function load() {
    var xmlhttp;

    xmlhttp = new XMLHttpRequest();

    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == XMLHttpRequest.DONE ) {
           if(xmlhttp.status == 200){
               document.getElementById("myDiv").innerHTML += xmlhttp.responseText;
           }
           else if(xmlhttp.status == 400) {
              alert('There was an error 400')
           }
           else {
               alert('something else other than 200 was returned')
           }
        }
    }

    xmlhttp.open("GET", yoururl, true);
    xmlhttp.send();
}

You need to define yoururl and link the function to the click event of your paging button or run it when you scroll.


text:
Q: socket.io routing issue with a node.js express 3 app running in a virtual directory with iisnode Errors:
Trying to access http://localhost/appDirectory/socket.io gives:
Cannot GET /appDirectory/socket.io
Or to put it another way when trying to load the client file on the page I get this error:
GET http://localhost/appDirectory/socket.io/socket.io.js 404 (Not Found)
If I load the client file as static content the connect line produces this error:
GET http://localhost/appDirectory/socket.io/1/?t=1365535131937 404 (Not Found)
Server code:
var express = require('express'),
namespace = require('express-namespace'),
routes = require('./routes'),
http = require('http'),
app = express(),
server = app.listen(process.env.PORT),
io = require('socket.io').listen(server);
var appDir = '/appDirectory';

app.configure(function(){
  app.set('env', process.env.NODE_ENV || 'development');
  app.set('/views', __dirname + '/views');
  app.set('view engine', 'jade');
  app.use(app.router);
  app.use(appDir, require('stylus').middleware(__dirname + '/public'));
  app.use(appDir, express.static(path.join(__dirname, '/public')));
});

app.get(appDir + '/', routes.index);

io.sockets.on('connection', function (socket) {
  socket.emit('message', 'lol');
});

Client code:
<script src="/appDirectory/socket.io/socket.io.js"></script>
<script type="text/javascript">
  var socket = io.connect(appDir, { resource: appDir.substring(1) + '/socket.io' });
  socket.on('connect', function () {
    console.log('connected');
  });
</script>

The web config file that's getting this to work is...
Web.config:
<configuration>
<system.webServer>
  <handlers>
    <add name="iisnode" path="app.js" verb="*" modules="iisnode" />
  </handlers>
  <iisnode loggingEnabled="true" debuggingEnabled="true" debuggerPathSegment="debug" />
  <rewrite>
    <rules>
      <clear />
      <rule name="Debug" patternSyntax="Wildcard" stopProcessing="true">
        <match url="app.js/debug*" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
        <action type="None" />
      </rule>
      <rule name="app" patternSyntax="Wildcard">
        <match url="*" negate="false" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
        <action type="Rewrite" url="app.js" />
      </rule>
    </rules>
  </rewrite>
</system.webServer>
</configuration>

My gut feeling is that the express routing is interfering with the socket.io routing or that the socket.io routing is not compatible with the virtual directory. I did see some mention of namespacing with socket.io and I did try the following...
io.of(appDir).on('connection', function (socket) {
  socket.emit('message', 'lol');
});

But that didn't seem to fix the problem.
I have tried a number of different things on the client code side but I don't think that is the root problem or the http://localhost/appDirectory/socket.io/socket.io.js would be working.
The application is running as a virtual directory and is built on:
- node.js 0.10.3 for windows
- iis 7
- iisnode 0.2.4
- express.js 3.0.0rc1
- jade
- socket.io

The module "express namespace" seems to make things work.
I am aware that iisnode was "designed" to be run as a separate site and I'm also aware that express doesn't like being in a virtual directory, but I am pretty sure this is possible.
Interesting update!
Changing the line:
io = require('socket.io').listen(server);

To:
io = require('socket.io').listen(server, { resource: appDir + '/socket.io' });

Causes the iis worker process w3wp.exe to crash...
As seen here http://i.imgur.com/65RGia3.png?1
However the url http://localhost/appDirectory/socket.io then seems to work.
Failed attempts at fixing this FYI:

*

*adding the web.config setting for iisnode nodeProcessCountPerApplication="1"

Possible solution:
If you are stuggling with this same issue, I found this which might help you...
http://tomasz.janczuk.org/2013/01/hosting-socketio-websocket-apps-in-iis.html

A: A little bit of a stab in the dark, but if you're using Express 3.x, your problem may be that you're using the older Express 2.x syntax for hooking up Socket.io with Express.
See: https://github.com/visionmedia/express/wiki/Migrating-from-2.x-to-3.x#socketio-compatibility for the new integration method.

A: It looks like you're on the right track. Using the following configuration, it works for me (not using IIS, though):

// server
io = require('socket.io').listen(server, { resource : '/appDirectory/socket.io' });

// client
<script src="/appDirectory/socket.io/socket.io.js"></script>
...
var socket = io.connect('', { resource: 'appDirectory/socket.io' });

I wonder why your IIS process is crashing, could you post the image elsewhere (Dropbox, free image hoster) perhaps?


text:
Q: MySQL - improve a heavy multiple child-nested queries query I'm on a task to improve an app's DB query. This heaving-loading query takes roughly 3-5 minutes to complete which is unacceptable.
The previous developers built this query and they didn't do this job very well though. Now I'm having a bunch of child-queries in the main query which I have to improve. Looks like those child-queries are killing it.
Could anybody advise me which is the best approach to this?
SELECT
   `j`.`id`          AS          `job_id`,
   `j`.`job_number`          AS `job_number`,
   `j`.`job_status`          AS `job_status`,
   `j`.`job_registration_date`          AS `job_registered`,
   `j`.`created`          AS `job_created`,
   `q`.`quote_type_id`          AS `quote_type_id`,
   `qt`.`name`          AS `quote_type_name`,
   `q`.`created_by`          AS `consultant_id`,
   (SELECT
      Concat(`pr`.`first_name`,
      ' ',
      `pr`.`last_name`)
   FROM
      `profiles` `pr`
   WHERE
      (
         `pr`.`user_id` = `q`.`created_by`
      ))          AS `consultant_name`,
   `q`.`domain_id`          AS `domain_id`,
   `p`.`id`          AS `package_id`,
   `q`.`id`          AS `quote_id`,
   `q`.`client_id`          AS `client_id`,
   Concat(`c`.`title`,
   ' ',
   `c`.`first_name`,
   ' ',
   `c`.`last_name`)          AS          `client_name`,
   `q`.`site_id`          AS `site_id`,
   `st`.`name`          AS `site_name`,
   Truncate(Abs(( `q`.`accepted_cost` / 1.1 )),
   2)          AS `est_sale`,

   Coalesce((SELECT
      Sum(`i`.`amount`)
   FROM
      `invoices` `i`
   WHERE
      ( ( `i`.`void` <> 1 )
      AND ( `i`.`job_id` = `j`.`id` ) )),
   (SELECT
      Sum(`i`.`amount`)
   FROM
      `invoices` `i`
   WHERE
      (          ( `i`.`void` <>            1 )
      AND (          `i`.`job_id` = `j`.`id` ) )),
   0)          AS `actual_sale`,

   Coalesce((SELECT
      Sum(( `pp`.`qty` * `pp`.`unit_price` ))
   FROM
      `package_products` `pp`
   WHERE
      ( `pp`.`package_id` = `p`.`id` )),
   (SELECT
      Sum((          `pp`.`qty` * `pp`.`unit_price` ))
   FROM
      `package_products` `pp`
   WHERE
      ( `pp`.`package_id`            = `p`.`id` )),
   0)                        AS `total_package_product`,

   Coalesce((SELECT
      Sum(( `ppt`.`qty` * `ppt`.`unit_price` ))
   FROM
      `package_parts` `ppt`
   WHERE
      ( `ppt`.`package_id` = `p`.`id` )),
   (SELECT
      Sum(( `ppt`.`qty` * `ppt`.`unit_price` ))
   FROM
      `package_parts` `ppt`
   WHERE
      ( `ppt`.`package_id` = `p`.`id` )),
   0)          AS `total_package_part`,

   Coalesce((SELECT
      Truncate(Abs(Sum(( ( `lc`.`number_of_technician` *                                              `lc`.`hours` ) *   `lc`.`hours_rate` ))),
      2)
   FROM
      `labour_costs` `lc`
   WHERE
      ( `lc`.`package_id` = `p`.`id` )),
   (SELECT
      Truncate(   Abs(   Sum(( ( `lc`.`number_of_technician` *   `lc`.`hours` ) *   `lc`.`hours_rate` ))),
      2)
   FROM
      `labour_costs` `lc`
   WHERE
      ( `lc`.`package_id` = `p`.`id` )),
   0)                              AS          `total_labor_cost`,

   Coalesce((SELECT
      Sum(( `pmi`.`qty` * `pmi`.`cost` ))
   FROM
      `package_misc_items` `pmi`
   WHERE
      ( `pmi`.`package_id` = `p`.`id` )),
   (SELECT
      Sum(( `pmi`.`qty` * `pmi`.`cost` ))
   FROM
      `package_misc_items` `pmi`
   WHERE
      ( `pmi`.`package_id` = `p`.`id` )),
   0)                                    AS          `total_package_misc`,
   `p`.`discount`                                                            AS          `discount`,

   Coalesce((SELECT
      ( CASE
         WHEN ( Sum(`jf`.`amount`) <> 0 ) THEN   Truncate(Abs(   Sum(`jf`.`amount`)),
         2)
         ELSE NULL
      end ) AS `acufile_amount`
   FROM
      ((`acufiles` `a`
   JOIN
      `acufile_categories` `c`
         ON(( `c`.`id` = `a`.`category_id` )))
   JOIN
      `job_files` `jf`
         ON(( `jf`.`acufile_id` = `a`.`id` )))
   WHERE
      ( ( `c`.`abbr` = 'CREDINV' )
      AND ( `jf`.`job_id` = `j`.`id` ) )),
   0)                AS   `total_acufile_amount`,

   Coalesce((SELECT
      Truncate(Abs(Sum(( `ts`.`hours` *   `ef`.`e_total_hourly_rate` ))),
      2)
   FROM
      ((`timesheet_entries` `ts`
   JOIN
      `users` `u`
         ON(( `ts`.`user_id` = `u`.`id` )))
   JOIN
      `employee_financials` `ef`
         ON(( `ef`.`user_id` = `u`.`id` )))
   WHERE
      ( `ts`.`job_id` = `j`.`id` )),
   (SELECT
      Truncate(Abs(   Sum(( `ts`.`hours` *   `ef`.`e_total_hourly_rate` ))),
      2) AS   `e_total_labor_timecost`
   FROM
      (   (`timesheet_entries` `ts`
   JOIN
      `users` `u`
         ON(( `ts`.`user_id` = `u`.`id` )))
   JOIN
      `employee_financials` `ef`
         ON(( `ef`.`user_id` = `u`.`id` )))
   WHERE
      ( `ts`.`job_id` =        `j`.`id` )),
   0) AS   `total_labor_timecost`
FROM
   (((((((`packages` `p`
JOIN
   `quote_options` `qo`
      ON(
         (
            `qo`.`id` = `p`.`quote_option_id`
         )
      )
   )
JOIN
`quotes` `q`
   ON(
      (
         `q`.`id` = `qo`.`quote_id`
      )
   )
)
JOIN
`quote_types` `qt`
ON(
   (
      `qt`.`id` = `q`.`quote_type_id`
   )
)
)
JOIN
`jobs` `j`
ON(
(
   `q`.`id` = `j`.`quote_id`
)
)
)
JOIN
`contacts` `c`
ON(
(
`c`.`id` = `q`.`client_id`
)
)
)
LEFT JOIN
`companies` `co`
ON(
(
`co`.`id` = `c`.`company_id`
)
)
)
LEFT JOIN
`sites` `st`
ON(
(
`q`.`site_id` = `st`.`id`
)
)
)
WHERE
(
`p`.`accepted` = 1
)
GROUP  BY
`p`.`id`


text:
Q: Read SMS for opt programically in Maui android I am trying to read sms for otp in my maui appliaction(balzor).i tryied with BroadcastReceiver which was not working fine .now trying with LifecycleEvents i want to fire LogEvent whenever new message arrives to my phone.
                       public static class MauiProgram{
public static MauiApp CreateMauiApp()
{
    var builder = MauiApp.CreateBuilder();
    builder
        .UseMauiApp<App>()
        .ConfigureFonts(fonts =>
        {
            fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
        }).ConfigureLifecycleEvents(events => {

        events.AddAndroid(android => android
            .OnActivityResult((activity, requestCode, resultCode, data) => LogEvent("OnActivityResult", requestCode.ToString()))
            .OnStart((activity) => LogEvent("OnStart"))
            .OnCreate((activity, bundle) => LogEvent("OnCreate"))

            .OnStop((activity) => LogEvent("OnStop")));

        static void LogEvent(string eventName, string type = null)
        {
            System.Diagnostics.Debug.WriteLine($"Lifecycle event: {eventName}{(type == null ? string.Empty : $" ({type})")}");
        }

    });

    builder.Services.AddSingleton<WeatherForecastService>();

    return builder.Build();
}


text:
Q: Constraint layout center vertically if place I center my two Input layout vertically in my view using chaining. I also have an image view and a text view on top of this two Input layout. I would like to have this Input Layout center only if the view enough space.
Right now the Input layout are always center and the text go over the image.
In ios i would use constraint priority to do so but it looks like this is not available for constraint layout yet?
What i have right now

What I want to have is

Edit
Sorry i should have add the text :)
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/registration_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/transparent">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_marginEnd="32dp"
        android:layout_marginStart="32dp"
        android:layout_marginTop="32dp"
        android:adjustViewBounds="true"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/logo" />

    <!--To get the focus when page appear-->
    <include layout="@layout/layout_focus_interceptor" />

    <TextView
        android:id="@+id/tv_extra_info"
        style="@style/TextContent"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="16dp"
        android:layout_marginEnd="16dp"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="16dp"
        android:gravity="center"
        app:layout_constraintBottom_toTopOf="@+id/input_layout_email"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/imageView" />

    <android.support.design.widget.TextInputLayout
        android:id="@+id/input_layout_email"
        style="@style/TextInputLayout"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="@dimen/margin_bottom_text_input_layout"
        android:layout_marginTop="8dp"
        android:theme="@style/PreAuthorizationTextTheme"
        app:layout_constraintBottom_toTopOf="@id/input_layout_email_confirmation"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_chainStyle="packed">

        <android.support.design.widget.TextInputEditText
            android:id="@+id/etxt_email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="textEmailAddress"
            android:nextFocusLeft="@id/etxt_email"
            android:nextFocusUp="@id/etxt_email"
            tools:hint="@string/general_email" />
    </android.support.design.widget.TextInputLayout>

    <android.support.design.widget.TextInputLayout
        android:id="@+id/input_layout_email_confirmation"
        style="@style/TextInputLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="@dimen/margin_bottom_text_input_layout"
        android:layout_marginTop="@dimen/margin_top_text_input_layout"
        android:theme="@style/PreAuthorizationTextTheme"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@id/input_layout_email">

        <android.support.design.widget.TextInputEditText
            android:id="@+id/et_email_confirmation"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="textEmailAddress"
            android:nextFocusLeft="@id/etxt_email"
            android:nextFocusUp="@id/etxt_email"
            tools:hint="@string/registration_email_confirmation" />

    </android.support.design.widget.TextInputLayout>

</android.support.constraint.ConstraintLayout>

A: I don't know how to do this either! But I was able to come up with something that comes close to what you're looking for.
What I did was create a Guideline element fixed at a particular height that caused my views to seem vertically centered when they were positioned below it. For different size phones, this will probably be off by a pixel or ten, but it should never be too bad.
I then create a Barrier that references the guideline and the other view I want to "dodge". And I position my other elements with respect to this barrier.
My XML:
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <View
        android:id="@+id/rect"
        android:layout_width="300dp"
        android:layout_height="100dp"
        android:layout_marginTop="16dp"
        android:background="#fac"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"/>

    <android.support.constraint.Guideline
        android:id="@+id/guideline"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:orientation="horizontal"
        app:layout_constraintGuide_percent="0.34"/>

    <android.support.constraint.Barrier
        android:id="@+id/barrier"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:barrierDirection="bottom"
        app:constraint_referenced_ids="rect,guideline"/>

    <View
        android:id="@+id/first"
        android:layout_width="0dp"
        android:layout_height="48dp"
        android:layout_marginTop="16dp"
        android:background="#caf"
        app:layout_constraintTop_toBottomOf="@id/barrier"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"/>

    <View
        android:id="@+id/second"
        android:layout_width="0dp"
        android:layout_height="48dp"
        android:layout_marginTop="16dp"
        android:background="#caf"
        app:layout_constraintTop_toBottomOf="@+id/first"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"/>

</android.support.constraint.ConstraintLayout>

With a short rect view the two middle views appear vertically centered, and with a tall rect view the two middle views get pushed down:


text:
Q: How to remove redundant contents in json by python? [{...
  {'adminregion': {'id': 'SAS', 'iso2code': '8S', 'value': 'South Asia'},
      'capitalCity': 'Kabul',
      'id': 'AFG',
      'incomeLevel': {'id': 'LIC', 'iso2code': 'XM', 'value': 'Low income'},
      'iso2Code': 'AF',
      'latitude': '34.5228',
      'lendingType': {'id': 'IDX', 'iso2code': 'XI', 'value': 'IDA'},
      'longitude': '69.1761',
      'name': 'Afghanistan',
      'region': {'id': 'SAS', 'iso2code': '8S', 'value': 'South Asia'}},
...}]

The above is a part of my JSON file from world bank collected by API, but I don't need every single column. I would like to know how to delete the column that I don't actually need?
I am happy with the result below:
[{...
  {
      'id': 'AFG',
      'incomeLevel': 'Low income',
      'name': 'Afghanistan',
      'region': 'South Asia'},
...}]

A: Here is a simple for-loop approach given that the json object you provided is the format for each object in the array.
res = []

for item in data:
    id_ = item.get('id')
    income = item.get('incomeLevel').get('value')
    name = item.get('name')
    region = item.get('region').get('value')
    final = {'id': id_, 'incomeLevel': income, 'name': name, 'region': region}
    res.append(final)

print(res)

[{'id': 'AFG',
  'incomeLevel': 'Low income',
  'name': 'Afghanistan',
  'region': 'South Asia'}]

Or another approach would be:
keys = ['id', 'incomeLevel', 'name', 'region']
res = []

for item in data:
    out = {}
    for k, v in item.items():
        if k in keys:
            if isinstance(v, dict):
                out.update({k: v.get('value')})
            else:
                out.update({k: v})
    res.append(out)

print(res)

[{'id': 'AFG',
  'incomeLevel': 'Low income',
  'name': 'Afghanistan',
  'region': 'South Asia'}]


text:
Q: Use case of DB design I wondered if there is any site out there with some detailed examples of normalization and DB design in general. Any comments are welcome.

A: Wikipedia page and this Dev Shed page should give you a  good start.
The following blog page has some links to some good articles on general database design.
The first about the "10 Common Database Design Mistakes" has a good outline of some common pitfalls
and problems seen when database design is not thoroughly planned.


text:
Q: how do I spread exponential number to array? I have a number 1e+30. I want to create an array with each digit in an index in the array.
Eg:
256 -> [...(256 + "")] -> ["2", "5", "6"]
I can't do that to 1e+30. I get NaN. How do I do this?

A: One solution you can do is to use .toLocaleString to get the scientific notation into a string, and then split.

const stringified = (1e+30).toLocaleString('fullwide', {useGrouping:false});
const array = stringified.split("");
console.log(array);

A: You could take BigInt and convert the value to a string. The problem is the accuracy of the value.

var value = 1e30,
    array = Array.from(BigInt(value).toString());

console.log(array.join(''));
console.log(array);

For an accurate value, you could calculate the value directly as bigint type.

var array = Array.from((BigInt(10) ** BigInt(30)).toString());

console.log(array.join(''));
console.log(array);


text:
Q: How can I validate OAuth 2.0 token user details in @PreAuthorize annotation in Spring Boot REST service I need to make a check in @PreAuthorize annotation. Something like:
@PreAuthorize("hasRole('ROLE_VIEWER') or hasRole('ROLE_EDITOR')")

That is OK but I also need to validate some user details stored in the OAuth 2.0 token with those in the request path so I would need to do something like (oauthToken.userDetails is just an example:
@PreAuthorize("#pathProfileId.equals(oauthToken.userDetails.profileId)")

(profileId is not userId or userName, it is a user details that we add in the OAuth token when we create it)
What is the simplest way to make OAuth token properties visible in the preauthorized annotation security expression language?

A: You have two options:
1-
Setting UserDetailsService instance into DefaultUserAuthenticationConverter
and set converter to JwtAccessTokenConverter so when spring calls extractAuthentication method from DefaultUserAuthenticationConverter it found (userDetailsService != null) so it get the whole UserDetails object by calling implementation of loadUserByUsername when calling this line:

userDetailsService.loadUserByUsername((String) map.get(USERNAME))

implemented in next method inside spring class org.springframework.security.oauth2.provider.token.DefaultUserAuthenticationConverter.java but just adding it to clarify how spring get principal object from map (first getting it by username, and if userDetailsService not null so it get the whole object):
//Note: This method implemented by spring but just putting it to show where spring exctract principal object and how extracting it
public Authentication extractAuthentication(Map<String, ?> map) {
        if (map.containsKey(USERNAME)) {
            Object principal = map.get(USERNAME);
            Collection<? extends GrantedAuthority> authorities = getAuthorities(map);
            if (userDetailsService != null) {
                UserDetails user = userDetailsService.loadUserByUsername((String) map.get(USERNAME));
                authorities = user.getAuthorities();
                principal = user;
            }
            return new UsernamePasswordAuthenticationToken(principal, "N/A", authorities);
        }
        return null;
    }

So what you need to implement in your microservice is:
@Bean//this method just used with token store bean example: new JwtTokenStore(tokenEnhancer());
public JwtAccessTokenConverter tokenEnhancer() {
    /**
    * CustomTokenConverter is a class extends JwtAccessTokenConverter
    * which override "enhance" to add extra information to OAuth2AccessToken after
    * authenticate the user and get it by loadUserByUsername implementation
    * like profileId in your case
    **/
    JwtAccessTokenConverter converter = new CustomTokenConverter();

    DefaultAccessTokenConverter datc = new DefaultAccessTokenConverter();
    datc.setUserTokenConverter(userAuthenticationConverter());
    converter.setAccessTokenConverter(datc);

    //Other method code implementation....
}

@Autowired
private UserDetailsService userDetailsService;

@Bean
public UserAuthenticationConverter userAuthenticationConverter() {
    DefaultUserAuthenticationConverter duac = new DefaultUserAuthenticationConverter();
    duac.setUserDetailsService(userDetailsService);
    return duac;
 }

Note: this first way will hit database in every request so it load user by username and get UserDetails object so it assign it to principal object inside authentication.

2-
If for any reason you see it's better to not hit database in each request and no problem about executing data needed like profileId from token passed in request.
Assuming you know that old authorities assigned to user when generating oauth2 token will always be in token till it goes invalid even after you change it in database for user who passes the token in request so user could call a method not allowed to him/her anymore after extracting token and it was allowed before extracting the token.
So this means if user authorities changed after generating the token, new authorities will not be checked by @PreAuthorize as it's not removed or added to token and you have to wait till old token goes invalid or expired so user forced to execute the service again to get new oauth token.
Anyway, in this second option you only need to override extractAuthentication method inside CustomTokenConverter class extends JwtAccessTokenConverter and forget about setting access token converter converter.setAccessTokenConverter from tokenEnhancer() method in first option, and here are the whole CustomTokenConverter you can use it for reading data from token and return principal object not just string username:
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;

import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;

public class CustomTokenConverter extends JwtAccessTokenConverter {

    // This is the method you need to override to read data direct from token passed in request
    @Override
    public OAuth2Authentication extractAuthentication(Map<String, ?> map) {
        OAuth2Authentication authentication = super.extractAuthentication(map);

        Object userIdObj = map.get(AuthenticationUtils.USER_ID);
        UUID userId = userIdObj != null ? UUID.fromString(userIdObj.toString()) : null;
        Object profileIdObj = map.get(AuthenticationUtils.PROFILE_ID);
        UUID profileId = profileIdObj != null ? UUID.fromString(profileIdObj.toString()) : null;
        Object firstNameObj = map.get(AuthenticationUtils.FIRST_NAME);
        String firstName = firstNameObj != null ? String.valueOf(firstNameObj) : null;
        Object lastNameObj = map.get(AuthenticationUtils.LAST_NAME);
        String lastName = lastNameObj != null ? String.valueOf(lastNameObj) : null;

        JwtUser principal = new JwtUser(userId, profileId, authentication.getUserAuthentication().getName(), "N/A", authentication.getUserAuthentication().getAuthorities(), firstName, lastName);

        authentication = new OAuth2Authentication(authentication.getOAuth2Request(),
                new UsernamePasswordAuthenticationToken(principal, "N/A", authentication.getUserAuthentication().getAuthorities()));
        return authentication;
    }

    @Override
    public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) {
        JwtUser user = (JwtUser) authentication.getPrincipal();
        Map<String, Object> info = new LinkedHashMap<>(accessToken.getAdditionalInformation());
        if (user.getId() != null)
            info.put(AuthenticationUtils.USER_ID, user.getId());
        if (user.getProfileId() != null)
            info.put(AuthenticationUtils.PROFILE_ID, user.getProfileId());
        if (isNotNullNotEmpty(user.getFirstName()))
            info.put(AuthenticationUtils.FIRST_NAME, user.getFirstName());
        if (isNotNullNotEmpty(user.getLastName()))
            info.put(AuthenticationUtils.LAST_NAME, user.getLastName());

        DefaultOAuth2AccessToken customAccessToken = new DefaultOAuth2AccessToken(accessToken);
        customAccessToken.setAdditionalInformation(info);
        return super.enhance(customAccessToken, authentication);
    }

    private boolean isNotNullNotEmpty(String str) {
        return Optional.ofNullable(str).map(String::trim).map(string -> !str.isEmpty()).orElse(false);
    }

}

Finally: Guess how i know you are asking about JWT used with OAuth2?
Because i am a part of your company :P and you know that :P


text:
Q: excel- date bigger than today how can I make that in column i can only write date more or equal today,
not day in past.
Do i need to use macro... or...??
Any idea?

A: If you are using SQL Sever than you can add below check CONSTRAINT.
ALTER TABLE TableName
ADD CONSTRAINT ColumnName CHECK (ColumnName >= GetDate() );

A: As You have mentioned "Excel" in title of the question.
Select cells/column where you want this restriction.
Go to Data > Data Validation > Select the following criteria,

*

*Allow: Date

*Data: greater than or equal to

*Start Date: =today()

Done!
PS: You can customise the error message from Error alert tab on the Data validation window.

A: try this for PostgreSQL:
ALTER TABLE your_table ADD CHECK (your_date_column >= now());

try this for Oracle:
ALTER TABLE your_table ADD CHECK (your_date_column >= CURRENT_TIMESTAMP);


text:
Q: Program not reading from Binary file I'm trying to create a test program for a project that I'm doing in school.
One important aspect of my project is to have a login system.
In int main() I have a menu which calls login(); or createAccount(); based on the users choice. login(); further calls loginToken(); to generate int authToken with value 0 or 1. It calls loginAuth() which in turn checks the value of authToken and authenticates the login.
In int main(); when I call createAccount() it writes the the vales or newUsername and newPassword into a binary file accounts.bin. However, when I call login() the if condition I made to check whether loginEntry is open says that it is closed, even though I just opened it the line before.
I'd appreciate some help because this has been bothering me for days.
#include<iostream>
#include<string.h>
#include<fstream>
#include <limits>

using namespace std;

class Account{
  private:

    char enteredUsername[20];
    char enteredPassword[20];
    int authToken;
    char newUsername[20];
    char newPassword[20];
    ofstream loginDetails;
    ifstream loginEntry;

  public:
    void login(){ // to enter username or password
        cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');  //to clear cin buffer

        loginEntry.open("account.bin", ios::in|ios::binary); // to read newUsername and newPassword
            if (!loginDetails.is_open()) {  //to check whether file is open or not
            cout<<"File not open";
            }
            else {
                loginEntry.read(newUsername,sizeof(newUsername));
                loginEntry.read(newPassword,sizeof(newPassword));
            }
          loginEntry.close();

        cout<<"\nEnter Username: ";
        cin.getline(enteredUsername, sizeof(enteredUsername));
        cout<<"\nEnter Password: ";
        cin.getline(enteredPassword, sizeof(enteredPassword));
        loginToken();
    }
    void loginToken(){ // to generate login token if enteredUsername and enteredPassword match newUsername and newPassword in account.bin

        if(strcmp(enteredUsername,"user")==0 && strcmp(enteredPassword,"admin")==0)
            authToken=1;

        else
            authToken=0;

        loginAuth(); // to check value of login token and allow or deny access
    }
    void loginAuth(){
        if(authToken==1)
            cout<<"Login succesfull!!";
        else
            cout<<"Login Failed. Returning to Menu";

        getchar();
    }
    void createAccount(){  // to create newUsername and newPassword which are saved in account.bin
        cin.ignore(numeric_limits<streamsize>::max(), '\n');    //to clear cin buffer

        cout<<"\nEnter new Username: ";
        cin.getline(newUsername,sizeof(newUsername));
        cout<<"\nEnter new Password: ";
        cin.getline(newPassword,sizeof(newPassword));

        loginDetails.open("account.bin", ios::out|ios::binary); //writing in account.bin

            loginDetails.write(newUsername, sizeof(enteredUsername));
            loginDetails.write(newPassword, sizeof(enteredPassword));

        loginDetails.close();
        cout<<"\nYour account has been created. Returning to Menu";
        getchar();
    }
};

int main(){
Account test;
int userChoice;

do{
    system("cls");
    cout<<"Welcome to xyz.com";
    cout<<"\n*Press 1 to Login\n*Not a memeber? Press 2 to create an account and be awesome!!\n*If you're tired, press 3 to leave "<<endl;
    cin>>userChoice;

    switch(userChoice){
        case 1:{
            test.login();
            break;
        }
        case 2:{
            test.createAccount();
            break;
        }
    }
}while(userChoice!=3);

cout<<"GoodBye!! :)";
return 0;
}

A: In login() you have:
loginEntry.open("account.bin", ios::in|ios::binary);

And then you have
if (!loginDetails.is_open()) {

You have opened "entry", not "details", but you are checking "details", which is why it says the error.
EDIT
There are 2 new potential problems I can see.
In createAccount(), the second parameter sizeof() is returning a size of 0 because enteredUsername and enteredPassword hasn't been used in your method, writing nothing to the file. You probably meant to use newUsername and newPassword instead.
loginDetails.write(newUsername, sizeof(enteredUsername));
loginDetails.write(newPassword, sizeof(enteredPassword));

In loginToken() you use constants like 'user', instead of the variables you just created in login() called newUsername. Furthermore,
loginEntry.read(newUsername,sizeof(newUsername)); //unused
loginEntry.read(newPassword,sizeof(newPassword)); //unused
if(strcmp(enteredUsername,"user")==0 && strcmp(enteredPassword,"admin")==0)

Finally, you are using getLine in your code, which means you might be reading the \n character at the end of input.
cin.getline(enteredUsername, sizeof(enteredUsername));


text:
Q: Legend in ggplot2 I am trying to understand how to change the title and labels in the legend when using ggplot2 in R. I have searched online trying to find the answer, and it seems like I need to use the scale_xxx_yyy command in some way, but I can't seem to get it right. A simple example:
x <- rnorm(100)

dens1 <- density(x, 0.1, kernel = "rectangular")
dens2 <- density(x, 0.1, kernel = "gaussian")

df <- data.frame(x = dens1$x, y1 = dens1$y, y2 = dens2$y)

pl <- ggplot(df, aes(x)) + geom_line(aes(y=y1, colour = "y1")) + geom_line(aes(y=y2, colour = "y2"))
pl + scale_fill_discrete(name="Kernels", breaks=c("y1", "y2"), labels=c("Rectangular", "Gaussian"))

I want the legend to have title "Kernels" and labels "Rectangular" and "Gaussian", but nothing happens. I have also tried scale_linetype_discrete(name = "Kernels") and labs(linetype="Kernels") as suggested elsewhere, buit still nothing.
What am I doing wrong?

A: Try this. As @Pascal said, scale_color_discrete is the one for you. I guess the more you us ggplot2, the more you get used to the scale_xxx_yyy business. The cookbook suggested by @A.Val is a great book. Here is the link for you
library(dplyr)
library(tidyr)
library(ggplot2)

df <- data.frame(x = dens1$x, y1 = dens1$y, y2 = dens2$y) %>%
      gather(variable, value, - x)

ggplot(df, aes(x = x, y = value, color = variable)) +
geom_line() +
scale_color_discrete(name = "Kernels", breaks=c("y1", "y2"), labels =c("Rectangular", "Gaussian"))


text:
Q: $\chi(M)=\#(M_{\triangle}, M_{\triangle})$ , and orientations of tubular neighborhood I would like to show that $\chi(M)=\#(M_{\triangle}, M_{\triangle})$ when $M$ is a compact oriented manifold, where $M_{\triangle}$ is the diagonal submanifold of $M\times M$. My definition of $\chi(M):=\#(M,Z(M),TM)$, where $Z(M)$ is the zero section of $TM$.
I belive the idea is to consider a tubular neighborhood $W$ of $M_{\triangle}$ and we have a canonical  isomorphism between the normal bundle of $M_{\triangle}$ in $M$ and $TM$. So that we get an embedding $\phi :TM\rightarrow W$ such that $\phi|M=id$.  Now take a section $f:M\rightarrow TM$ that is transverse to the zero section, and if we consider $\phi\circ f\circ i $, where $i: M_{\triangle}\rightarrow M$, we get that the map $\phi\circ f\circ i : M_{\triangle}\rightarrow M\times M$ is transverse to $M_{\triangle}$ and homotopic to the identity and so we can use it to compute the intersection number. Now it's clear that the set of points that intersect $M_{\triangle}$ are the points where $f$ vanishes but the part is troubling me is what does $\phi $ do to the orientation ? That is generally speaking if I have a tubular neighborhood and the normal bundle of the submanifold is orientable and so is the manifold of which we are making the tubular neighborhood will the tubular neighborhood map be orientation-preserving ? I know that to define this map we start by considering $x+y$ and of course this will be orientation-preserving but then we take on extensions and such and I don't know if this will ruin the orientability.
If it does happen to be that $\phi$ preserves the orientation then we have that $\chi(M)=\#(M_{\triangle},M_{\triangle})$, if it could reverse the orientation then I am out of ideas on how to prove this fact.
Any enlightment is appreciated. Thanks in advance.


text:
Q: Need to update records between tables with matching values I need to update a column table from another table where there are maching value between corresponding records. I have the following statement but I need help with the syntax.
 UPDATE table_a
    SET field_1 = table_b.field_1
    WHERE table_a.field_2=table_b.field_2
      AND table_a.field_3=table_b.field_3
      AND table_a.field_4=table_b.field_4
      AND table_a.field_5=table_b.field_5


text:
Q: If MVC controller can also return JSON result, why use ASP.NET Web API for the same purpose? Why would one use ASP.NET Web API Controller when we can return JSON using MVC controller?

A: Data formats, content negotiation, self-hosting(avoiding IIS) and importance of method signature are the key reasons to use web api. Please have a look at the following links and it will help you in understanding the difference between the both:-
http://www.binaryintellect.net/articles/7bfdd512-91e3-49a4-865d-6dd03ace73fb.aspx
Using WebAPI or MVC to return JSON in ASP.NET


text:
Q: Oracle AQ - how to determine if a listener is listening to the queue If I have an AQ set up, but my listener (Mule JMS endpoint) is not receiving any messages. Is there a view that I can query to determine what listeners Oracle thinks are connected to the queue?).

A: From http://wedostreams.blogspot.ca/2009/01/oracle-aq-buffered-queues-101.html:

You can check queue subscribers by querying the AQ$MYQUEUE_TABLE_S view (or AQ$_MYQUEUE_TABLE_S table) like below:

col name    format a12
col address format a40

select name, address
from aq$myqueue_table_s
where queue='MYQUEUE';

NAME      ADDRESS
------------ -------------------------
SUBSCRIBER1
SUBSCRIBER2