Dreamer's sky
Hi, I'm Dreamer.
Friday, July 25, 2025
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
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
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))