Friday, July 25, 2025

memo 调查这些 股票

调查一下这些股票

东京电力 9501  价格 571
川崎汽船 9107  price 2179
丸红 8002, 3090
sakura inter 3778, price 3645


Wednesday, December 11, 2024

Run Ollama locally

 

Python


pip install ollama


import ollama

response = ollama.chat(model='gemma2', messages=[  {    'role': 'user',    'content': 'Why is the sky blue?',  },])

print(response['message']['content'])


Java 

Gradle 

// https://mvnrepository.com/artifact/dev.langchain4j/langchain4j-ollama

implementation 'dev.langchain4j:langchain4j-ollama:0.36.2'




package ollama.test;


import dev.langchain4j.model.chat.ChatLanguageModel;

import dev.langchain4j.model.ollama.OllamaChatModel;


public class Test {


public static void main(String[] args) {


ChatLanguageModel model = OllamaChatModel.builder()

.baseUrl("http://localhost:11434")

.modelName("gemma2")

.build();

String answer = model.generate("Provide 3 short bullet points explaining why Java is awesome");


System.out.println(answer);

}

}

Tuesday, August 20, 2024

一个和牛逼的量化交易项目

VNPY

 https://github.com/vnpy/vnpy

fork了,以后有机会好好学习学习

Wednesday, July 31, 2024

关于管理系统的页面布局

 横向布局 menu横在页面上部。


这种样子的系统,简单,但是不容易扩展。

如果主菜单,有是个以上,就比较悲剧了。


竖向布局

相对来说,扩展性好很多。

加上竖向滚动条,无限滚,也无碍


所以得花时间,把系统改成竖向布局了

Tuesday, May 07, 2024

Monitoring element in html

 


// Attach a scroll event listener

window.addEventListener('scroll', function() {

    const element = document.getElementById('tta');

    const rect = element.getBoundingClientRect();


    // Check if the element is in the viewport

    if (rect.top < window.innerHeight && rect.bottom >= 0) {

        console.log('Element is visible');

    } else {

        console.log('Element is not visible');

    }

})



const element = document.getElementById('tta');

const rect = element.getBoundingClientRect();


console.log('Left:', rect.left);

console.log('Top:', rect.top);

console.log('Right:', rect.right);

console.log('Bottom:', rect.bottom);

Monday, May 06, 2024

public vue library


1, create project and build

 npm create vite@latest hello-world-- --template vue


cd hello-world

npm install


2, delete unnecessary file

delete src/App.vue, src/style.css


3, set vite to library mode

https://vitejs.dev/guide/build#library-mode


// vite.config.js
import { resolve } from "path";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

export default defineConfig({
  plugins: [vue()],
  build: {
    lib: {
      // Could also be a dictionary or array of multiple entry points
      entry: resolve(__dirname, "src/main.js"),
      name: "HelloWorld",
      // the proper extensions will be added
      fileName: "hello-world",
    },
    rollupOptions: {
      // make sure to externalize deps that shouldn't be bundled
      // into your library
      external: ["vue"],
      output: {
        // Provide global variables to use in the UMD build
        // for externalized deps
        globals: {
          vue: "Vue",
        },
      },
    },
  },
});




// package.json


  "name": "hello-world",
  "private": false,
  "version": "0.0.0",
  "type": "module",
  "files": ["dist"],
  "main": "./dist/hello-world.umd.cjs",
  "module": "./dist/hello-world.js",
  "exports": {
    ".": {
      "import": "./dist/hello-world.js",
      "require": "./dist/hello-world.umd.cjs"
    },
    "./dist/style.css": "./dist/style.css"
  },



// main.js

import HelloWorld from "./components/HelloWorld.vue";
export { HelloWorld };


4,  run following command in project folder

npm link


5, link to other local project

npm link hello-world


6, test library
<script setup>
import { HelloWorld } from "hello-world";
import "hello-world/dist/style.css";
</script>

<template>
  <hello-world msg="large"></hello-world>
</template>

<style></style>





Friday, April 22, 2022

按照日期,整理文件


import os

import shutil

import time

from datetime import datetime

import shutil

import glob

from pathlib import Path

from pathlib import Path


src = r"D:\pic"

dst = r"E:\PicDT"


files = glob.glob(src + r'\**\*.*', recursive=True)


for filename in files:

    if Path((filename)).is_file():

        created = (os.path.getmtime(filename))

        createYmd = datetime.fromtimestamp(created).strftime("%Y-%m-%d")

        if not os.path.exists(os.path.join(dst, createYmd)):

            os.mkdir(os.path.join(dst, createYmd))

        shutil.copy2(filename, os.path.join(dst, createYmd ,Path(filename).name))