text:
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace Core.Commands
{
    public static class CatCommand
    {

        private static int s_linesCount = 0;
        private static int s_linesCountName = 0;
        /// <summary>
        /// Output to console specific lines from a file containing a specific string.
        /// </summary>
        /// <param name="searchString"> Search parameter. </param>
        /// <param name="currentDir">Current directory. </param>
        /// <param name="input"> File name to search in. </param>
        /// <param name="savedFile"> File name where to store the result data. </param>
        /// <returns>string</returns>
        public static string FileOutput(string input, string currentDir, string searchString = null, string savedFile = null)
        {
            var output = new StringBuilder();
            input = FileSystem.SanitizePath(input, currentDir);
            int lineCount = 0;

            if (!File.Exists(input))
            {
                Console.WriteLine("File " + input + " dose not exist!");
                return output.ToString();
            }

            using (var streamReader = new StreamReader(input))
            {
                string line;
                while ((line = streamReader.ReadLine()) != null)
                {
                    lineCount++;
                    if (string.IsNullOrWhiteSpace(searchString))
                    {
                        output.AppendLine(line);
                        continue;
                    }

                    if (line.ToLower().Contains(searchString.ToLower()))
                    {
                        output.AppendLine($"Line {lineCount} : {line}");
                    }
                }

                streamReader.Close();
            }

            if (!string.IsNullOrEmpty(savedFile))
            {
                return FileSystem.SaveFileOutput(savedFile, currentDir, output.ToString());
            }

            return output.ToString();
        }

        /// <summary>
        /// Output to console lines that contains a specific string.
        /// </summary>
        /// <param name="searchString"> Search parameter. </param>
        /// <param name="currentDir">Current directory. </param>
        /// <param name="paths"> File names to search in. </param>
        /// <param name="savedFile"> File name where to store the result data. </param>
        /// <param name="searchAll"> Search in all files from current directory. </param>
        /// <returns>string</returns>
        public static string MultiFileOutput(string searchString, string currentDir, IEnumerable<string> paths, string savedFile, bool searchAll, string fileName = null)
        {
            StringBuilder output = new StringBuilder();
            if (searchAll)
            {
                string[] files = Directory.GetFiles(currentDir);

                if (!string.IsNullOrEmpty(fileName))
                {
                    foreach (var file in files)
                    {
                        var fileInfo = new FileInfo(file);

                        if (!string.IsNullOrEmpty(fileName) && fileInfo.Name.Contains(fileName))
                        {
                            // var nFile = SanitizePath(file, currentDir);
                            if (!File.Exists(file))
                            {
                                FileSystem.ErrorWriteLine("File " + file + " dose not exist!");
                                continue;
                            }

                            output.AppendLine($"---------------- {file} ----------------");
                            LineOutput(output, file, currentDir, searchString);
                        }
                    }
                }
                else
                {
                    foreach (var file in files)
                    {
                        if (!File.Exists(file))
                        {
                            FileSystem.ErrorWriteLine("File " + file + " dose not exist!");
                            continue;
                        }
                        output.AppendLine($"---------------- {file} ----------------");
                        LineOutput(output, file, currentDir, searchString);
                    }
                }
                var directoryInfo = new DirectoryInfo(currentDir).GetDirectories();
                foreach (var dir in directoryInfo)
                {
                    string p = "";
                    string oD = MultiFileOutput(searchString, dir.FullName, p.Split(' '), savedFile, true, fileName);
                    if (!string.IsNullOrWhiteSpace(oD))
                    {
                        output.AppendLine(oD);
                    }
                }
            }
            else
            {
                foreach (var file in paths)
                {
                    var nFile = FileSystem.SanitizePath(file, currentDir);
                    if (!File.Exists(nFile))
                    {
                        FileSystem.ErrorWriteLine("File " + nFile + " dose not exist!");
                        continue;
                    }

                    output.AppendLine($"---------------- {nFile} ----------------");
                    LineOutput(output, nFile, currentDir, searchString);
                }
            }

            if (!string.IsNullOrEmpty(savedFile) && searchAll == false)
            {
                return FileSystem.SaveFileOutput(savedFile, currentDir, output.ToString());
            }

            return output.ToString();
        }

        private static void LineOutput(StringBuilder stringBuilder,string file,string currentDir,string searchString)
        {
            string oFile = FileOutput(file, currentDir, searchString);
            if (oFile.StartsWith("Line"))
            {
                stringBuilder.AppendLine(FileOutput(file, currentDir, searchString));
            }
        }

        private static void TotalLinesCounter(string currentDir, string fileName, bool fileCount)
        {
            var files =  Directory.GetFiles(currentDir);

            foreach(var file in files)
            {
                if (fileCount)
                {
                    if (file.Contains(fileName))
                    {
                        var lines = File.ReadLines(file);
                        foreach (var line in lines)
                        {
                            if (!string.IsNullOrEmpty(line))
                            {
                                s_linesCountName++;
                            }
                        }
                    }
                }
                else
                {
                    var lines = File.ReadLines(file);
                    foreach (var line in lines)
                    {
                        if (!string.IsNullOrEmpty(line))
                        {
                            s_linesCount++;
                        }
                    }
                }
            }

            var directories = new DirectoryInfo(currentDir).GetDirectories();
            foreach(var dir in directories)
            {
                TotalLinesCounter(dir.FullName,fileName,fileCount);
            }
        }

        /// <summary>
        /// Outputs the lines count from all files in a directory and subdirectories.
        /// </summary>
        /// <param name="currentDir">Directory localtion.</param>
        /// <returns></returns>
        public static int LineCounts(string currentDir)
        {
            TotalLinesCounter(currentDir,"",false);
            return s_linesCount;
        }

        /// <summary>
        /// Ouputs the lines count all files that contains a specific text, in a directory and subdirectories.
        /// </summary>
        /// <param name="currentDir">Directory location.</param>
        /// <param name="fileName">Custom text included in filename.</param>
        /// <returns></returns>
        public static int LineCountsName(string currentDir, string fileName = null)
        {
            TotalLinesCounter(currentDir,fileName,true);
            return s_linesCountName;
        }

        /// <summary>
        /// Clears all the lines count.
        /// </summary>
        public static void ClearCounter()
        {
            s_linesCount = 0;
            s_linesCountName = 0;
        }
    }
}

repository: bowfield/xTerminal

repo_name: bowfield/xTerminal

branch_name: refs/heads/main

extension: cs


text:
package guardian

import (
	"github.com/orientwalt/htdf/codec"
	sdk "github.com/orientwalt/htdf/types"
	abci "github.com/tendermint/tendermint/abci/types"
)

const (
	QueryProfilers = "profilers"
	QueryTrustees  = "trustees"
)

func NewQuerier(k Keeper) sdk.Querier {
	return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, sdk.Error) {
		switch path[0] {
		case QueryProfilers:
			return queryProfilers(ctx, k)
		case QueryTrustees:
			return queryTrustees(ctx, k)
		default:
			return nil, sdk.ErrUnknownRequest("unknown guardian query endpoint")
		}
	}
}

func queryProfilers(ctx sdk.Context, k Keeper) ([]byte, sdk.Error) {
	profilersIterator := k.ProfilersIterator(ctx)
	defer profilersIterator.Close()
	var profilers []Guardian
	for ; profilersIterator.Valid(); profilersIterator.Next() {
		var profiler Guardian
		k.cdc.MustUnmarshalBinaryLengthPrefixed(profilersIterator.Value(), &profiler)
		profilers = append(profilers, profiler)
	}

	bz, err := codec.MarshalJSONIndent(k.cdc, profilers)
	if err != nil {
		return nil, sdk.MarshalResultErr(err)
	}
	return bz, nil
}

func queryTrustees(ctx sdk.Context, k Keeper) ([]byte, sdk.Error) {
	trusteesIterator := k.TrusteesIterator(ctx)
	defer trusteesIterator.Close()
	var trustees []Guardian
	for ; trusteesIterator.Valid(); trusteesIterator.Next() {
		var trustee Guardian
		k.cdc.MustUnmarshalBinaryLengthPrefixed(trusteesIterator.Value(), &trustee)
		trustees = append(trustees, trustee)
	}

	bz, err := codec.MarshalJSONIndent(k.cdc, trustees)
	if err != nil {
		return nil, sdk.MarshalResultErr(err)
	}
	return bz, nil
}

license_type: permissive

branch_name: refs/heads/master

extension: go


text:
SUMMARY = "A stress shell script that Linaro provides for basic test"
LICENSE = "GPL-2.0"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6"

SRC_URI = "file://stress.sh"

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

FILES_${PN} = "/tools"

extension: bb


text:
package config_test

import (
	. "github.com/onsi/ginkgo/v2"
)

var _ = Describe("Server", func() {
})

license: MIT

repository: eisengrind/docker-altv-server

repo_name: eisengrind/docker-altv-server

gha_license_id: MIT

gha_language: Go


text:
package main

import (
	"testing"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

func Test(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "Link Looker")
}

var _ = Describe("#getPage", func() {
	It("when given a valid url", func() {
		validURL := "https://www.google.com"
		_, err := getPage(validURL)
		Ω(err).Should(BeNil())
	})

	It("when given a bad URL", func() {
		validURL := "https://www.fdafsfdsafdsa.com"
		_, err := getPage(validURL)
		Ω(err).ShouldNot(BeNil())
	})

	It("when given an invalid URL", func() {
		validURL := "https://www.warrendouglas.com/jfdlasjskl"
		_, err := getPage(validURL)
		Ω(err).ShouldNot(BeNil())
	})
})

var _ = Describe("#getPageContent", func() {
	It("when given a valid page body", func() {
		validURL := "https://www.google.com"
		page, _ := getPage(validURL)
		_, err := getPageContent(page)
		Ω(err).Should(BeNil())
	})

	It("when given nil for a body", func() {
		_, err := getPageContent(nil)
		Ω(err).ShouldNot(BeNil())
	})
})

var _ = Describe("#getLinks", func() {
	It("when given a valid page body", func() {
		validURL := "https://www.warrendouglas.com"
		page, _ := getPage(validURL)
		doc, _ := getPageContent(page)
		links, err := getLinks(doc)
		Ω(err).Should(BeNil())
		expectedLinks := 18
		Ω(len(links)).Should(Equal(expectedLinks))
	})

	It("when given nil for a body", func() {
		_, err := getLinks(nil)
		Ω(err).ShouldNot(BeNil())
	})
})

var _ = Describe("#getPageLinks", func() {
	It("when given a valid url", func() {
		validURL := "https://www.warrendouglas.com"
		links, err := getPageLinks(validURL)
		expectedLinks := 18
		Ω(len(links)).Should(Equal(expectedLinks))
		Ω(err).Should(BeNil())
	})

	It("when given a valid url", func() {
		validURL := "https://www.fdafdsf.com"
		links, err := getPageLinks(validURL)
		Ω(links).Should(BeNil())
		Ω(err).ShouldNot(BeNil())
	})
})

repository: ryanbenson/link-looker-go

repo_name: ryanbenson/link-looker-go


text:
using Cofoundry.Plugins.ErrorLogging.Data;

namespace Cofoundry.Plugins.ErrorLogging.Domain;

public class GetErrorDetailsByIdQueryHandler
    : IQueryHandler<GetErrorDetailsByIdQuery, ErrorDetails>
    , IPermissionRestrictedQueryHandler<GetErrorDetailsByIdQuery, ErrorDetails>
{
    private readonly ErrorLoggingDbContext _dbContext;

    public GetErrorDetailsByIdQueryHandler(
        ErrorLoggingDbContext dbContext
        )
    {
        _dbContext = dbContext;
    }

    public async Task<ErrorDetails> ExecuteAsync(GetErrorDetailsByIdQuery query, IExecutionContext executionContext)
    {
        var error = await _dbContext
            .Errors
            .AsNoTracking()
            .Where(u => u.ErrorId == query.ErrorId)
            .Select(e => new ErrorDetails()
            {
                CreateDate = e.CreateDate,
                Data = e.Data,
                EmailSent = e.EmailSent,
                ErrorId = e.ErrorId,
                ExceptionType = e.ExceptionType,
                Form = e.Form,
                QueryString = e.QueryString,
                Session = e.QueryString,
                Source = e.Source,
                StackTrace = e.StackTrace,
                Target = e.Target,
                Url = e.Url,
                UserAgent = e.UserAgent
            })
            .SingleOrDefaultAsync();

        return error;
    }

    public IEnumerable<IPermissionApplication> GetPermissions(GetErrorDetailsByIdQuery query)
    {
        yield return new ErrorLogReadPermission();
    }
}

gha_language: C#


text:
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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
 *
 *   https://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.
 */

// Code generated by mockery v2.32.4. DO NOT EDIT.

package transactions

import mock "github.com/stretchr/testify/mock"

// MockRequestTransactionRunnable is an autogenerated mock type for the RequestTransactionRunnable type
type MockRequestTransactionRunnable struct {
	mock.Mock
}

type MockRequestTransactionRunnable_Expecter struct {
	mock *mock.Mock
}

func (_m *MockRequestTransactionRunnable) EXPECT() *MockRequestTransactionRunnable_Expecter {
	return &MockRequestTransactionRunnable_Expecter{mock: &_m.Mock}
}

// Execute provides a mock function with given fields: _a0
func (_m *MockRequestTransactionRunnable) Execute(_a0 RequestTransaction) {
	_m.Called(_a0)
}

// MockRequestTransactionRunnable_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute'
type MockRequestTransactionRunnable_Execute_Call struct {
	*mock.Call
}

// Execute is a helper method to define mock.On call
//   - _a0 RequestTransaction
func (_e *MockRequestTransactionRunnable_Expecter) Execute(_a0 interface{}) *MockRequestTransactionRunnable_Execute_Call {
	return &MockRequestTransactionRunnable_Execute_Call{Call: _e.mock.On("Execute", _a0)}
}

func (_c *MockRequestTransactionRunnable_Execute_Call) Run(run func(_a0 RequestTransaction)) *MockRequestTransactionRunnable_Execute_Call {
	_c.Call.Run(func(args mock.Arguments) {
		run(args[0].(RequestTransaction))
	})
	return _c
}

func (_c *MockRequestTransactionRunnable_Execute_Call) Return() *MockRequestTransactionRunnable_Execute_Call {
	_c.Call.Return()
	return _c
}

func (_c *MockRequestTransactionRunnable_Execute_Call) RunAndReturn(run func(RequestTransaction)) *MockRequestTransactionRunnable_Execute_Call {
	_c.Call.Return(run)
	return _c
}

// NewMockRequestTransactionRunnable creates a new instance of MockRequestTransactionRunnable. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
// The first argument is typically a *testing.T value.
func NewMockRequestTransactionRunnable(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockRequestTransactionRunnable {
	mock := &MockRequestTransactionRunnable{}
	mock.Mock.Test(t)

	t.Cleanup(func() { mock.AssertExpectations(t) })

	return mock
}

branch_name: refs/heads/develop

gha_language: Java


text:
import {Component, EventEmitter, OnInit, Output} from '@angular/core';

@Component({
    selector: 'app-burger-menu',
    templateUrl: './burger-menu.component.html',
    styleUrls: ['./burger-menu.component.scss']
})
export class BurgerMenuComponent implements OnInit {

    @Output() sidebar = new EventEmitter<boolean>();

    state: boolean

    constructor() {
    }

    ngOnInit(): void {
        this.state = false;
    }

    toggleVisibility(){
        this.state = !this.state;
        this.sidebar.emit(this.state)
    }

}

extension: ts


text:
DESCRIPTION = "The GIMP is the GNU Image Manipulation Program."
HOMEPAGE = "http://www.gimp.org"
SECTION = "x11/graphics"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=878e3965c7b52d85827c75f5a2f3b314"

DEPENDS = "babl gdk-pixbuf-native libart-lgpl gtk+ jpeg libpng libexif tiff webkit-gtk lcms gegl poppler"

PR = "r1"

inherit gnome

SRC_URI = "ftp://ftp.gimp.org/pub/gimp/v2.6/gimp-${PV}.tar.bz2 \
           file://gimp-2.6.11-poppler18.patch"
SRC_URI[md5sum] = "bb2939fe13e54fc7255cef5d097bb5dd"
SRC_URI[sha256sum] = "9b6d08d0803b3912ea596d1b77b9c21ee13778c23388a225c004b8c1587cb0a1"

EXTRA_OECONF = "--disable-python \
                --without-wmf"

do_configure_append() {
	find ${S} -name Makefile | xargs sed -i s:'-I$(includedir)':'-I.':g
	find ${S} -name Makefile | xargs sed -i s:'-I/usr/include':'-I${STAGING_INCDIR}':g
}

FILES_${PN}-dbg += "${libdir}/gimp/2.0/*/.debug"


text:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE eagle SYSTEM "eagle.dtd">
<eagle version="7.2.0">
<drawing>
<settings>
<setting alwaysvectorfont="no"/>
<setting verticaltext="up"/>
</settings>
<grid distance="0.1" unitdist="inch" unit="inch" style="lines" multiple="1" display="no" altdistance="0.01" altunitdist="inch" altunit="inch"/>
<layers>
<layer number="1" name="Top" color="4" fill="1" visible="no" active="no"/>
<layer number="16" name="Bottom" color="1" fill="1" visible="no" active="no"/>
<layer number="17" name="Pads" color="2" fill="1" visible="no" active="no"/>
<layer number="18" name="Vias" color="2" fill="1" visible="no" active="no"/>
<layer number="19" name="Unrouted" color="6" fill="1" visible="no" active="no"/>
<layer number="20" name="Dimension" color="15" fill="1" visible="no" active="no"/>
<layer number="21" name="tPlace" color="7" fill="1" visible="no" active="no"/>
<layer number="22" name="bPlace" color="7" fill="1" visible="no" active="no"/>
<layer number="23" name="tOrigins" color="15" fill="1" visible="no" active="no"/>
<layer number="24" name="bOrigins" color="15" fill="1" visible="no" active="no"/>
<layer number="25" name="tNames" color="7" fill="1" visible="no" active="no"/>
<layer number="26" name="bNames" color="7" fill="1" visible="no" active="no"/>
<layer number="27" name="tValues" color="7" fill="1" visible="no" active="no"/>
<layer number="28" name="bValues" color="7" fill="1" visible="no" active="no"/>
<layer number="29" name="tStop" color="7" fill="3" visible="no" active="no"/>
<layer number="30" name="bStop" color="7" fill="6" visible="no" active="no"/>
<layer number="31" name="tCream" color="7" fill="4" visible="no" active="no"/>
<layer number="32" name="bCream" color="7" fill="5" visible="no" active="no"/>
<layer number="33" name="tFinish" color="6" fill="3" visible="no" active="no"/>
<layer number="34" name="bFinish" color="6" fill="6" visible="no" active="no"/>
<layer number="35" name="tGlue" color="7" fill="4" visible="no" active="no"/>
<layer number="36" name="bGlue" color="7" fill="5" visible="no" active="no"/>
<layer number="37" name="tTest" color="7" fill="1" visible="no" active="no"/>
<layer number="38" name="bTest" color="7" fill="1" visible="no" active="no"/>
<layer number="39" name="tKeepout" color="4" fill="11" visible="no" active="no"/>
<layer number="40" name="bKeepout" color="1" fill="11" visible="no" active="no"/>
<layer number="41" name="tRestrict" color="4" fill="10" visible="no" active="no"/>
<layer number="42" name="bRestrict" color="1" fill="10" visible="no" active="no"/>
<layer number="43" name="vRestrict" color="2" fill="10" visible="no" active="no"/>
<layer number="44" name="Drills" color="7" fill="1" visible="no" active="no"/>
<layer number="45" name="Holes" color="7" fill="1" visible="no" active="no"/>
<layer number="46" name="Milling" color="3" fill="1" visible="no" active="no"/>
<layer number="47" name="Measures" color="7" fill="1" visible="no" active="no"/>
<layer number="48" name="Document" color="7" fill="1" visible="no" active="no"/>
<layer number="49" name="Reference" color="7" fill="1" visible="no" active="no"/>
<layer number="50" name="dxf" color="7" fill="1" visible="no" active="no"/>
<layer number="51" name="tDocu" color="7" fill="1" visible="no" active="no"/>
<layer number="52" name="bDocu" color="7" fill="1" visible="no" active="no"/>
<layer number="53" name="tGND_GNDA" color="7" fill="9" visible="no" active="no"/>
<layer number="54" name="bGND_GNDA" color="1" fill="9" visible="no" active="no"/>
<layer number="56" name="wert" color="7" fill="1" visible="no" active="no"/>
<layer number="91" name="Nets" color="2" fill="1" visible="yes" active="yes"/>
<layer number="92" name="Busses" color="1" fill="1" visible="yes" active="yes"/>
<layer number="93" name="Pins" color="2" fill="1" visible="no" active="yes"/>
<layer number="94" name="Symbols" color="4" fill="1" visible="yes" active="yes"/>
<layer number="95" name="Names" color="7" fill="1" visible="yes" active="yes"/>
<layer number="96" name="Values" color="7" fill="1" visible="yes" active="yes"/>
<layer number="97" name="Info" color="7" fill="1" visible="yes" active="yes"/>
<layer number="98" name="Guide" color="6" fill="1" visible="yes" active="yes"/>
<layer number="100" name="Muster" color="7" fill="1" visible="no" active="no"/>
<layer number="101" name="Patch_Top" color="12" fill="4" visible="yes" active="yes"/>
<layer number="102" name="Vscore" color="7" fill="1" visible="yes" active="yes"/>
<layer number="103" name="tMap" color="7" fill="1" visible="yes" active="yes"/>
<layer number="104" name="Name" color="16" fill="1" visible="yes" active="yes"/>
<layer number="105" name="tPlate" color="7" fill="1" visible="yes" active="yes"/>
<layer number="106" name="bPlate" color="7" fill="1" visible="yes" active="yes"/>
<layer number="107" name="Crop" color="7" fill="1" visible="yes" active="yes"/>
<layer number="116" name="Patch_BOT" color="9" fill="4" visible="yes" active="yes"/>
<layer number="121" name="_tsilk" color="7" fill="1" visible="yes" active="yes"/>
<layer number="122" name="_bsilk" color="7" fill="1" visible="yes" active="yes"/>
<layer number="151" name="HeatSink" color="7" fill="1" visible="yes" active="yes"/>
<layer number="200" name="200bmp" color="1" fill="10" visible="yes" active="yes"/>
<layer number="201" name="201bmp" color="2" fill="10" visible="yes" active="yes"/>
<layer number="202" name="202bmp" color="3" fill="10" visible="yes" active="yes"/>
<layer number="203" name="203bmp" color="4" fill="10" visible="yes" active="yes"/>
<layer number="204" name="204bmp" color="5" fill="10" visible="yes" active="yes"/>
<layer number="205" name="205bmp" color="6" fill="10" visible="yes" active="yes"/>
<layer number="206" name="206bmp" color="7" fill="10" visible="yes" active="yes"/>
<layer number="207" name="207bmp" color="8" fill="10" visible="yes" active="yes"/>
<layer number="208" name="208bmp" color="9" fill="10" visible="yes" active="yes"/>
<layer number="250" name="Descript" color="3" fill="1" visible="no" active="no"/>
<layer number="251" name="SMDround" color="12" fill="11" visible="no" active="no"/>
<layer number="254" name="cooling" color="7" fill="1" visible="yes" active="yes"/>
</layers>
<schematic>
<libraries>
<library name="ng">
<packages>
<package name="1206">
<description>RESISTOR

chip</description>
<wire x1="0.9525" y1="-0.8128" x2="-0.9652" y2="-0.8128" width="0.1524" layer="51"/>
<wire x1="0.9525" y1="0.8128" x2="-0.9652" y2="0.8128" width="0.1524" layer="51"/>
<wire x1="-2.3206" y1="0.983" x2="2.3206" y2="0.983" width="0.0508" layer="39"/>
<wire x1="2.3206" y1="0.983" x2="2.3206" y2="-0.983" width="0.0508" layer="39"/>
<wire x1="2.3206" y1="-0.983" x2="-2.3206" y2="-0.983" width="0.0508" layer="39"/>
<wire x1="-2.3206" y1="-0.983" x2="-2.3206" y2="0.983" width="0.0508" layer="39"/>
<smd name="2" x="1.422" y="0" dx="1.6" dy="1.803" layer="1"/>
<smd name="1" x="-1.422" y="0" dx="1.6" dy="1.803" layer="1"/>
<text x="-1.397" y="1.143" size="1.27" layer="25">>NAME</text>
<text x="-1.397" y="-2.413" size="1.27" layer="27">>VALUE</text>
<rectangle x1="-1.6891" y1="-0.8763" x2="-0.9525" y2="0.8763" layer="51"/>
<rectangle x1="0.9525" y1="-0.8763" x2="1.6891" y2="0.8763" layer="51"/>
<rectangle x1="-0.3" y1="-0.7" x2="0.3" y2="0.7" layer="35"/>
</package>
<package name="0402">
<description>RESISTOR</description>
<wire x1="-0.245" y1="0.224" x2="0.245" y2="0.224" width="0.1524" layer="51"/>
<wire x1="0.245" y1="-0.224" x2="-0.245" y2="-0.224" width="0.1524" layer="51"/>
<wire x1="-1.092" y1="0.5338" x2="1.092" y2="0.5338" width="0.0508" layer="39"/>
<wire x1="1.092" y1="0.5338" x2="1.092" y2="-0.5338" width="0.0508" layer="39"/>
<wire x1="1.092" y1="-0.5338" x2="-1.092" y2="-0.5338" width="0.0508" layer="39"/>
<wire x1="-1.092" y1="-0.5338" x2="-1.092" y2="0.5338" width="0.0508" layer="39"/>
<smd name="1" x="-0.65" y="0" dx="0.7" dy="0.9" layer="1"/>
<smd name="2" x="0.65" y="0" dx="0.7" dy="0.9" layer="1"/>
<text x="-0.635" y="0.635" size="1.27" layer="25">>NAME</text>
<text x="-0.635" y="-1.905" size="1.27" layer="27">>VALUE</text>
<rectangle x1="-0.554" y1="-0.3048" x2="-0.254" y2="0.2951" layer="51"/>
<rectangle x1="0.2588" y1="-0.3048" x2="0.5588" y2="0.2951" layer="51"/>
<rectangle x1="-0.1999" y1="-0.4001" x2="0.1999" y2="0.4001" layer="35"/>
</package>
</packages>
<symbols>
<symbol name="RESISTOR">
<wire x1="-2.54" y1="0" x2="-2.159" y2="1.016" width="0.2032" layer="94"/>
<wire x1="-2.159" y1="1.016" x2="-1.524" y2="-1.016" width="0.2032" layer="94"/>
<wire x1="-1.524" y1="-1.016" x2="-0.889" y2="1.016" width="0.2032" layer="94"/>
<wire x1="-0.889" y1="1.016" x2="-0.254" y2="-1.016" width="0.2032" layer="94"/>
<wire x1="-0.254" y1="-1.016" x2="0.381" y2="1.016" width="0.2032" layer="94"/>
<wire x1="0.381" y1="1.016" x2="1.016" y2="-1.016" width="0.2032" layer="94"/>
<wire x1="1.016" y1="-1.016" x2="1.651" y2="1.016" width="0.2032" layer="94"/>
<wire x1="1.651" y1="1.016" x2="2.286" y2="-1.016" width="0.2032" layer="94"/>
<wire x1="2.286" y1="-1.016" x2="2.54" y2="0" width="0.2032" layer="94"/>
<text x="-3.81" y="1.4986" size="1.778" layer="95">>NAME</text>
<text x="-3.81" y="-3.302" size="1.778" layer="96">>VALUE</text>
<pin name="2" x="5.08" y="0" visible="off" length="short" direction="pas" swaplevel="1" rot="R180"/>
<pin name="1" x="-5.08" y="0" visible="off" length="short" direction="pas" swaplevel="1"/>
</symbol>
</symbols>
<devicesets>
<deviceset name="RESISTOR" prefix="R" uservalue="yes">
<gates>
<gate name="G$1" symbol="RESISTOR" x="0" y="0"/>
</gates>
<devices>
<device name="1206" package="1206">
<connects>
<connect gate="G$1" pin="1" pad="1"/>
<connect gate="G$1" pin="2" pad="2"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="0402" package="0402">
<connects>
<connect gate="G$1" pin="1" pad="1"/>
<connect gate="G$1" pin="2" pad="2"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
</devices>
</deviceset>
</devicesets>
</library>
<library name="01_ng">
<description>Neil Gershenfeld's library</description>
<packages>
<package name="5MM">
<description>5 mm, round</description>
<wire x1="2.54" y1="-1.905" x2="2.54" y2="1.905" width="0.2032" layer="21"/>
<wire x1="2.54" y1="-1.905" x2="2.54" y2="1.905" width="0.254" layer="21" curve="-286.260205" cap="flat"/>
<wire x1="-1.143" y1="0" x2="0" y2="1.143" width="0.1524" layer="51" curve="-90" cap="flat"/>
<wire x1="0" y1="-1.143" x2="1.143" y2="0" width="0.1524" layer="51" curve="90" cap="flat"/>
<wire x1="-1.651" y1="0" x2="0" y2="1.651" width="0.1524" layer="51" curve="-90" cap="flat"/>
<wire x1="0" y1="-1.651" x2="1.651" y2="0" width="0.1524" layer="51" curve="90" cap="flat"/>
<wire x1="-2.159" y1="0" x2="0" y2="2.159" width="0.1524" layer="51" curve="-90" cap="flat"/>
<wire x1="0" y1="-2.159" x2="2.159" y2="0" width="0.1524" layer="51" curve="90" cap="flat"/>
<circle x="0" y="0" radius="2.54" width="0.1524" layer="21"/>
<pad name="IN" x="-1.27" y="0" drill="0.8128" diameter="1.4224"/>
<pad name="OUT" x="1.27" y="0" drill="0.8128" diameter="1.4224"/>
<text x="3.175" y="0.5334" size="1.27" layer="25" ratio="10">>NAME</text>
<text x="3.2004" y="-1.8034" size="1.27" layer="27" ratio="10">>VALUE</text>
</package>
</packages>
<symbols>
<symbol name="OT-NO">
<wire x1="-3.048" y1="-2.54" x2="-1.27" y2="-0.762" width="0.1524" layer="94"/>
<wire x1="-1.27" y1="-0.762" x2="-2.413" y2="-1.143" width="0.1524" layer="94"/>
<wire x1="-2.413" y1="-1.143" x2="-1.651" y2="-1.905" width="0.1524" layer="94"/>
<wire x1="-1.651" y1="-1.905" x2="-1.27" y2="-0.762" width="0.1524" layer="94"/>
<wire x1="-1.143" y1="1.143" x2="-2.286" y2="0.762" width="0.1524" layer="94"/>
<wire x1="-2.286" y1="0.762" x2="-1.524" y2="0" width="0.1524" layer="94"/>
<wire x1="-1.524" y1="0" x2="-1.143" y2="1.143" width="0.1524" layer="94"/>
<wire x1="-2.921" y1="-0.635" x2="-1.143" y2="1.143" width="0.1524" layer="94"/>
<wire x1="2.54" y1="2.54" x2="0" y2="0" width="0.1524" layer="94"/>
<wire x1="0" y1="0" x2="2.286" y2="-2.286" width="0.1524" layer="94"/>
<wire x1="1.778" y1="-1.016" x2="2.286" y2="-2.286" width="0.1524" layer="94"/>
<wire x1="2.286" y1="-2.286" x2="2.54" y2="-2.54" width="0.1524" layer="94"/>
<wire x1="2.286" y1="-2.286" x2="1.016" y2="-1.778" width="0.1524" layer="94"/>
<wire x1="1.016" y1="-1.778" x2="1.778" y2="-1.016" width="0.1524" layer="94"/>
<text x="5.08" y="2.54" size="1.778" layer="95">>NAME</text>
<text x="5.08" y="0" size="1.778" layer="96">>VALUE</text>
<rectangle x1="-0.381" y1="-2.54" x2="0.381" y2="2.54" layer="94"/>
<pin name="E" x="2.54" y="-5.08" visible="off" length="short" direction="pas" rot="R90"/>
<pin name="C" x="2.54" y="5.08" visible="off" length="short" direction="pas" rot="R270"/>
</symbol>
</symbols>
<devicesets>
<deviceset name="PHOTOTRANSISTOR" prefix="T" uservalue="yes">
<description>PHOTO TRANSISTOR</description>
<gates>
<gate name="1" symbol="OT-NO" x="0" y="0"/>
</gates>
<devices>
<device name="5MM" package="5MM">
<connects>
<connect gate="1" pin="C" pad="IN"/>
<connect gate="1" pin="E" pad="OUT"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
</devices>
</deviceset>
</devicesets>
</library>
<library name="01_adafruit">
<packages>
<package name="1X01">
<description>PIN HEADER</description>
<wire x1="-0.635" y1="1.27" x2="0.635" y2="1.27" width="0.1524" layer="21"/>
<wire x1="0.635" y1="1.27" x2="1.27" y2="0.635" width="0.1524" layer="21"/>
<wire x1="1.27" y1="0.635" x2="1.27" y2="-0.635" width="0.1524" layer="21"/>
<wire x1="1.27" y1="-0.635" x2="0.635" y2="-1.27" width="0.1524" layer="21"/>
<wire x1="-1.27" y1="0.635" x2="-1.27" y2="-0.635" width="0.1524" layer="21"/>
<wire x1="-0.635" y1="1.27" x2="-1.27" y2="0.635" width="0.1524" layer="21"/>
<wire x1="-1.27" y1="-0.635" x2="-0.635" y2="-1.27" width="0.1524" layer="21"/>
<wire x1="0.635" y1="-1.27" x2="-0.635" y2="-1.27" width="0.1524" layer="21"/>
<pad name="1" x="0" y="0" drill="1.016" diameter="1.9304" shape="octagon"/>
<text x="-1.3462" y="1.8288" size="1.27" layer="25" ratio="10">>NAME</text>
<text x="-1.27" y="-3.175" size="1.27" layer="27">>VALUE</text>
<rectangle x1="-0.254" y1="-0.254" x2="0.254" y2="0.254" layer="51"/>
</package>
</packages>
<symbols>
<symbol name="PINHD1">
<wire x1="-6.35" y1="-2.54" x2="1.27" y2="-2.54" width="0.4064" layer="94"/>
<wire x1="1.27" y1="-2.54" x2="1.27" y2="2.54" width="0.4064" layer="94"/>
<wire x1="1.27" y1="2.54" x2="-6.35" y2="2.54" width="0.4064" layer="94"/>
<wire x1="-6.35" y1="2.54" x2="-6.35" y2="-2.54" width="0.4064" layer="94"/>
<text x="-6.35" y="3.175" size="1.778" layer="95">>NAME</text>
<text x="-6.35" y="-5.08" size="1.778" layer="96">>VALUE</text>
<pin name="1" x="-2.54" y="0" visible="pad" length="short" direction="pas" function="dot"/>
</symbol>
</symbols>
<devicesets>
<deviceset name="PINHD-1X1" prefix="JP" uservalue="yes">
<description>Pin header 1x1 for 0.1" spacing

With round pins</description>
<gates>
<gate name="G$1" symbol="PINHD1" x="0" y="0"/>
</gates>
<devices>
<device name="" package="1X01">
<connects>
<connect gate="G$1" pin="1" pad="1"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
</devices>
</deviceset>
</devicesets>
</library>
</libraries>
<attributes>
</attributes>
<variantdefs>
</variantdefs>
<classes>
<class number="0" name="default" width="0" drill="0">
</class>
</classes>
<parts>
<part name="R1" library="ng" deviceset="RESISTOR" device="1206" value="499"/>
<part name="T1" library="01_ng" deviceset="PHOTOTRANSISTOR" device="5MM"/>
<part name="JP1" library="01_adafruit" deviceset="PINHD-1X1" device=""/>
<part name="JP2" library="01_adafruit" deviceset="PINHD-1X1" device=""/>
<part name="JP3" library="01_adafruit" deviceset="PINHD-1X1" device=""/>
</parts>
<sheets>
<sheet>
<plain>
</plain>
<instances>
<instance part="R1" gate="G$1" x="30.48" y="58.42" rot="R90"/>
<instance part="T1" gate="1" x="40.64" y="78.74" rot="R270"/>
<instance part="JP1" gate="G$1" x="45.72" y="45.72" rot="R270"/>
<instance part="JP2" gate="G$1" x="38.1" y="45.72" rot="R270"/>
<instance part="JP3" gate="G$1" x="30.48" y="45.72" rot="R270"/>
</instances>
<busses>
</busses>
<nets>
<net name="N$2" class="0">
<segment>
<pinref part="R1" gate="G$1" pin="2"/>
<wire x1="30.48" y1="63.5" x2="30.48" y2="68.58" width="0.1524" layer="91"/>
<wire x1="30.48" y1="68.58" x2="38.1" y2="68.58" width="0.1524" layer="91"/>
<wire x1="30.48" y1="68.58" x2="30.48" y2="76.2" width="0.1524" layer="91"/>
<junction x="30.48" y="68.58"/>
<pinref part="T1" gate="1" pin="E"/>
<wire x1="30.48" y1="76.2" x2="35.56" y2="76.2" width="0.1524" layer="91"/>
<pinref part="JP2" gate="G$1" pin="1"/>
<wire x1="38.1" y1="48.26" x2="38.1" y2="68.58" width="0.1524" layer="91"/>
</segment>
</net>
<net name="+5V" class="0">
<segment>
<wire x1="45.72" y1="48.26" x2="45.72" y2="76.2" width="0.1524" layer="91"/>
<pinref part="T1" gate="1" pin="C"/>
<pinref part="JP1" gate="G$1" pin="1"/>
</segment>
</net>
<net name="N$1" class="0">
<segment>
<pinref part="R1" gate="G$1" pin="1"/>
<pinref part="JP3" gate="G$1" pin="1"/>
<wire x1="30.48" y1="48.26" x2="30.48" y2="53.34" width="0.1524" layer="91"/>
</segment>
</net>
</nets>
</sheet>
</sheets>
</schematic>
</drawing>
</eagle>

repository: FabAcademyFR/fabacademy-fr

repo_name: FabAcademyFR/fabacademy-fr

extension: sch

filename: INPUT DEVICE.sch


text:
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

import type { UA_Version } from './UA_Version';

export type UA_UserAgreement = {
    id: string;
    content: string;
    version: UA_Version;
    updated: string;
}

gha_language: TypeScript


text:
DESCRIPTION = "Python GObject bindings"
SECTION = "devel/python"
LICENSE = "LGPL"
DEPENDS = "libffi python-pygobject-native-${PV} glib-2.0"
PE = "1"

PR = "r3"

MAJ_VER = "${@bb.data.getVar('PV',d,1).split('.')[0]}.${@bb.data.getVar('PV',d,1).split('.')[1]}"

SRC_URI = "\
  ftp://ftp.gnome.org/pub/GNOME/sources/pygobject/${MAJ_VER}/pygobject-${PV}.tar.bz2 \
  file://generate-constants.patch \
"
S = "${WORKDIR}/pygobject-${PV}"

inherit autotools distutils-base pkgconfig

# necessary to let the call for python-config succeed
export BUILD_SYS
export HOST_SYS

# It picks up the introspection pc for the host sysroot without a knob to disable it, so force it to false
do_configure_prepend() {
	sed -i 's:have_gobject_introspection=true:have_gobject_introspection=false:g' configure.ac
}

do_install_append() {
	install -d ${D}${datadir}/pygobject/
	cp -PpRfR docs/* ${D}${datadir}/pygobject/
	install -d ${D}${datadir}/gtk-doc/html/pygobject/
	cp docs/style.css ${D}${datadir}/gtk-doc/html/pygobject/
}

PACKAGES += "${PN}-lib"

RDEPENDS_${PN} += "python-textutils"

FILES_${PN} = "${libdir}/python*"
FILES_${PN}-lib = "${libdir}/lib*.so.*"
FILES_${PN}-dev += "${bindir} ${datadir}"
FILES_${PN}-dbg += "${libdir}/.debug"

SRC_URI[md5sum] = "10e1fb79be3d698476a28b1e1b0c5640"
SRC_URI[sha256sum] = "41e923a3f4426a3e19f6d154c424e3dac6f39defca77af602ac6272ce270fa81"

repository: overo/overo-oe-natty

repo_name: overo/overo-oe-natty

branch_name: HEAD


text:
package main

type parser struct {
	captureBeginPattern pattern
	captureEndPattern   pattern
	capturedDataHandler dataHandler
	ignoredDataHandler  dataHandler
	findCaptureBegin    bool
	capturedData        []byte
}

func (p *parser) Init(captureBegin []byte, captureEnd []byte, capturedDataHandler dataHandler, ignoredDataHandler dataHandler) *parser {
	p.captureBeginPattern.Init(captureBegin)
	p.captureEndPattern.Init(captureEnd)
	p.capturedDataHandler = capturedDataHandler
	p.ignoredDataHandler = ignoredDataHandler
	p.findCaptureBegin = true
	return p
}

func (p *parser) FeedData(data []byte) bool {
	var ignoredData []byte

Loop:
	for {
		if p.findCaptureBegin {
			ignoredData = ignoredData[:0]
			i, ok := p.captureBeginPattern.FindStop(data, &ignoredData)

			if len(ignoredData) >= 1 {
				if !p.ignoredDataHandler(ignoredData) {
					return false
				}
			}

			if !ok {
				break Loop
			}

			data = data[i:]
			p.findCaptureBegin = false
		} else {
			i, ok := p.captureEndPattern.FindStop(data, &p.capturedData)

			if !ok {
				break Loop
			}

			if !p.capturedDataHandler(p.capturedData) {
				return false
			}

			p.capturedData = nil
			data = data[i:]
			p.findCaptureBegin = true
		}
	}

	return true
}

type pattern struct {
	raw                 []byte
	kmpNext             []int
	matchedPrefixLength int
}

func (p *pattern) Init(raw []byte) *pattern {
	p.raw = raw
	p.kmpNext = makeKMPNext(raw)
	return p
}

func (p *pattern) FindStop(data []byte, skippedData *[]byte) (int, bool) {
	i, j := 0, p.matchedPrefixLength

	for ; i < len(data) && j < len(p.raw); i, j = i+1, j+1 {
		k := j

		for j >= 0 && data[i] != p.raw[j] {
			j = p.kmpNext[j]
		}

		if j < k {
			if j < 0 {
				*skippedData = append(*skippedData, p.raw[:k]...)
				*skippedData = append(*skippedData, data[i])
			} else {
				*skippedData = append(*skippedData, p.raw[:k-j]...)
			}
		}
	}

	if j < len(p.raw) {
		p.matchedPrefixLength = j
		return 0, false
	}

	p.matchedPrefixLength = 0
	return i, true
}

func makeKMPNext(pattern []byte) []int {
	kmpNext := make([]int, len(pattern))

	for i, j := 0, -1; i < len(pattern); i, j = i+1, j+1 {
		kmpNext[i] = j

		for j >= 0 && pattern[i] != pattern[j] {
			j = kmpNext[j]
		}
	}

	return kmpNext
}

type dataHandler func(data []byte) (ok bool)


text:
include_guard()

include(colorful-message)
include(GoogleTest)

# https://stackoverflow.com/questions/733475/cmake-ctest-make-test-doesnt-build- tests
function(setup_tests_meta_target META_TARGET)
  add_custom_target(${META_TARGET}_build)
  add_custom_target(
    ${META_TARGET}
    COMMAND ${CMAKE_CTEST_COMMAND} . --schedule-random --output-on-failure --label-regex
            ${META_TARGET}
    DEPENDS ${META_TARGET}_build
    COMMENT "Build and run tests in ${META_TARGET} meta target"
    VERBATIM)
endfunction()

# Add Dependency between `TARGET_TO_ATTACH` and META_TARGETS _builds
function(attach_targets_to_meta_target)
  set(options)
  set(oneValueArgs TARGET_TO_ATTACH)
  set(multiValueArgs META_TARGETS)
  cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
  foreach(META_TARGET ${ARGS_META_TARGETS})
    add_dependencies(${META_TARGET}_build ${ARGS_TARGET_TO_ATTACH})
  endforeach()
endfunction()

# SUT allows to access private headers of system under test target SOURCES are *.cpp fiels with
# tests DEPENDS allows to create private dependnecy to test target eg. gtest META_TARGETS allows to
# add `TEST_TARGET` as depenency to meta tagets
function(add_test_executable TEST_TARGET)
  set(options)
  set(oneValueArgs SUT)
  set(multiValueArgs SOURCES DEPENDS META_TARGETS)
  cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
  if(NOT ARGS_SOURCES)
    cmessage(FATAL_ERROR "Target: ${TEST_TARGET} lacks sources.")
  endif()
  add_executable(${TEST_TARGET} "${ARGS_SOURCES}")
  target_link_libraries(${TEST_TARGET} PRIVATE "${ARGS_SUT}" "${ARGS_DEPENDS}" GTest::gmock
                                               GTest::gtest GTest::gtest_main)
  if(ARGS_SUT)
    target_include_directories(${TEST_TARGET}
                               PRIVATE $<TARGET_PROPERTY:${ARGS_SUT},INCLUDE_DIRECTORIES>)
  endif()
  gtest_discover_tests(${TEST_TARGET} PROPERTIES LABELS "${ARGS_META_TARGETS}")
  attach_targets_to_meta_target(TARGET_TO_ATTACH ${TEST_TARGET} META_TARGETS ${ARGS_META_TARGETS})
endfunction()

# MOCKS defines library, which will be mocked by `MOCKS_TARGET_NAME` DIR directory where mock files
# are stored META_TARGETS allows to add `MOCKS_TARGET_NAME` as depenency to meta tagets
function(add_mocks_target MOCKS_TARGET_NAME)
  set(options)
  set(oneValueArgs MOCKS DIR)
  set(multiValueArgs META_TARGETS)
  cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
  if(NOT ARGS_MOCKS)
    cmessage(FATAL_ERROR "Target: ${MOCKS_TARGET_NAME} lacks target to mock.")
  endif()
  if(NOT ARGS_DIR)
    cmessage(FATAL_ERROR "Target: ${MOCKS_TARGET_NAME} lacks directory with mocks.")
  endif()
  add_library(${MOCKS_TARGET_NAME} INTERFACE)
  # GoogleTest MOCKMETHOD macro uses zero-arguments variadic macros
  target_compile_options(${MOCKS_TARGET_NAME} INTERFACE "-Wno-gnu-zero-variadic-macro-arguments")
  target_include_directories(${MOCKS_TARGET_NAME} INTERFACE ${ARGS_DIR})
  target_link_libraries(${MOCKS_TARGET_NAME} INTERFACE ${ARGS_MOCKS} GTest::gmock)
  attach_targets_to_meta_target(TARGET_TO_ATTACH ${MOCKS_TARGET_NAME}
                                META_TARGETS ${ARGS_META_TARGETS})
endfunction()

repository: paweldac/cmake-template

repo_name: paweldac/cmake-template

extension: cmake


text:
package main

import "fmt"

//HummerModel 悍马模型
type HummerModel interface {
	start()
	stop()
	alarm()
	engineBoom()
	isAlarm() bool
	// set
}

//HummerH1Model 悍马类
type HummerH1Model struct {
	alarmFlag bool
}

func (hm *HummerH1Model) alarm() {
	fmt.Println("悍马H1鸣笛...")
}

func (hm *HummerH1Model) engineBoom() {
	fmt.Println("悍马H1引擎声音是这样的...")
}

func (hm *HummerH1Model) start() {
	fmt.Println("悍马H1发动...")
}

func (hm *HummerH1Model) stop() {
	fmt.Println("悍马H1停车...")
}

func (hm *HummerH1Model) isAlarm() bool {
	return hm.alarmFlag
}

func (hm *HummerH1Model) setalarm(flag bool) {
	hm.alarmFlag = flag
}

//调用入口...
func run(hm HummerModel) {
	//发动..
	hm.start()
	//引擎开始轰鸣
	hm.engineBoom()
	//看到一条狗挡路 就开始按喇叭 (喵喵喵?)
	if hm.isAlarm() {
		hm.alarm()
	}
	//停车...
	hm.stop()
}

func main() {
	hummer := new(HummerH1Model)
	hummer.setalarm(true)
	run(hummer)
}

repository: scbizu/DesignPattern

repo_name: scbizu/DesignPattern


text:
namespace ForumSystem.Web.Services.Statistics
{
    using System.Linq;

    using ForumSystem.Data;

    public class StatisticsService : IStatisticsService
    {
        private readonly ApplicationDbContext data;

        public StatisticsService(ApplicationDbContext data)
            => this.data = data;

        public StatisticsServiceModel Total()
        {
            var totalUsers = this.data.Users.Count();
            var totalPosts = this.data.Posts.Count();
            var totalVotes = this.data.Votes.Count();
            var totalComments = this.data.Comments.Count();

            return new StatisticsServiceModel
            {
                TotalUsers = totalUsers,
                TotalPosts = totalPosts,
                TotalVotes = totalVotes,
                TotalComments = totalComments,
            };
        }
    }
}