file_path stringlengths 3 280 | file_language stringclasses 66
values | content stringlengths 1 1.04M | repo_name stringlengths 5 92 | repo_stars int64 0 154k | repo_description stringlengths 0 402 | repo_primary_language stringclasses 108
values | developer_username stringlengths 1 25 | developer_name stringlengths 0 30 | developer_company stringlengths 0 82 |
|---|---|---|---|---|---|---|---|---|---|
pyngo/__init__.py | Python | """Pydantic Package for Adding Models into a Django or Django Rest Framework Project"""
__version__ = "2.4.1"
from .errors import drf_error_details
from .openapi import ParameterDict, openapi_params
from .querydict import QueryDictModel, querydict_to_dict
__all__ = (
"ParameterDict",
"QueryDictModel",
"q... | yezz123/pyngo | 89 | Pydantic model support for Django & Django-Rest-Framework ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
pyngo/errors.py | Python | from collections.abc import Sequence
from typing import Any
from pydantic import ValidationError
def drf_error_details(exception: ValidationError) -> dict[str, Any]:
"""
Convert a pydantic ValidationError into a DRF-style error response.
Args:
exception (ValidationError): The exception to conver... | yezz123/pyngo | 89 | Pydantic model support for Django & Django-Rest-Framework ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
pyngo/openapi.py | Python | import types
from typing import Literal, Optional, Type, TypedDict, Union, cast, get_args, get_origin
from pydantic import BaseModel
from pydantic.fields import FieldInfo
_In = Literal["query", "header", "path", "cookie"]
ParameterDict = TypedDict(
"ParameterDict",
{
"name": str,
"in": _In,
... | yezz123/pyngo | 89 | Pydantic model support for Django & Django-Rest-Framework ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
pyngo/querydict.py | Python | from collections import deque
from types import NoneType, UnionType
from typing import Any, Type, get_args, get_origin
from django.http import QueryDict
from pydantic import BaseModel
from pydantic.fields import FieldInfo
from typing_extensions import Self
class QueryDictModel(BaseModel):
"""
A model that ca... | yezz123/pyngo | 89 | Pydantic model support for Django & Django-Rest-Framework ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/errors_test.py | Python | from typing import List, Optional
import pytest
from pydantic import BaseModel, ValidationError, field_validator
from pyngo import drf_error_details
from pyngo.errors import get_nested
class NestedModel(BaseModel):
str_field: str
@field_validator("str_field")
@classmethod
def must_be_bar(cls, value... | yezz123/pyngo | 89 | Pydantic model support for Django & Django-Rest-Framework ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/openapi_test.py | Python | from typing import Dict, Optional
import pytest
from pydantic import BaseModel, Field
from pyngo import ParameterDict, openapi_params
class TestPydanticModelToOpenapiParameters:
def test_only_primitive_types_allowed(self) -> None:
class Model(BaseModel):
non_primitive: Dict[str, str]
... | yezz123/pyngo | 89 | Pydantic model support for Django & Django-Rest-Framework ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/querydict_test.py | Python | import os
from collections import deque
from typing import Annotated, Any, Deque, Dict, FrozenSet, List, Optional, Tuple, Union
import pytest
from django.http import QueryDict
from pydantic import ConfigDict, Field
from pyngo import QueryDictModel
os.environ["DJANGO_SETTINGS_MODULE"] = "tests.settings"
class Model... | yezz123/pyngo | 89 | Pydantic model support for Django & Django-Rest-Framework ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/settings.py | Python | # Empty settings file just so we can pass Django
| yezz123/pyngo | 89 | Pydantic model support for Django & Django-Rest-Framework ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
__tests__/input.test.ts | TypeScript | import {
getInputs,
getVenvInput,
getVersionInput,
getCacheInput,
isCacheAllowed
} from '../src/inputs'
import * as core from '@actions/core'
jest.mock('@actions/core')
const mockedCore = core as jest.Mocked<typeof core>
const TEST_ENV_VARS = {
INPUT_MISSING: '',
INPUT_FALSY: 'false',
INPUT_TRUTHY: '... | yezz123/setup-uv | 43 | Set up your GitHub Actions workflow with a specific version of uv | TypeScript | yezz123 | Yasser Tahiri | Yezz LLC. |
src/cache.ts | TypeScript | import * as core from '@actions/core'
import * as cache from '@actions/cache'
import * as exec from '@actions/exec'
import * as io from '@actions/io'
import * as fs from 'fs'
import * as crypto from 'crypto'
import * as path from 'path'
import * as os from 'os'
const UV_CACHE_DIR =
process.env.UV_CACHE_DIR || path.j... | yezz123/setup-uv | 43 | Set up your GitHub Actions workflow with a specific version of uv | TypeScript | yezz123 | Yasser Tahiri | Yezz LLC. |
src/find.ts | TypeScript | import { addPath } from '@actions/core'
import { exec } from '@actions/exec'
import { mv } from '@actions/io'
import { downloadTool } from '@actions/tool-cache'
import os from 'os'
import path from 'path'
const UV_UNIX_LATEST_URL = 'https://astral.sh/uv/install.sh'
const UV_WIN_LATEST_URL = 'https://astral.sh/uv/inst... | yezz123/setup-uv | 43 | Set up your GitHub Actions workflow with a specific version of uv | TypeScript | yezz123 | Yasser Tahiri | Yezz LLC. |
src/inputs.ts | TypeScript | import { getInput, notice, warning } from '@actions/core'
import semver from 'semver'
export interface Inputs {
version: string | null
venv: string | null
cache: boolean
}
export function getInputs(): Inputs {
const version = getVersionInput('uv-version')
return {
version,
venv: getVenvInput('uv-ven... | yezz123/setup-uv | 43 | Set up your GitHub Actions workflow with a specific version of uv | TypeScript | yezz123 | Yasser Tahiri | Yezz LLC. |
src/main.ts | TypeScript | import { setFailed, getInput, warning } from '@actions/core'
import { findUv } from './find'
import { getInputs, isCacheAllowed } from './inputs'
import { activateVenv, createVenv } from './venv'
import { setupCache, restoreCache, saveCache, minimizeCache } from './cache'
async function run(): Promise<void> {
try {
... | yezz123/setup-uv | 43 | Set up your GitHub Actions workflow with a specific version of uv | TypeScript | yezz123 | Yasser Tahiri | Yezz LLC. |
src/venv.ts | TypeScript | import { exec } from '@actions/exec'
import { exportVariable, addPath } from '@actions/core'
import os from 'os'
import path from 'path'
const uvBinPath = path.join(os.homedir(), '.local', 'bin')
export async function createVenv(venv: string) {
if (os.platform() === 'win32') {
await exec('powershell', [
'... | yezz123/setup-uv | 43 | Set up your GitHub Actions workflow with a specific version of uv | TypeScript | yezz123 | Yasser Tahiri | Yezz LLC. |
app/__init__.py | Python | __version__ = "0.0.1"
| yezz123/stripe-template | 14 | Template for integrating stripe into your FastAPI application 💸 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
app/main.py | Python | from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.router.includes import app as router
from app.settings.config import Settings
config = Settings()
app = FastAPI(
description=config.API_DESCRIPTION,
title=config.API_TITLE,
version=config.API_VERSION,
docs_url=con... | yezz123/stripe-template | 14 | Template for integrating stripe into your FastAPI application 💸 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
app/router/includes.py | Python | from fastapi import APIRouter
from app.router.v1 import health, payment
app = APIRouter()
app.include_router(payment.app, tags=["Payment"])
app.include_router(health.router, tags=["Health"])
| yezz123/stripe-template | 14 | Template for integrating stripe into your FastAPI application 💸 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
app/router/v1/health.py | Python | from fastapi import APIRouter
router = APIRouter()
@router.get("/health")
async def health_check() -> str:
return "Pong!"
| yezz123/stripe-template | 14 | Template for integrating stripe into your FastAPI application 💸 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
app/router/v1/payment.py | Python | import stripe
from decouple import config
from fastapi import APIRouter, HTTPException, Request
from fastapi.responses import RedirectResponse
from pydantic import EmailStr, constr
from stripe import Customer, checkout, error
from app.settings.config import Settings
setting = Settings()
app = APIRouter()
stripe.ap... | yezz123/stripe-template | 14 | Template for integrating stripe into your FastAPI application 💸 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
app/settings/config.py | Python | from typing import List
from pydantic import BaseSettings, HttpUrl
class Settings(BaseSettings):
HOST: HttpUrl = "http://127.0.0.1:8000"
PAYMENT_METHOD_TYPES: List[str] = ["sepa_debit", "card"]
API_DOC_URL: str = "/docs"
API_OPENAPI_URL: str = "/openapi.json"
API_REDOC_URL: str = "/redoc"
API... | yezz123/stripe-template | 14 | Template for integrating stripe into your FastAPI application 💸 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
scripts/clean.sh | Shell | #!/bin/sh -e
rm -f `find . -type f -name '*.py[co]' `
rm -f `find . -type f -name '*~' `
rm -f `find . -type f -name '.*~' `
rm -f `find . -type f -name .coverage`
rm -f `find . -type f -name ".coverage.*"`
rm -rf `find . -name __pycache__`
rm -rf `find . -type d -name '*.egg-info' `
rm -rf `find . -type d -name 'pip-... | yezz123/stripe-template | 14 | Template for integrating stripe into your FastAPI application 💸 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
scripts/format.sh | Shell | #!/usr/bin/env bash
set -e
set -x
pre-commit run --all-files --verbose --show-diff-on-failure
| yezz123/stripe-template | 14 | Template for integrating stripe into your FastAPI application 💸 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
scripts/test.sh | Shell | #!/usr/bin/env bash
set -e
set -x
echo "ENV=${ENV}"
export PYTHONPATH=.
pytest --cov=app --cov=tests --cov-report=term-missing --cov-fail-under=80
| yezz123/stripe-template | 14 | Template for integrating stripe into your FastAPI application 💸 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/test_health.py | Python | from fastapi.testclient import TestClient
from app.main import app
client = TestClient(app)
def test_health() -> None:
response = client.get("/health")
assert response.status_code == 200
assert response.json() == "Pong!"
| yezz123/stripe-template | 14 | Template for integrating stripe into your FastAPI application 💸 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/test_payment.py | Python | from unittest.mock import Mock, patch
import pytest
import stripe
from fastapi.testclient import TestClient
from app.main import app
from app.router.v1.payment import session_url
from app.settings.config import Settings
config = Settings()
client = TestClient(app)
# Mock the stripe checkout session
@pytest.fixture... | yezz123/stripe-template | 14 | Template for integrating stripe into your FastAPI application 💸 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/test_version.py | Python | import app
def test_version() -> None:
assert app.__version__ == "0.0.1"
| yezz123/stripe-template | 14 | Template for integrating stripe into your FastAPI application 💸 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
jsonlib.h | C/C++ Header | //
// jsonlib.h
//
// Copyright (c) 2021 Yuji Hirose. All rights reserved.
// MIT License
//
#pragma once
#include <rapidjson/reader.h>
#include <functional>
#include <string>
namespace jsonlib {
using namespace rapidjson;
struct Handlers {
std::function<void()> Null;
std::function<void(bool b)> Bool;
st... | yhirose/cpp-jsonlib | 7 | A C++17 single-file header-only library to wrap RapidJSON SAX interface | C++ | yhirose | ||
mmaplib.h | C/C++ Header | //
// mmaplib.h
//
// Copyright (c) 2021 Yuji Hirose. All rights reserved.
// MIT License
//
#ifndef _CPPMMAPLIB_MMAPLIB_H_
#define _CPPMMAPLIB_MMAPLIB_H_
#if defined(_WIN32)
#include <windows.h>
#else
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#endif
#include <stdexcept>
n... | yhirose/cpp-mmaplib | 72 | A single file C++11 header-only memory mapped file library. | C++ | yhirose | ||
include/searchlib.h | C/C++ Header | //
// searchlib.h
//
// Copyright (c) 2021 Yuji Hirose. All rights reserved.
// MIT License
//
#pragma once
#include <algorithm>
#include <functional>
#include <map>
#include <optional>
#include <string>
#include <string_view>
#include <unordered_map>
#include <vector>
namespace searchlib {
//-------------------... | yhirose/cpp-searchlib | 33 | A C++17 full-text search engine library | C++ | yhirose | ||
scope/lib/flags.h | C/C++ Header | #ifndef FLAGS_H_
#define FLAGS_H_
#include <algorithm>
#include <array>
#include <optional>
#include <sstream>
#include <string>
#include <string_view>
#include <unordered_map>
#include <vector>
namespace flags {
namespace detail {
using argument_map =
std::unordered_map<std::string_view, std::optional<std::strin... | yhirose/cpp-searchlib | 33 | A C++17 full-text search engine library | C++ | yhirose | ||
scope/main.cpp | C++ | #include <iostream>
#include "lib/flags.h"
void usage() {
std::cout << R"(usage: scope [options] <command> [<args>]
commends:
index source INDEX_PATH - index documents
search INDEX_PATH [query] - search in documents
options:
-v verbose output
)";
}
int error(int code) {
... | yhirose/cpp-searchlib | 33 | A C++17 full-text search engine library | C++ | yhirose | ||
src/invertedindex.cpp | C++ | //
// invertedindex.cpp
//
// Copyright (c) 2021 Yuji Hirose. All rights reserved.
// MIT License
//
#include "searchlib.h"
#include "utils.h"
namespace searchlib {
IPostings::~IPostings() = default;
IInvertedIndex::~IInvertedIndex() = default;
//-----------------------------------------------------------------... | yhirose/cpp-searchlib | 33 | A C++17 full-text search engine library | C++ | yhirose | ||
src/lib/peglib.h | C/C++ Header | //
// peglib.h
//
// Copyright (c) 2020 Yuji Hirose. All rights reserved.
// MIT License
//
#pragma once
#include <algorithm>
#include <any>
#include <cassert>
#include <cctype>
#if __has_include(<charconv>)
#include <charconv>
#endif
#include <cstring>
#include <functional>
#include <initializer_list>
#include <... | yhirose/cpp-searchlib | 33 | A C++17 full-text search engine library | C++ | yhirose | ||
src/lib/unicodelib_encodings.h | C/C++ Header | //
// unicodelib_encodings.h
//
// Copyright (c) 2020 Yuji Hirose. All rights reserved.
// MIT License
//
#pragma once
#include <cstdlib>
#include <string>
#if !defined(__cplusplus) || __cplusplus < 201703L
#error "Requires complete C++17 support"
#endif
/*
namespace utf8 {
size_t codepoint_length(char32... | yhirose/cpp-searchlib | 33 | A C++17 full-text search engine library | C++ | yhirose | ||
src/query.cpp | C++ | //
// query.cpp
//
// Copyright (c) 2021 Yuji Hirose. All rights reserved.
// MIT License
//
#include "lib/peglib.h"
#include "searchlib.h"
#include "utils.h"
namespace searchlib {
std::optional<Expression> parse_query(const IInvertedIndex &inverted_index,
Normalizer normaliz... | yhirose/cpp-searchlib | 33 | A C++17 full-text search engine library | C++ | yhirose | ||
src/search.cpp | C++ | //
// search.cpp
//
// Copyright (c) 2021 Yuji Hirose. All rights reserved.
// MIT License
//
#include <array>
#include <cassert>
#include <iostream>
#include <numeric>
#include "./utils.h"
#include "searchlib.h"
namespace searchlib {
class TermSearchResult : public IPostings {
public:
TermSearchResult(const I... | yhirose/cpp-searchlib | 33 | A C++17 full-text search engine library | C++ | yhirose | ||
src/tokenizer.cpp | C++ | //
// tokenizer.cpp
//
// Copyright (c) 2021 Yuji Hirose. All rights reserved.
// MIT License
//
#include "lib/unicodelib.h"
#include "lib/unicodelib_encodings.h"
#include "searchlib.h"
using namespace unicode;
namespace searchlib {
TextRange text_range(const TextRangeList<TextRange> &text_range_list,
... | yhirose/cpp-searchlib | 33 | A C++17 full-text search engine library | C++ | yhirose | ||
src/utils.cpp | C++ | //
// utils.cpp
//
// Copyright (c) 2021 Yuji Hirose. All rights reserved.
// MIT License
//
#include "utils.h"
#include "lib/unicodelib_encodings.h"
namespace searchlib {
std::string u8(std::u32string_view u32) { return unicode::utf8::encode(u32); }
std::u32string u32(std::string_view u8) { return unicode::utf... | yhirose/cpp-searchlib | 33 | A C++17 full-text search engine library | C++ | yhirose | ||
src/utils.h | C/C++ Header | //
// utils.h
//
// Copyright (c) 2021 Yuji Hirose. All rights reserved.
// MIT License
//
#pragma once
#include <string>
namespace searchlib {
std::string u8(std::u32string_view u32);
std::u32string u32(std::string_view u8);
} // namespace searchlib
| yhirose/cpp-searchlib | 33 | A C++17 full-text search engine library | C++ | yhirose | ||
test/split_to_chapters.py | Python | import sys
from itertools import groupby
lines = [line.rstrip().split('\t') for line in sys.stdin.readlines()]
for key, group in groupby(lines, key=lambda x: [int(x[1]), int(x[2])]):
book, chap = key
text = '\\n'.join([x[4] for x in group])
print('{:d}{:02d}\t{}'.format(book, chap, text))
| yhirose/cpp-searchlib | 33 | A C++17 full-text search engine library | C++ | yhirose | ||
test/test.cc | C++ | #include <gtest/gtest.h>
#include <searchlib.h>
#include "test_utils.h"
using namespace searchlib;
std::vector<std::string> sample_documents = {
"This is the first document.",
"This is the second document.",
"This is the third document. This is the second sentence in the third.",
"Fourth document",
... | yhirose/cpp-searchlib | 33 | A C++17 full-text search engine library | C++ | yhirose | ||
test/test_kjv.cc | C++ | #include <gtest/gtest.h>
#include <searchlib.h>
#include <filesystem>
#include <fstream>
#include "test_utils.h"
using namespace searchlib;
const auto KJV_PATH = "../../test/t_kjv.tsv";
auto normalizer = [](auto sv) { return unicode::to_lowercase(sv); };
static auto kjv_index() {
InMemoryInvertedIndex<TextRang... | yhirose/cpp-searchlib | 33 | A C++17 full-text search engine library | C++ | yhirose | ||
test/test_kjv_chapters.cc | C++ | #include <gtest/gtest.h>
#include <searchlib.h>
#include <filesystem>
#include <fstream>
#include "test_utils.h"
using namespace searchlib;
const auto KJV_PATH = "../../test/t_kjv_chapters.tsv";
auto normalizer = [](auto sv) { return unicode::to_lowercase(sv); };
static auto kjv_index() {
return make_in_memory... | yhirose/cpp-searchlib | 33 | A C++17 full-text search engine library | C++ | yhirose | ||
test/test_utils.h | C/C++ Header | #include <sstream>
#include "lib/unicodelib.h"
#include "utils.h"
inline bool close_enough(double expect, double actual) {
auto tolerance = 0.001;
return (expect - tolerance) <= actual && actual <= (expect + tolerance);
}
#define EXPECT_AP(a, b) EXPECT_TRUE(close_enough(a, b))
inline std::u32string to_lowercas... | yhirose/cpp-searchlib | 33 | A C++17 full-text search engine library | C++ | yhirose | ||
test.cc | C++ | #include <iostream>
#include <strstream>
#include <unistd.h>
#include "threadpool.h"
using namespace std;
int main(void) {
threadpool::pool pool;
pool.start(4);
thread t = thread([&] {
size_t id = 0;
while (id < 20) {
pool.enqueue([=] {
sleep(1);
strstream ss;
ss << "[jo... | yhirose/cpp-threadpool | 19 | C++11 header-only thread pool library | C++ | yhirose | ||
threadpool.h | C/C++ Header | //
// threadpool.h
//
// Copyright (c) 2019 Yuji Hirose. All rights reserved.
// MIT License
//
#ifndef CPPHTTPLIB_THREADPOOL_H
#define CPPHTTPLIB_THREADPOOL_H
#include <condition_variable>
#include <functional>
#include <list>
#include <mutex>
#include <thread>
#include <vector>
namespace threadpool {
class poo... | yhirose/cpp-threadpool | 19 | C++11 header-only thread pool library | C++ | yhirose | ||
scripts/gen_property_values.py | Python | import sys
import re
MaxCode = 0x0010FFFF
r = re.compile(r"^[0-9A-F]+(?:\.\.[0-9A-F]+)?\s*;\s*(.+?)\s*(?:#.+)?$")
names = []
for line in sys.stdin.readlines():
m = r.match(line)
if m:
name = ''.join([x.title() if x.islower() else x for x in re.split(r"[ -]", m.group(1))])
if not name in names... | yhirose/cpp-unicodelib | 122 | A C++17 header-only Unicode library. (Unicode 17.0.0) | C++ | yhirose | ||
scripts/gen_tables.py | Python | import sys
import re
#------------------------------------------------------------------------------
# Constants
#------------------------------------------------------------------------------
MaxCopePoint = 0x0010FFFF
#------------------------------------------------------------------------------
# Utilities
#-----... | yhirose/cpp-unicodelib | 122 | A C++17 header-only Unicode library. (Unicode 17.0.0) | C++ | yhirose | ||
scripts/gen_unicode_names.py | Python | import sys
import re
def getNameAliases(ucd):
dict = {}
fin = open(ucd + '/NameAliases.txt')
for line in fin:
line = line.rstrip()
if len(line) > 0 and line[0] != '#':
flds = line.split(';')
cp = int(flds[0], 16)
if not cp in dict:
dict[cp... | yhirose/cpp-unicodelib | 122 | A C++17 header-only Unicode library. (Unicode 17.0.0) | C++ | yhirose | ||
scripts/update.py | Python | #!/usr/bin/env python3
"""
Update unicodelib.h with UCD.
This script processes unicodelib.h and updates all generated blocks
by executing the commands specified in COMMAND: lines.
"""
import re
import subprocess
import sys
import os
def find_generated_blocks(content):
"""
Find all generated blocks in the co... | yhirose/cpp-unicodelib | 122 | A C++17 header-only Unicode library. (Unicode 17.0.0) | C++ | yhirose | ||
scripts/update.sh | Shell | #!/bin/bash
cd "$(dirname "$0")/.."
set -e
uv run scripts/update.py
uv run scripts/gen_unicode_names.py UCD > unicodelib_names.h
| yhirose/cpp-unicodelib | 122 | A C++17 header-only Unicode library. (Unicode 17.0.0) | C++ | yhirose | ||
test/test.cpp | C++ | #include <unicodelib.h>
#include <unicodelib_encodings.h>
#include <catch2/catch_test_macros.hpp>
#include <fstream>
#include <sstream>
using namespace std;
using namespace unicode;
template <class Fn>
void split(const char *b, const char *e, char d, Fn fn) {
int i = 0;
int beg = 0;
while (e ? (b + i != e) :... | yhirose/cpp-unicodelib | 122 | A C++17 header-only Unicode library. (Unicode 17.0.0) | C++ | yhirose | ||
test/test2.cpp | C++ | // This file is to check duplicate symbols
#include <catch2/catch_test_macros.hpp>
#include <unicodelib.h>
TEST_CASE("Duplicate Check", "[duplicate]") {
REQUIRE(unicode::is_white_space(U'a') == false);
}
| yhirose/cpp-unicodelib | 122 | A C++17 header-only Unicode library. (Unicode 17.0.0) | C++ | yhirose | ||
unicodelib_encodings.h | C/C++ Header | //
// unicodelib_encodings.h
//
// Copyright (c) 2025 Yuji Hirose. All rights reserved.
// MIT License
//
#pragma once
#include <cstdint>
#include <cstdlib>
#include <string>
#if !defined(__cplusplus) || __cplusplus < 201703L
#error "Requires complete C++17 support"
#endif
/*
namespace utf8 {
size_t code... | yhirose/cpp-unicodelib | 122 | A C++17 header-only Unicode library. (Unicode 17.0.0) | C++ | yhirose | ||
example/example.cpp | C++ | #include <filesystem>
#include <iostream>
#include "zipper.h"
namespace fs = std::filesystem;
int main() {
{
zipper::Zip zip("test_copy.zip");
zipper::enumerate("test.zip", [&zip](auto &unzip) {
if (unzip.is_dir()) {
zip.add_dir(unzip.file_path());
} else {
std::string buf;
... | yhirose/cpp-zipper | 29 | A single file C++ header-only minizip wrapper library | C++ | yhirose | ||
zipper.h | C/C++ Header | //
// zipper.h
//
// This code is based on 'Making MiniZip Easier to Use' by John Schember.
// https://nachtimwald.com/2019/09/08/making-minizip-easier-to-use/
//
// Copyright (c) 2021 Yuji Hirose. All rights reserved.
// MIT License
//
#pragma once
#include <minizip/unzip.h>
#include <minizip/zip.h>
#include <... | yhirose/cpp-zipper | 29 | A single file C++ header-only minizip wrapper library | C++ | yhirose | ||
fzbz.cc | C++ | //
// FizzBuzzLang
// A Programming Language just for writing Fizz Buzz program. :)
//
// Copyright (c) 2021 Yuji Hirose. All rights reserved.
// MIT License
//
#include <fstream>
#include <variant>
#include "peglib.h"
using namespace std;
using namespace peg;
using namespace peg::udl;
//-----------------------... | yhirose/fizzbuzzlang | 6 | A Programming Language just for writing Fizz Buzz program. :) | C++ | yhirose | ||
include/array.h | C/C++ Header | #pragma once
#include <metal.h>
#include <concepts>
#include <iostream>
#include <iterator>
#include <limits>
#include <ranges>
namespace mtl {
using shape_type = std::vector<size_t>;
using strides_type = shape_type;
//------------------------------------------------------------------------------
template <value_... | yhirose/mtlcpp | 16 | Utilities for Metal-cpp | C++ | yhirose | ||
include/metal.h | C/C++ Header | #pragma once
#include <Metal/Metal.hpp>
#include <numeric>
#include <sstream>
namespace mtl {
template <typename T>
concept value_type =
std::same_as<T, float> || std::same_as<T, int> || std::same_as<T, bool>;
template <typename T>
concept arithmetic = std::is_arithmetic_v<T>;
//-------------------------------... | yhirose/mtlcpp | 16 | Utilities for Metal-cpp | C++ | yhirose | ||
include/mtlcpp.h | C/C++ Header | #pragma once
#include "./metal.h"
#include "./array.h"
| yhirose/mtlcpp | 16 | Utilities for Metal-cpp | C++ | yhirose | ||
metal-cpp_macOS14.2_iOS17.2/Metal/Metal.hpp | C++ Header | //
// Metal.hpp
//
// Autogenerated on February 11, 2024.
//
// Copyright 2020-2023 Apple Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LIC... | yhirose/mtlcpp | 16 | Utilities for Metal-cpp | C++ | yhirose | ||
test/bench.cpp | C++ | #define NS_PRIVATE_IMPLEMENTATION
#define MTL_PRIVATE_IMPLEMENTATION
#define ANKERL_NANOBENCH_IMPLEMENT
#include <mtlcpp.h>
#include <eigen3/Eigen/Core>
#include "nanobench.h"
using namespace ankerl::nanobench;
void add() {
const size_t n = 10'000'000;
auto a = mtl::ones<float>({n});
auto b = mtl::ones<floa... | yhirose/mtlcpp | 16 | Utilities for Metal-cpp | C++ | yhirose | ||
test/doctest.h | C/C++ Header | // ====================================================================== lgtm [cpp/missing-header-guard]
// == DO NOT MODIFY THIS FILE BY HAND - IT IS AUTO GENERATED BY CMAKE! ==
// ======================================================================
//
// doctest.h - the lightest feature-rich C++ single-header test... | yhirose/mtlcpp | 16 | Utilities for Metal-cpp | C++ | yhirose | ||
test/mnist.cpp | C++ | #define NS_PRIVATE_IMPLEMENTATION
#define MTL_PRIVATE_IMPLEMENTATION
#include <mtlcpp.h>
#include <sys/stat.h>
#include <fstream>
#include <iostream>
#include <map>
class memory_mapped_file {
public:
memory_mapped_file(const char* path) {
fd_ = open(path, O_RDONLY);
assert(fd_ != -1);
struct stat sb;... | yhirose/mtlcpp | 16 | Utilities for Metal-cpp | C++ | yhirose | ||
test/nanobench.h | C/C++ Header | // __ _ _______ __ _ _____ ______ _______ __ _ _______ _ _
// | \ | |_____| | \ | | | |_____] |______ | \ | | |_____|
// | \_| | | | \_| |_____| |_____] |______ | \_| |_____ | |
//
// Microbenchmark framework for C++11/14/17/20
// https://github.com/martinus/nanobench
//
// Lice... | yhirose/mtlcpp | 16 | Utilities for Metal-cpp | C++ | yhirose | ||
test/test.cpp | C++ | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest.h"
#define ANKERL_NANOBENCH_IMPLEMENT
#include "nanobench.h"
#define NS_PRIVATE_IMPLEMENTATION
#define MTL_PRIVATE_IMPLEMENTATION
#include <Metal/Metal.hpp>
| yhirose/mtlcpp | 16 | Utilities for Metal-cpp | C++ | yhirose | ||
test/test_2lnn.cpp | C++ | #include <mtlcpp.h>
#include "doctest.h"
mtl::array<float> mean_square_error_derivative(float dout,
const mtl::array<float>& out,
const mtl::array<float>& Y) {
return dout * (2 * (out - Y));
}
mtl::array<float> sigmoid_de... | yhirose/mtlcpp | 16 | Utilities for Metal-cpp | C++ | yhirose | ||
test/test_array.cpp | C++ | #include <mtlcpp.h>
#include <iostream>
#include <ranges>
#include "doctest.h"
using namespace mtl;
auto itoa(size_t size, size_t init = 1) {
return std::views::iota(init) | std::views::take(size);
}
//------------------------------------------------------------------------------
TEST_CASE("array: scalar size")... | yhirose/mtlcpp | 16 | Utilities for Metal-cpp | C++ | yhirose | ||
test/test_examples.cpp | C++ | #include <mtlcpp.h>
#include "doctest.h"
using namespace mtl;
TEST_CASE("example: create empty array") {
auto i = empty<int>({2, 3, 2});
auto f = empty<float>({2, 3, 2});
// auto d = empty<double>({2, 3}); // cannot compile...
}
TEST_CASE("example: create array with constants") {
auto s = array<float>(1);
... | yhirose/mtlcpp | 16 | Utilities for Metal-cpp | C++ | yhirose | ||
test/test_perceptron.cpp | C++ | #include <mtlcpp.h>
#include "doctest.h"
class LogicGate {
private:
float w0 = 0.1;
float w1 = 0.1;
float b = 0.1;
auto range(size_t count) {
return std::views::iota(1) | std::views::take(count);
}
int predict(int x0, int x1) {
auto y = (x0 * w0) + (x1 * w1) + b;
return y > 0 ? 1 : 0;
}
... | yhirose/mtlcpp | 16 | Utilities for Metal-cpp | C++ | yhirose | ||
fetch_leetcode.py | Python | #!/usr/bin/env python3
"""获取 LeetCode CN 的所有简单题目 - 只做 easy,不要忘了为什么出发"""
import requests
url = "https://leetcode.cn/graphql/"
headers = {"Content-Type": "application/json"}
query = """
query problemsetQuestionList($categorySlug: String, $limit: Int, $skip: Int, $filters: QuestionListFilterInput) {
problemsetQuestion... | yihong0618/2026 | 11 | 2026 | Python | yihong0618 | yihong | apache |
get_up.py | Python | import argparse
import random
import os
import tempfile
import duckdb
import pendulum
import requests
import telebot
from github import Auth, Github
from telegramify_markdown import markdownify
from zhconv import convert
# 1 real get up
GET_UP_ISSUE_NUMBER = 1
GET_UP_MESSAGE_TEMPLATE = """今天的起床时间是--{get_up_time}。
起床... | yihong0618/2026 | 11 | 2026 | Python | yihong0618 | yihong | apache |
test_daily_message.py | Python | #!/usr/bin/env python3
"""测试每天生成的完整起床消息"""
import os
import sys
import pendulum
# 导入 get_up.py 中的函数
sys.path.insert(0, os.path.dirname(__file__))
from get_up import (
GET_UP_MESSAGE_TEMPLATE,
TIMEZONE,
get_one_sentence,
get_day_of_year,
get_year_progress,
get_running_distance,
get_history_... | yihong0618/2026 | 11 | 2026 | Python | yihong0618 | yihong | apache |
src/rogvibe/__init__.py | Python | """Rogvibe - A terminal-based viber selection tool."""
from __future__ import annotations
from .app import DEFAULT_PARTICIPANTS, LotteryApp, SlotMachineApp, run, run_slot_machine
from .models import SpinFinished, SpinTick
from .widgets import LotteryWheel
__all__ = [
"DEFAULT_PARTICIPANTS",
"LotteryApp",
... | yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
src/rogvibe/__main__.py | Python | """Command-line interface for rogvibe."""
from __future__ import annotations
import sys
from typing import Sequence
from .app import run, run_flip_card, run_slot_machine
def main(argv: Sequence[str] | None = None) -> None:
"""CLI entrypoint invoked via `python -m rogvibe` or project scripts."""
args = list... | yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
src/rogvibe/app.py | Python | """Main entry point and public API for rogvibe."""
from __future__ import annotations
from typing import Iterable
from .apps import FlipCardApp, LotteryApp, SlotMachineApp
from .constants import FALLBACK_DEFAULTS
from .utils import detect_default_participants
# Prefer detected providers, otherwise fall back to samp... | yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
src/rogvibe/apps/__init__.py | Python | """Application classes for rogvibe."""
from __future__ import annotations
from .flip_card_app import FlipCardApp
from .lottery_app import LotteryApp
from .slot_machine_app import SlotMachineApp
__all__ = [
"LotteryApp",
"SlotMachineApp",
"FlipCardApp",
]
| yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
src/rogvibe/apps/flip_card_app.py | Python | """Flip card game application."""
from __future__ import annotations
from typing import Any
from rich.text import Text
from textual.app import App, ComposeResult
from textual.containers import Vertical
from textual.widgets import Footer, Static
from ..models.messages import AllCardsMatched, PairMatched
from ..utils... | yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
src/rogvibe/apps/lottery_app.py | Python | """Lottery wheel application."""
from __future__ import annotations
from typing import Any, Sequence
from rich.text import Text
from textual.app import App, ComposeResult
from textual.containers import Vertical
from textual.widgets import Footer, Static
from ..constants import SPECIAL_PARTICIPANTS
from ..models.mes... | yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
src/rogvibe/apps/slot_machine_app.py | Python | """Slot machine application."""
from __future__ import annotations
from collections import Counter
from typing import Any
from rich.text import Text
from textual.app import App, ComposeResult
from textual.containers import Vertical
from textual.widgets import Footer, Static
from ..models.messages import SlotAllStop... | yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
src/rogvibe/config.py | Python | """Deprecated: Configuration has been moved to constants.py"""
from __future__ import annotations
from .constants import MAYBE_VIBER
__all__ = ["MAYBE_VIBER"]
| yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
src/rogvibe/constants.py | Python | """Constants and configuration for rogvibe."""
from __future__ import annotations
# Fallback participant names
FALLBACK_DEFAULTS: list[str] = [
"handy",
"handy",
"handy",
"handy",
]
# List of potential viber commands to detect on the system
# add more here PR welcome
MAYBE_VIBER: list[str] = [
"k... | yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
src/rogvibe/models/__init__.py | Python | """Message models for rogvibe."""
from __future__ import annotations
from .messages import (
SlotAllStopped,
SlotReelSpinning,
SlotReelStopped,
SpinFinished,
SpinTick,
)
__all__ = [
"SpinFinished",
"SpinTick",
"SlotReelSpinning",
"SlotReelStopped",
"SlotAllStopped",
]
| yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
src/rogvibe/models/messages.py | Python | """Message classes for widget communication."""
from __future__ import annotations
from textual.message import Message
from textual.widget import Widget
class SpinFinished(Message):
"""Fired when the wheel stops spinning."""
def __init__(self, sender: Widget, winner: str) -> None:
try:
... | yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
src/rogvibe/utils/__init__.py | Python | """Utility functions for rogvibe."""
from __future__ import annotations
from .detector import detect_default_participants
from .executor import execute_command
__all__ = [
"detect_default_participants",
"execute_command",
]
| yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
src/rogvibe/utils/detector.py | Python | """Participant detection utilities."""
from __future__ import annotations
import random
import shutil
from ..constants import MAYBE_VIBER
def detect_default_participants() -> list[str]:
"""Detect available viber commands on the system.
Returns:
List of detected providers, shuffled and padded to ap... | yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
src/rogvibe/utils/executor.py | Python | """Command execution utilities."""
from __future__ import annotations
import os
import shlex
import shutil
import sys
from contextlib import nullcontext
from typing import Any
def execute_command(winner: str, app: Any) -> None:
"""Execute the winner as a command and exit the app.
Args:
winner: The ... | yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
src/rogvibe/widgets/__init__.py | Python | """UI widgets for rogvibe."""
from __future__ import annotations
from .flip_card import Card, FlipCardGrid
from .lottery_wheel import LotteryWheel
from .slot_machine import SlotMachineLever, SlotMachineReel, SlotMachineWidget
__all__ = [
"LotteryWheel",
"SlotMachineReel",
"SlotMachineLever",
"SlotMac... | yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
src/rogvibe/widgets/flip_card.py | Python | """Flip card game widget."""
from __future__ import annotations
from textual.app import ComposeResult
from textual.containers import Grid
from textual.message import Message
from textual.widget import Widget
from textual.widgets import Static
class Card(Static):
"""A single card widget."""
def __init__(sel... | yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
src/rogvibe/widgets/lottery_wheel.py | Python | """Lottery wheel widget."""
from __future__ import annotations
import random
from typing import Any, Sequence
from rich import box
from rich.align import Align
from rich.panel import Panel
from rich.table import Table
from rich.text import Text
from textual.reactive import reactive
from textual.widget import Widget
... | yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
src/rogvibe/widgets/slot_machine.py | Python | """Slot machine widgets."""
from __future__ import annotations
import random
from typing import Any
from rich.text import Text
from textual.app import ComposeResult
from textual.containers import Horizontal
from textual.reactive import reactive
from textual.widget import Widget
from ..models.messages import SlotAll... | yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
tests/__init__.py | Python | """Test package for rogvibe."""
| yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
tests/conftest.py | Python | """Pytest configuration and fixtures for rogvibe tests."""
import pytest
from unittest.mock import Mock
@pytest.fixture
def mock_app():
"""Create a mock Textual app for testing."""
app = Mock()
app.suspend = Mock()
app.exit = Mock()
return app
@pytest.fixture
def mock_widget():
"""Create a ... | yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
tests/test_app.py | Python | """Tests for rogvibe.app module."""
from unittest.mock import Mock, patch
from rogvibe.app import run, run_slot_machine, run_flip_card, DEFAULT_PARTICIPANTS
class TestApp:
"""Test cases for app module functions."""
def test_run_with_none_participants(self):
"""Test run function with None participant... | yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
tests/test_config.py | Python | """Tests for rogvibe.config module."""
class TestConfig:
"""Test cases for config module."""
def test_maybe_viber_import(self):
"""Test that MAYBE_VIBER can be imported from config."""
from rogvibe.config import MAYBE_VIBER
assert MAYBE_VIBER is not None
assert isinstance(MAY... | yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
tests/test_constants.py | Python | """Tests for rogvibe.constants module."""
from rogvibe.constants import (
FALLBACK_DEFAULTS,
MAYBE_VIBER,
ANIMATION_COLORS,
BORDER_COLORS,
CELEBRATION_EMOJIS,
DICE_FACES,
DICE_EMOJI,
TARGET_EMOJI,
SPECIAL_PARTICIPANTS,
)
class TestConstants:
"""Test cases for constants."""
... | yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
tests/test_detector.py | Python | """Tests for rogvibe.utils.detector module."""
from unittest.mock import patch
from rogvibe.utils.detector import detect_default_participants
class TestDetector:
"""Test cases for detector module."""
def test_detect_default_participants_no_providers(self):
"""Test when no providers are detected."""
... | yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
tests/test_main.py | Python | """Tests for rogvibe.__main__ module."""
from unittest.mock import patch
from rogvibe.__main__ import main
class TestMain:
"""Test cases for main function."""
def test_main_with_slot_argument(self):
"""Test main function with --slot argument."""
with patch("rogvibe.__main__.run_slot_machine"... | yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
tests/test_models/test_messages.py | Python | """Tests for rogvibe.models.messages module."""
from unittest.mock import Mock
from textual.widget import Widget
from rogvibe.models.messages import (
SpinFinished,
SpinTick,
SlotReelSpinning,
SlotReelStopped,
SlotAllStopped,
AllCardsMatched,
PairMatched,
)
class TestMessages:
"""Test... | yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
tests/test_utils/test_executor.py | Python | """Tests for rogvibe.utils.executor module."""
from unittest.mock import Mock, patch
from rogvibe.utils.executor import execute_command
class TestExecutor:
"""Test cases for executor module."""
def test_execute_command_with_code(self):
"""Test execute_command with 'code' command adds '.' argument.""... | yihong0618/rogvibe | 28 | Rogue your vibe hero like rogue like. | Python | yihong0618 | yihong | apache |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.