阅读视图

发现新文章,点击刷新页面。

Docker 搭建Github文件加速

前言

之前是nginx反代github,但是那样要解析很多个子域名,而有些人只需要下载加速就行了

截图

图片[1]-新锐博客

开源地址

Github:https://github.com/sky22333/hub-proxy

教程

命令安装

打开SSH链接并且输入如下代码安装docker容器

docker run -d 
  --name ghproxy 
  -p 5000:5000 
  --restart always 
  ghcr.io/sky22333/hub-proxy

设置反代

1.宝塔新建网站,PHP版本选择纯静态。

2.找到反向代理,添加反向代理,URL为ip+端口

3.反代设置完成,可以通过网站访问了。

nginx反向代理github

前言

因为众所周知的缘故,github时常访问不了,于是就想着反代一下,刚好有台华为云的香港服务器,于是火毅盾的负责人就给了我以下代码

此反代除了登录其他基本没啥问题

教程

1.打开宝塔面板,找到网站的反向代理,设置代理地址为https://github.com,发送域名为$host,然后确定之后可以看到有个配置文件,将如下代码放进去

location ^~ / {
    # 将请求代理到 GitHub
    proxy_pass https://github.com;

    # 设置转发到后端服务器的请求头
    proxy_set_header Host github.com;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_http_version 1.1;

    # 清空 Accept-Encoding 头,防止后端返回压缩内容
    proxy_set_header Accept-Encoding "";

    # 替换响应内容中的字符串
    sub_filter "github.githubassets.com" "assets-github.xrbk.cn";
    sub_filter "github.com" "github.xrbk.cn";
    sub_filter "api.github.com" "api-github.xrbk.cn";
    sub_filter 'raw.githubusercontent.com' 'raw.github.xrbk.cn';
    sub_filter_once off;
    sub_filter_types *;

    # 处理 302 重定向中的地址替换
    proxy_redirect ~^https://raw.githubusercontent.com(.*)$ https://raw.github.xrbk.cn$1;

    # 隐藏后端服务器返回的 Content-Security-Policy 头
    proxy_hide_header Content-Security-Policy;

    # 添加自定义的 Content-Security-Policy 头
    add_header Content-Security-Policy "default-src 'self'; img-src *; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'";

    # 静态文件缓存设置
    set $static_fileHbPPNEua 0;
    if ($uri ~* ".(gif|png|jpg|css|js|woff|woff2)$") {
        set $static_fileHbPPNEua 1;
        expires 1m;
    }
    if ($static_fileHbPPNEua = 0) {
        add_header Cache-Control no-cache;
    }
}

2.其中为xrbk.cn的后缀都需要更改为你的域名

3.在宝塔的网站里比如github.xrbk.cn中再添加其他例如api-github.xrbk.cn的域名

4.去服务商那解析这几个子域名即可

高效利用 GitHub 搜索,精准快速获取所需

1 前言

在互联网上寻找某件事情需要有正确的搜索技巧,在 GitHub 也不例外,通过一些搜索的语法和策略,可以帮助更精准、快速地定位到有价值的项目和代码片段。

在使用搜索前需要了解一个存储库大概包含哪些内容,可以在存储库详情页面查看,具体可参考下图。

image-20240702024947554

2 基础搜索语法

2.1 关键词搜索

最直接的方式,只需在搜索框中输入关键词,如:data visualization

image-20240702001751465

2.2 引号精确匹配

如果想要精确搜索某个短语,可以将其用引号括起来,如:"data visualization"

image-20240702002338077

3 高级搜索语法

3.1 按基本信息

语法描述
xxx in:name匹配名称中带有 xxx 的存储库
xxx in:description匹配说明中带有 xxx 的存储库
xxx in:topics匹配标签中带有 xxx 的存储库
xxx in:readme匹配自述文件中带有 xxx 的存储库
  • 示例1:匹配名称中带有 hexo 的存储库
1
hexo in:name

image-20240702025307675

  • 示例2:匹配标签中带有 hexo 的存储库
1
hexo in:topics

image-20240702025551676

3.2 按星数、分支数

语法描述
stars:m…n匹配 m 到 n 个星数的存储库
stars:>n匹配大于 n 个星数的存储库
>为判断,还可替换为>=<<=
forks:m…n匹配 m 到 n 个分支数的存储库
forks:<=n匹配小于等于 n 个分支数的存储库
<=为判断,还可替换为>>=<
  • 示例1:匹配小于等于 656 个星数的存储库(以 hexo 为例)
1
hexo stars:<=656

image-20240702031319498

  • 示例2:匹配大于 3k 分支数的存储库(以 hexo 为例)
1
hexo forks:>3000

image-20240702131951013

3.3 按语言

语法描述
language:LANGUAGE匹配编程语言为 LANGUAGE 的存储库
  • 示例:匹配语言为 TypeScript 的存储库(以 hexo 为例)
1
hexo language:TypeScript

image-20240702132715661

3.4 按创建时间、更新时间

语法描述
created:<YYYY-MM-DD匹配 YYYY 年 MM 月 DD 日之前创建的存储库
pushed:>YYYY-MM-DD匹配 YYYY 年 MM 月 DD 日之后更新的存储库
  • 示例:匹配 2024 年 2 月之后更新的存储库(以 hexo 为例)
1
hexo pushed:>=2024-03-01

image-20240702133521937

3.5 按用户、组织

语法描述
user:USERNAME匹配用户为 USERNAME 的存储库
org:ORGNAME匹配组织为 ORGNAME 的存储库
  • 示例:匹配用户为 hexojs 的存储库(以 hexo 为例)
1
hexo user:hexojs

image-20240702134656735

3.6 按许可证

语法描述
license:LICENSE匹配许可证为 LICENSE 的存储库
常用许可关键词有:MITApache-2.0GPL
  • 示例:匹配许可证为 Apache-2.0 的存储库(以 hexo 为例)
1
hexo license:Apache-2.0

image-20240702140718485

4 组合搜索技巧

结合前面的基础、高级搜索语法,可以实现更复杂、更精确的搜索。

  • 示例1:搜索 2024 年之后更新、星数大于 1k 的 hexo 存储库
1
hexo pushed:>=2024-01-01 stars:>1000

image-20240702141816163

  • 示例2:搜索 MIT 许可证、组织为 GitHub 、语言使用 JavaScript 的所有存储库
1
license:MIT org:github language:JavaScript

image-20240702141755227

5 利用高级搜索界面

GitHub 提供了一个高级搜索界面,通过它可以更直观地设置各种搜索条件,包括高级选项、存储库选项、代码选项、问题选项、用户选项等。

GitHub 高级搜索

6 写在最后

熟练掌握 GitHub 的搜索语法和技巧,能够大大提高在开源世界中的探索效率,更快地找到所需的代码资源,加速开发进程。在 GitHub 中诸如此类的效率方法还有很多,如果感兴趣可以查阅官方文档学习。

Simple Live - 聚合多平台的全网直播

介绍

Simple Live是一款聚合多个国内直播平台的第三方软件,它融合了哔哩哔哩、斗鱼、虎牙、抖音等平台,为用户提供了一个统一的观看界面。这个开源项目允许用户在不同的直播平台间切换,而不需要下载各自的官方APP,从而节省了空间和时间。

支持平台:

  • 虎牙直播
  • 斗鱼直播
  • 哔哩哔哩直播
  • 抖音直播

APP支持平台

  •  Android
  •  iOS
  •  Windows BETA
  •  MacOS BETA
  •  Linux BETA
  •  Android TV BETA

请到Releases下载最新版本,iOS请下载ipa文件自行签名安装

Windows可前往应用商店下载UWP版聚合直播

Android TV代码在tv分支, 桌面代码在desktop分支

截图

图片[1]-新锐博客

下载地址

Github全平台链接:https://github.com/xiaoyaocz/dart_simple_live

镜像站:https://hub.yzuu.cf/xiaoyaocz/dart_simple_live

推荐一款开源API开发工具

前言

无论是搭建网站还是其他的时候都缺不了API的支持,今天给大家推荐一款在GITHUB上高达19.3K的start的开源API开发工具-Bruno

截图

图片[1]-新锐博客

介绍

Bruno 是一款全新且创新的 API 客户端,旨在颠覆 Postman 和其他类似工具。

Bruno 直接在您的电脑文件夹中存储您的 API 信息。我们使用纯文本标记语言 Bru 来保存有关 API 的信息。

您可以使用 Git 或您选择的任何版本控制系统来对您的API信息进行版本控制和协作。

Bruno 仅限离线使用。我们计划永不向 Bruno 添加云同步功能。我们重视您的数据隐私,并认为它应该留在您的设备上

教程

GitHub:https://github.com/usebruno/bruno

下载地址:https://www.usebruno.com/downloads

 

利用 jsdelivr cdn 给Github图床加速

前言

很多站长因为节省服务器的空间,所以使用了Pic和Github来存储图片,但是访问速度堪忧,今天就教大家如何给图床加速。

教程

  1. 找到Github的图片原地址,例如:https://github.com/weilain/cdn-photo/blob/main/banner/bannar.jpg
  2. 按照规则替换图片地址:https://cdn.jsdelivr.net/gh/{user}/{repo}/图片路径
  3. 替换后链接为:https://cdn.jsdelivr.net/gh/weilain/cdn-photo/banner/bannar.jpg

结语

尝试了一下  访问速度还是很快的,比github快多了

利用cloudflare给github加速

前言

众所周知,github的访问总是会不尽如人意,有时候就会很快有时候就会访问不了,有大佬就想到了用cloudflare结合自定义域给github加速

教程

  1. 首先注册一个cloudflare的账号,然后创建一个workers。
  2. 填写完名称以后部署完成之后,点击快速编辑并将如下代码放到js中
// 你要镜像的网站.
const upstream = "www.github.com";
// 镜像网站的目录,比如你想镜像某个网站的二级目录则填写二级目录的目录名,镜像 google 用不到,默认即可.
const upstream_path = "/";
// 镜像站是否有手机访问专用网址,没有则填一样的.
const upstream_mobile = "www.github.com";
// 屏蔽国家和地区.
const blocked_region = ["KP", "SY", "PK", "CU"];
// 屏蔽 IP 地址.
const blocked_ip_address = ["0.0.0.0", "127.0.0.1"];
// 镜像站是否开启 HTTPS.
const https = true;
// 文本替换.
const replace_dict = {
  $upstream: "$custom_domain",
  "//github.com": "",
};
// 以下保持默认,不要动
addEventListener("fetch", (event) => {
  event.respondWith(fetchAndApply(event.request));
});
async function fetchAndApply(request) {
  const region = request.headers.get("cf-ipcountry").toUpperCase();
  const ip_address = request.headers.get("cf-connecting-ip");
  const user_agent = request.headers.get("user-agent");
  let response = null;
  let url = new URL(request.url);
  let url_hostname = url.hostname;
  if (https == true) {
    url.protocol = "https:";
  } else {
    url.protocol = "http:";
  }
  if (await device_status(user_agent)) {
    var upstream_domain = upstream;
  } else {
    var upstream_domain = upstream_mobile;
  }
  url.host = upstream_domain;
  if (url.pathname == "/") {
    url.pathname = upstream_path;
  } else {
    url.pathname = upstream_path + url.pathname;
  }
  if (blocked_region.includes(region)) {
    response = new Response(
      "Access denied: WorkersProxy is not available in your region yet.",
      {
        status: 403,
      }
    );
  } else if (blocked_ip_address.includes(ip_address)) {
    response = new Response(
      "Access denied: Your IP address is blocked by WorkersProxy.",
      {
        status: 403,
      }
    );
  } else {
    let method = request.method;
    let request_headers = request.headers;
    let new_request_headers = new Headers(request_headers);
    new_request_headers.set("Host", url.hostname);
    new_request_headers.set("Referer", url.hostname);
    let original_response = await fetch(url.href, {
      method: method,
      headers: new_request_headers,
    });
    let original_response_clone = original_response.clone();
    let original_text = null;
    let response_headers = original_response.headers;
    let new_response_headers = new Headers(response_headers);
    let status = original_response.status;
    new_response_headers.set("access-control-allow-origin", "*");
    new_response_headers.set("access-control-allow-credentials", true);
    new_response_headers.delete("content-security-policy");
    new_response_headers.delete("content-security-policy-report-only");
    new_response_headers.delete("clear-site-data");
    const content_type = new_response_headers.get("content-type");
    if (content_type.includes("text/html") && content_type.includes("UTF-8")) {
      original_text = await replace_response_text(
        original_response_clone,
        upstream_domain,
        url_hostname
      );
    } else {
      original_text = original_response_clone.body;
    }
    response = new Response(original_text, {
      status,
      headers: new_response_headers,
    });
  }
  return response;
}
async function replace_response_text(response, upstream_domain, host_name) {
  let text = await response.text();
  var i, j;
  for (i in replace_dict) {
    j = replace_dict[i];
    if (i == "$upstream") {
      i = upstream_domain;
    } else if (i == "$custom_domain") {
      i = host_name;
    }
    if (j == "$upstream") {
      j = upstream_domain;
    } else if (j == "$custom_domain") {
      j = host_name;
    }
    let re = new RegExp(i, "g");
    text = text.replace(re, j);
  }
  return text;
}
async function device_status(user_agent_info) {
  var agents = [
    "Android",
    "iPhone",
    "SymbianOS",
    "Windows Phone",
    "iPad",
    "iPod",
  ];
  var flag = true;
  for (var v = 0; v < agents.length; v++) {
    if (user_agent_info.indexOf(agents[v]) > 0) {
      flag = false;
      break;
    }
  }
  return flag;
}

 

改动此代码还可以加速其他网站

最后,添加路由就行(需要将域名托管在 cf 上)

结语

如果有空闲域名可以尝试部署一下,这样访问github等网站就比较方便了。

❌