text:
// Copyright 2021 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package executor_test

import (
	"fmt"
	"strings"
	"testing"

	"github.com/pingcap/tidb/errno"
	"github.com/pingcap/tidb/infoschema"
	"github.com/pingcap/tidb/parser/auth"
	"github.com/pingcap/tidb/parser/mysql"
	"github.com/pingcap/tidb/parser/terror"
	"github.com/pingcap/tidb/testkit"
	"github.com/pingcap/tidb/util/dbterror/exeerrors"
	"github.com/stretchr/testify/require"
)

func TestGrantGlobal(t *testing.T) {
	store := testkit.CreateMockStore(t)

	tk := testkit.NewTestKit(t, store)
	// Create a new user.
	createUserSQL := `CREATE USER 'testGlobal'@'localhost' IDENTIFIED BY '123';`
	tk.MustExec(createUserSQL)
	// Make sure all the global privs for new user is "N".
	for _, v := range mysql.AllDBPrivs {
		sql := fmt.Sprintf("SELECT %s FROM mysql.User WHERE User=\"testGlobal\" and host=\"localhost\";", mysql.Priv2UserCol[v])
		r := tk.MustQuery(sql)
		r.Check(testkit.Rows("N"))
	}

	// Grant each priv to the user.
	for _, v := range mysql.AllGlobalPrivs {
		sql := fmt.Sprintf("GRANT %s ON *.* TO 'testGlobal'@'localhost';", mysql.Priv2Str[v])
		tk.MustExec(sql)
		sql = fmt.Sprintf("SELECT %s FROM mysql.User WHERE User=\"testGlobal\" and host=\"localhost\"", mysql.Priv2UserCol[v])
		tk.MustQuery(sql).Check(testkit.Rows("Y"))
	}

	// Create a new user.
	createUserSQL = `CREATE USER 'testGlobal1'@'localhost' IDENTIFIED BY '123';`
	tk.MustExec(createUserSQL)
	tk.MustExec("GRANT ALL ON *.* TO 'testGlobal1'@'localhost';")
	// Make sure all the global privs for granted user is "Y".
	for _, v := range mysql.AllGlobalPrivs {
		sql := fmt.Sprintf("SELECT %s FROM mysql.User WHERE User=\"testGlobal1\" and host=\"localhost\"", mysql.Priv2UserCol[v])
		tk.MustQuery(sql).Check(testkit.Rows("Y"))
	}
	// with grant option
	tk.MustExec("GRANT ALL ON *.* TO 'testGlobal1'@'localhost' WITH GRANT OPTION;")
	for _, v := range mysql.AllGlobalPrivs {
		sql := fmt.Sprintf("SELECT %s FROM mysql.User WHERE User=\"testGlobal1\" and host=\"localhost\"", mysql.Priv2UserCol[v])
		tk.MustQuery(sql).Check(testkit.Rows("Y"))
	}
}

func TestGrantDBScope(t *testing.T) {
	store := testkit.CreateMockStore(t)

	tk := testkit.NewTestKit(t, store)
	// Create a new user.
	createUserSQL := `CREATE USER 'testDB'@'localhost' IDENTIFIED BY '123';`
	tk.MustExec(createUserSQL)
	// Make sure all the db privs for new user is empty.
	sql := `SELECT * FROM mysql.db WHERE User="testDB" and host="localhost"`
	tk.MustQuery(sql).Check(testkit.Rows())

	// Grant each priv to the user.
	for _, v := range mysql.AllDBPrivs {
		sql := fmt.Sprintf("GRANT %s ON test.* TO 'testDB'@'localhost';", mysql.Priv2Str[v])
		tk.MustExec(sql)
		sql = fmt.Sprintf("SELECT %s FROM mysql.DB WHERE User=\"testDB\" and host=\"localhost\" and db=\"test\"", mysql.Priv2UserCol[v])
		tk.MustQuery(sql).Check(testkit.Rows("Y"))
	}

	// Create a new user.
	createUserSQL = `CREATE USER 'testDB1'@'localhost' IDENTIFIED BY '123';`
	tk.MustExec(createUserSQL)
	tk.MustExec("USE test;")
	tk.MustExec("GRANT ALL ON * TO 'testDB1'@'localhost';")
	// Make sure all the db privs for granted user is "Y".
	for _, v := range mysql.AllDBPrivs {
		sql := fmt.Sprintf("SELECT %s FROM mysql.DB WHERE User=\"testDB1\" and host=\"localhost\" and db=\"test\";", mysql.Priv2UserCol[v])
		tk.MustQuery(sql).Check(testkit.Rows("Y"))
	}

	// Grant in wrong scope.
	err := tk.ExecToErr(` grant create user on test.* to 'testDB1'@'localhost';`)
	require.True(t, terror.ErrorEqual(err, exeerrors.ErrWrongUsage.GenWithStackByArgs("DB GRANT", "GLOBAL PRIVILEGES")))

	err = tk.ExecToErr("GRANT SUPER ON test.* TO 'testDB1'@'localhost';")
	require.True(t, terror.ErrorEqual(err, exeerrors.ErrWrongUsage.GenWithStackByArgs("DB GRANT", "NON-DB PRIVILEGES")))
}

func TestWithGrantOption(t *testing.T) {
	store := testkit.CreateMockStore(t)

	tk := testkit.NewTestKit(t, store)
	// Create a new user.
	createUserSQL := `CREATE USER 'testWithGrant'@'localhost' IDENTIFIED BY '123';`
	tk.MustExec(createUserSQL)
	// Make sure all the db privs for new user is empty.
	sql := `SELECT * FROM mysql.db WHERE User="testWithGrant" and host="localhost"`
	tk.MustQuery(sql).Check(testkit.Rows())

	// Grant select priv to the user, with grant option.
	tk.MustExec("GRANT select ON test.* TO 'testWithGrant'@'localhost' WITH GRANT OPTION;")
	tk.MustQuery("SELECT grant_priv FROM mysql.DB WHERE User=\"testWithGrant\" and host=\"localhost\" and db=\"test\"").Check(testkit.Rows("Y"))

	tk.MustExec("CREATE USER 'testWithGrant1'")
	tk.MustQuery("SELECT grant_priv FROM mysql.user WHERE User=\"testWithGrant1\"").Check(testkit.Rows("N"))
	tk.MustExec("GRANT ALL ON *.* TO 'testWithGrant1'")
	tk.MustQuery("SELECT grant_priv FROM mysql.user WHERE User=\"testWithGrant1\"").Check(testkit.Rows("N"))
	tk.MustExec("GRANT ALL ON *.* TO 'testWithGrant1' WITH GRANT OPTION")
	tk.MustQuery("SELECT grant_priv FROM mysql.user WHERE User=\"testWithGrant1\"").Check(testkit.Rows("Y"))
}

func TestGrantTableScope(t *testing.T) {
	store := testkit.CreateMockStore(t)

	tk := testkit.NewTestKit(t, store)
	// Create a new user.
	createUserSQL := `CREATE USER 'testTbl'@'localhost' IDENTIFIED BY '123';`
	tk.MustExec(createUserSQL)
	tk.MustExec(`CREATE TABLE test.test1(c1 int);`)
	// Make sure all the table privs for new user is empty.
	tk.MustQuery(`SELECT * FROM mysql.Tables_priv WHERE User="testTbl" and host="localhost" and db="test" and Table_name="test1"`).Check(testkit.Rows())

	// Grant each priv to the user.
	for _, v := range mysql.AllTablePrivs {
		sql := fmt.Sprintf("GRANT %s ON test.test1 TO 'testTbl'@'localhost';", mysql.Priv2Str[v])
		tk.MustExec(sql)
		rows := tk.MustQuery(`SELECT Table_priv FROM mysql.Tables_priv WHERE User="testTbl" and host="localhost" and db="test" and Table_name="test1";`).Rows()
		require.Len(t, rows, 1)
		row := rows[0]
		require.Len(t, rows, 1)
		p := fmt.Sprintf("%v", row[0])
		require.Greater(t, strings.Index(p, mysql.Priv2SetStr[v]), -1)
	}
	// Create a new user.
	createUserSQL = `CREATE USER 'testTbl1'@'localhost' IDENTIFIED BY '123';`
	tk.MustExec(createUserSQL)
	tk.MustExec("USE test;")
	tk.MustExec(`CREATE TABLE test2(c1 int);`)
	// Grant all table scope privs.
	tk.MustExec("GRANT ALL ON test2 TO 'testTbl1'@'localhost' WITH GRANT OPTION;")
	// Make sure all the table privs for granted user are in the Table_priv set.
	for _, v := range mysql.AllTablePrivs {
		rows := tk.MustQuery(`SELECT Table_priv FROM mysql.Tables_priv WHERE User="testTbl1" and host="localhost" and db="test" and Table_name="test2";`).Rows()
		require.Len(t, rows, 1)
		row := rows[0]
		require.Len(t, rows, 1)
		p := fmt.Sprintf("%v", row[0])
		require.Greater(t, strings.Index(p, mysql.Priv2SetStr[v]), -1)
	}

	tk.MustGetErrMsg("GRANT SUPER ON test2 TO 'testTbl1'@'localhost';",
		"[executor:1144]Illegal GRANT/REVOKE command; please consult the manual to see which privileges can be used")
}

func TestGrantColumnScope(t *testing.T) {
	store := testkit.CreateMockStore(t)

	tk := testkit.NewTestKit(t, store)
	// Create a new user.
	createUserSQL := `CREATE USER 'testCol'@'localhost' IDENTIFIED BY '123';`
	tk.MustExec(createUserSQL)
	tk.MustExec(`CREATE TABLE test.test3(c1 int, c2 int);`)

	// Make sure all the column privs for new user is empty.
	tk.MustQuery(`SELECT * FROM mysql.Columns_priv WHERE User="testCol" and host="localhost" and db="test" and Table_name="test3" and Column_name="c1"`).Check(testkit.Rows())
	tk.MustQuery(`SELECT * FROM mysql.Columns_priv WHERE User="testCol" and host="localhost" and db="test" and Table_name="test3" and Column_name="c2"`).Check(testkit.Rows())

	// Grant each priv to the user.
	for _, v := range mysql.AllColumnPrivs {
		sql := fmt.Sprintf("GRANT %s(c1) ON test.test3 TO 'testCol'@'localhost';", mysql.Priv2Str[v])
		tk.MustExec(sql)
		rows := tk.MustQuery(`SELECT Column_priv FROM mysql.Columns_priv WHERE User="testCol" and host="localhost" and db="test" and Table_name="test3" and Column_name="c1";`).Rows()
		require.Len(t, rows, 1)
		row := rows[0]
		require.Len(t, rows, 1)
		p := fmt.Sprintf("%v", row[0])
		require.Greater(t, strings.Index(p, mysql.Priv2SetStr[v]), -1)
	}

	// Create a new user.
	createUserSQL = `CREATE USER 'testCol1'@'localhost' IDENTIFIED BY '123';`
	tk.MustExec(createUserSQL)
	tk.MustExec("USE test;")
	// Grant all column scope privs.
	tk.MustExec("GRANT ALL(c2) ON test3 TO 'testCol1'@'localhost';")
	// Make sure all the column privs for granted user are in the Column_priv set.
	for _, v := range mysql.AllColumnPrivs {
		rows := tk.MustQuery(`SELECT Column_priv FROM mysql.Columns_priv WHERE User="testCol1" and host="localhost" and db="test" and Table_name="test3" and Column_name="c2";`).Rows()
		require.Len(t, rows, 1)
		row := rows[0]
		require.Len(t, rows, 1)
		p := fmt.Sprintf("%v", row[0])
		require.Greater(t, strings.Index(p, mysql.Priv2SetStr[v]), -1)
	}

	tk.MustGetErrMsg("GRANT SUPER(c2) ON test3 TO 'testCol1'@'localhost';",
		"[executor:1221]Incorrect usage of COLUMN GRANT and NON-COLUMN PRIVILEGES")
}

func TestIssue2456(t *testing.T) {
	store := testkit.CreateMockStore(t)

	tk := testkit.NewTestKit(t, store)
	tk.MustExec("CREATE USER 'dduser'@'%' IDENTIFIED by '123456';")
	tk.MustExec("CREATE DATABASE `dddb_%`;")
	tk.MustExec("CREATE table `dddb_%`.`te%` (id int);")
	tk.MustExec("GRANT ALL PRIVILEGES ON `dddb_%`.* TO 'dduser'@'%';")
	tk.MustExec("GRANT ALL PRIVILEGES ON `dddb_%`.`te%` to 'dduser'@'%';")
}

func TestNoAutoCreateUser(t *testing.T) {
	store := testkit.CreateMockStore(t)

	tk := testkit.NewTestKit(t, store)
	tk.MustExec(`DROP USER IF EXISTS 'test'@'%'`)
	tk.MustExec(`SET sql_mode='NO_AUTO_CREATE_USER'`)
	_, err := tk.Exec(`GRANT ALL PRIVILEGES ON *.* to 'test'@'%' IDENTIFIED BY 'xxx'`)
	require.Error(t, err)
	require.True(t, terror.ErrorEqual(err, exeerrors.ErrCantCreateUserWithGrant))
}

func TestCreateUserWhenGrant(t *testing.T) {
	store := testkit.CreateMockStore(t)

	tk := testkit.NewTestKit(t, store)
	tk.MustExec(`DROP USER IF EXISTS 'test'@'%'`)
	// This only applies to sql_mode:NO_AUTO_CREATE_USER off
	tk.MustExec(`SET SQL_MODE=''`)
	tk.MustExec(`GRANT ALL PRIVILEGES ON *.* to 'test'@'%' IDENTIFIED BY 'xxx'`)
	// Make sure user is created automatically when grant to a non-exists one.
	tk.MustQuery(`SELECT user FROM mysql.user WHERE user='test' and host='%'`).Check(
		testkit.Rows("test"),
	)
	tk.MustExec(`DROP USER IF EXISTS 'test'@'%'`)
	// Grant without a password.
	tk.MustExec(`GRANT ALL PRIVILEGES ON *.* to 'test'@'%'`)
	// Make sure user is created automatically when grant to a non-exists one.
	tk.MustQuery(`SELECT user, plugin FROM mysql.user WHERE user='test' and host='%'`).Check(
		testkit.Rows("test mysql_native_password"),
	)
	tk.MustExec(`DROP USER IF EXISTS 'test'@'%'`)
}

func TestCreateUserWithTooLongName(t *testing.T) {
	store := testkit.CreateMockStore(t)

	tk := testkit.NewTestKit(t, store)
	err := tk.ExecToErr("CREATE USER '1234567890abcdefGHIKL1234567890abcdefGHIKL@localhost'")
	require.Truef(t, terror.ErrorEqual(err, exeerrors.ErrWrongStringLength), "ERROR 1470 (HY000): String '1234567890abcdefGHIKL1234567890abcdefGHIKL' is too long for user name (should be no longer than 32)")
	err = tk.ExecToErr("CREATE USER 'some_user_name@host_1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890X'")
	require.Truef(t, terror.ErrorEqual(err, exeerrors.ErrWrongStringLength), "ERROR 1470 (HY000): String 'host_1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij12345' is too long for host name (should be no longer than 255)")
}

func TestGrantPrivilegeAtomic(t *testing.T) {
	store := testkit.CreateMockStore(t)

	tk := testkit.NewTestKit(t, store)
	tk.MustExec(`drop role if exists r1, r2, r3, r4;`)
	tk.MustExec(`create role r1, r2, r3;`)
	tk.MustExec(`create table test.testatomic(x int);`)

	_, err := tk.Exec(`grant update, select, insert, delete on *.* to r1, r2, r4;`)
	require.True(t, terror.ErrorEqual(err, exeerrors.ErrCantCreateUserWithGrant))
	tk.MustQuery(`select Update_priv, Select_priv, Insert_priv, Delete_priv from mysql.user where user in ('r1', 'r2', 'r3', 'r4') and host = "%";`).Check(testkit.Rows(
		"N N N N",
		"N N N N",
		"N N N N",
	))
	tk.MustExec(`grant update, select, insert, delete on *.* to r1, r2, r3;`)
	_, err = tk.Exec(`revoke all on *.* from r1, r2, r4, r3;`)
	require.Error(t, err)
	tk.MustQuery(`select Update_priv, Select_priv, Insert_priv, Delete_priv from mysql.user where user in ('r1', 'r2', 'r3', 'r4') and host = "%";`).Check(testkit.Rows(
		"Y Y Y Y",
		"Y Y Y Y",
		"Y Y Y Y",
	))

	err = tk.ExecToErr(`grant update, select, insert, delete on test.* to r1, r2, r4;`)
	require.True(t, terror.ErrorEqual(err, exeerrors.ErrCantCreateUserWithGrant))
	tk.MustQuery(`select Update_priv, Select_priv, Insert_priv, Delete_priv from mysql.db where user in ('r1', 'r2', 'r3', 'r4') and host = "%";`).Check(testkit.Rows())
	tk.MustExec(`grant update, select, insert, delete on test.* to r1, r2, r3;`)
	err = tk.ExecToErr(`revoke all on *.* from r1, r2, r4, r3;`)
	require.Error(t, err)
	tk.MustQuery(`select Update_priv, Select_priv, Insert_priv, Delete_priv from mysql.db where user in ('r1', 'r2', 'r3', 'r4') and host = "%";`).Check(testkit.Rows(
		"Y Y Y Y",
		"Y Y Y Y",
		"Y Y Y Y",
	))

	err = tk.ExecToErr(`grant update, select, insert, delete on test.testatomic to r1, r2, r4;`)
	require.True(t, terror.ErrorEqual(err, exeerrors.ErrCantCreateUserWithGrant))
	tk.MustQuery(`select Table_priv from mysql.tables_priv where user in ('r1', 'r2', 'r3', 'r4') and host = "%";`).Check(testkit.Rows())
	tk.MustExec(`grant update, select, insert, delete on test.testatomic to r1, r2, r3;`)
	err = tk.ExecToErr(`revoke all on *.* from r1, r2, r4, r3;`)
	require.Error(t, err)
	tk.MustQuery(`select Table_priv from mysql.tables_priv where user in ('r1', 'r2', 'r3', 'r4') and host = "%";`).Check(testkit.Rows(
		"Select,Insert,Update,Delete",
		"Select,Insert,Update,Delete",
		"Select,Insert,Update,Delete",
	))

	tk.MustExec(`drop role if exists r1, r2, r3, r4;`)
	tk.MustExec(`drop table test.testatomic;`)
}

func TestIssue2654(t *testing.T) {
	store := testkit.CreateMockStore(t)

	tk := testkit.NewTestKit(t, store)
	tk.MustExec(`DROP USER IF EXISTS 'test'@'%'`)
	tk.MustExec(`CREATE USER 'test'@'%' IDENTIFIED BY 'test'`)
	tk.MustExec("GRANT SELECT ON test.* to 'test'")
	rows := tk.MustQuery(`SELECT user,host FROM mysql.user WHERE user='test' and host='%'`)
	rows.Check(testkit.Rows(`test %`))
}

func TestGrantUnderANSIQuotes(t *testing.T) {
	store := testkit.CreateMockStore(t)

	tk := testkit.NewTestKit(t, store)
	// Fix a bug that the GrantExec fails in ANSI_QUOTES sql mode
	// The bug is caused by the improper usage of double quotes like:
	// INSERT INTO mysql.user ... VALUES ("..", "..", "..")
	tk.MustExec(`SET SQL_MODE='ANSI_QUOTES'`)
	tk.MustExec(`GRANT ALL PRIVILEGES ON video_ulimit.* TO web@'%' IDENTIFIED BY 'eDrkrhZ>l2sV'`)
	tk.MustExec(`REVOKE ALL PRIVILEGES ON video_ulimit.* FROM web@'%';`)
	tk.MustExec(`DROP USER IF EXISTS 'web'@'%'`)
}

func TestMaintainRequire(t *testing.T) {
	store := testkit.CreateMockStore(t)

	tk := testkit.NewTestKit(t, store)

	// test create with require
	tk.MustExec(`CREATE USER 'ssl_auser'@'%' require issuer '/CN=TiDB admin/OU=TiDB/O=PingCAP/L=San Francisco/ST=California/C=US' subject '/CN=tester1/OU=TiDB/O=PingCAP.Inc/L=Haidian/ST=Beijing/C=ZH' cipher 'AES128-GCM-SHA256'`)
	tk.MustExec(`CREATE USER 'ssl_buser'@'%' require subject '/CN=tester1/OU=TiDB/O=PingCAP.Inc/L=Haidian/ST=Beijing/C=ZH' cipher 'AES128-GCM-SHA256'`)
	tk.MustExec(`CREATE USER 'ssl_cuser'@'%' require cipher 'AES128-GCM-SHA256'`)
	tk.MustExec(`CREATE USER 'ssl_duser'@'%'`)
	tk.MustExec(`CREATE USER 'ssl_euser'@'%' require none`)
	tk.MustExec(`CREATE USER 'ssl_fuser'@'%' require ssl`)
	tk.MustExec(`CREATE USER 'ssl_guser'@'%' require x509`)
	tk.MustQuery("select * from mysql.global_priv where `user` like 'ssl_%'").Check(testkit.Rows(
		"% ssl_auser {\"ssl_type\":3,\"ssl_cipher\":\"AES128-GCM-SHA256\",\"x509_issuer\":\"/CN=TiDB admin/OU=TiDB/O=PingCAP/L=San Francisco/ST=California/C=US\",\"x509_subject\":\"/CN=tester1/OU=TiDB/O=PingCAP.Inc/L=Haidian/ST=Beijing/C=ZH\"}",
		"% ssl_buser {\"ssl_type\":3,\"ssl_cipher\":\"AES128-GCM-SHA256\",\"x509_subject\":\"/CN=tester1/OU=TiDB/O=PingCAP.Inc/L=Haidian/ST=Beijing/C=ZH\"}",
		"% ssl_cuser {\"ssl_type\":3,\"ssl_cipher\":\"AES128-GCM-SHA256\"}",
		"% ssl_duser {}",
		"% ssl_euser {}",
		"% ssl_fuser {\"ssl_type\":1}",
		"% ssl_guser {\"ssl_type\":2}",
	))

	// test grant with require
	tk.MustExec("CREATE USER 'u1'@'%'")
	tk.MustExec("GRANT ALL ON *.* TO 'u1'@'%' require issuer '/CN=TiDB admin/OU=TiDB/O=PingCAP/L=San Francisco/ST=California/C=US' and subject '/CN=tester1/OU=TiDB/O=PingCAP.Inc/L=Haidian/ST=Beijing/C=ZH'") // add new require.
	tk.MustQuery("select priv from mysql.global_priv where `Host` = '%' and `User` = 'u1'").Check(testkit.Rows("{\"ssl_type\":3,\"x509_issuer\":\"/CN=TiDB admin/OU=TiDB/O=PingCAP/L=San Francisco/ST=California/C=US\",\"x509_subject\":\"/CN=tester1/OU=TiDB/O=PingCAP.Inc/L=Haidian/ST=Beijing/C=ZH\"}"))
	tk.MustExec("GRANT ALL ON *.* TO 'u1'@'%' require cipher 'AES128-GCM-SHA256'") // modify always overwrite.
	tk.MustQuery("select priv from mysql.global_priv where `Host` = '%' and `User` = 'u1'").Check(testkit.Rows("{\"ssl_type\":3,\"ssl_cipher\":\"AES128-GCM-SHA256\"}"))
	tk.MustExec("GRANT select ON *.* TO 'u1'@'%'") // modify without require should not modify old require.
	tk.MustQuery("select priv from mysql.global_priv where `Host` = '%' and `User` = 'u1'").Check(testkit.Rows("{\"ssl_type\":3,\"ssl_cipher\":\"AES128-GCM-SHA256\"}"))
	tk.MustExec("GRANT ALL ON *.* TO 'u1'@'%' require none") // use require none to clean up require.
	tk.MustQuery("select priv from mysql.global_priv where `Host` = '%' and `User` = 'u1'").Check(testkit.Rows("{}"))

	// test alter with require
	tk.MustExec("CREATE USER 'u2'@'%'")
	tk.MustExec("alter user 'u2'@'%' require ssl")
	tk.MustQuery("select priv from mysql.global_priv where `Host` = '%' and `User` = 'u2'").Check(testkit.Rows("{\"ssl_type\":1}"))
	tk.MustExec("alter user 'u2'@'%' require x509")
	tk.MustQuery("select priv from mysql.global_priv where `Host` = '%' and `User` = 'u2'").Check(testkit.Rows("{\"ssl_type\":2}"))
	tk.MustExec("alter user 'u2'@'%' require issuer '/CN=TiDB admin/OU=TiDB/O=PingCAP/L=San Francisco/ST=California/C=US' subject '/CN=tester1/OU=TiDB/O=PingCAP.Inc/L=Haidian/ST=Beijing/C=ZH' cipher 'AES128-GCM-SHA256'")
	tk.MustQuery("select priv from mysql.global_priv where `Host` = '%' and `User` = 'u2'").Check(testkit.Rows("{\"ssl_type\":3,\"ssl_cipher\":\"AES128-GCM-SHA256\",\"x509_issuer\":\"/CN=TiDB admin/OU=TiDB/O=PingCAP/L=San Francisco/ST=California/C=US\",\"x509_subject\":\"/CN=tester1/OU=TiDB/O=PingCAP.Inc/L=Haidian/ST=Beijing/C=ZH\"}"))
	tk.MustExec("alter user 'u2'@'%' require none")
	tk.MustQuery("select priv from mysql.global_priv where `Host` = '%' and `User` = 'u2'").Check(testkit.Rows("{}"))

	// test show create user
	tk.MustExec(`CREATE USER 'u3'@'%' require issuer '/CN=TiDB admin/OU=TiDB/O=PingCAP/L=San Francisco/ST=California/C=US' subject '/CN=tester1/OU=TiDB/O=PingCAP.Inc/L=Haidian/ST=Beijing/C=ZH' cipher 'AES128-GCM-SHA256'`)
	tk.MustQuery("show create user 'u3'").Check(testkit.Rows("CREATE USER 'u3'@'%' IDENTIFIED WITH 'mysql_native_password' AS '' REQUIRE CIPHER 'AES128-GCM-SHA256' ISSUER '/CN=TiDB admin/OU=TiDB/O=PingCAP/L=San Francisco/ST=California/C=US' SUBJECT '/CN=tester1/OU=TiDB/O=PingCAP.Inc/L=Haidian/ST=Beijing/C=ZH' PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT"))

	// check issuer/subject/cipher value
	err := tk.ExecToErr(`CREATE USER 'u4'@'%' require issuer 'CN=TiDB,OU=PingCAP'`)
	require.Error(t, err)
	err = tk.ExecToErr(`CREATE USER 'u5'@'%' require subject '/CN=TiDB\OU=PingCAP'`)
	require.Error(t, err)
	err = tk.ExecToErr(`CREATE USER 'u6'@'%' require subject '/CN=TiDB\NC=PingCAP'`)
	require.Error(t, err)
	err = tk.ExecToErr(`CREATE USER 'u7'@'%' require cipher 'AES128-GCM-SHA1'`)
	require.Error(t, err)
	err = tk.ExecToErr(`CREATE USER 'u8'@'%' require subject '/CN'`)
	require.Error(t, err)
	tk.MustGetErrMsg(`CREATE USER 'u9'@'%' require cipher 'TLS_AES_256_GCM_SHA384' cipher 'RC4-SHA'`, "Duplicate require CIPHER clause")
	tk.MustGetErrMsg(`CREATE USER 'u9'@'%' require issuer 'CN=TiDB,OU=PingCAP' issuer 'CN=TiDB,OU=PingCAP2'`, "Duplicate require ISSUER clause")
	tk.MustGetErrMsg(`CREATE USER 'u9'@'%' require subject '/CN=TiDB\OU=PingCAP' subject '/CN=TiDB\OU=PingCAP2'`, "Duplicate require SUBJECT clause")
	err = tk.ExecToErr(`CREATE USER 'u9'@'%' require ssl ssl`)
	require.Error(t, err)
	err = tk.ExecToErr(`CREATE USER 'u9'@'%' require x509 x509`)
	require.Error(t, err)
}

func TestMaintainAuthString(t *testing.T) {
	store := testkit.CreateMockStore(t)

	tk := testkit.NewTestKit(t, store)
	tk.MustExec(`CREATE USER 'maint_auth_str1'@'%' IDENTIFIED BY 'foo'`)
	tk.MustQuery("SELECT authentication_string FROM mysql.user WHERE `Host` = '%' and `User` = 'maint_auth_str1'").Check(testkit.Rows("*F3A2A51A9B0F2BE2468926B4132313728C250DBF"))
	tk.MustExec(`ALTER USER 'maint_auth_str1'@'%' REQUIRE SSL`)
	tk.MustQuery("SELECT authentication_string FROM mysql.user WHERE `Host` = '%' and `User` = 'maint_auth_str1'").Check(testkit.Rows("*F3A2A51A9B0F2BE2468926B4132313728C250DBF"))
}

func TestGrantOnNonExistTable(t *testing.T) {
	store := testkit.CreateMockStore(t)

	tk := testkit.NewTestKit(t, store)
	tk.MustExec("create user genius")
	tk.MustExec("use test")
	err := tk.ExecToErr("select * from nonexist")
	require.True(t, terror.ErrorEqual(err, infoschema.ErrTableNotExists))
	err = tk.ExecToErr("grant Select,Insert on nonexist to 'genius'")
	require.True(t, terror.ErrorEqual(err, infoschema.ErrTableNotExists))

	tk.MustExec("create table if not exists xx (id int)")
	// Case insensitive, differ from MySQL default behaviour.
	// In TiDB, system variable lower_case_table_names = 2, which means compare table name using lower case.
	tk.MustExec("grant Select,Insert on XX to 'genius'")
	tk.MustExec("grant Select,Insert on xx to 'genius'")
	tk.MustExec("grant Select,Update on test.xx to 'genius'")

	// issue #29268
	tk.MustExec("CREATE DATABASE d29268")
	defer tk.MustExec("DROP DATABASE IF EXISTS d29268")
	tk.MustExec("USE d29268")
	tk.MustExec("CREATE USER u29268")
	defer tk.MustExec("DROP USER u29268")

	// without create privilege
	err = tk.ExecToErr("GRANT SELECT ON t29268 TO u29268")
	require.Error(t, err)
	require.True(t, terror.ErrorEqual(err, infoschema.ErrTableNotExists))
	err = tk.ExecToErr("GRANT DROP, INSERT ON t29268 TO u29268")
	require.Error(t, err)
	require.True(t, terror.ErrorEqual(err, infoschema.ErrTableNotExists))
	err = tk.ExecToErr("GRANT UPDATE, CREATE VIEW, SHOW VIEW ON t29268 TO u29268")
	require.Error(t, err)
	require.True(t, terror.ErrorEqual(err, infoschema.ErrTableNotExists))
	err = tk.ExecToErr("GRANT DELETE, REFERENCES, ALTER ON t29268 TO u29268")
	require.Error(t, err)
	require.True(t, terror.ErrorEqual(err, infoschema.ErrTableNotExists))

	// with create privilege
	tk.MustExec("GRANT CREATE ON t29268 TO u29268")
	tk.MustExec("GRANT CREATE, SELECT ON t29268 TO u29268")
	tk.MustExec("GRANT CREATE, DROP, INSERT ON t29268 TO u29268")

	// check privilege
	tk.Session().Auth(&auth.UserIdentity{Username: "u29268", Hostname: "localhost"}, nil, nil, nil)
	tk.MustExec("USE d29268")
	tk.MustExec("CREATE TABLE t29268 (c1 int)")
	tk.MustExec("INSERT INTO t29268 VALUES (1), (2)")
	tk.MustQuery("SELECT c1 FROM t29268").Check(testkit.Rows("1", "2"))
	tk.MustExec("DROP TABLE t29268")

	// check grant all
	tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "localhost"}, nil, nil, nil)
	tk.MustExec("GRANT ALL ON t29268 TO u29268")
}

func TestIssue22721(t *testing.T) {
	store := testkit.CreateMockStore(t)

	tk := testkit.NewTestKit(t, store)
	tk.MustExec("use test")
	tk.MustExec("create table if not exists xx (id int)")
	tk.MustExec("CREATE USER 'sync_ci_data'@'%' IDENTIFIED BY 'sNGNQo12fEHe0n3vU';")
	tk.MustExec("GRANT USAGE ON *.* TO 'sync_ci_data'@'%';")
	tk.MustExec("GRANT USAGE ON sync_ci_data.* TO 'sync_ci_data'@'%';")
	tk.MustExec("GRANT USAGE ON test.* TO 'sync_ci_data'@'%';")
	tk.MustExec("GRANT USAGE ON test.xx TO 'sync_ci_data'@'%';")
}

func TestPerformanceSchemaPrivGrant(t *testing.T) {
	store := testkit.CreateMockStore(t)

	tk := testkit.NewTestKit(t, store)
	tk.MustExec("use test")
	tk.MustExec("create user issue27867;")
	defer func() {
		tk.MustExec("drop user issue27867;")
	}()
	require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "localhost"}, nil, nil, nil))
	tk.MustGetErrCode("grant all on performance_schema.* to issue27867;", errno.ErrDBaccessDenied)
	// Check case insensitivity
	tk.MustGetErrCode("grant all on PERFormanCE_scHemA.* to issue27867;", errno.ErrDBaccessDenied)
	// Check other database privileges
	tk.MustExec("grant select on performance_schema.* to issue27867;")
	tk.MustGetErrCode("grant insert on performance_schema.* to issue27867;", errno.ErrDBaccessDenied)
	tk.MustGetErrCode("grant update on performance_schema.* to issue27867;", errno.ErrDBaccessDenied)
	tk.MustGetErrCode("grant delete on performance_schema.* to issue27867;", errno.ErrDBaccessDenied)
	tk.MustGetErrCode("grant drop on performance_schema.* to issue27867;", errno.ErrDBaccessDenied)
	tk.MustGetErrCode("grant lock tables on performance_schema.* to issue27867;", errno.ErrDBaccessDenied)
	tk.MustGetErrCode("grant create on performance_schema.* to issue27867;", errno.ErrDBaccessDenied)
	tk.MustGetErrCode("grant references on performance_schema.* to issue27867;", errno.ErrDBaccessDenied)
	tk.MustGetErrCode("grant alter on PERFormAnCE_scHemA.* to issue27867;", errno.ErrDBaccessDenied)
	tk.MustGetErrCode("grant execute on performance_schema.* to issue27867;", errno.ErrDBaccessDenied)
	tk.MustGetErrCode("grant index on PERFormanCE_scHemA.* to issue27867;", errno.ErrDBaccessDenied)
	tk.MustGetErrCode("grant create view on performance_schema.* to issue27867;", errno.ErrDBaccessDenied)
	tk.MustGetErrCode("grant show view on performance_schema.* to issue27867;", errno.ErrDBaccessDenied)
}

func TestGrantDynamicPrivs(t *testing.T) {
	store := testkit.CreateMockStore(t)

	tk := testkit.NewTestKit(t, store)
	tk.MustExec("create user dyn")

	err := tk.ExecToErr("GRANT BACKUP_ADMIN ON test.* TO dyn")
	require.True(t, terror.ErrorEqual(err, exeerrors.ErrIllegalPrivilegeLevel))
	err = tk.ExecToErr("GRANT BOGUS_GRANT ON *.* TO dyn")
	require.True(t, terror.ErrorEqual(err, exeerrors.ErrDynamicPrivilegeNotRegistered))

	tk.MustExec("GRANT BACKUP_Admin ON *.* TO dyn") // grant one priv
	tk.MustQuery("SELECT * FROM mysql.global_grants WHERE `Host` = '%' AND `User` = 'dyn' ORDER BY user,host,priv,with_grant_option").Check(testkit.Rows("dyn % BACKUP_ADMIN N"))

	tk.MustExec("GRANT SYSTEM_VARIABLES_ADMIN, BACKUP_ADMIN ON *.* TO dyn") // grant multiple
	tk.MustQuery("SELECT * FROM mysql.global_grants WHERE `Host` = '%' AND `User` = 'dyn' ORDER BY user,host,priv,with_grant_option").Check(
		testkit.Rows("dyn % BACKUP_ADMIN N", "dyn % SYSTEM_VARIABLES_ADMIN N"),
	)

	tk.MustExec("GRANT ROLE_ADMIN, BACKUP_ADMIN ON *.* TO dyn WITH GRANT OPTION") // grant multiple with GRANT option.
	tk.MustQuery("SELECT * FROM mysql.global_grants WHERE `Host` = '%' AND `User` = 'dyn' ORDER BY user,host,priv,with_grant_option").Check(
		testkit.Rows("dyn % BACKUP_ADMIN Y", "dyn % ROLE_ADMIN Y", "dyn % SYSTEM_VARIABLES_ADMIN N"),
	)

	tk.MustExec("GRANT SYSTEM_VARIABLES_ADMIN, Select, ROLE_ADMIN ON *.* TO dyn") // grant mixed dynamic/non dynamic
	tk.MustQuery("SELECT Grant_Priv FROM mysql.user WHERE `Host` = '%' AND `User` = 'dyn'").Check(testkit.Rows("N"))
	tk.MustQuery("SELECT WITH_GRANT_OPTION FROM mysql.global_grants WHERE `Host` = '%' AND `User` = 'dyn' AND Priv='SYSTEM_VARIABLES_ADMIN'").Check(testkit.Rows("N"))

	tk.MustExec("GRANT CONNECTION_ADMIN, Insert ON *.* TO dyn WITH GRANT OPTION") // grant mixed dynamic/non dynamic with GRANT option.
	tk.MustQuery("SELECT Grant_Priv FROM mysql.user WHERE `Host` = '%' AND `User` = 'dyn'").Check(testkit.Rows("Y"))
	tk.MustQuery("SELECT WITH_GRANT_OPTION FROM mysql.global_grants WHERE `Host` = '%' AND `User` = 'dyn' AND Priv='CONNECTION_ADMIN'").Check(testkit.Rows("Y"))
}

func TestNonExistTableIllegalGrant(t *testing.T) {
	store := testkit.CreateMockStore(t)

	tk := testkit.NewTestKit(t, store)
	tk.MustExec("create user u29302")
	defer tk.MustExec("drop user u29302")
	// Table level, not existing table, illegal privilege
	tk.MustGetErrCode("grant create temporary tables on NotExistsD29302.NotExistsT29302 to u29302", mysql.ErrIllegalGrantForTable)
	tk.MustGetErrCode("grant lock tables on test.NotExistsT29302 to u29302", mysql.ErrIllegalGrantForTable)
	// Column level, not existing table, illegal privilege
	tk.MustGetErrCode("grant create temporary tables (NotExistsCol) on NotExistsD29302.NotExistsT29302 to u29302;", mysql.ErrWrongUsage)
}

func TestIssue34610(t *testing.T) {
	store := testkit.CreateMockStore(t)
	tk := testkit.NewTestKit(t, store)
	tk.MustExec("DROP DATABASE IF EXISTS d1;")
	tk.MustExec("CREATE DATABASE d1;")
	tk.MustExec("USE d1;")
	tk.MustExec("CREATE USER user_1@localhost;")
	defer func() {
		tk.MustExec("DROP DATABASE d1;")
		tk.MustExec("DROP USER user_1@localhost;")
	}()

	tk.MustExec("CREATE TABLE T1(f1 INT);")
	tk.MustGetErrCode("CREATE TABLE t1(f1 INT);", mysql.ErrTableExists)
	tk.MustExec("GRANT SELECT ON T1 to user_1@localhost;")
	tk.MustExec("GRANT SELECT ON t1 to user_1@localhost;")
}

func TestIssue38293(t *testing.T) {
	store := testkit.CreateMockStore(t)
	tk := testkit.NewTestKit(t, store)
	tk.Session().GetSessionVars().User = &auth.UserIdentity{Username: "root", Hostname: "localhost"}
	tk.MustExec("DROP USER IF EXISTS test")
	tk.MustExec("CREATE USER test")
	defer func() {
		tk.MustExec("DROP USER test")
	}()
	tk.MustExec("GRANT SELECT ON `mysql`.`db` TO test")
	tk.MustQuery("SELECT `Grantor` FROM `mysql`.`tables_priv` WHERE User = 'test'").Check(testkit.Rows("root@localhost"))
}

repository: pingcap/tidb

repo_name: pingcap/tidb


text:
package main

import "net"

func GetRandomAddress() (*net.TCPAddr, error) {
	laddr, err := net.ResolveTCPAddr("tcp", "localhost:0") // Port == 0 - free
	if err != nil {
		return laddr, err
	}
	l, err := net.ListenTCP("tcp", laddr)
	l.Close()
	return l.Addr().(*net.TCPAddr), err
}

repository: butterflyfx/butterflyfx-cli

license_type: permissive

repo_name: butterflyfx/butterflyfx-cli

branch_name: refs/heads/master

extension: go


text:
@article{meteleshko2019novel154619359,
 address = {United Kingdom},
 author = {Meteleshko, Yulia I. and Nemukhin, Alexander and Khrenova, Maria},
 doi = {10.1039/c8pp00361k},
 issn = {1474-9092; 1474-905X},
 journal = {Photochemical and Photobiological Sciences},
 language = {english},
 pages = {177--189},
 publisher = {United Kingdom},
 title = {Novel flavin-based fluorescent proteins with red-shifted emission bands: a computational study},
 volume = {18},
 year = {2019}
}

license: MIT

repository: polyakoviv/LCC

repo_name: polyakoviv/LCC

branch_name: refs/heads/main

extension: bib


text:
% This file was created with JabRef 2.10.
% Encoding: UTF-8

@Article{luque2014a,
  Title                    = {Fast convergence of learning requires plasticity between inferior olive and deep cerebellar nuclei in a manipulation task: a closed-loop robotic simulation},
  Author                   = {Luque, Niceto R and Garrido, Jes{\'u}s A and Carrillo, Richard R and D'Angelo, Egidio and Ros, Eduardo},
  Journal                  = {Frontiers in computational neuroscience},
  Year                     = {2014},
  Pages                    = {97},
  Volume                   = {8},

  Publisher                = {Frontiers}
}

repository: EduardoRosLab/neurorobotics-website

repo_name: EduardoRosLab/neurorobotics-website


text:
// Copyright 2011-2012 Brent Rowland.
// Use of this source code is governed the Apache License, Version 2.0, as described in the LICENSE file.

package pdf

import "testing"

type afmFontSelection struct {
	family         string
	weight         string
	style          string
	ranges         []string
	postscriptName string
}

var testAfmSelectData = []afmFontSelection{
	{"Helvetica", "", "", nil, "Helvetica"},
	{"Helvetica", "", "Oblique", nil, "Helvetica-Oblique"},
	{"Helvetica", "", "oblique", nil, "Helvetica-Oblique"},
	{"Helvetica", "", "Italic", nil, "Helvetica-Oblique"},
	{"Helvetica", "", "italic", nil, "Helvetica-Oblique"},
	{"Helvetica", "Bold", "", nil, "Helvetica-Bold"},
	{"Helvetica", "bold", "", nil, "Helvetica-Bold"},
	{"Helvetica", "Bold", "Italic", nil, "Helvetica-BoldOblique"},
	{"helvetica", "bold", "italic", nil, "Helvetica-BoldOblique"},

	{"Courier", "", "", nil, "Courier"},
	{"Courier", "", "Oblique", nil, "Courier-Oblique"},
	{"Courier", "", "oblique", nil, "Courier-Oblique"},
	{"Courier", "", "Italic", nil, "Courier-Oblique"},
	{"Courier", "", "italic", nil, "Courier-Oblique"},
	{"Courier", "Bold", "", nil, "Courier-Bold"},
	{"Courier", "bold", "", nil, "Courier-Bold"},
	{"Courier", "Bold", "Italic", nil, "Courier-BoldOblique"},
	{"courier", "bold", "italic", nil, "Courier-BoldOblique"},

	{"Times", "", "", nil, "Times-Roman"},
	{"Times", "", "Italic", nil, "Times-Italic"},
	{"Times", "", "italic", nil, "Times-Italic"},
	{"Times", "", "Oblique", nil, "Times-Italic"},
	{"Times", "", "oblique", nil, "Times-Italic"},
	{"Times", "Bold", "", nil, "Times-Bold"},
	{"Times", "bold", "", nil, "Times-Bold"},
	{"Times", "Bold", "Italic", nil, "Times-BoldItalic"},
	{"times", "bold", "italic", nil, "Times-BoldItalic"},

	{"ZapfDingbats", "", "", nil, "ZapfDingbats"},
	{"zapfdingbats", "", "", nil, "ZapfDingbats"},
	{"Symbol", "", "", nil, "Symbol"},
	{"symbol", "", "", nil, "Symbol"},

	{"Zapf Chancery", "Medium", "Italic", nil, "ZapfChancery-MediumItalic"},
	{"zapf chancery", "medium", "italic", nil, "ZapfChancery-MediumItalic"},
}

func testAfmFonts(families ...string) (fonts []*Font) {
	fc, err := NewAfmFontCollection("../afm/data/fonts/*.afm")
	if err != nil {
		panic(err)
	}
	for _, family := range families {
		metrics, err := fc.Select(family, "", "", nil)
		if err != nil {
			panic(err)
		}
		font := &Font{family: family, metrics: metrics}
		fonts = append(fonts, font)
	}
	return
}

func TestAfmFontCollection(t *testing.T) {
	var fc AfmFontCollection

	if err := fc.Add("../afm/data/fonts/*.afm"); err != nil {
		t.Fatal(err)
	}

	expectNI(t, "Len", 77, fc.Len())
	for _, fs := range testAfmSelectData {
		f, err := fc.Select(fs.family, fs.weight, fs.style, fs.ranges)
		if err == nil {
			expectNS(t, fs.postscriptName, fs.postscriptName, f.PostScriptName())
		} else {
			t.Error(err)
		}
	}
	bogusFont, err2 := fc.Select("Bogus", "Medium", "", nil)
	expect(t, "Bogus Select Font", bogusFont == nil)
	expectNS(t, "Bogus Select Error", "Font 'Bogus Medium ' not found", err2.Error())
}

// 81,980,000 ns
// 45,763,220 ns
// 13,754,000 ns
// 12,035,539 ns go1.1.1
// 11,984,518 ns go1.1.2
// 10,951,804 ns go1.2.1
// 13,275,334 ns go1.4.2
func BenchmarkAfmFontCollection_Add(b *testing.B) {
	for i := 0; i < b.N; i++ {
		var fc AfmFontCollection
		if err := fc.Add("../afm/data/fonts/*.afm"); err != nil {
			b.Fatal(err)
		}
		if fc.Len() != 77 {
			b.Fatalf("Unexpected number of fonts found: %d.", fc.Len())
		}
	}
}

// 44,797 ns
// 40,640 ns go1.1.1
// 41,299 ns go1.1.2
// 39,918 ns go1.2.1
// 99,394 ns go1.4.2
func BenchmarkAfmFontCollection_Select(b *testing.B) {
	b.StopTimer()
	var fc AfmFontCollection
	if err := fc.Add("../afm/data/fonts/*.afm"); err != nil {
		b.Fatal(err)
	}
	b.StartTimer()

	for i := 0; i < b.N; i++ {
		fc.Select("Times", "Bold", "Italic", nil)
	}
}

repository: hasancgi/leadtype

repo_name: hasancgi/leadtype


text:
/*
  arpmon  Implements a REST API to query ARP scanning results

  Written by Glen Darling, April 2021.
*/

package main

import (
	"context"
	"fmt"
	"github.com/j-keck/arping"
	"log"
	"net"
	"net/http"
	"os"
	"os/signal"
	"strconv"
	"strings"
	"sync"
	"syscall"
	"time"
)

const ADDRESS_FIRST int = 1
const ADDRESS_LAST int = 254
const WORKER_SLEEP_SEC = 6
const ARP_TIMEOUT time.Duration = (6 * time.Second)
const NOT_FOUND string = ""

const GPS_DEBUG = false

func debug(formatStr string, args ...interface{}) {
	if GPS_DEBUG {
		log.Printf("DEBUG: "+formatStr, args...)
	}
}

type Server struct {

	// Threading
	wg                   sync.WaitGroup
	mutex                sync.RWMutex
	ch                   chan int
	number_of_goroutines int

	// REST server
	url_base string

	// LAN monitoring
	prefix   string
	my_octet int
	my_mac   string
	hosts    map[int]string
}

func ServerFactory(url_base, cidr, my_ipv4, my_mac string, n int) *Server {
	arping.SetTimeout(ARP_TIMEOUT)
	var hosts = make(map[int]string)
	for i := ADDRESS_FIRST; i <= ADDRESS_LAST; i++ {
		hosts[i] = NOT_FOUND
	}
	octets := strings.Split(my_ipv4, ".")
	octet, err := strconv.Atoi(octets[len(octets)-1])
	if err != nil {
		log.Fatal(err)
	}
	hosts[octet] = my_mac
	s := &Server{hosts: hosts}
	s.mutex.Lock()
	s.number_of_goroutines = n
	s.ch = make(chan int, s.number_of_goroutines)
	s.url_base = url_base
	s.prefix = strings.Join(strings.Split(cidr, ".")[:3], ".") + "."
	s.my_octet = octet
	s.my_mac = my_mac
	s.mutex.Unlock()
	segment_size := 256 / s.number_of_goroutines
	for i := 0; i < s.number_of_goroutines; i++ {
		min := i * segment_size
		if min < ADDRESS_FIRST {
			min = ADDRESS_FIRST
		}
		max := (i+1)*segment_size - 1
		if max > ADDRESS_LAST {
			max = ADDRESS_LAST
		}
		s.mutex.Lock()
		s.wg.Add(1)
		go s.work(min, max)
		s.mutex.Unlock()
	}
	return s
}

func (s *Server) arp_ping(octet int, ip string) {
	debug("--> arp-ping(%d, %s)\n", octet, ip)
	// Do an ARP probe and wait for response
	// arping.EnableVerboseLog()
	mac, msec, err := arping.Ping(net.ParseIP(ip))
	if err == arping.ErrTimeout {
		debug("<-- %s  [timeout]\n", ip)
		s.mutex.Lock()
		s.hosts[octet] = NOT_FOUND
		s.mutex.Unlock()
	} else if err != nil {
		// log.Printf("Ignoring error from arping.Ping():\n   %v", err)
	} else {
		mac_str := strings.ToUpper(fmt.Sprint(mac))
		debug("<-- %s (%s) %d usec\n", ip, mac_str, msec/1000)
		s.mutex.Lock()
		s.hosts[octet] = mac_str
		s.mutex.Unlock()
	}
}

func (s *Server) work(min int, max int) {
	debug("WORKER(%d .. %d)\n", min, max)
	defer s.wg.Done()
	s.mutex.RLock()
	my_octet := s.my_octet
	prefix := s.prefix
	s.mutex.RUnlock()
	for {
		for i := min; i <= max; i++ {
			if i != my_octet {
				ip := prefix + fmt.Sprint(i)
				s.arp_ping(i, ip)
				for j := 0; j < (2 * WORKER_SLEEP_SEC); j++ {
					select {
					case <-s.ch:
						debug("<== WORKER(%d .. %d)\n", min, max)
						return
					default:
						time.Sleep(500 * time.Millisecond)
					}
				}
			}
		}
	}
}

// Construct a response of only unique MAC addresses found, one per line.
func (s *Server) macs() string {
	var macs = make(map[string]bool)
	for i := ADDRESS_FIRST; i <= ADDRESS_LAST; i++ {
		s.mutex.RLock()
		mac := s.hosts[i]
		s.mutex.RUnlock()
		debug("MAC=%v\n", mac)
		if NOT_FOUND != mac {
			macs[mac] = true
		}
	}
	var response string = ""
	format := "%s\n"
	for mac, _ := range macs {
		response += fmt.Sprintf(format, mac)
	}
	return response
}

// Construct a CSV response of "IP,MAC" lines
func (s *Server) csv(prefix string) string {
	var response string = ""
	format := "%s,%s\n"
	for i := ADDRESS_FIRST; i <= ADDRESS_LAST; i++ {
		s.mutex.RLock()
		mac := s.hosts[i]
		s.mutex.RUnlock()
		if NOT_FOUND != mac {
			ip := prefix + fmt.Sprint(i)
			response += fmt.Sprintf(format, ip, mac)
		}
	}
	return response
}

// Construct a JSON response in this form:
//  {
//    "hosts": [
//      {
//        "ip": "x.x.x.x",
//        "mac": "xx:xx:xx:xx:xx:xx"
//      },
//      ...
//    ]
//  }
func (s *Server) json(prefix string) string {
	var response string = "{\n  \"hosts\":[\n"
	format := "    {\"ip\":\"%s\",\"mac\":\"%s\"}"
	count := 0
	for i := ADDRESS_FIRST; i <= ADDRESS_LAST; i++ {
		s.mutex.RLock()
		mac := s.hosts[i]
		s.mutex.RUnlock()
		if NOT_FOUND != mac {
			if count > 0 {
				response += ",\n"
			}
			count++
			ip := prefix + fmt.Sprint(i)
			response += fmt.Sprintf(format, ip, mac)
		}
	}
	response += "\n  ]\n}\n"
	return response
}

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	log.Printf("REQUEST: %s %v\n", r.Method, r.URL)
	s.mutex.RLock()
	prefix := s.prefix
	url_base := s.url_base
	s.mutex.RUnlock()
	url := fmt.Sprintf("%v", r.URL)
	debug(url)
	var response string
	if url_base+"/macs" == url {
		response = s.macs()
	} else if url_base+"/csv" == url {
		response = s.csv(prefix)
	} else if url_base+"/json" == url {
		response = s.json(prefix)
	} else {
		log.Fatal("Impossible URL: " + url)
	}
	_, err := fmt.Fprintf(w, response)
	if err != nil {
		log.Print(err)
	} else {
		log.Print(response)
	}
}

func get_env_or_default(name string, def string) string {
	var val string = os.Getenv(name)
	debug("ENV %s==\"%v\"\n", name, val)
	if "" == val {
		return def
	} else {
		return val
	}
}

func main() {

	// Collect configuration from the process environment
	var cidr string = get_env_or_default("CIDR", "")
	var my_ipv4 string = get_env_or_default("IPV4", "")
	var my_mac string = strings.ToUpper(get_env_or_default("MAC", ""))
	var port string = fmt.Sprintf(":%s", get_env_or_default("PORT", "1234"))
	var url_base string = get_env_or_default("URL_BASE", "/")
	var goroutines_str string = get_env_or_default("GOROUTINES", "4")
	if "" == cidr || "" == my_ipv4 || "" == my_mac {
		log.Fatal("\"CIDR\", \"IPV4\" and \"MAC\" must be set in environment.")
	}
	n, err := strconv.Atoi(goroutines_str)
	if err != nil {
		log.Fatal(err)
	}

	// Channel "sigs" will receive OS signals
	sigs := make(chan os.Signal, 1)
	signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)

	// Create the Server object that does all the work
	s := ServerFactory(url_base, cidr, my_ipv4, my_mac, n)

	// Make it into an HTTP REST API server
	rest_server := &http.Server{Addr: port, Handler: http.DefaultServeMux}
	http.Handle(url_base+"/macs", s)
	http.Handle(url_base+"/csv", s)
	http.Handle(url_base+"/json", s)
	go func() {
		debug("Starting REST server at %s, with URL base \"%s\"\n", port, url_base)
		err := rest_server.ListenAndServe()
		debug("REST server has terminated.\n")
		if err != nil {
			log.Fatal(err)
		}
	}()

	// Signal handler
	go func() {

		// Block waiting for signals
		<-sigs
		log.Println("SIGNAL!")

		// Send s.number_of_goroutines messages (each will receive one)
		for i := 0; i < s.number_of_goroutines; i++ {
			s.ch <- i
		}

		// End the web server
		ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
		defer cancel()
		rest_server.Shutdown(ctx)

		log.Println("Waiting for threads to complete (please be patient)...")
	}()

	s.wg.Wait()
	log.Println("Graceful shutdown complete.")
}

repository: MegaMosquito/ARPmon

repo_name: MegaMosquito/ARPmon


text:
@inproceedings{Kenny:2018,
 abstract = {Data movement is considered the main performance concern
for exascale, including both on-node memory and off-node
network communication. Indeed, many application traces show
significant time spent in MPI calls, potentially indicating
that faster networks must be provisioned for scalability.
However, equating MPI times with network communication
delays ignores synchronization delays and software
overheads independent of network hardware. Using
point-to-point protocol details, we explore the
decomposition of MPI time into communication,
synchronization and software stack components using
architecture simulation. Detailed validation using Bayesian
inference is used to identify the sensitivity of
performance to specific latency/bandwidth parameters for
different network protocols and to quantify associated
uncertainties. The inference combined with trace replay
shows that synchronization and MPI software stack overhead
are at least as important as the network itself in
determining time spent in communication routines.},
 address = {Cham},
 author = {Kenny, J. and Sargsyan, K. and Knight, S. and
Michelogiannakis, G. and Wilke, J.},
 booktitle = {High Performance Computing},
 doi = {10.1007/978-3-319-92040-5_14},
 editor = {Yokota, Rio and Weiland, Michèle and Keyes, David and
Trinitis, Carsten},
 isbn = {978-3-319-92040-5},
 month = {May},
 pages = {269--288},
 publisher = {Springer International Publishing},
 title = {The Pitfalls of Provisioning Exascale Networks: A Trace
Replay Analysis for Understanding Communication
Performance},
 year = {2018}
}


text:
DESCRIPTION = "Backend library for the free nx-clients"
HOMEPAGE = "http://freenx.berlios.de/"
SECTION = "libs"
LICENSE = "GPL"
PR = "r2"

RDEPENDS = "nxproxy nxssh"

SRC_URI = "http://download.berlios.de/freenx/freenx-client-${PV}.tar.bz2 \
	   file://gcc4.3-ftbfs.patch;patch=1 \
	   file://dodnx.patch;patch=1 \
	   file://gcc-warnings.patch;patch=1 \
	   file://restorekeyboard.patch;patch=1 \
	   file://publicKey.patch;patch=1 \
	   file://deletelogfiles.patch;patch=1 \
	   file://ssh_dnserror.patch;patch=1 \
	  "

S = "${WORKDIR}/freenx-client-${PV}/nxcl"

EXTRA_OECONF += "--without-nxcmd \
	         --without-doxygen \
                "

inherit lib_package autotools pkgconfig

do_stage () {
	autotools_stage_all
}

extension: bb


text:
DESCRIPTION = "Google gRPC"
HOMEPAGE = "http://www.grpc.io/"
SECTION = "devel/python"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57"

DEPENDS += "${PYTHON_PN}-protobuf"

SRC_URI += "file://0001-setup.py-Do-not-mix-C-and-C-compiler-options.patch"
SRC_URI_append_class-target = " file://ppc-boringssl-support.patch \
                                file://riscv64_support.patch \
                                file://0001-Fix-build-on-riscv32.patch \
"
SRC_URI[md5sum] = "ccaf4e7eb4f031d926fb80035d193b98"
SRC_URI[sha256sum] = "a899725d34769a498ecd3be154021c4368dd22bdc69473f6ec46779696f626c4"

RDEPENDS_${PN} = "${PYTHON_PN}-protobuf \
                  ${PYTHON_PN}-setuptools \
                  ${PYTHON_PN}-six \
"

inherit setuptools3
inherit pypi

export GRPC_PYTHON_DISABLE_LIBC_COMPATIBILITY = "1"

do_compile_prepend_toolchain-clang() {
    export GRPC_PYTHON_CFLAGS='-fvisibility=hidden -fno-wrapv -fno-exceptions'
}

CLEANBROKEN = "1"

BBCLASSEXTEND = "native nativesdk"

CCACHE_DISABLE = "1"

gha_license_id: MIT


text:
@Article{DongE,
  Title                    = {An interactive web-based dashboard to track COVID-19 in real time.},

  Author                   = {{Dong E, Du H, Gardner L.}},
  Year                     = {2020},

  Type                     = {Journal Article},
  Url                      = {10.1016/S1473-3099(20)30120-1}
}

@Misc{JHU,
  Title                    = {COVID-19 Data Repository by the Center for Systems Science and Engineering (CSSE) at Johns Hopkins Universit},
  Author                   = {{Johns Hopkins University}},
  Year                     = {2020},

  Type                     = {Journal Article},
  Url                      = {https://github.com/CSSEGISandData/COVID-19}
}


text:
package stack

type ArrayStack struct {
	pool   []interface{}
	length int
}

func NewArrayStack(size int) *ArrayStack {
	return &ArrayStack{pool: make([]interface{}, size)}
}

func (s *ArrayStack) Size() int {
	return s.length
}

func (s *ArrayStack) IsEmpty() bool {
	return s.length == 0
}

func (s *ArrayStack) Push(e interface{}) interface{} {
	if s.length == len(s.pool) {
		newPool := make([]interface{}, len(s.pool)*2)
		copy(newPool, s.pool)
		s.pool = newPool
	}

	s.pool[s.length] = e
	s.length++

	return e
}

func (s *ArrayStack) Pop() (e interface{}, err error) {
	if s.length == 0 {
		return nil, ErrEmpty
	}

	s.length--
	return s.pool[s.length], nil
}

func (s *ArrayStack) Top() (e interface{}, err error) {
	if s.length == 0 {
		return nil, ErrEmpty
	}

	return s.pool[s.length-1], nil
}


text:
DESCRIPTION = "This module hooks $SIG{__WARN__} and converts warnings to Test::More \
\"fail()\" calls. It is designed to be used with \"done_testing\", when \
you don't need to know the test count in advance."

SECTION = "libs"
LICENSE = "Apache-2.0"
PR = "r0"

MAINTAINER=	"Poky <poky@yoctoproject.org>"
HOMEPAGE=	"https://metacpan.org/release/Test-FailWarnings"

LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"

SRC_URI = "http://cpan.metacpan.org/authors/id/D/DA/DAGOLDEN/Test-FailWarnings-0.008.tar.gz"

SRC_URI[md5sum] = "c03d51f550dbfd9945722ff7f4c32717"
SRC_URI[sha256sum] = "da34ef9029f6849d6026201d49127d054ee6ac4b979c82210315f5721964a96f"
DEPENDS += "capture-tiny-perl-native"

S = "${WORKDIR}/Test-FailWarnings-${PV}"

inherit cpan

do_compile() {
	export LIBC="$(find ${STAGING_DIR_TARGET}/${base_libdir}/ -name 'libc-*.so')"
	cpan_do_compile
}

BBCLASSEXTEND = "native"

repository: rehsack/meta-cpan

repo_name: rehsack/meta-cpan

gha_language: BitBake


text:
inherit native
require cmake.inc

do_install() {
	oe_runmake install
}

SRC_URI[md5sum] = "50f387d0436696c4a68b5512a72c9cde"
SRC_URI[sha256sum] = "9cdd2152e37b05d0d40d334a1bb2dfc0250021797360f971c6ea3d457ac9fdf2"


text:
@article{flores2015uncovering,
 author = {Flores, Enrique and Barrón-Cedeño, Alberto and Moreno, Lidia and Rosso, Paolo},
 journal = {Computer Applications in Engineering Education},
 number = {3},
 pages = {383--390},
 title = {Uncovering source code reuse in large-scale academic environments},
 volume = {23},
 year = {2015}
}

repository: albarron/academic-kickstart

repo_name: albarron/academic-kickstart


text:
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"

DESCRIPTION = "Package used to work around consoleblank=0 turning screen off from startup"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

inherit allarch systemd

SRC_URI = " file://fb-unblank.service"

RDEPENDS_${PN} = " bash systemd"

do_install () {
    install -d ${D}/${systemd_unitdir}/system
    install -m 0755 ${WORKDIR}/fb-unblank.service ${D}/${systemd_unitdir}/system/fb-unblank.service
}

SYSTEMD_SERVICE_${PN} = "fb-unblank.service"

COMPATIBLE_MACHINE = "jetson-tx2"


text:
SUMMARY = "Text unidecode"
HOMEPAGE = "https://github.com/kmike/text-unidecode"
LICENSE = "Artistic-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=ccfb8875bc60bc3d6e91e42e5e8f5587"

inherit pypi setuptools3

SRC_URI[md5sum] = "53a0a6c5aef8f5eb5834e78e0fdf0499"
SRC_URI[sha256sum] = "bad6603bb14d279193107714b288be206cac565dfa49aa5b105294dd5c4aab93"

repository: sbabic/meta-homeassistant

repo_name: sbabic/meta-homeassistant


text:
package redis

import (
	"context"
	"fmt"
	"log"

	"github.com/go-redis/redis/v8"
	"github.com/spf13/viper"
)

var (
	Client *redis.Client
)

func init() {
	redisHost := viper.GetString("REDIS_HOST")
	redisPort := viper.GetString("REDIS_PORT")
	redisPass := viper.GetString("REDIS_PASSWORD")
	redisDbname := viper.GetInt("REDIS_DATABASE")

	addr := fmt.Sprintf("%s:%s", redisHost, redisPort)
	Client = redis.NewClient(&redis.Options{
		Addr:     addr,        // 접근 url 및 port
		Password: redisPass,   // password "" 값은 없다는 뜻
		DB:       redisDbname, // 0이면 기본 DB 사용
	})

	ctx := context.Background()
	log.Println("redis 연결 중...")
	if _, err := Client.Ping(ctx).Result(); err != nil {
		log.Panic("redis 연결에 실패하였습니다.\n\t" + err.Error())
	}

	log.Printf("redis starting at %s, DB: %d\n", addr, redisDbname)
}

repository: parkgang/modern-board

repo_name: parkgang/modern-board


text:
angular.module('plugins')
    .directive('proteinBaselineExpression', ['$log', function ($log) {
        'use strict';

        return {
            restrict: 'E',
            templateUrl: 'plugins/protein-baseline-expression.html',
            scope: {
                target: '='
            }
        };
    }]);

extension: js


text:
# Recipe for building the MDM9607 Kernel tree
# Biktorgj 2020
# Released under the MIT license (see COPYING.MIT for the terms)

inherit kernel
inherit pythonnative

DESCRIPTION = "Linux Kernel for Qualcomm MDM9607-MTP"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=d7810fab7487fb0aad327b76f1be7cd7"

# Set compatible machines for this kernel
COMPATIBLE_MACHINE = "mdm9607"
# Dependencies
DEPENDS += "mkbootimg-native dtbtool-native libgcc python-native dtc-native"

# Base paths
SRC_URI   =  "git://github.com/Biktorgj/quectel_eg25_kernel.git;branch=linux-3.18.140"
SRCREV = "${AUTOREV}"
S = "${WORKDIR}/git"

PR = "${DISTRO}"
PVBASE := "${PV}"
PV = "1.0+git${SRCPV}"
KERNEL_IMAGETYPE ?= "zImage"
KERNEL_DEFCONFIG_mdm9607 ?= "${S}/arch/arm/configs/mdm9607-perf_defconfig"
KERNEL_DEVICETREE ?= "qcom/mdm9607-mtp.dtb"

QCOM_BOOTIMG_ROOTFS ?= "undefined"
SD_QCOM_BOOTIMG_ROOTFS ?= "undefined"
# set output file names
BOOT_IMAGE_BASE_NAME = "boot-${KERNEL_IMAGE_NAME}"
BOOT_IMAGE_SYMLINK_NAME = "boot-${KERNEL_IMAGE_LINK_NAME}"
# CMDLine params
QCOM_BOOTIMG_PAGE_SIZE = "2048"
KERNEL_CMDLINE = "noinitrd ro console=ttyHSL0,115200,n8 androidboot.hardware=qcom ehci-hcd.park=3 msm_rtb.filter=0x37 lpm_levels.sleep_disabled=1"
QCOM_BOOTIMG_KERNEL_BASE = "0x80000000"
KERNEL_TAGS_ADDR = "0x81E00000"
do_compile[nostamp] = "1"

kernel_conf_variable() {
	CONF_SED_SCRIPT="$CONF_SED_SCRIPT /CONFIG_$1[ =]/d;"
	if test "$2" = "n"
	then
		echo "# CONFIG_$1 is not set" >> ${B}/.config
	else
		echo "CONFIG_$1=$2" >> ${B}/.config
	fi
}

do_configure_prepend() {
	echo "" > ${B}/.config
	CONF_SED_SCRIPT=""

	kernel_conf_variable LOCALVERSION "\"${LOCALVERSION}\""
	kernel_conf_variable LOCALVERSION_AUTO y

	if [ -f '${WORKDIR}/defconfig' ]; then
		sed -e "${CONF_SED_SCRIPT}" < '${WORKDIR}/defconfig' >> '${B}/.config'
	else
		sed -e "${CONF_SED_SCRIPT}" < '${KERNEL_DEFCONFIG}' >> '${B}/.config'
	fi

	if [ "${SCMVERSION}" = "y" ]; then
		# Add GIT revision to the local version
		head=`git --git-dir=${S}/.git  rev-parse --verify --short HEAD 2> /dev/null`
		printf "%s%s" +g $head > ${B}/.scmversion
	fi

	yes '' | oe_runmake -C ${S} O=${B} oldconfig
        oe_runmake -C ${S} O=${B} savedefconfig && cp ${B}/defconfig ${WORKDIR}/defconfig.saved
}

# append DTB
do_compile_append() {
    ${STAGING_BINDIR_NATIVE}/dtbTool ${B}/arch/arm/boot/dts/qcom/ -s 2048 -o ${B}/arch/arm/boot/dts/qcom/dtb.img -p scripts/dtc/ -v
}

# param ${1} partition where rootfs is located
# param ${2} output boot image file name
priv_make_image() {
    ${STAGING_BINDIR_NATIVE}/mkbootimg --kernel ${B}/arch/arm/boot/${KERNEL_IMAGETYPE} \
              --ramdisk ${B}/initrd.gz \
              --output ${DEPLOYDIR}/${2}.img \
              --pagesize ${QCOM_BOOTIMG_PAGE_SIZE} \
              --base ${QCOM_BOOTIMG_KERNEL_BASE} \
              --tags-addr ${KERNEL_TAGS_ADDR} \
              --dt ${B}/arch/arm/boot/dts/qcom/dtb.img \
              --cmdline "${KERNEL_CMDLINE}"
}

do_deploy_append() {
    # mkbootimg requires an initrd file, make fake one that will be ignored
    # during boot
    touch ${B}/initrd.gz

    # don't build bootimg if rootfs partition is not defined
    if [ "${QCOM_BOOTIMG_ROOTFS}" == "undefined"]; then
        bbfatal "Rootfs partition must be defined"
    fi

    priv_make_image ${QCOM_BOOTIMG_ROOTFS} ${BOOT_IMAGE_BASE_NAME}
    ln -sf ${BOOT_IMAGE_BASE_NAME}.img ${DEPLOYDIR}/${BOOT_IMAGE_SYMLINK_NAME}.img
}

repository: PsychoGame/meta-qcom

repo_name: PsychoGame/meta-qcom

branch_name: refs/heads/hardknott


text:
@article{Anselin1992a,
author = {Luc Anselin and John O'Loughlin},
journal = {The New Geopolitics},
keywords = {Computing with Data,Data Mining,Data Visualization,Exploratory Data Analysis,Machine Learning,Scientific visualization,Statistical Model Building},
number = {},
pages = {39--75},
title = {{Geography of international conflict and cooperation: spatial dependence and regional context in Africa}},
volume = {},
year = {1992}
}

@article{DataQuality2010,
author = {M. Sun  and W.S. Wong},
journal = {Cartography and Geography Information Science},
keywords = {Computing with Data,Data Mining,Data Visualization,Exploratory Data Analysis,Machine Learning,Scientific visualization,Statistical Model Building},
number = {4},
pages = {285--300},
title = {{Incorporating Data Quality Information in Mapping American Community Survey Data}},
volume = {37},
year = {2010}
}

@article{Tobler1970,
author = {Tobler, Waldo R.},
journal = {Economic Geography},
keywords = {First law of geography},
number = {2},
pages = {234--240},
title = {{A Computer Movie Simulating Urban Growth in the Detroit Region}},
url = {http://www.geog.ucsb.edu/~tobler/publications/pdf_docs/A-Computer-Movie.pdf},
volume = {46},
year = {1970}
}

@article{DykeUnwin2001,
author = {Dykes, J. A. and Unwin, D. J.},
journal = {In Case Studies of Visualization in the Social Sciences: Technical Report},
keywords = {Mapping rates},
number = {43},
pages = {29-54},
title = {{Maps of the Census: A Rough Guide}},
url = {http://www.agocg.ac.uk/reports/visual/casestud/dykes/dykes.pdf},
volume = {43},
year = {2001}
}

repository: mgimond/Spatial

repo_name: mgimond/Spatial

gha_language: HTML


text:
SUMMARY = "AAMP Gstreamer plugin"
DESCRIPTION = "Advanced Adaptive Micro Player GStreamer plugin support playback of HLS and MPEGDash contents"
HOMEPAGE = "https://github.com/rdkcmf/rdk-gst-plugins-rdk-aamp"
LICENSE = "LGPLv2.1+"
LIC_FILES_CHKSUM = "file://COPYING.LGPL;md5=2a626f155f0a604febb7d0fc6b0611af"

DEPENDS_append = " aamp gstreamer1.0 gstreamer1.0-plugins-base wpeframework-clientlibraries"

PV = "0.1.gitr${SRCPV}"

RECIPE_BRANCH ?= "stable2"
SRC_URI = "\
   git://github.com/rdkcmf/rdk-gst-plugins-rdk-aamp.git;protocol=https;branch=${RECIPE_BRANCH} \
"
SRCREV ?= "8a0d9ef607ea254aff4b897137fd1f743db74c29"

S = "${WORKDIR}/git"

inherit cmake

PACKAGECONFIG ??= " ${@bb.utils.contains('DISTRO_FEATURES', 'opencdm', 'opencdm', '', d)}"
PACKAGECONFIG[opencdm] = "-DCMAKE_DASH_DRM=ON -DCMAKE_CDM_DRM=ON -DCMAKE_USE_OPENCDM_ADAPTER=ON,,"

FILES_${PN} += "${libdir}"

# Fixme, something is pointing to a non-symlink and that pulls in -dev packages
INSANE_SKIP_${PN} = "dev-deps"

repository: WebPlatformForEmbedded/meta-wpe

repo_name: WebPlatformForEmbedded/meta-wpe


text:
if(ANDROID OR LINUX)
	# WIN32 Should be unset after project() line to work correctly
	unset(WIN32)
	unset(WINDOWS)
endif()

message(STATUS "CMAKE_VERSION = ${CMAKE_VERSION}")
message(STATUS "CMAKE_SYSTEM = ${CMAKE_SYSTEM}")
message(STATUS "CMAKE_SYSTEM_NAME = ${CMAKE_SYSTEM_NAME}")
message(STATUS "CMAKE_SYSTEM_VERSION = ${CMAKE_SYSTEM_VERSION}")
message(STATUS "BUILD_PLATFORM = ${BUILD_PLATFORM}")
message(STATUS "BUILD_CPU_ARCHITECTURE = ${BUILD_CPU_ARCHITECTURE}")
message(STATUS "OUTPUT_DIRECTORY_NAME = ${OUTPUT_DIRECTORY_NAME}")

if(NOT ${CMAKE_GENERATOR} MATCHES "Visual Studio")
	set(valid_configs Debug Profile Release)
	list(FIND valid_configs "${CMAKE_BUILD_TYPE}" config_index)
	if(${config_index} EQUAL -1)
		message(SEND_ERROR "Build type \"${CMAKE_BUILD_TYPE}\" is not supported, set CMAKE_BUILD_TYPE to one of ${valid_configs}")
	endif()
endif()

# Correct output directory slashes, has to be done after toolchain includes
if (OUTPUT_DIRECTORY)
  string(REPLACE "\\" "/" OUTPUT_DIRECTORY "${OUTPUT_DIRECTORY}")
else()
  # Note that PROJECT_DIR can be different depending on whether we're building the engine or a standalone game / plugin project
  set(OUTPUT_DIRECTORY "${PROJECT_DIR}/bin")
endif()

if(OUTPUT_DIRECTORY_NAME)
  set(OUTPUT_DIRECTORY "${OUTPUT_DIRECTORY}/${OUTPUT_DIRECTORY_NAME}")
  set(OUTPUT_DIRECTORY_NAME "")
endif()

set(BASE_OUTPUT_DIRECTORY         "${OUTPUT_DIRECTORY}")
set(BASE_OUTPUT_DIRECTORY_DEBUG   "${OUTPUT_DIRECTORY}")
set(BASE_OUTPUT_DIRECTORY_PROFILE "${OUTPUT_DIRECTORY}")
set(BASE_OUTPUT_DIRECTORY_RELEASE "${OUTPUT_DIRECTORY}_release")

set(OUTPUT_DIRECTORY_SUFFIX "" CACHE STRING "Optional suffix for the binary output directory")
if(OUTPUT_DIRECTORY_SUFFIX)
  set(OUTPUT_DIRECTORY "${OUTPUT_DIRECTORY}_${OUTPUT_DIRECTORY_SUFFIX}")
endif()

if (OUTPUT_DIRECTORY)
  if(OPTION_DEDICATED_SERVER)
    set(OUTPUT_DIRECTORY "${OUTPUT_DIRECTORY}_dedicated")
  endif()

  message(STATUS "OUTPUT_DIRECTORY=${OUTPUT_DIRECTORY}")
  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${OUTPUT_DIRECTORY}")
  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${OUTPUT_DIRECTORY}")
  set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${OUTPUT_DIRECTORY}/lib")
  set(EXECUTABLE_OUTPUT_PATH "${OUTPUT_DIRECTORY}")

  # Make sure the output directory exists
  file(MAKE_DIRECTORY "${OUTPUT_DIRECTORY}")
endif (OUTPUT_DIRECTORY)

# Prefix all Visual Studio solution folder names with this string
set(VS_FOLDER_PREFIX "BLACKBOX/")

set(MODULES CACHE INTERNAL "List of engine modules being built" FORCE)
set(GAME_MODULES CACHE INTERNAL "List of game modules being built" FORCE)

set(game_folder CACHE INTERNAL "Game folder used for resource files on Windows" FORCE)

# Define Options
get_property(global_defines DIRECTORY "${BLACKBOX_DIR}" PROPERTY COMPILE_DEFINITIONS)
get_property(global_includes DIRECTORY "${BLACKBOX_DIR}" PROPERTY INCLUDE_DIRECTORIES)
get_property(global_links DIRECTORY "${BLACKBOX_DIR}" PROPERTY LINK_DIRECTORIES)

if(NOT EXISTS "${CMAKE_BINARY_DIR}/ProjectCVarOverrides.h")
	file(WRITE "${CMAKE_BINARY_DIR}/ProjectCVarOverrides.h" "")
endif ()
list(APPEND global_defines "BB_CVAR_OVERRIDE_FILE=\"${CMAKE_BINARY_DIR}/ProjectCVarOverrides.h\"")

if(NOT EXISTS "${CMAKE_BINARY_DIR}/ProjectCVarWhitelist.h")
	file(WRITE "${CMAKE_BINARY_DIR}/ProjectCVarWhitelist.h" "")
endif ()
list(APPEND global_defines "BB_CVAR_WHITELIST_FILE=\"${CMAKE_BINARY_DIR}/ProjectCVarWhitelist.h\"")

if(NOT EXISTS "${CMAKE_BINARY_DIR}/ProjectEngineDefineOverrides.h")
	file(WRITE "${CMAKE_BINARY_DIR}/ProjectEngineDefineOverrides.h" "")
endif ()
list(APPEND global_defines "BB_ENGINE_DEFINE_OVERRIDE_FILE=\"${CMAKE_BINARY_DIR}/ProjectEngineDefineOverrides.h\"")

if (OPTION_RUNTIME_CVAR_OVERRIDES)
	list(APPEND global_defines "USE_RUNTIME_CVAR_OVERRIDES")
endif()
# custom defines
list(APPEND global_defines "BLACKBOX_DEFINE")

include("${TOOLS_CMAKE_DIR}/CommonOptions.cmake")
include("${TOOLS_CMAKE_DIR}/CommonMacros.cmake")

# Must be included after SDK_DIR definition
include("${TOOLS_CMAKE_DIR}/CopyFilesToBin.cmake")

if(OPTION_STATIC_LINKING)
	# Enable static libraries
	MESSAGE(STATUS "Use Static Linking (.lib/.a)")
	set(BUILD_SHARED_LIBS FALSE)
else()
	# Enable dynamic libraries
	MESSAGE(STATUS "Use Dynamic Linking (.dll/.so)")
	set(BUILD_SHARED_LIBS TRUE)
endif()

if (OPTION_USE_GUI)
	add_compile_definitions(ENABLE_DEBUG_GUI)
endif()
if (CMAKE_COMPILER_ID STREQUAL "MSVC")
	add_definitions("/ZI")
endif()

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

include("${TOOLS_CMAKE_DIR}/ClangFormat.cmake")
include("${TOOLS_CMAKE_DIR}/Build.cmake")

repository: kovdennik/TestEngine

repo_name: kovdennik/TestEngine

extension: cmake


text:
@article{RN993,
 author = {Alsahafi, A. J. and Cheng, A. C.},
 doi = {10.1016/j.ijid.2016.02.004},
 issn = {1878-3511 (Electronic)
1201-9712 (Linking)},
 journal = {Int J Infect Dis},
 pages = {1-4},
 title = {The epidemiology of Middle East respiratory syndrome coronavirus in the Kingdom of Saudi Arabia, 2012-2015},
 type = {Journal Article},
 url = {http://www.ncbi.nlm.nih.gov/pubmed/26875601},
 volume = {45},
 year = {2016}
}


text:
\begin{thebibliography}{}
%\bibliographystyle{gost780s}

@inproceedings{BK06,
	author = {Berman, Piotr and Karpinski, Marek},
	title = {8/7 approximation Algorithm for {(1,2)-TSP}},
	booktitle = {Proceedings of the Seventeenth Annual ACM-SIAM Symposium on Discrete Algorithm},
	series = {SODA '06},
	year = {2006},
	isbn = {0-89871-605-5},
	location = {Miami, Florida},
	pages = {641--648},
	numpages = {8},
	url = {http://dl.acm.org/citation.cfm?id=1109557.1109627},
	acmid = {1109627},
	publisher = {Society for Industrial and Applied Mathematics},
	address = {Philadelphia, PA, USA},
}

@techreport{C76,
added-at = {2008-01-10T17:04:02.000+0100},
author = {Christofides, Nicos},
biburl = {https://www.bibsonomy.org/bibtex/2107ce5afe4cdd886e5cf863b16533205/jvrb_regulski},
institution = {Graduate School of Industrial Administration, Carnegie Mellon University},
interhash = {17c4f6224da4a8ead47972fd788d7556},
intrahash = {107ce5afe4cdd886e5cf863b16533205},
keywords = {3(2006)12},
number = 388,
timestamp = {2008-01-10T17:06:15.000+0100},
title = {Worst-case analysis of a new heuristic for the travelling salesman problem},
type = {Technical Report},
year = 1976
}

@book{K72,
	author={R. M. Karp},
	title="Reducibility among Combinatorial Problems",
	editor={R. E. Miller, J. W. Thatcher},
	publisher={Plenum},
	address={New York},
	year=1972
}

@Inbook{EK01,
	author="Engebretsen, Lars
	and Karpinski, Marek",
	editor="Orejas, Fernando
	and Spirakis, Paul G.
	and van Leeuwen, Jan",
	title="Approximation Hardness of TSP with Bounded Metrics",
	bookTitle="Automata, Languages and Programming: 28th International Colloquium, ICALP 2001 Crete, Greece, July 8--12, 2001 Proceedings",
	year="2001",
	publisher="Springer Berlin Heidelberg",
	address="Berlin, Heidelberg",
	pages="201--212",
	abstract="The general asymmetric (and metric) TSP is known to be approximable only to within an O(log n) factor, and is also known to be approximable within a constant factor as soon as the metric is bounded. In this paper we study the asymmetric and symmetric TSP problems with bounded metrics and prove approximation lower bounds of 101/100 and 203/202, respectively, for these problems. We prove also approximation lower bounds of 321/320 and 743/742 for the asymmetric and symmetric TSP with distances one and two.",
	isbn="978-3-540-48224-6",
	doi="10.1007/3-540-48224-5_17",
	url="https://doi.org/10.1007/3-540-48224-5_17"
}

@inproceedings{BR05,
	author = {Bl\"{a}ser, M. and Ram, L. Shankar},
	title = {An Improved Approximation Algorithm for TSP with Distances One and Two},
	booktitle = {Proceedings of the 15th International Conference on Fundamentals of Computation Theory},
	series = {FCT'05},
	year = {2005},
	isbn = {3-540-28193-2, 978-3-540-28193-1},
	location = {L\&\#252;beck, Germany},
	pages = {504--515},
	numpages = {12},
	url = {http://dx.doi.org/10.1007/11537311_44},
	doi = {10.1007/11537311_44},
	acmid = {2153515},
	publisher = {Springer-Verlag},
	address = {Berlin, Heidelberg},
}

@article{PY93,
author = {Papadimitriou, Christos H. and Yannakakis, Mihalis},
title = {The Traveling Salesman Problem with Distances One and Two},
journal = {Math. Oper. Res.},
issue_date = {Feb. 1993},
volume = {18},
number = {1},
month = feb,
year = {1993},
issn = {0364-765X},
pages = {1--11},
numpages = {11},
url = {http://dx.doi.org/10.1287/moor.18.1.1},
doi = {10.1287/moor.18.1.1},
acmid = {154541},
publisher = {INFORMS},
address = {Institute for Operations Research and the Management Sciences (INFORMS), Linthicum, Maryland, USA},
keywords = {computational complexity, polynomial-time algorithms, traveling salesman},
}

@incollection{JP85,
	author={D. S. Johnson and C. H. Papadimitriou},
	editor={E. L. Lawler and J. K. Lenstra and A. H. J. Rinnooy Kan and D. B. Shmoys},
	title="The Travelling Salesman Problem",
	booktitle="Computational Complexity",
	year=1985,
	publisher={John Wiley \& Sons},
	address= "Chichester",
	pages=37-85
}

@book{BA09,
author = {Arora, Sanjeev and Barak, Boaz},
title = {Computational Complexity: A Modern Approach},
year = {2009},
isbn = {0521424267, 9780521424264},
edition = {1st},
publisher = {Cambridge University Press},
address = {New York, NY, USA},
}

@book{M17,
	author=" Мусатов, Д. В.",
	title="Сложность вычислений",
	page=46,
}

\end{thebibliography}

license: Unlicense

repository: Wiki-fan/MIPT-all

repo_name: Wiki-fan/MIPT-all


text:
@online{HeusEtal17a,
	Author = {Andrew C. Heusser and Paxton C. Fitzpatrick and Campbell E. Field and Kirsten Ziman and Jeremy R. Manning},
	Title = {Quail Documentation},
	Url = {http://cdl-quail.readthedocs.io/en/latest/},
	Year = 2017}

@online{HeusEtal17,
	Author = {Andrew C. Heusser and Paxton C. Fitzpatrick and Campbell E. Field and Kirsten Ziman and Jeremy R. Manning},
	Doi = {10.5281/zenodo.1003184},
	Title = {Quail: a Python toolbox for analyzing and plotting free recall data},
	Url = {https://doi.org/10.5281/zenodo.1003183},
	Year = 2017}

@book{Ebbi13,
	Address = {New York},
	Author = {H. Ebbinghaus},
	Title = {On Memory: A contribution to experimental psychology},
	Year = 1913}

@incollection{MannEtal15,
	Author = {J. R. Manning and K. A. Norman and M. J. Kahana},
	Booktitle = {The Cognitive Neurosciences, Fifth edition},
	Editor = {M. Gazzaniga},
	Pages = {557--566},
	Publisher = {{MIT} Press},
	Title = {The role of context in episodic memory},
	Year = 2015}

@article{Murd62a,
	Author = {B. B. Murdock},
	Doi = {10.1037/h0045106},
	Journal = {Journal of Experimental Psychology},
	Pages = {482-488},
	Title = {The serial position effect of free recall},
	Volume = 64,
	Year = 1962}

@article{Kaha96,
	Author = {M. J. Kahana},
	Doi = {10.3758/BF03197276},
	Journal = {Memory \& Cognition},
	Title = {Associative retrieval processes in free recall},
	Volume = 24,
	Year = 1996}

@book{Kaha12,
	Author = {M. J. Kahana},
	Journal = {Oxford University Press},
	Title = {Foundations of Human Memory},
	Address = {New York, NY},
	Year = 2012}

@article{Hoga75,
	Author = {R. M. Hogan},
	Date-Modified = {2017-10-09 20:03:48 +0000},
	Doi = {10.3758/BF03212898},
	Journal = {MC},
	Pages = {197--209},
	Title = {Interitem encoding and directed search in free recall},
	Volume = 3,
	Year = 1975}

@misc{WaskEtal16,
	Author = {M. Waskom and O. Botvinnik and D. O'Kane and P. Hobson and S. Lukauskas and D. C. Gemperline and T. Augspurger and Y. Halchenko and J. B. Cole and J. Warmenhoven and J. de Ruiter and C. Pye and S. Hoyer and J. Vanderplas and S. Villalba and G. Kunter and E. Quintero and P. Bachant and M. Martin and K. Meyer and A. Miles and Y. Ram and T. Yarkoni and M. L. Williams and C. Evans and C. Fitzgerald and Brian and C. Fonnesbeck and A. Lee and A. Qalieh},
	Doi = {10.5281/zenodo.54844},
	Title = {Seaborn: v0.7.1},
	Year = 2016}

repository: ContextLab/quail

repo_name: ContextLab/quail

gha_language: Python


text:
package main

import (
	"flag"
	log "github.com/inconshreveable/log15"
	"github.com/tidwall/redcon"
	"github.com/tinylib/msgp/msgp"
	"os"
	"os/signal"
	"syscall"
	"time"
)

var (
	flagAddr = flag.String("addr", ":6488", "redcon port")
	flagDbPath = flag.String("dbPath", "leaderboard.db", "leaderboard db path")
	store = &Store{}
)

func main () {
	flag.Parse()

	leaderboardDB, err := os.OpenFile(*flagDbPath, os.O_RDWR|os.O_CREATE, 0644)
	if err != nil {
		panic(err)
	}
	store = NewStore()
	err = msgp.ReadFile(store, leaderboardDB)

	if err != nil {
		saveDb(store, leaderboardDB)
	}

	log.Info("LeaderboardDB Start", "port", *flagAddr)

	go runRedcon()
	go syncDb(store,leaderboardDB)

	c := make(chan os.Signal, 1)
	signal.Notify(c, syscall.SIGINT, syscall.SIGKILL, syscall.SIGTERM)

	<-c
	saveDb(store,leaderboardDB)

}

func runRedcon() {
	err := redcon.ListenAndServe(*flagAddr, onRedconCommand, onRedconConnect, onRedconClose)
	if err != nil {
		log.Crit("Redcon server startup failed", "error", err.Error())
		os.Exit(1)
	}
}

func syncDb(store *Store, db *os.File) {
	for {
		time.Sleep(5 * time.Minute)
		saveDb(store,db)
	}
}

func saveDb(store *Store, db *os.File) {
	store.mu.Lock()
	msgp.WriteFile(store, db)
	store.mu.Unlock()
}

repository: fatihkahveci/leaderboard-db

repo_name: fatihkahveci/leaderboard-db


text:
SUMMARY = "Set of files for testing losless compression algorithms"
DESCRIPTION = "Set of files for testing losless compression algorithms"
HOMEPAGE = "http://corpus.canterbury.ac.nz"
SECTION = "misc"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6"

S = "${WORKDIR}/corpus"

SRC_URI = "http://corpus.canterbury.ac.nz/resources/calgary.tar.gz"

SRC_URI[md5sum] = "651d06b35d3d39522157cf8dc4a3d01c"
SRC_URI[sha256sum] = "e109eebdc19c5cee533c58bd6a49a4be3a77cc52f84ba234a089148a4f2093b7"

do_unpack () {
	mkdir -p ${S}
	tar -xf ${DL_DIR}/calgary.tar.gz -C ${WORKDIR}/corpus
}

FILES_${PN} = "/lib/firmware/*"

do_install () {
	install -d ${D}/lib/firmware
	install -m 664 ${S}/* ${D}/lib/firmware
}

repository: linkessence/Galileo

repo_name: linkessence/Galileo


text:
@article{maia_chagas_functional_2013,
 journal = {Front. Neural Circuits},
 abstract = {Sensory receptors determine the type and the quantity of information available for perception. Here, we quantified and characterized the information transferred by primary afferents in the rat whisker system using neural system identification. Quantification of ‘how much’ information is conveyed by primary afferents, using the direct method, a classical information theoretic tool, revealed that primary afferents transfer huge amounts of information (up to 529 bits/s). Information theoretic analysis of instantaneous spike-triggered kinematic stimulus features was used to gain functional insight on ‘what’ is coded by primary afferents. Amongst the kinematic variables tested - position, velocity, and acceleration - primary afferent spikes encoded velocity best. The other two variables contribute to information transfer, but only if combined with velocity. We further revealed three additional characteristics that play a role in information transfer by primary afferents. Firstly, primary afferent spikes show preference for well separated multiple stimuli (i.e. well separated sets of combinations of the three instantaneous kinematic variables). Secondly, spikes are sensitive to short strips of the stimulus trajectory (up to 10 ms pre-spike time), and thirdly, they show spike patterns (precise doublet and triplet spiking). In order to deal with these complexities, we used a flexible probabilistic neuron model fitting mixtures of Gaussians to the spike triggered stimulus distributions, which quantitatively captured the contribution of the mentioned features and allowed us to achieve a full functional analysis of the total information rate indicated by the direct method. We found that instantaneous position, velocity, and acceleration explained about 50% of the total information rate. Adding a 10 ms pre-spike interval of stimulus trajectory achieved 80-90%. The final 10-20% were found to be due to non-linear coding by spike bursts.},
 author = {Maia Chagas, André and Theis, Lucas and Sengupta, Biswa and Stüttgen, Maik Christopher and Bethge, Matthias and Schwarz, Cornelius},
 copyright = {Creative Commons Attribution-ShareAlike 4.0 International License (CC-BY-SA)},
 doi = {10.3389/fncir.2013.00190},
 file = {Full Text PDF:files/1365/Maia Chagas et al. - 2013 - Functional analysis of ultra high information rate.pdf:application/pdf},
 issn = {1662-5110},
 keywords = {Vibrissae, Information Theory, primary afferents, rat, spike-triggered mixture model, tactile coding, whisker},
 language = {English},
 title = {Functional analysis of ultra high information rates conveyed by rat vibrissal primary afferents},
 url = {https://www.frontiersin.org/articles/10.3389/fncir.2013.00190/full},
 urldate = {2019-10-10},
 volume = {7},
 year = {2013}
}

repository: amchagas/academic-kickstart

repo_name: amchagas/academic-kickstart


text:
SUMMARY = "Chromium Widget for AGL"
LICENSE = "Apache-2.0"

SRC_URI = " \
	file://${P}.tar.gz \
	"

LIC_FILES_CHKSUM = "file://LICENSE;md5=e72738c318ffac1ce4ee9664f25cdbe0"

RDEPENDS_pn_chromium-widget = "chromium"

inherit aglwgt


text:
@article{Cellinese2021-gp,
  title    = "Phyloreferences: {Tree-Native}, {Reproducible}, and
              {Machine-Interpretable} {Taxon} {Concepts}",
  author   = "Cellinese, Nico and Conix, Stijn and Lapp, Hilmar",
  abstract = "Evolutionary and organismal biology, similar to other fields in
              biology, have become inundated with data. At the same rate, we
              are experiencing a surge in broader evolutionary and ecological
              syntheses for which tree-thinking is the staple for a variety of
              post-tree analyses. To fully take advantage of this wealth of
              data to discover and understand large-scale evolutionary and
              ecological patterns, computational data integration, i.e. the use
              of machines to link data at large scale by shared entities, is
              crucial. The most common shared entity by which evolutionary and
              ecological data need to be linked is the taxon to which they
              belong. In this paper, we propose a set of requirements that a
              system for defining such taxa should meet for computational data
              science: taxon definitions should maintain conceptual
              consistency, be reproducible via a known algorithm, be
              computationally automatable, and be applicable across the tree of
              life. We argue that Linnaean names based in Linnaean taxonomy, by
              far the most prevalent means of linking data to taxa, fail to
              meet these requirements due to fundamental theoretical and
              practical shortfalls. We argue that for the purposes of
              data-integration we should instead use phylogenetic clade
              definitions transformed into formal logic expressions. We call
              such expressions phyloreferences, and argue that, unlike Linnaean
              names, they meet all requirements for effective data-integration.",
  journal  = "Philosophy, Theory and Practice in Biology",
  year     = {2021},
  pages    = {Accepted. Preprint available on {EcoEvoRxiv} at \url{https://doi.org/10.32942/osf.io/57yjs}},
}

@ARTICLE{De_Queiroz1992-oq,
  title     = "Phylogenetic Taxonomy",
  author    = "de Queiroz, Kevin and Gauthier, Jacques",
  journal   = "Annu. Rev. Ecol. Syst.",
  publisher = "Annual Reviews",
  volume    =  23,
  number    =  1,
  pages     = "449--480",
  month     =  nov,
  year      =  1992,
  doi       =  {10.1146/annurev.es.23.110192.002313}
}

@ARTICLE{De_Queiroz1992-vy,
  title   = "Phylogenetic definitions and taxonomic philosophy",
  author  = "de Queiroz, Kevin",
  journal = "Biol. Philos.",
  volume  =  7,
  number  =  3,
  pages   = "295--313",
  year    =  1992,
  doi     =  {10.1007/BF00129972}
}

% The entry below contains non-ASCII chars that could not be converted
% to a LaTeX equivalent.
@ARTICLE{De_Queiroz1990-ho,
  title     = "Phylogeny as a central principle in taxonomy: Phylogenetic
               definitions of taxon names",
  author    = "de Queiroz, Kevin and Gauthier, Jacques",
  abstract  = "Defining the names of taxa in terms of common ancestry, that is,
               using phylogenetic definitions of taxon names, departs from a
               tradition of character-based definitions by granting the concept
               of evolution a central role in taxonomy. Phylogenetic
               definitions bear on other taxonomic principles and practices,
               including the following:(1) Names cannot be applied to
               nonmonophyletic taxa as the result of mistaken ideas about
               relationships or characters. Such mistakes do not affect
               conclusions about the monophyly of taxa but about …",
  journal   = "Syst. Zool.",
  publisher = "Oxford University Press (OUP)",
  volume    =  39,
  number    =  4,
  pages     = "307",
  month     =  dec,
  year      =  1990,
  doi       =  {10.2307/2992353}
}

% The entry below contains non-ASCII chars that could not be converted
% to a LaTeX equivalent.
@ARTICLE{Kazakov2014-uk,
  author    = {Yevgeny Kazakov and Markus Kr{\"{o}}tzsch and Franti{\v{s}}ek
               Siman{\v{c}}{\'{\i}}k},
  title     = {The Incredible {ELK:} From Polynomial Procedures to Efficient
               Reasoning with {$\mathcal{EL}$} Ontologies},
  journal   = {J. Autom. Reasoning},
  volume    = {53},
  number    = {1},
  publisher = {Springer},
  year      = {2014},
  pages     = {1-61},
  doi       = {10.1007/s10817-013-9296-3}
}

@TECHREPORT{W3C_OWL_Working_Group2012-we,
  title       = "{OWL} 2 Web Ontology Language Document Overview",
  author      = "{W3C OWL Working Group}",
  institution = "World Wide Web Consortium (W3C)",
  month       =  dec,
  year        =  2012,
  url          = {https://www.w3.org/TR/owl2-overview/}
}

@ARTICLE{De_Queiroz2007-xm,
  title    = "Toward an integrated system of clade names",
  author   = "de Queiroz, Kevin",
  abstract = "Although the proposition that higher taxa should correspond to
              clades is widely accepted, current nomenclature does not
              distinguish clearly between different clades in nested series. In
              particular, the same name is often applied to a total clade, its
              crown clade, and clades originating with various nodes, branches,
              and apomorphies in between. An integrated system of clade names
              is described based on categories of clades defined with respect
              to lineages that have survived to the present time. In this
              system, the most widely known names are applied to crown clades,
              the names of total clades are formed by adding a standard prefix
              to the names of the corresponding crowns, and the names of
              apomorphy clades describe the specific apomorphies with which
              they originated. Relative to traditional approaches, this
              integrated approach to naming clades is both more precise
              concerning the associations of names with particular clades and
              more efficient with regard to the cognitive effort required to
              recognize the names of corresponding crown and total clades. It
              also seems preferable to five alternatives that could be used to
              make the same distinctions. The integrated system of clade names
              has several advantages, including the facilitation of
              communication among biologists who study distantly related
              clades, promoting a broader conceptualization of the origins of
              distinctive clades of extant organisms and emphasizing the
              continuous nature of evolution.",
  journal  = "Syst. Biol.",
  volume   =  56,
  number   =  6,
  pages    = "956--974",
  month    =  dec,
  year     =  2007,
  language = "en",
  doi      = {10.1080/10635150701656378}
}

@BOOK{De_Queiroz2020-vt,
  title     = "International Code of Phylogenetic Nomenclature ({PhyloCode)}: A
               Phylogenetic Code of Biological Nomenclature",
  author    = "de Queiroz, Kevin and Cantino, Philip D",
  abstract  = "The PhyloCode is a set of principles, rules, and recommendations
               governing phylogenetic nomenclature, a system for naming taxa by
               explicit reference to phylogeny. In contrast, the current
               botanical, zoological, and bacteriological codes define taxa by
               reference to taxonomic ranks (e.g., family, genus) and types.
               This code will govern the names of clades; species names will
               still be governed by traditional codes. The PhyloCode is
               designed so that it can be used concurrently with the rank-based
               codes. It is not meant to replace existing names but to provide
               an alternative system for governing the application of both
               existing and newly proposed names. Key Features Provides clear
               regulations for naming clades Based on expressly phylogenetic
               principles Complements existing codes of nomenclature Eliminates
               the reliance on taxonomic ranks in favor of phylogenetic
               relationships Related Titles: Rieppel, O. Phylogenetic
               Systematics: Haeckel to Hennig (ISBN 978-1-4987-5488-0) de
               Queiroz, K., Cantino, P. D. and Gauthier, J. A. Phylonyms: A
               Companion to the PhyloCode (ISBN 978-1-138-33293-5).",
  publisher = "CRC Press",
  month     =  june,
  year      =  2020,
  language  = "en",
  url       =  {https://www.routledge.com/International-Code-of-Phylogenetic-Nomenclature-PhyloCode/Queiroz-Cantino/p/book/9781138332829},
  isbn      =  9781138332829
}

@ARTICLE{Horridge2011-fu,
  title     = "The {OWL} {API}: A {Java} {API} for {OWL} ontologies",
  author    = "Horridge, Matthew and Bechhofer, Sean",
  journal   = "Semant. Web",
  publisher = "IOS Press",
  volume    =  2,
  number    =  1,
  pages     = "11--21",
  year      =  2011,
  doi       =  {10.3233/SW-2011-0025}
}

@software{gaurav_vaidya_2021_4697965,
  author       = {Gaurav Vaidya and
                  Hilmar Lapp},
  title        = {{phyloref}/{jphyloref}: JPhyloRef v1.1.1},
  month        = aug,
  year         = 2021,
  publisher    = {Zenodo},
  version      = {v1.1.1},
  doi          = {10.5281/zenodo.5178723},
  url          = {https://doi.org/10.5281/zenodo.5178723}
}

repository: phyloref/jphyloref

repo_name: phyloref/jphyloref

gha_language: Java


text:
# Specify your custom search paths for Windows platforms

# The folder where you are keeping all of your libs/includes (if you like keeping them out of your MinGW install).
# This is the path to where I keep my libraries.
set(WINDOWS_LIBRARY_PATH "D:/Env/Libraries/")

# These are the folder names for the libraries you downloaded.
# If you downloaded a different version than the ones listed here, you'll probably need to edit these.
set(WINDOWS_GLUT_FOLDER "freeglut-3.0.0")
set(WINDOWS_GLEW_FOLDER "glew-1.12.0")
#set(WINDOWS_FREETYPE_FOLDER "freetype-2.5.5")
set(WINDOWS_ASSIMP_FOLDER "assimp")
set(WINDOWS_ZLIB_FOLDER "zlib")
set(WINDOWS_FREETYPE_FOLDER "freetype")

repository: JohnRThomas/opengl-examples

repo_name: JohnRThomas/opengl-examples


text:
SUMMARY = "Shell scripts for EMI test"
LICENSE = "GPL-2.0"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6"

SRC_URI = "file://emi_run \
	   file://emi_rs232.sh \
	   file://dupchar.sh \
	   file://emi-test.service"

inherit systemd

do_install() {
    install -d ${D}/tools
    install -m 755 ${WORKDIR}/emi_run ${D}/tools/emi_run
    install -m 755 ${WORKDIR}/emi_rs232.sh ${D}/tools/emi_rs232.sh
    install -m 755 ${WORKDIR}/dupchar.sh ${D}/tools/dupchar.sh

    install -d ${D}${systemd_unitdir}/system
    install -m 0644 ${WORKDIR}/emi-test.service ${D}${systemd_unitdir}/system
}

SYSTEMD_SERVICE_${PN} = "emi-test.service"
SYSTEMD_AUTO_ENABLE_${PN} = "disable"

FILES_${PN} = "/tools"

repository: ADVANTECH-Corp/meta-advantech

repo_name: ADVANTECH-Corp/meta-advantech

branch_name: refs/heads/krogoth

gha_language: Shell


text:
message("When calling setup_boost(BOOST_LIBS, ...), skip part '-lboost_' at each library in list BOOST_LIBS...")

function(assert_boost)
    message("BOOST_FOUND=${BOOST_FOUND}")
    if (NOT BOOST_FOUND)
        message(FATAL_ERROR "ERROR: Boost is not found")
    endif ()
endfunction()

macro(setup_boost)
    unset(BOOST_FOUND CACHE)

    if (DEFINED ARGN1)
        set(BOOST_DIR ${ARGN1})
    else ()
        set(BOOST_DIR ${CMAKE_SOURCE_DIR}/extern/Boost)
    endif ()

    message("BOOST_DIR = ${BOOST_DIR}")

    set(BOOST_LIB_PATH ${BOOST_DIR}/lib)
    set(BOOST_INCLUDE_PATH ${BOOST_DIR}/include)

    set(ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH}:${BOOST_LIB_PATH}")

    MESSAGE(ENV{OPAL_PREFIX=$ENV{OPAL_PREFIX})
    MESSAGE(ENV{LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH})

    option(BOOST_FOUND "Set flag that BOOST is found now" ON)

    message("BOOST_FOUND=${BOOST_FOUND}")
endmacro()

function(target_link_libraries_boost TARGET)

    assert_boost()

    JOIN(BOOST_LIBS -lboost_ "${ARGN}")

    MESSAGE(BOOST_LIBS=${BOOST_LIBS})

    target_link_libraries(${TARGET} ${BOOST_LIBS})

endfunction()

macro(add_executable_boost TARGET SOURCES BOOST_LIBS)

    if (DEFINED ARGN)
        set(BOOST_LIBS ${ARGN})
    else ()
        set(BOOST_LIBS)
    endif ()

    ppr_blue("add_executable_boost : TARGET=${TARGET}; SOURCES=${SOURCES}...")

    assert_boost()

    if (NOT DEFINED PROJECT_NAME)
        message("BOOST project not defined. Set PROJECT(${TARGET})...")
        PROJECT(${TARGET})
    endif ()

    add_executable(${TARGET} ${SOURCES})
    #if(DEFINED FAKE_TARGET_BOOST)
    #  add_dependencies(${TARGET} ${FAKE_TARGET_BOOST})
    #endif()

    # Attach directories
    target_link_directories(${TARGET} PRIVATE ${BOOST_LIB_PATH})
    target_include_directories(${TARGET} PRIVATE ${BOOST_INCLUDE_PATH})
    target_link_libraries_boost(${TARGET} ${BOOST_LIBS})

    set_target_properties(${TARGET} PROPERTIES FOLDER extern)

    target_compile_definitions(${TARGET} PRIVATE
            OPAL_PREFIX=$ENV{OPAL_PREFIX}
            LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}
            WITH_BOOST=1
            )

    config_bin_output(${TARGET})

endmacro()

macro(add_module_boost_python TARGET SOURCES)

    if (DEFINED ARGN)
        set(BOOST_LIBS ${ARGN})
    else ()
        set(BOOST_LIBS)
    endif ()

    ppr_blue("add_module_boost_python : CCSD=${CMAKE_CURRENT_SOURCE_DIR} : TARGET=${TARGET}; SOURCES=${SOURCES}...")

    assert_boost()
    assert_python()

    if (NOT DEFINED PROJECT_NAME)
        message("BOOST project not defined. Set PROJECT(${TARGET})...")
        PROJECT(${TARGET})
    endif ()

    add_module_python(${TARGET} ${SOURCES})
    #if(DEFINED FAKE_TARGET_BOOST)
    #  add_dependencies(${TARGET} ${FAKE_TARGET_BOOST})
    #endif()

    # Attach directories
    target_link_directories(${TARGET} PRIVATE ${BOOST_LIB_PATH})
    target_include_directories(${TARGET} PRIVATE ${BOOST_INCLUDE_PATH})
    target_link_libraries_boost(${TARGET} ${BOOST_LIBS})

    set_target_properties(${TARGET} PROPERTIES FOLDER extern)

    target_compile_definitions(${TARGET} PRIVATE
            LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}
            WITH_BOOST=1
            WITH_BOOST_PYTHON=1
            )

endmacro()

macro(add_python_init TARGET PYTHON_INI)

    get_target_property(RUNTIME_DIR ${TARGET} RUNTIME_OUTPUT_DIRECTORY_${CMAKE_BUILD_TYPE})

endmacro()

macro(add_executable_boost_ompi TARGET SOURCES)

    if (DEFINED ARGN)
        set(BOOST_LIBS ${ARGN})
    else ()
        set(BOOST_LIBS)
    endif ()

    assert_boost()
    assert_ompi()

    ppr_blue("BUILD boost + ompi EXE with BOOST-LIBS: ${BOOST_LIBS}...")

    if (NOT DEFINED PROJECT_NAME)
        message("BOOST + OMPI project not defined. Set PROJECT(${TARGET})...")
        PROJECT(${TARGET})
    endif ()

    add_executable(${TARGET} ${SOURCES})
    #if(DEFINED FAKE_TARGET_OMPI)
    #  add_dependencies(${TARGET} ${FAKE_TARGET_OMPI})
    #endif()

    # Attach directories
    target_link_directories(${TARGET} PRIVATE ${MPI_LIB_PATH} ${BOOST_LIB_PATH})
    target_include_directories(${TARGET} PRIVATE ${MPI_INCLUDE_PATH} ${BOOST_INCLUDE_PATH})

    # Attach openmpi flags
    target_compile_options(${TARGET} PRIVATE ${MPI_CXX_COMPILE_FLAGS})
    target_link_libraries(${TARGET} ${MPI_CXX_LINK_FLAGS})
    target_link_libraries_boost(${TARGET} ${BOOST_LIBS} mpi serialization)

    set_target_properties(${TARGET} PROPERTIES FOLDER extern)

    target_compile_definitions(${TARGET} PRIVATE
            OPAL_PREFIX=$ENV{OPAL_PREFIX}
            LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}
            WITH_BOOS=1
            WITH_BOOST_MPI=1
            )

    config_bin_output(${TARGET})

endmacro()

macro(post_build_run_boost_mpi TARGET NP)

    add_custom_command(TARGET ${TARGET}
            POST_BUILD COMMAND
            echo OPAL_PREFIX=$ENV{OPAL_PREFIX}
            LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}
            ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${NP} $<TARGET_FILE:${TARGET}>)

    add_custom_command(TARGET ${TARGET}
            POST_BUILD COMMAND
            OPAL_PREFIX=$ENV{OPAL_PREFIX}
            LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}
            ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${NP} $<TARGET_FILE:${TARGET}> || true)

endmacro()


text:
DESCRIPTION = "pam_krb5 package"
HOMEPAGE = "http://sourceforge.net/projects/pam-krb5/"
MAINTAINER = "Steven Yang <steven.yang@avocent.com>"
SECTION = "libs"
PRIORITY = "optional"
LICENSE = ""
PR = "r0"

DEPENDS = "libpam krb5"
RDEPENDS = "libpam krb5"

SRC_URI = "${SOURCEFORGE_MIRROR}/pam_krb5/pam_krb5_snap-${PV}.tar.gz;localpath=${DL_DIR}/pam_krb5_snap-${PV}.tar.gz"

S=${WORKDIR}/pam_krb5_snap-${PV}

inherit autotools

#EXTRA_OECONF += "ac_cv_build_pam_krb5afs=yes BUILD_PAM_KRB5AFS=yes"

# This is crude - the modules maybe should each have independent ipks
PACKAGES = "${PN}-dbg ${PN} ${PN}-doc ${PN}-dev ${PN}-locale"

FILES_${PN} = "\
	/lib/security/pam_* \
	/etc/* \
	"
do_configure() {
	oe_runconf
}

do_compile() {
	oe_runmake
}

do_stage() {
	install -m 0755 ${S}/.libs/pam_*.so ${STAGING_LIBDIR}
}

do_install() {
	oe_runmake install DESTDIR=${D}
}


text:
package structure

import (
	"encoding/json"
	"fmt"
)

// 任务集
type MissionPlanning struct {
	Missions []Mission `json:"missions"`
}

// 每个任务由一个主任务和一组子任务组成。
// 主任务有且只有一个，子任务有0个到多个。
type Mission struct {
	TheMainMission MainMission  `json:"mainMissions"`
	TheSubMissions []SubMission `json:"submissions"`
}

// 主任务
type MainMission struct {
	Name string `json:"name"`
	Para string `json:"para"`
}

// 机器人到达指定位置后，执行的子任务
// 目前有：升降杆上升/下降，获取热红外影像，获取温湿度值
type SubMission struct {
	Name string `json:"name"`
	Para string `json:"para"`
}

func (mp *MissionPlanning) UnmarshalJSON(strJSON string) (err error) {
	err = json.Unmarshal([]byte(strJSON), mp)
	if err != nil {
		return fmt.Errorf("MissionPlanning json.Unmarshal error: %v", err)
	} else {
		return nil
	}
}

func (mp *MissionPlanning) MarshalJSON() (strJSON string, err error) {
	data, err := json.MarshalIndent(mp, "", "    ")
	if err != nil {
		return "", fmt.Errorf("MissionPlanning MarshalJSON error: %v", err)
	} else {
		strJSON = string(data)
		return strJSON, nil
	}
}

gha_language: Go


text:
################################################################################
# Author: Urs R. Haehner (haehneru@itp.phys.ethz.ch)
#
# Checks for CUDA and MAGMA and accordingly sets DCA_HAVE_CUDA and DCA_HAVE_MAGMA.
# In addition, set DCA_CUDA_LIBS.

set(CUDA_GPU_ARCH "sm_60" CACHE STRING "Name of the real architecture to build for.")
set(MAGMA_DIR "" CACHE PATH "Path to the MAGMA installation directory. Hint for CMake to find MAGMA.")

set(DCA_HAVE_CUDA FALSE CACHE INTERNAL "")
set(DCA_HAVE_MAGMA FALSE CACHE INTERNAL "")
set(DCA_CUDA_LIBS "" CACHE INTERNAL "")

# Find CUDA.
find_package(CUDA REQUIRED)

if (CUDA_FOUND)
  # set(DCA_HAVE_CUDA TRUE CACHE INTERNAL "")
  # dca_add_haves_define(DCA_HAVE_CUDA)
  list(APPEND DCA_CUDA_LIBS ${CUDA_LIBRARIES} ${CUDA_cusparse_LIBRARY} ${CUDA_cublas_LIBRARY})
  CUDA_INCLUDE_DIRECTORIES(${CUDA_INCLUDE_DIRS})
endif()

# Find MAGMA.
find_library(MAGMA_LIBRARY
  NAMES libmagma.a magma
  HINTS ${MAGMA_DIR}/lib)
find_path(MAGMA_INCLUDE_DIR magma.h HINTS ${MAGMA_DIR}/include)
mark_as_advanced(MAGMA_LIBRARY MAGMA_INCLUDE_DIR)

if (MAGMA_LIBRARY AND MAGMA_INCLUDE_DIR)
  set(DCA_HAVE_MAGMA TRUE CACHE INTERNAL "")
  dca_add_haves_define(DCA_HAVE_MAGMA)
  # magma as of 2.2.0 is setup to build with openmp
  # if FindOpenMP.cmake finds it.
  # This can lead to link problems for us since
  # we don't otherwise have anything to do with openmp.
  # I have built magma without openmp for
  # CI. But if you naively use a random systems
  # magma expect to have a link error.
  list(APPEND DCA_CUDA_LIBS ${MAGMA_LIBRARY} ${CUDA_cusparse_LIBRARY})
  CUDA_INCLUDE_DIRECTORIES(${MAGMA_INCLUDE_DIR})
endif()

# At the moment the GPU code requires MAGMA. Therefore we set DCA_HAVE_CUDA to true, only if both
# CUDA and MAGMA have been found.
if (CUDA_FOUND AND DCA_HAVE_MAGMA)
  set(DCA_HAVE_CUDA TRUE CACHE INTERNAL "")
  dca_add_haves_define(DCA_HAVE_CUDA)
endif()

repository: gbalduzz/DCA

repo_name: gbalduzz/DCA


text:
# Start with the minial image as a base
require minimal-nilrt-image.bb

# Change description
DESCRIPTION = " \
    Fully-featured run-mode image for LabVIEW Comms. Includes drivers, \
    daemons, and other utilities required for RT targets to interact \
    with Comms. \
"

# Append additional software
IMAGE_INSTALL_NODEPS += " \
    lvrt \
    ni-datacomms-lvinterface \
    libninwstreams \
    ni-service-locator \
    ni-varclient-rt \
"

IMAGE_INSTALL_NODEPS_append_x64 = " \
    mt \
    ni-flexrio \
    ni-p2p \
    ni-pxiplatformservices \
    ni-sync \
    niusrprio \
    ni-watchdog \
"

repository: NIwkoe/meta-nilrt

repo_name: NIwkoe/meta-nilrt

branch_name: refs/heads/nilrt/master/sumo


text:
## Robin Sebastian (https://github.com/robseb) (git@robseb.de) 2019-2021

SUMMARY = "Linux Kernel 5.4.74 LTS for Intel PSG (ALTERA) SoC-FPGAs"
DESCRIPTION = "Linux Kernel 5.4.74 LTS for Intel PSG (ALTERA) SoC-FPGAs"

LINUX_VERSION = "5.4.74"
LINUX_VERSION_SUFFIX = "-lts"

SRCREV = "f8f8365913778a80bdc3ddd8548b85298b4588bc"

include linux-altera.inc

FILESEXTRAPATHS_prepend := "${THISDIR}/config:"
LIC_FILES_CHKSUM = "file://COPYING;md5=bbea815ee2795b2f4230826c0c6b8814"

SRC_URI_append_cyclone5 = " file://lbdaf.scc "
SRC_URI_append_arria5 = " file://lbdaf.scc "
SRC_URI_append_arria10 = " file://lbdaf.scc "

repository: BobAfwata/meta-intelfpga

repo_name: BobAfwata/meta-intelfpga