text:
/*
 * Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved.
 *
 * 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.
 */

#include <tencentcloud/zj/v20190121/model/SendSmsRequest.h>
#include <tencentcloud/core/utils/rapidjson/document.h>
#include <tencentcloud/core/utils/rapidjson/writer.h>
#include <tencentcloud/core/utils/rapidjson/stringbuffer.h>

using namespace TencentCloud::Zj::V20190121::Model;
using namespace std;

SendSmsRequest::SendSmsRequest() :
    m_licenseHasBeenSet(false),
    m_phoneHasBeenSet(false),
    m_templateIdHasBeenSet(false),
    m_paramsHasBeenSet(false),
    m_signHasBeenSet(false),
    m_senderIdHasBeenSet(false),
    m_smsTypeHasBeenSet(false),
    m_internationalHasBeenSet(false),
    m_contentHasBeenSet(false)
{
}

string SendSmsRequest::ToJsonString() const
{
    rapidjson::Document d;
    d.SetObject();
    rapidjson::Document::AllocatorType& allocator = d.GetAllocator();

    if (m_licenseHasBeenSet)
    {
        rapidjson::Value iKey(rapidjson::kStringType);
        string key = "License";
        iKey.SetString(key.c_str(), allocator);
        d.AddMember(iKey, rapidjson::Value(m_license.c_str(), allocator).Move(), allocator);
    }

    if (m_phoneHasBeenSet)
    {
        rapidjson::Value iKey(rapidjson::kStringType);
        string key = "Phone";
        iKey.SetString(key.c_str(), allocator);
        d.AddMember(iKey, rapidjson::Value(rapidjson::kArrayType).Move(), allocator);

        for (auto itr = m_phone.begin(); itr != m_phone.end(); ++itr)
        {
            d[key.c_str()].PushBack(rapidjson::Value().SetString((*itr).c_str(), allocator), allocator);
        }
    }

    if (m_templateIdHasBeenSet)
    {
        rapidjson::Value iKey(rapidjson::kStringType);
        string key = "TemplateId";
        iKey.SetString(key.c_str(), allocator);
        d.AddMember(iKey, rapidjson::Value(m_templateId.c_str(), allocator).Move(), allocator);
    }

    if (m_paramsHasBeenSet)
    {
        rapidjson::Value iKey(rapidjson::kStringType);
        string key = "Params";
        iKey.SetString(key.c_str(), allocator);
        d.AddMember(iKey, rapidjson::Value(rapidjson::kArrayType).Move(), allocator);

        for (auto itr = m_params.begin(); itr != m_params.end(); ++itr)
        {
            d[key.c_str()].PushBack(rapidjson::Value().SetString((*itr).c_str(), allocator), allocator);
        }
    }

    if (m_signHasBeenSet)
    {
        rapidjson::Value iKey(rapidjson::kStringType);
        string key = "Sign";
        iKey.SetString(key.c_str(), allocator);
        d.AddMember(iKey, rapidjson::Value(m_sign.c_str(), allocator).Move(), allocator);
    }

    if (m_senderIdHasBeenSet)
    {
        rapidjson::Value iKey(rapidjson::kStringType);
        string key = "SenderId";
        iKey.SetString(key.c_str(), allocator);
        d.AddMember(iKey, rapidjson::Value(m_senderId.c_str(), allocator).Move(), allocator);
    }

    if (m_smsTypeHasBeenSet)
    {
        rapidjson::Value iKey(rapidjson::kStringType);
        string key = "SmsType";
        iKey.SetString(key.c_str(), allocator);
        d.AddMember(iKey, m_smsType, allocator);
    }

    if (m_internationalHasBeenSet)
    {
        rapidjson::Value iKey(rapidjson::kStringType);
        string key = "International";
        iKey.SetString(key.c_str(), allocator);
        d.AddMember(iKey, m_international, allocator);
    }

    if (m_contentHasBeenSet)
    {
        rapidjson::Value iKey(rapidjson::kStringType);
        string key = "Content";
        iKey.SetString(key.c_str(), allocator);
        d.AddMember(iKey, rapidjson::Value(m_content.c_str(), allocator).Move(), allocator);
    }

    rapidjson::StringBuffer buffer;
    rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
    d.Accept(writer);
    return buffer.GetString();
}

string SendSmsRequest::GetLicense() const
{
    return m_license;
}

void SendSmsRequest::SetLicense(const string& _license)
{
    m_license = _license;
    m_licenseHasBeenSet = true;
}

bool SendSmsRequest::LicenseHasBeenSet() const
{
    return m_licenseHasBeenSet;
}

vector<string> SendSmsRequest::GetPhone() const
{
    return m_phone;
}

void SendSmsRequest::SetPhone(const vector<string>& _phone)
{
    m_phone = _phone;
    m_phoneHasBeenSet = true;
}

bool SendSmsRequest::PhoneHasBeenSet() const
{
    return m_phoneHasBeenSet;
}

string SendSmsRequest::GetTemplateId() const
{
    return m_templateId;
}

void SendSmsRequest::SetTemplateId(const string& _templateId)
{
    m_templateId = _templateId;
    m_templateIdHasBeenSet = true;
}

bool SendSmsRequest::TemplateIdHasBeenSet() const
{
    return m_templateIdHasBeenSet;
}

vector<string> SendSmsRequest::GetParams() const
{
    return m_params;
}

void SendSmsRequest::SetParams(const vector<string>& _params)
{
    m_params = _params;
    m_paramsHasBeenSet = true;
}

bool SendSmsRequest::ParamsHasBeenSet() const
{
    return m_paramsHasBeenSet;
}

string SendSmsRequest::GetSign() const
{
    return m_sign;
}

void SendSmsRequest::SetSign(const string& _sign)
{
    m_sign = _sign;
    m_signHasBeenSet = true;
}

bool SendSmsRequest::SignHasBeenSet() const
{
    return m_signHasBeenSet;
}

string SendSmsRequest::GetSenderId() const
{
    return m_senderId;
}

void SendSmsRequest::SetSenderId(const string& _senderId)
{
    m_senderId = _senderId;
    m_senderIdHasBeenSet = true;
}

bool SendSmsRequest::SenderIdHasBeenSet() const
{
    return m_senderIdHasBeenSet;
}

uint64_t SendSmsRequest::GetSmsType() const
{
    return m_smsType;
}

void SendSmsRequest::SetSmsType(const uint64_t& _smsType)
{
    m_smsType = _smsType;
    m_smsTypeHasBeenSet = true;
}

bool SendSmsRequest::SmsTypeHasBeenSet() const
{
    return m_smsTypeHasBeenSet;
}

uint64_t SendSmsRequest::GetInternational() const
{
    return m_international;
}

void SendSmsRequest::SetInternational(const uint64_t& _international)
{
    m_international = _international;
    m_internationalHasBeenSet = true;
}

bool SendSmsRequest::InternationalHasBeenSet() const
{
    return m_internationalHasBeenSet;
}

string SendSmsRequest::GetContent() const
{
    return m_content;
}

void SendSmsRequest::SetContent(const string& _content)
{
    m_content = _content;
    m_contentHasBeenSet = true;
}

bool SendSmsRequest::ContentHasBeenSet() const
{
    return m_contentHasBeenSet;
}

repository: TencentCloud/tencentcloud-sdk-cpp

repo_name: TencentCloud/tencentcloud-sdk-cpp

extension: cpp


text:
package main

import (
	"time"

	"gopkg.in/redis.v6"
)

// https://godoc.org/gopkg.in/redis.v6

//------------- Client ------------------------------------
var _client *redis.ClusterClient

//GetRedisClient 初始化redis连接并返回client
func GetRedisClient() *redis.ClusterClient {
	if _client != nil {
		return _client
	}

	_client = redis.NewClusterClient(&redis.ClusterOptions{
		Addrs: "conf.Config.Redis.Host",
	})
	// log.Debugf("Connect to redis %v", conf.Config.Redis)

	_, err := _client.Ping().Result()
	if err != nil {
		panic(err)
	}
	return _client
}

//------------- Redis Lock ------------------------------------
func RedisLock(key string, expire time.Duration) (bool, error) {
	ok, err := GetRedisClient().SetNX(key, key, expire).Result()
	// log.Debugf("redis lock %v", key)
	return ok, err
}

func RedisUnLock(key string) {
	GetRedisClient().Del(key)
	// log.Debugf("redis unlock %v", key)
	return
}

//-------------- Redis HTML Server ----------------------------
func RedisSetStaticHtml(key, html string) (err error) {
	return
}

func RedistGetStaticHTML(key string) (html string, err error) {
	return
}

func main() {
	//
}

license: MIT

repository: charleswan/golang-src

license_type: permissive

repo_name: charleswan/golang-src

branch_name: refs/heads/master

extension: go


text:
package main

import (
	"fmt"
	"log"
	"net/http"

	"github.com/go-redis/redis"
)

func main() {
	client := redis.NewClient(&redis.Options{
		Addr: "localhost:6379",
	})

	http.HandleFunc("/ping", func(w http.ResponseWriter, r *http.Request) {
		w.Header().Set("Content-Type", "text/plain")
		status, err := client.Ping().Result()
		if err != nil {
			log.Printf("ping: error from redis: %v", err)
			w.WriteHeader(500)
			fmt.Fprintf(w, "Ping oopsie: %v\n", err)
			return
		}
		fmt.Fprintf(w, "Ok\nStatus: %v\n", status)
		return
	})
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		w.Header().Set("Content-Type", "text/plain")
		n, err := client.Incr("hits").Result()
		if err != nil {
			log.Printf("error from redis: %v", err)
			w.WriteHeader(500)
			fmt.Fprintf(w, "oopsie: %v\n", err)
			return
		}
		fmt.Fprintf(w, "Hits: %v\n", n)
		return
	})

	addr := "127.0.0.1:8080"
	log.Printf("Listening on http://%s", addr)
	log.Fatal(http.ListenAndServe(addr, nil))
}

license: Unlicense

repository: schmichael/rediweb

repo_name: schmichael/rediweb


text:
// *****************************************************************************
/*!
  \file      src/UnitTest/tests/Mesh/TestReorder.h
  \copyright 2012-2015, J. Bakosi, 2016-2018, Los Alamos National Security, LLC.
  \brief     Unit tests for Mesh/Reorder
  \details   Unit tests for Mesh/Reorder. All unit tests start from simple mesh
     connectivities defined in the code. The tetrahedron mesh in Gmsh ASCII
     format is as follows. Note that ids start from zero in the code, but from
     one in Gmsh.
     \code{.sh}
       $MeshFormat
       2.2 0 8
       $EndMeshFormat
       $Nodes
       14
       1 0 0 0
       2 1 0 0
       3 1 1 0
       4 0 1 0
       5 0 0 1
       6 1 0 1
       7 1 1 1
       8 0 1 1
       9 0.5 0.5 0
       10 0.5 0.5 1
       11 0.5 0 0.5
       12 1 0.5 0.5
       13 0.5 1 0.5
       14 0 0.5 0.5
       $EndNodes
       $Elements
       24
       1 4 1 0 12 14 9 11
       2 4 1 0 10 14 13 12
       3 4 1 0 14 13 12 9
       4 4 1 0 10 14 12 11
       5 4 1 0 1 14 5 11
       6 4 1 0 7 6 10 12
       7 4 1 0 14 8 5 10
       8 4 1 0 8 7 10 13
       9 4 1 0 7 13 3 12
       10 4 1 0 1 4 14 9
       11 4 1 0 13 4 3 9
       12 4 1 0 3 2 12 9
       13 4 1 0 4 8 14 13
       14 4 1 0 6 5 10 11
       15 4 1 0 1 2 9 11
       16 4 1 0 2 6 12 11
       17 4 1 0 6 10 12 11
       18 4 1 0 2 12 9 11
       19 4 1 0 5 14 10 11
       20 4 1 0 14 8 10 13
       21 4 1 0 13 3 12 9
       22 4 1 0 7 10 13 12
       23 4 1 0 14 4 13 9
       24 4 1 0 14 1 9 11
       $EndElements
     \endcode
     Here is the simple triangle mesh used below by the unit tests in Gmsh ASCII
     format. Note that ids start from zero in the code, but from one in Gmsh.
     \code{.sh}
       $MeshFormat
       2.2 0 8
       $EndMeshFormat
       $Nodes
       14
       1 0 0 0
       2 1 0 0
       3 1 1 0
       4 0 1 0
       5 0 0 1
       6 1 0 1
       7 1 1 1
       8 0 1 1
       9 0.5 0.5 0
       10 0.5 0.5 1
       11 0.5 0 0.5
       12 1 0.5 0.5
       13 0.5 1 0.5
       14 0 0.5 0.5
       $EndNodes
       $Elements
       24
       1 2 2 0 1 1 9 2
       2 2 2 0 1 1 4 9
       3 2 2 0 1 2 9 3
       4 2 2 0 1 3 9 4
       5 2 2 0 2 5 6 10
       6 2 2 0 2 5 10 8
       7 2 2 0 2 6 7 10
       8 2 2 0 2 7 8 10
       9 2 2 0 3 1 2 11
       10 2 2 0 3 1 11 5
       11 2 2 0 3 2 6 11
       12 2 2 0 3 5 11 6
       13 2 2 0 4 2 3 12
       14 2 2 0 4 2 12 6
       15 2 2 0 4 3 7 12
       16 2 2 0 4 6 12 7
       17 2 2 0 5 3 4 13
       18 2 2 0 5 3 13 7
       19 2 2 0 5 4 8 13
       20 2 2 0 5 7 13 8
       21 2 2 0 6 1 14 4
       22 2 2 0 6 1 5 14
       23 2 2 0 6 4 14 8
       24 2 2 0 6 5 8 14
       $EndElements
     \endcode
*/
// *****************************************************************************
#ifndef test_Reorder_h
#define test_Reorder_h

#include "NoWarning/tut.h"

#include "Reorder.h"
#include "DerivedData.h"

namespace tut {

//! All tests in group inherited from this base
struct Reorder_common {};

// Test group shortcuts
// The 2nd template argument is the max number of tests in this group. If
// omitted, the default is 50, specified in tut/tut.hpp.
using Reorder_group = test_group< Reorder_common, MAX_TESTS_IN_GROUP >;
using Reorder_object = Reorder_group::object;

//! Define test group
static Reorder_group Reorder( "Mesh/Reorder" );

//! Test definitions for group

//! Attempt to shift empty container using shiftToZero
template<> template<>
void Reorder_object::test< 1 >() {
  set_test_name( "shiftToZero graceful with empty inpoel" );

  // Attempt to shift node IDs with empty connectivity. If some error happens or an
  // exception is throw that will go to the screen; no further tests are
  // necessary.
  std::vector< std::size_t > empty;
  tk::shiftToZero( empty );
}

//! Shift node ids to zero in line mesh
template<> template<>
void Reorder_object::test< 2 >() {
  set_test_name( "shiftToZero for lines" );

  // Mesh connectivity for simple line-only mesh
  std::vector< std::size_t > inpoel { 1, 2,
                                      2, 3,
                                      3, 4,
                                      4, 1,
                                      5, 6,
                                      6, 7,
                                      7, 8,
                                      8, 5,
                                      1, 5,
                                      2, 6,
                                      3, 7,
                                      4, 8 };

  // Shift node IDs to start from zero
  tk::shiftToZero( inpoel );

  // Test new extents of node IDs in element connectivity
  auto min = std::min_element( begin(inpoel), end(inpoel) );
  ensure_equals( "node ids should start from zero", *min, 0 );
}

//! Shift node ids to zero in triangle mesh
template<> template<>
void Reorder_object::test< 3 >() {
  set_test_name( "shiftToZero for triangles" );

  // Mesh connectivity for simple triangle-only mesh
  std::vector< std::size_t > inpoel { 1,  9,  2,
                                      1,  4,  9,
                                      2,  9,  3,
                                      3,  9,  4,
                                      5,  6, 10,
                                      5, 10,  8,
                                      6,  7, 10,
                                      7,  8, 10,
                                      1,  2, 11,
                                      1, 11,  5,
                                      2,  6, 11,
                                      5, 11,  6,
                                      2,  3, 12,
                                      2, 12,  6,
                                      3,  7, 12,
                                      6, 12,  7,
                                      3,  4, 13,
                                      3, 13,  7,
                                      4,  8, 13,
                                      7, 13,  8,
                                      1, 14,  4,
                                      1,  5, 14,
                                      4, 14,  8,
                                      5,  8, 14 };

  // Shift node IDs to start from zero
  tk::shiftToZero( inpoel );

  // Test new extents of node IDs in element connectivity
  auto min = std::min_element( begin(inpoel), end(inpoel) );
  ensure_equals( "node ids should start from zero", *min, 0 );
}

//! Shift node ids to zero in tetrahedron-only mesh
template<> template<>
void Reorder_object::test< 4 >() {
  set_test_name( "shiftToZero for tetrahedra" );

  // Mesh connectivity for simple tetrahedron-only mesh
  std::vector< std::size_t > inpoel { 12, 14,  9, 11,
                                      10, 14, 13, 12,
                                      14, 13, 12,  9,
                                      10, 14, 12, 11,
                                      1,  14,  5, 11,
                                      7,   6, 10, 12,
                                      14,  8,  5, 10,
                                      8,   7, 10, 13,
                                      7,  13,  3, 12,
                                      1,   4, 14,  9,
                                      13,  4,  3,  9,
                                      3,   2, 12,  9,
                                      4,   8, 14, 13,
                                      6,   5, 10, 11,
                                      1,   2,  9, 11,
                                      2,   6, 12, 11,
                                      6,  10, 12, 11,
                                      2,  12,  9, 11,
                                      5,  14, 10, 11,
                                      14,  8, 10, 13,
                                      13,  3, 12,  9,
                                      7,  10, 13, 12,
                                      14,  4, 13,  9,
                                      14,  1,  9, 11 };

  // Shift node IDs to start from zero
  tk::shiftToZero( inpoel );

  // Test new extents of node IDs in element connectivity
  auto min = std::min_element( begin(inpoel), end(inpoel) );
  ensure_equals( "node ids should start from zero", *min, 0 );
}

//! Renumber triangle mesh
template<> template<>
void Reorder_object::test< 5 >() {
  set_test_name( "renumber triangle mesh" );

  // Mesh connectivity for simple triangle mesh
  std::vector< std::size_t > inpoel { 1,  9,  2,
                                      1,  4,  9,
                                      2,  9,  3,
                                      3,  9,  4,
                                      5,  6, 10,
                                      5, 10,  8,
                                      6,  7, 10,
                                      7,  8, 10,
                                      1,  2, 11,
                                      1, 11,  5,
                                      2,  6, 11,
                                      5, 11,  6,
                                      2,  3, 12,
                                      2, 12,  6,
                                      3,  7, 12,
                                      6, 12,  7,
                                      3,  4, 13,
                                      3, 13,  7,
                                      4,  8, 13,
                                      7, 13,  8,
                                      1, 14,  4,
                                      1,  5, 14,
                                      4, 14,  8,
                                      5,  8, 14 };

  // Shift node IDs to start from zero
  tk::shiftToZero( inpoel );

  // Renumber triangle mesh
  const auto psup = tk::genPsup( inpoel, 3, tk::genEsup( inpoel, 3 ) );
  auto map = tk::renumber( psup );
  tk::remap( inpoel, map );

  // Test the result of reordering
  std::vector< std::size_t > correct_renumbered_inpoel{ 0, 4, 1,
                                                        0, 2, 4,
                                                        1, 4, 7,
                                                        7, 4, 2,
                                                        3, 8, 12,
                                                        3, 12, 10,
                                                        8, 13, 12,
                                                        13, 10, 12,
                                                        0, 1, 5,
                                                        0, 5, 3,
                                                        1, 8, 5,
                                                        3, 5, 8,
                                                        1, 7, 9,
                                                        1, 9, 8,
                                                        7, 13, 9,
                                                        8, 9, 13,
                                                        7, 2, 11,
                                                        7, 11, 13,
                                                        2, 10, 11,
                                                        13, 11, 10,
                                                        0, 6, 2,
                                                        0, 3, 6,
                                                        2, 6, 10,
                                                        3, 10, 6 };
  ensure( "reordered triangle mesh incorrect",
          inpoel == correct_renumbered_inpoel );
}

//! Renumber tetrahedron mesh
template<> template<>
void Reorder_object::test< 6 >() {
  set_test_name( "renumber tetrahedron mesh" );

  // Mesh connectivity for simple tetrahedron-only mesh
  std::vector< std::size_t > inpoel { 12, 14,  9, 11,
                                      10, 14, 13, 12,
                                      14, 13, 12,  9,
                                      10, 14, 12, 11,
                                      1,  14,  5, 11,
                                      7,   6, 10, 12,
                                      14,  8,  5, 10,
                                      8,   7, 10, 13,
                                      7,  13,  3, 12,
                                      1,   4, 14,  9,
                                      13,  4,  3,  9,
                                      3,   2, 12,  9,
                                      4,   8, 14, 13,
                                      6,   5, 10, 11,
                                      1,   2,  9, 11,
                                      2,   6, 12, 11,
                                      6,  10, 12, 11,
                                      2,  12,  9, 11,
                                      5,  14, 10, 11,
                                      14,  8, 10, 13,
                                      13,  3, 12,  9,
                                      7,  10, 13, 12,
                                      14,  4, 13,  9,
                                      14,  1,  9, 11 };

  // Shift node IDs to start from zero
  tk::shiftToZero( inpoel );

  // Renumber triangle mesh
  const auto psup = tk::genPsup( inpoel, 4, tk::genEsup( inpoel, 4 ) );
  auto map = tk::renumber( psup );
  tk::remap( inpoel, map );

  // Test the result of reordering
  std::vector< std::size_t > correct_renumbered_inpoel{ 9, 6, 4, 5,
                                                        12, 6, 11, 9,
                                                        6, 11, 9, 4,
                                                        12, 6, 9, 5,
                                                        0, 6, 3, 5,
                                                        13, 8, 12, 9,
                                                        6, 10, 3, 12,
                                                        10, 13, 12, 11,
                                                        13, 11, 7, 9,
                                                        0, 2, 6, 4,
                                                        11, 2, 7, 4,
                                                        7, 1, 9, 4,
                                                        2, 10, 6, 11,
                                                        8, 3, 12, 5,
                                                        0, 1, 4, 5,
                                                        1, 8, 9, 5,
                                                        8, 12, 9, 5,
                                                        1, 9, 4, 5,
                                                        3, 6, 12, 5,
                                                        6, 10, 12, 11,
                                                        11, 7, 9, 4,
                                                        13, 12, 11, 9,
                                                        6, 2, 11, 4,
                                                        6, 0, 4, 5 };

  ensure( "reordered tetrahedron mesh incorrect",
          inpoel == correct_renumbered_inpoel );
}

} // tut::

#endif // test_Reorder_h

repository: evan-charmworks/quinoa

repo_name: evan-charmworks/quinoa

extension: h


text:
package main

import (
	"flag"
	"github.com/esrrhs/gohome/common"
	"github.com/esrrhs/gohome/loggo"
	"github.com/esrrhs/gohome/network"
	"io"
	"net"
)

func main() {

	defer common.CrashLog()

	listen := flag.String("l", "", "listen addr")
	target := flag.String("t", "", "target addr")
	nolog := flag.Int("nolog", 0, "write log file")
	noprint := flag.Int("noprint", 0, "print stdout")
	loglevel := flag.String("loglevel", "info", "log level")

	flag.Parse()

	if *listen == "" || *target == "" {
		flag.Usage()
		return
	}

	level := loggo.LEVEL_INFO
	if loggo.NameToLevel(*loglevel) >= 0 {
		level = loggo.NameToLevel(*loglevel)
	}
	loggo.Ini(loggo.Config{
		Level:     level,
		Prefix:    "yellowsocks",
		MaxDay:    3,
		NoLogFile: *nolog > 0,
		NoPrint:   *noprint > 0,
	})
	loggo.Info("start...")

	tcpaddr, err := net.ResolveTCPAddr("tcp", *listen)
	if err != nil {
		loggo.Error("listen fail %s", err)
		return
	}

	tcplistenConn, err := net.ListenTCP("tcp", tcpaddr)
	if err != nil {
		loggo.Error("Error listening for tcp packets: %s", err)
		return
	}
	loggo.Info("listen ok %s", tcpaddr.String())

	dstaddr, err := net.ResolveTCPAddr("tcp", *target)
	if err != nil {
		loggo.Error("target fail %s", err)
		return
	}
	loggo.Info("target %s", dstaddr.String())

	for {
		conn, err := tcplistenConn.AcceptTCP()
		if err != nil {
			loggo.Info("Error accept tcp %s", err)
			continue
		}

		go process(conn, dstaddr)
	}
}

func process(conn *net.TCPConn, socks5addr *net.TCPAddr) {

	defer common.CrashLog()

	loggo.Info("start conn from %s", conn.RemoteAddr())

	host, port, err := getOriginalDst(conn)

	loggo.Info("parse conn from %s -> %s:%d", conn.RemoteAddr(), host, port)

	socks5conn, err := net.DialTCP("tcp", nil, socks5addr)
	if err != nil {
		loggo.Info("dial socks5 conn fail %s %v", socks5addr, err)
		return
	}

	loggo.Info("dial socks5 conn ok %s -> %s:%d", conn.RemoteAddr(), host, port)

	err = network.Sock5Handshake(socks5conn, 0, "", "")
	if err != nil {
		loggo.Error("sock5Handshake fail %s", err)
		return
	}

	loggo.Info("Handshake socks5 conn ok %s -> %s:%d", conn.RemoteAddr(), host, port)

	err = network.Sock5SetRequest(socks5conn, host, port, 0)
	if err != nil {
		conn.Close()
		loggo.Error("sock5SetRequest fail %s", err)
		return
	}

	loggo.Info("SetRequest socks5 conn ok %s -> %s:%d", conn.RemoteAddr(), host, port)

	go transfer(conn, socks5conn, conn.RemoteAddr().String(), socks5conn.RemoteAddr().String())
	go transfer(socks5conn, conn, socks5conn.RemoteAddr().String(), conn.RemoteAddr().String())

	loggo.Info("process conn ok %s -> %s:%d", conn.RemoteAddr(), host, port)
}

func transfer(destination io.WriteCloser, source io.ReadCloser, dst string, src string) {
	defer common.CrashLog()
	defer destination.Close()
	defer source.Close()
	loggo.Info("begin transfer from %s -> %s", src, dst)
	io.Copy(destination, source)
	loggo.Info("end transfer from %s -> %s", src, dst)
}

repository: esrrhs/yellowsocks

repo_name: esrrhs/yellowsocks


text:
require ${COREBASE}/meta/recipes-extended/bash/bash.inc

LICENSE = "GPLv2+"
LIC_FILES_CHKSUM = "file://COPYING;md5=fd5d9bcabd8ed5a54a01ce8d183d592a"

PR = "r11"

SRC_URI = "${GNU_MIRROR}/bash/bash-${PV}.tar.gz;name=tarball \
           ${GNU_MIRROR}/bash/bash-3.2-patches/bash32-049;apply=yes;striplevel=0;name=patch001 \
           ${GNU_MIRROR}/bash/bash-3.2-patches/bash32-050;apply=yes;striplevel=0;name=patch002 \
           ${GNU_MIRROR}/bash/bash-3.2-patches/bash32-051;apply=yes;striplevel=0;name=patch003"

SRC_URI[tarball.md5sum] = "338dcf975a93640bb3eaa843ca42e3f8"
SRC_URI[tarball.sha256sum] = "128d281bd5682ba5f6953122915da71976357d7a76490d266c9173b1d0426348"
SRC_URI[patch001.md5sum] = "af571a2d164d5abdcae4499e94e8892c"
SRC_URI[patch001.sha256sum] = "b1217ed94bdb95dc878fa5cabbf8a164435eb0d9da23a392198f48566ee34a2f"
SRC_URI[patch002.md5sum] = "8443d4385d73ec835abe401d90591377"
SRC_URI[patch002.sha256sum] = "081bb03c580ecee63ba03b40beb3caf509eca29515b2e8dd3c078503609a1642"
SRC_URI[patch003.md5sum] = "15c6653042e9814aa87120098fc7a849"
SRC_URI[patch003.sha256sum] = "354886097cd95b4def77028f32ee01e2e088d58a98184fede9d3ce9320e218ef"

SRC_URI[md5sum] = "338dcf975a93640bb3eaa843ca42e3f8"
SRC_URI[sha256sum] = "128d281bd5682ba5f6953122915da71976357d7a76490d266c9173b1d0426348"

extension: bb


text:
package sim

import (
	"fmt"
	"time"

	"github.com/itglobal/dashboard/tile"
)

const animStepDuration = 1 * time.Second
const stateStepDuration = 5 * time.Second

type simProvider struct {
	uid     string
	ids     []tile.ID
	manager tile.Manager
}

// Gets provider unique ID
func (p *simProvider) ID() string {
	return p.uid
}

// Gets provider type key
func (p *simProvider) Type() string {
	return providerType
}

// Initializes a provider
func (p *simProvider) Init() error {
	op := p.manager.BeginUpdate(p)

	for i := 0; i < len(p.ids); i++ {
		p.ids[i] = tile.ID(newUID())

		t := op.AddOrUpdateTile(p.ids[i])

		t.SetType(tile.TypeTextStatusProgress)
		t.SetSize(tile.Size2x)
		t.SetState(tile.StateError)
		t.Clear()
		t.SetTitleText(fmt.Sprintf("generated item %d", i))
	}

	op.EndUpdate()

	for i, id := range p.ids {
		go p.animate(i, id)
	}

	return nil
}

type animationFunc func(p *simProvider, id tile.ID)

func pendingAnimation(p *simProvider, id tile.ID) {
	for progress := 0; progress <= 100; progress += 10 {

		op := p.manager.BeginUpdate(p)

		t := op.AddOrUpdateTile(id)
		t.Clear()
		t.SetState(tile.StateIndeterminate)
		t.SetDescriptionText(fmt.Sprintf("Running (%d%%)", progress))
		t.SetStatusValue(progress)

		op.EndUpdate()

		time.Sleep(animStepDuration)
	}
}

func goodAnimation(p *simProvider, id tile.ID) {
	op := p.manager.BeginUpdate(p)

	t := op.AddOrUpdateTile(id)
	t.Clear()
	t.SetState(tile.StateSuccess)
	t.SetDescriptionText("Successful result text content")

	op.EndUpdate()

	time.Sleep(stateStepDuration)
}

func badAnimation(p *simProvider, id tile.ID) {
	op := p.manager.BeginUpdate(p)

	t := op.AddOrUpdateTile(id)
	t.Clear()
	t.SetState(tile.StateError)
	t.SetDescriptionText("Unsuccessful result text content")

	op.EndUpdate()

	time.Sleep(stateStepDuration)
}

var animationSteps = []animationFunc{pendingAnimation, goodAnimation, pendingAnimation, badAnimation}

func (p *simProvider) animate(index int, id tile.ID) {
	index = index % len(animationSteps)

	for {
		animationSteps[index](p, id)

		index++
		if index >= len(animationSteps) {
			index = 0
		}
	}
}

repository: ITGlobal/dashboard

repo_name: ITGlobal/dashboard

gha_license_id: MIT

gha_language: Go


text:
// +build sgx_enclave

package adapters

/*
#cgo LDFLAGS: -L../sgx/target/ -ladapters
#include <stdlib.h>
#include "../sgx/libadapters/adapters.h"
*/
import "C"

import (
	"nulink/core/store"
	"nulink/core/store/models"
	"encoding/json"
	"fmt"
	"unsafe"

	"github.com/pkg/errors"
)

// Perform returns the input's "result" field, multiplied times the adapter's
// "times" field.
//
// For example, if input value is "99.994" and the adapter's "times" is
// set to "100", the result's value will be "9999.4".
func (ma *Multiply) Perform(input models.RunInput, _ *store.Store) models.RunOutput {
	adapterJSON, err := json.Marshal(ma)
	if err != nil {
		return models.NewRunOutputError(err)
	}
	inputJSON, err := json.Marshal(input)
	if err != nil {
		return models.NewRunOutputError(err)
	}

	cAdapter := C.CString(string(adapterJSON))
	defer C.free(unsafe.Pointer(cAdapter))
	cInput := C.CString(string(inputJSON))
	defer C.free(unsafe.Pointer(cInput))

	buffer := make([]byte, 8192)
	output := (*C.char)(unsafe.Pointer(&buffer[0]))
	bufferCapacity := C.int(len(buffer))
	outputLen := C.int(0)
	outputLenPtr := (*C.int)(unsafe.Pointer(&outputLen))

	if _, err = C.multiply(cAdapter, cInput, output, bufferCapacity, outputLenPtr); err != nil {
		return models.NewRunOutputError(fmt.Errorf("SGX multiply: %v", err))
	}

	sgxResult := C.GoStringN(output, outputLen)
	var result models.RunResult
	if err := json.Unmarshal([]byte(sgxResult), &result); err != nil {
		return models.NewRunOutputError(fmt.Errorf("unmarshaling SGX result: %v", err))
	}

	if result.ErrorMessage.Valid {
		return models.NewRunOutputError(errors.New(result.ErrorMessage.String))
	}
	return models.NewRunOutputComplete(result.Data)
}

repository: smartercontractkits/nulink

repo_name: smartercontractkits/nulink

branch_name: refs/heads/develop


text:
# Base this image on rpi-hwup-image
include rpi-hwup-image.bb

SPLASH = "psplash-raspberrypi"

IMAGE_FEATURES += "ssh-server-dropbear splash"

repository: rzr/meta-raspberrypi

repo_name: rzr/meta-raspberrypi

gha_language: C


text:
package director
/*
* File Generated by enaml generator
* !!! Please do not edit this file !!!
*/
type UserManagement struct {

	/*Uaa - Descr: Symmetric key to verify Uaa token Default: <nil>
*/
	Uaa *Uaa `yaml:"uaa,omitempty"`

	/*Local - Descr: List of users that can authenticate with director in non-Uaa mode Default: <nil>
*/
	Local *Local `yaml:"local,omitempty"`

	/*Provider - Descr: User management implementation (local|uaa) Default: local
*/
	Provider interface{} `yaml:"provider,omitempty"`

}

repository: s-matyukevich/omg-cli

repo_name: s-matyukevich/omg-cli


text:
set(DEFAULT_PROJECT_OPTIONS
    CXX_STANDARD                    11
    LINKER_LANGUAGE                 "CXX"
    # This property is True by default for SHARED and MODULE library targets and False otherwise
    POSITION_INDEPENDENT_CODE       ON
)

# TODO divide compile options in each build type
set(DEFAULT_COMPILE_OPTIONS
    # -Wall
    # Code coverage options
    -g
    -O0
    # -fprofile-arcs
    # -ftest-coverage
    --coverage
)

# TODO divide linker options in each build type
set(DEFAULT_LINKER_OPTIONS
    # -fprofile-arcs  # implies -lgcov
    --coverage
)

extension: cmake


text:
DESCRIPTION = "Open Source multimedia player."
SECTION = "multimedia"
HOMEPAGE = "http://www.mplayerhq.hu/"
DEPENDS = "libvpx live555 libdvdread libtheora virtual/libsdl ffmpeg xsp zlib \
           libpng jpeg liba52 freetype fontconfig alsa-lib lzo ncurses \
           libxv virtual/libx11 libass speex faad2"

RDEPENDS_${PN} = "mplayer-common"
PROVIDES = "mplayer"
RPROVIDES_${PN} = "mplayer"
RCONFLICTS_${PN} = "mplayer"

LICENSE = "GPLv3"
LIC_FILES_CHKSUM = "file://LICENSE;md5=d32239bcb673463ab874e80d47fae504"

SRC_URI = "git://repo.or.cz/mplayer.git;branch=master \
           file://cross.compile.codec-cfg.patch \
"

SRCREV = "e3f5043233336d8b4b0731c6a8b42a8fda5535ac"

ARM_INSTRUCTION_SET = "arm"

PV = "2.0+gitr${SRCPV}"
PR = "r10"

PARALLEL_MAKE = ""

S = "${WORKDIR}/git"

FILES_${PN} = "${bindir}/mplayer ${libdir} /usr/etc/mplayer/"
CONFFILES_${PN} += "/usr/etc/mplayer/input.conf \
                    /usr/etc/mplayer/example.conf \
                    /usr/etc/mplayer/codecs.conf \
"

inherit autotools pkgconfig

EXTRA_OECONF = " \
    --prefix=/usr \
    --mandir=${mandir} \
    --target=${SIMPLE_TARGET_SYS} \
    \
    --disable-lirc \
    --disable-lircc \
    --disable-joystick \
    --disable-vm \
    --disable-xf86keysym \
    --enable-tv \
    --disable-tv-v4l1 \
    --enable-tv-v4l2 \
    --disable-tv-bsdbt848 \
    --enable-rtc \
    --enable-networking \
    --disable-smb \
    --enable-live \
    --disable-dvdnav \
    --enable-dvdread \
    --disable-dvdread-internal \
    --disable-libdvdcss-internal \
    --disable-cdparanoia \
    --enable-freetype \
    --enable-sortsub \
    --disable-fribidi \
    --disable-enca \
    --disable-ftp \
    --disable-vstream \
    \
    --disable-gif \
    --enable-png \
    --enable-jpeg \
    --disable-libcdio \
    --disable-qtx \
    --disable-xanim \
    --disable-real \
    --disable-xvid \
    \
    --enable-speex \
    --enable-theora \
    --disable-ladspa \
    --disable-libdv \
    --enable-mad \
    --disable-xmms \
    --disable-musepack \
    \
    --disable-gl \
    --disable-vesa \
    --disable-svga \
    --enable-sdl \
    --disable-aa \
    --disable-caca \
    --disable-ggi \
    --disable-ggiwmh \
    --disable-directx \
    --disable-dxr3 \
    --disable-dvb \
    --disable-mga \
    --disable-xmga \
    --enable-xv \
    --disable-vm \
    --disable-xinerama \
    --enable-x11 \
    --enable-fbdev \
    --disable-3dfx \
    --disable-tdfxfb \
    --disable-s3fb \
    --disable-directfb \
    --disable-bl \
    --disable-tdfxvid \
    --disable-tga \
    --disable-pnm \
    --disable-md5sum \
    \
    --enable-alsa \
    --enable-ossaudio \
    --disable-arts \
    --disable-esd \
    --disable-pulse \
    --disable-jack \
    --disable-openal \
    --disable-nas \
    --disable-sgiaudio \
    --disable-sunaudio \
    --disable-win32waveout \
    --enable-select \
    --enable-libass \
    \
    --extra-libs=' -lXext -lX11 -lBasicUsageEnvironment -lUsageEnvironment -lgroupsock -lliveMedia -lstdc++ -lvorbis ' \
"

EXTRA_OECONF_append_armv6 = " --enable-armv6"
EXTRA_OECONF_append_armv7a = " --enable-armv6 --enable-neon"

PACKAGECONFIG[mad] = "--enable-mad,--disable-mad,libmad"
PACKAGECONFIG[a52] = "--enable-liba52,--disable-liba52,liba52"
PACKAGECONFIG[lame] = ",,lame"

FULL_OPTIMIZATION = "-fexpensive-optimizations -fomit-frame-pointer -frename-registers -O4 -ffast-math"
BUILD_OPTIMIZATION = "${FULL_OPTIMIZATION}"

CFLAGS_append = " -I${S}/libdvdread4 "

do_configure() {
    sed -i 's|/usr/include|${STAGING_INCDIR}|g' ${S}/configure
    sed -i 's|/usr/lib|${STAGING_LIBDIR}|g' ${S}/configure
    sed -i 's|/usr/\S*include[\w/]*||g' ${S}/configure
    sed -i 's|/usr/\S*lib[\w/]*||g' ${S}/configure
    sed -i 's|_install_strip="-s"|_install_strip=""|g' ${S}/configure
    sed -i 's|HOST_CC|BUILD_CC|' ${S}/Makefile

    export SIMPLE_TARGET_SYS="$(echo ${TARGET_SYS} | sed s:${TARGET_VENDOR}::g)"
    ./configure ${EXTRA_OECONF}

}

do_compile () {
    oe_runmake
}

do_install_append() {
    install -d ${D}/usr/etc/mplayer
    install ${S}/etc/input.conf ${D}/usr/etc/mplayer/
    install ${S}/etc/example.conf ${D}/usr/etc/mplayer/
    install ${S}/etc/codecs.conf ${D}/usr/etc/mplayer/
}

repository: ExorEmbedded/exor-workspace

repo_name: ExorEmbedded/exor-workspace

gha_language: Python


text:
package main

import (
	"archive/zip"
	"bufio"
	"database/sql"
	"encoding/csv"
	"fmt"
	"io"
	"net/http"
	"os"
	"path/filepath"
	"strconv"

	pq "github.com/lib/pq"
)

func main() {
	getData()
	Unzip("NaPTAN.zip", ".")
	postgresImport(csvParser())

	deleteExtraFiles()
}

func getData() {
	out, err := os.Create("NaPTAN.zip")
	if err != nil {
		panic(err)
	}

	defer out.Close()
	resp, err := http.Get("http://naptan.app.dft.gov.uk/DataRequest/Naptan.ashx?format=csv")
	if err != nil {
		panic(err)
	}

	_, err = io.Copy(out, resp.Body)
	if err != nil {
		panic(err)
	}

	err = out.Close()
	if err != nil {
		panic(err)
	}
}

func csvParser() [][]string {
	inputFile, _ := os.Open("Stops.csv")
	defer inputFile.Close()

	reader := csv.NewReader(bufio.NewReader(inputFile))

	var skimmed [][]string

	reader.Read()

	for {
		record, err := reader.Read()
		if err != nil {
			break
		}
		skimmed = append(skimmed, []string{record[0], record[4], record[29], record[30]})
	}

	return skimmed
}

func connectionInfo() string {
	configFile, err := os.Open("postgres.config")
	if err != nil {
		panic(err)
	}

	reader := bufio.NewReader(configFile)

	var config []byte

	//cut out source line
	reader.ReadLine()

	for {
		line, _, err := reader.ReadLine()
		if err != nil {
			break
		}

		config = append(config, line...)
		config = append(config, ' ')
	}

	return string(config)
}

func postgresImport(skimmed [][]string) {
	db, err := sql.Open("postgres", connectionInfo())
	if err != nil {
		panic(err)
	}

	db.Exec("DELETE FROM stops;")

	txn, err := db.Begin()
	if err != nil {
		panic(err)
	}

	stmt, err := txn.Prepare(pq.CopyIn("stops", "stop_id", "name", "lon", "lat"))
	if err != nil {
		fmt.Print(err.Error)
		panic(err)
	}

	for _, stop := range skimmed {
		lon, _ := strconv.ParseFloat(stop[2], 64)
		lat, _ := strconv.ParseFloat(stop[3], 64)
		stmt.Exec(stop[0], stop[1], lon, lat)
	}

	err = stmt.Close()
	if err != nil {
		panic(err)
	}

	err = txn.Commit()
	if err != nil {
		panic(err)
	}
}

func Unzip(src, dest string) error {
	r, err := zip.OpenReader(src)
	if err != nil {
		return err
	}
	defer func() {
		if err := r.Close(); err != nil {
			panic(err)
		}
	}()

	os.MkdirAll(dest, 0755)

	// Closure to address file descriptors issue with all the deferred .Close() methods
	extractAndWriteFile := func(f *zip.File) error {
		rc, err := f.Open()
		if err != nil {
			return err
		}
		defer func() {
			if err := rc.Close(); err != nil {
				panic(err)
			}
		}()

		path := filepath.Join(dest, f.Name)

		if f.FileInfo().IsDir() {
			os.MkdirAll(path, f.Mode())
		} else {
			os.MkdirAll(filepath.Dir(path), f.Mode())
			f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, f.Mode())
			if err != nil {
				return err
			}
			defer func() {
				if err := f.Close(); err != nil {
					panic(err)
				}
			}()

			_, err = io.Copy(f, rc)
			if err != nil {
				return err
			}
		}
		return nil
	}

	for _, f := range r.File {
		if f.Name == "Stops.csv" {
			err := extractAndWriteFile(f)
			if err != nil {
				return err
			}
		}
	}

	return nil
}

func deleteExtraFiles() {
	os.Remove("NaPTAN.zip")
	os.Remove("Stops.csv")
}

repository: CampusHackTeamMeme/Busoton-API

repo_name: CampusHackTeamMeme/Busoton-API


text:
package github

import (
	"context"

	"github.com/google/go-github/v32/github"
)

func (r *RepositoryClient) PostPRComment(ctx context.Context, pullNum int, data *string) error {
	_, _, err := r.Issues.CreateComment(ctx, r.Owner, r.Repo, pullNum, &github.IssueComment{
		Body: data,
	})
	return err
}

func (r *RepositoryClient) ListPRComments(ctx context.Context, pullNum int) ([]*github.IssueComment, error) {
	list, _, err := r.Issues.ListComments(ctx, r.Owner, r.Repo, pullNum, &github.IssueListCommentsOptions{})
	return list, err
}

func (r *RepositoryClient) ListCommitsFromPR(ctx context.Context, pullNum int) ([]string, error) {
	done := false
	page := 0
	var commits []string
	for !done {
		list, resp, err := r.PullRequests.ListCommits(ctx, r.Owner, r.Repo, pullNum,
			&github.ListOptions{Page: page, PerPage: 100})
		if err != nil {
			return nil, err
		}
		for _, l := range list {
			commits = append(commits, l.GetSHA())
		}
		if page = resp.NextPage; page == 0 {
			done = true
		}

	}
	return commits, nil
}

repository: operator-framework/flake-analyzer

repo_name: operator-framework/flake-analyzer


text:
package fmodels

type LanguagesWrapper struct {
	Status string `json:"status"`

	Message string `json:"message"`

	// response with all of the languages in the system
	Response []Language `json:"response"`
}

branch_name: refs/heads/main


text:
package zcncore

import (
	"testing"

	"github.com/stretchr/testify/require"
)

func TestCFBEncryption(t *testing.T) {
	key := "passphrase1111111111111111111111"
	mnemonics := "glare mistake gun joke bid spare across diagram wrap cube swear cactus cave repeat you brave few best wild lion pitch pole original wasp"

	encryptedMnemonics, err := Encrypt(key, mnemonics)

	require.Nil(t, err)
	require.NotEmpty(t, encryptedMnemonics)

	decryptedMnemonics, err := Decrypt(key, encryptedMnemonics)
	require.Nil(t, err)
	require.Equal(t, mnemonics, decryptedMnemonics)
}

func TestCBCEncryption(t *testing.T) {
	passphrase := "12345611111111111111111111111111"
	mnemonics := "cube reward february gym summer peanut marble slow puppy picnic cart waste aspect either anchor vacant horse north border wonder stamp mansion steak magic"

	enc, err := CryptoJsEncrypt(passphrase, mnemonics)
	require.Nil(t, err)

	dec, err := CryptoJsDecrypt(passphrase, string(enc))
	require.Nil(t, err)
	require.Equal(t, mnemonics, string(dec))
	encryptedMnemonics := "U2FsdGVkX1/Dz58HfdXjHGJioPZ8bnEWIfa0dZcz0JuizI/Tu1+1ncVv60f4w53VimvKG0dC5zhVFQC8dt7K7Lydutu/pquTCDfKt3AUK2iJ5mjN1n4rCvp5IMG+5fKuVyY0z+PbH5MgyJdAF1Fbsi3X+ccfd/ZB9jg6deHpneHDMxhRzuGKcKUuWA6+D/peQTGCmHCLbAPYswFUeF0Elcmgi1mx69UYeM1qgfumuFs="
	dec, err = CryptoJsDecrypt(passphrase, encryptedMnemonics)
	require.Nil(t, err)
	require.Equal(t, mnemonics, string(dec))
}

branch_name: refs/heads/staging


text:
package sasquatch

import (
	"fmt"
	"io/ioutil"

	"golang.org/x/crypto/ssh"
)

// A Recipient is a public key or other value that can encrypt an opaque file
// key to a recipient stanza.
type Recipient interface {
	Type() string
	Wrap(fileKey []byte) (*Stanza, error)
}

// FindRecipients returns all available recipients.
func FindRecipients() []Recipient {
	// from disk
	keys, err := FindSSHKeys()
	if err != nil {
		return nil
	}

	ids := []Recipient{}
	for _, key := range keys {
		key += ".pub"
		// fmt.Println("parsing", key)
		c, err := ioutil.ReadFile(key)
		if err != nil {
			// fmt.Println(err)
			continue
		}

		r, err := ParseRecipient(string(c))
		if err != nil {
			// fmt.Println(err)
			continue
		}
		ids = append(ids, r)
	}

	// from agent
	signers, err := SSHAgentSigners()
	if err != nil {
		return ids
	}

	for _, signer := range signers {
		i, err := NewChallengeRecipient(signer)
		if err != nil {
			continue
		}

		ids = append(ids, i)
	}

	return ids
}

// ParseRecipient creates a Recipient from an SSH public key.
func ParseRecipient(s string) (Recipient, error) {
	pubKey, _, _, _, err := ssh.ParseAuthorizedKey([]byte(s))
	if err != nil {
		return nil, fmt.Errorf("malformed SSH recipient: %q: %v", s, err)
	}

	var r Recipient
	switch t := pubKey.Type(); t {
	case "ssh-rsa":
		r, err = NewRSARecipient(pubKey)
	case "ssh-ed25519":
		r, err = NewEd25519Recipient(pubKey)
	default:
		return nil, fmt.Errorf("unknown SSH recipient type: %q", t)
	}
	if err != nil {
		return nil, fmt.Errorf("malformed SSH recipient: %q: %v", s, err)
	}

	return r, nil
}

repository: muesli/sasquatch

repo_name: muesli/sasquatch


text:
SUMMARY = "Kernel packages for a full dynamic ticks 'nohz' kernel for the NI Linux Real-Time distribution"
LICENSE = "MIT"

inherit packagegroup

RDEPENDS:${PN} = "\
	kernel-nohz \
	kernel-nohz-dev \
	kernel-nohz-modules \
	kernel-devsrc-nohz \
"

repository: ni/meta-nilrt

repo_name: ni/meta-nilrt

branch_name: refs/heads/nilrt/master/kirkstone

gha_language: Shell


text:
package enums

import "strings"

/**
 *朝代
 */
type DynastyLevel int

var DynastyMap = map[DynastyLevel]string{QIN: "先秦", HAN: "两汉", WEI_JIN: "魏晋", NAN_BEI: "南北朝", SUI: "隋代", TANG: "唐代", WU: "五代", SONG: "宋代", JIN: "金朝", YUAN: "元代", MING: "明代", QING: "清代",JIN_XIAN:"近现代"}

func GetDynastyLevel(word string) DynastyLevel {
	if len(word) <= 0 {
		return -1
	}

	var level DynastyLevel
	for k, v := range DynastyMap {
		if strings.EqualFold(v, word) {
			level = k
			break;
		}
	}
	return level
}

const (
	//先秦
	QIN DynastyLevel = iota
	//两汉
	HAN
	//魏晋
	WEI_JIN
	//南北朝
	NAN_BEI
	//隋代
	SUI
	//唐代
	TANG
	//五代
	WU
	//宋代
	SONG
	//金朝
	JIN
	//元代
	YUAN
	//明代
	MING
	//清代
	QING
	//近现代
	JIN_XIAN
)

repository: monomania/poem-parent

repo_name: monomania/poem-parent


text:
#include <library/cpp/testing/gtest/gtest.h>

#include <library/cpp/testing/gtest_extensions/assertions.h>

#include <library/cpp/yt/yson_string/convert.h>

#include <thread>

namespace NYT::NYson {
namespace {

////////////////////////////////////////////////////////////////////////////////

template <class T, class R = T, class U>
void Check(const U& value)
{
    auto str = ConvertToYsonString(static_cast<T>(value));
    auto anotherValue = ConvertFromYsonString<R>(str);
    EXPECT_EQ(static_cast<T>(value), anotherValue);
}

TEST(TConvertTest, Basic)
{
    Check<i8>(13);
    Check<i32>(13);
    Check<i64>(13);
    Check<i8>(-13);
    Check<i32>(-13);
    Check<i64>(-13);
    Check<ui8>(13);
    Check<ui32>(13);
    Check<ui64>(13);
    Check<TString>("");
    Check<TString>("hello");
    Check<TStringBuf, TString>("hello");
    Check<const char*, TString>("hello");
    Check<float>(3.14);
    Check<double>(3.14);
    Check<bool>(true);
    Check<bool>(false);
    Check<TInstant>(TInstant::Now());
    Check<TDuration>(TDuration::Seconds(123));
    Check<TGuid>(TGuid::FromString("12345678-12345678-abcdabcd-fefefefe"));
}

TEST(TConvertTest, InRange)
{
    EXPECT_EQ(ConvertFromYsonString<i16>(ConvertToYsonString(static_cast<i64>(-123))), -123);
    EXPECT_EQ(ConvertFromYsonString<ui16>(ConvertToYsonString(static_cast<ui64>(123))), 123U);
}

TEST(TConvertTest, OutOfRange)
{
    EXPECT_THROW_MESSAGE_HAS_SUBSTR(
        ConvertFromYsonString<i8>(ConvertToYsonString(static_cast<i64>(128))),
        TYsonLiteralParseException,
        "is out of expected range");
    EXPECT_THROW_MESSAGE_HAS_SUBSTR(
        ConvertFromYsonString<ui8>(ConvertToYsonString(static_cast<ui64>(256))),
        TYsonLiteralParseException,
        "is out of expected range");
}

TEST(TConvertTest, MalformedValues)
{
    EXPECT_THROW_MESSAGE_HAS_SUBSTR(
        ConvertFromYsonString<TInstant>(ConvertToYsonString(TStringBuf("sometime"))),
        TYsonLiteralParseException,
        "Error parsing \"instant\" value");
    EXPECT_THROW_MESSAGE_HAS_SUBSTR(
        ConvertFromYsonString<TGuid>(ConvertToYsonString(TStringBuf("1-2-3-g"))),
        TYsonLiteralParseException,
        "Error parsing \"guid\" value");
}

////////////////////////////////////////////////////////////////////////////////

} // namespace
} // namespace NYT::NYson

repository: catboost/catboost

repo_name: catboost/catboost


text:
DESCRIPTION = "Build all c7x0 kernels in one go"
SECTION = "kernel"
LICENSE = "GPLv2"
PROVIDES = "virtual/kernel"
PR = "r1"

COMPATIBLE_HOST = "arm.*-linux"

# For these old 2.4 kernels we override in sharprom-compatible.conf
#COMPATIBLE_MACHINE = "(corgi|husky|shepherd)"
COMPATIBLE_MACHINE = "none"

DEPENDS = "corgi-kernel-2.4-embedix shepherd-kernel-2.4-embedix husky-kernel-2.4-embedix"

PACKAGES = ""
EXCLUDE_FROM_WORLD = "1"

repository: overo/overo-oe-natty

repo_name: overo/overo-oe-natty

branch_name: HEAD


text:
DESCRIPTION = "Gridpad handstroke recognition"
SECTION = "x11"
LICENSE = "GPLv2"
DEPENDS = "ecore evas edje libfakekey"
PV = "2.0+svnr${SRCPV}"
PR = "r0"
SRCREV = "194"

SRC_URI = "svn://svn.om.vptt.ch/trunk/;proto=http;module=GridPad"
S = "${WORKDIR}/GridPad"

inherit autotools pkgconfig


text:
@inproceedings{Oomen:13b,
 address = {Washington, DC, USA},
 author = {T. Oomen and R. van der Maas and C.R. Rojas and H. Hjalmarsson},
 booktitle = {American Control Conference},
 pages = {},
 title = {Iteratively Learning the $H_ınfty$-Norm of Multivariable Systems Applied to Model-Error-Modeling of a Vibration Isolation System},
 year = {2013}
}

repository: hhjalmars/academic-kickstart

repo_name: hhjalmars/academic-kickstart

extension: bib


text:
package lib

import (
	"errors"
	"github.com/jotaen/klog/lib/jotaen/terminalformat"
	"github.com/jotaen/klog/src/app"
	"github.com/jotaen/klog/src/parser/parsing"
	"github.com/stretchr/testify/assert"
	"testing"
)

func TestFormatParserError(t *testing.T) {
	err := parsing.NewErrors([]parsing.Error{
		func() parsing.Error {
			err := parsing.NewError(parsing.NewLineFromString("Foo bar", 2), 4, 3)
			return err.Set("CODE", "Some Title", "A verbose description with details, potentially spanning multiple lines with a comprehensive text and tremendously helpful information.\nBut it respects newlines.")
		}(),
		func() parsing.Error {
			err := parsing.NewError(parsing.NewLineFromString("Some malformed text", 39), 0, 4)
			return err.Set("CODE", "Error", "Short explanation.")
		}(),
	})
	text := PrettifyError(err, false).Error()
	assert.Equal(t, ` ERROR in line 2:
    Foo bar
        ^^^
    Some Title: A verbose description with details, potentially
    spanning multiple lines with a comprehensive text
    and tremendously helpful information.
    But it respects newlines.

 ERROR in line 39:
    Some malformed text
    ^^^^
    Error: Short explanation.

`, terminalformat.StripAllAnsiSequences(text))
}

func TestFormatAppError(t *testing.T) {
	err := app.NewError("Some message", "A more detailed explanation", nil)
	text := PrettifyError(err, false).Error()
	assert.Equal(t, `Error: Some message
A more detailed explanation`, text)
}

func TestFormatAppErrorWithDebugFlag(t *testing.T) {
	textWithNilErr := PrettifyError(
		app.NewError("Some message", "A more detailed explanation", nil),
		true).Error()
	assert.Equal(t, `Error: Some message
A more detailed explanation`, textWithNilErr)

	textWithErr := PrettifyError(
		app.NewError("Some message", "A more detailed explanation", errors.New("ORIG_ERR")),
		true).Error()
	assert.Equal(t, `Error: Some message
A more detailed explanation

Original Error:
ORIG_ERR`, textWithErr)
}

func TestFormatRegularError(t *testing.T) {
	textWithNilErr := PrettifyError(errors.New("Some plain error"), true).Error()
	assert.Equal(t, `Error: Some plain error`, textWithNilErr)
}

repository: itsjwala/klog

repo_name: itsjwala/klog


text:
package events

import (
	"fmt"

	"github.com/bwmarrin/discordgo"
)

type JoinLeaveHandler struct{}

func NewJoinLeaveHandler() *JoinLeaveHandler {
	return &JoinLeaveHandler{}
}

func (h *JoinLeaveHandler) HandlerJoin(s *discordgo.Session, e *discordgo.GuildMemberAdd) {
	guild, err := s.Guild(e.GuildID)
	if err != nil {
		fmt.Println("Failed getting guild object: ", err)
		return
	}

	fmt.Printf("Member %s joined the guild %s\n", e.Member.User.String(), guild.Name)
}

func (h *JoinLeaveHandler) HandlerLeave(s *discordgo.Session, e *discordgo.GuildMemberRemove) {
	guild, err := s.Guild(e.GuildID)
	if err != nil {
		fmt.Println("Failed getting guild object: ", err)
		return
	}

	fmt.Printf("Member %s left the guild %s\n", e.Member.User.String(), guild.Name)
}

repository: zekroTutorials/discordgo

repo_name: zekroTutorials/discordgo