Skip to content

Instantly share code, notes, and snippets.

@ryanhex53
ryanhex53 / readme.md
Last active July 25, 2021 17:10
PKCS#8 PKCS#1 Convert

PUBLIC KEY

"BEGIN RSA PUBLIC KEY" is PKCS#1, which can only contain RSA keys. "BEGIN PUBLIC KEY" is PKCS#8, which can contain a variety of formats.

  • To convert from PKCS#8 to PKCS#1:

openssl rsa -pubin -in pub8.pem -RSAPublicKey_out -out pub1.pem

  • To convert from PKCS#1 to PKCS#8:
@ryanhex53
ryanhex53 / odoo_nginx.conf
Created May 27, 2021 07:56
odoo nginx config
#odoo server
upstream odoo {
server 127.0.0.1:8069;
}
upstream odoochat {
server 127.0.0.1:8072;
}
server
{
@ryanhex53
ryanhex53 / 3-4.cmd
Last active March 14, 2023 17:33
ffmpeg mp4 or hls tips
@echo off
rem 将任意视频剪切为3比4的画面并保持像素比例
set fullname=%1
set filename=%~n1
ffmpeg -i %fullname% -aspect 3:4 -vf "crop='min(iw,3/4*ih)':'min(ih,4/3*iw)':(iw/2)-(ow/2):(ih/2)-(oh/2)" %filename%-3-4.mp4
@ryanhex53
ryanhex53 / app.js
Created August 1, 2020 13:48
Minesweeper javascript web version
document.addEventListener('DOMContentLoaded', () => {
const params = new URLSearchParams(location.search);
const cols = parseInt(params.get('w')) || Math.floor(window.innerWidth / 35);
const rows = parseInt(params.get('h')) || Math.floor(window.innerHeight / 35);
const bombRatio = Math.max(0, Math.min(1, Number(params.get('r')) || 0.2));
const squares = [];
let isGameOver = false;
function createBoard() {
const grid = document.querySelector('.grid');
@ryanhex53
ryanhex53 / Utils.java
Last active July 21, 2020 15:40
compare specified child field between two json
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
public class Utils {
/**
* compare specified child field between two json
*
* @param json1 JsonObject or JsonArray in io.vertx.core.json
* @param json2 JsonObject or JsonArray in io.vertx.core.json
* @param path field path separate by dot, for example "modules.0.id", filed "modules" is JsonArray
@ryanhex53
ryanhex53 / utils.js
Created July 6, 2020 14:16
Represent a decimal by the given chars
/**
* represent a decimal by the given chars
* @param {Number} d decimal number
* @param {String} c target chars, default is 'hex' format, pass '01' for 'bin' format.
* more then 2 chars is required. for example encode(10) equals 'a', encode(10, '01') equals '1010'
*/
const encode = (d, c = '0123456789abcdef') => {
if (d >= c.length) {
return encode(parseInt(d / c.length), c) + c.charAt(d % c.length);
} else {
@ryanhex53
ryanhex53 / index.html
Created January 2, 2020 09:53
将图片的中间部分按比例投放到视图窗口中
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title></title>
</head>
<body>
<div id="app">
@ryanhex53
ryanhex53 / CupProblem.java
Last active November 17, 2019 04:26
水杯问题多语言版本
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* water cup problem solution java version
* 2019/11/16 ryanouyang
*/
@ryanhex53
ryanhex53 / app.js
Created August 2, 2019 10:43
auto balanced cluster express demo
const createError = require('http-errors');
const express = require('express');
const path = require('path');
const cookieParser = require('cookie-parser');
const session = require('express-session');
const RedisStore = require('connect-redis')(session);
const logger = require('morgan');
const indexRouter = require('./routes/index');
const usersRouter = require('./routes/users');
@ryanhex53
ryanhex53 / channel_v3.json
Created July 11, 2019 16:59
sublime v3 channel json
This file has been truncated, but you can view the full file.
{"schema_version": "3.0.0", "repositories": ["https://bitbucket.org/jjones028/p4sublime/raw/tip/packages.json", "https://packagecontrol.io/packages_2.json", "https://packagecontrol.io/repository.json", "https://packages.monokai.pro/packages.json", "https://raw.githubusercontent.com/20Tauri/DoxyDoxygen/master/DoxyDoxygen.json", "https://raw.githubusercontent.com/Andr3as/Sublime-SurroundWith/master/packages.json", "https://raw.githubusercontent.com/FichteFoll/sublime_packages/master/package_control.json", "https://raw.githubusercontent.com/Floobits/floobits-sublime/master/packages.json", "https://raw.githubusercontent.com/Harrison-M/indent.txt-sublime/master/packages.json", "https://raw.githubusercontent.com/Hexenon/FoxCode/master/packages.json", "https://raw.githubusercontent.com/Kaizhi/SublimeUpdater/master/packages.json", "https://raw.githubusercontent.com/Kasoki/FancyProjects/master/packages.json", "https://raw.githubusercontent.com/MattDMo/Neon-sublime-theme/master/packages.json", "https://raw.githubuserco