TeX: $\omega$, $|\cos(\phi)|$
TeX: \[ x^2 = 0 \]
利用 iframe 這個 html 的 tag,就可以在網頁中顯示其它網頁的內容
<iframe src="https://yourhost.com/path/to/notebook.html" width="100%" height="600px"></iframe>
To deploy a Quarto website to GitHub using the usethis
package in RStudio on Ubuntu 20.04, follow these steps:
Install Required Packages:
Ensure you have the usethis
, quarto
, and gitcreds
packages installed. You can install them using the following commands in RStudio:
install.packages("usethis")
install.packages("quarto")
install.packages("gitcreds")
Create a New Quarto Project:
Create a new Quarto project in RStudio. You can do this by navigating to File
> New Project
> New Directory
> Quarto Website
.
Set git username and password (token) if you first use git:
usethis::use_git_config(user.name = "Your Name", user.email = "your.email@example.com")
Set git token (password), you have to get the token from github.com before use:
gitcreds::gitcreds_set()
Configure Quarto for GitHub Pages:
Modify your _quarto.yml
file to specify the output directory as docs
:
project:
type: website
output-dir: docs
Build the website files:
system("quarto render")
Initialize Git: Initialize a Git repository in your project directory:
usethis::use_git()
Create a GitHub Repository:
Use usethis
to create a GitHub repository and link it to your local project:
usethis::use_github()
Configure GitHub Pages:
Go to your GitHub repository settings and configure GitHub Pages to publish from the docs
directory of the main
branch.
To deploy a Quarto website to GitHub using the usethis
package in RStudio on Ubuntu 20.04, follow these steps:
Install Required Packages:
Ensure you have the usethis
and quarto
packages installed. You can install them using the following commands in RStudio:
install.packages("usethis")
install.packages("quarto")
Create a New Quarto Project:
Create a new Quarto project in RStudio. You can do this by navigating to File
> New Project
> New Directory
> Quarto Website
.
Initialize Git: Initialize a Git repository in your project directory:
usethis::use_git()
Create a GitHub Repository:
Use usethis
to create a GitHub repository and link it to your local project:
usethis::use_github()
Configure Quarto for GitHub Pages:
Modify your _quarto.yml
file to specify the output directory as docs
:
project:
type: website
output-dir: docs
Add .nojekyll File:
Add a .nojekyll
file to the root of your repository to prevent GitHub Pages from processing your site with Jekyll:
touch .nojekyll
Render and Deploy Your Site: Render your Quarto site and push the changes to GitHub:
quarto render
git add docs
git commit -m "Publish site to docs/"
git push
Configure GitHub Pages:
Go to your GitHub repository settings and configure GitHub Pages to publish from the docs
directory of the main
branch.
import sqlite3
# Connect to your SQLite3 database
conn = sqlite3.connect('your_database_file.db')
cursor = conn.cursor()
# Execute the VACUUM command
cursor.execute('VACUUM')
# Close the connection
conn.close()
gnuplot 安裝後若需要 png 類型的輸出,可以依以下步驟安裝:
sudo apt-get update
sudo apt-get install build-essential
sudo apt-get build-dep gnuplot
sudo apt-get install libgd-dev libpng-dev
wget https://sourceforge.net/projects/gnuplot/files/gnuplot/5.2.8/gnuplot-5.2.8.tar.gz
tar -xzf gnuplot-5.2.8.tar.gz
cd gnuplot-5.2.8
./configure --with-gd --with-png
make
mack check
sudo make install
$ conda config --set auto_activate_base false
Ubuntu 24.04 中,Firefox 預設是從 snap 安裝,然而,從 snap 安裝的版本不能使用 gcin 中文輸入法。為了解決這個問題,我參考以下網頁,依照以下方法,成功安裝 Mozilla Builds Firefox,且可使用中文輸入法。
首先移除已安裝的 firefox:
$ sudo snap remove firefox
$ sudo apt remove firefox
然後參考:
Install Firefox from Mozilla builds
1. 從 Mozilla 官網下載 Firefox Linux 64-bit 版本,例如 firefox-127.0.1.tar.bz2
2. 按照以下步驟
$ tar xjf firefox-*.tar.bz2
$ sudo mv firefox /opt
$ sudo ln -s /opt/firefox/firefox /usr/local/bin/firefox
$ sudo wget https://raw.githubusercontent.com/mozilla/sumo-kb/main/install-firefox-linux/firefox.desktop -P /usr/local/share/applications
3. 在終端機執行
$ firefox
即可啟動,而且 gcin 可以正常使用。
我的測試環境
Ubuntu 20.04
NVIDIA-SMI 535.183.01 Driver Version: 535.183.01 CUDA Version: 12.2
用以下的方法,可以確保版本正確的問題
1. **Add NVIDIA package repositories**:
Ensure you have the CUDA repository added to your system. Follow these steps:
```sh
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub
sudo sh -c 'echo "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 /" > /etc/apt/sources.list.d/cuda.list'
sudo sh -c 'echo "deb https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu2004/x86_64 /" > /etc/apt/sources.list.d/cuda_learn.list'
```
2. **Update the package list**:
```sh
sudo apt update
```
3. **Install CUDA**:
Ensure you have CUDA installed. You can install a specific version if needed.
```sh
sudo apt install cuda-12-0
```
4. **Install cuDNN**:
Install the cuDNN package for CUDA 12.
```sh
sudo apt install libcudnn8=8.9.7.29-1+cuda12.2
sudo apt install libcudnn8-dev=8.9.7.29-1+cuda12.2
sudo apt install libcudnn8-samples=8.9.7.29-1+cuda12.2
```
Replace `8.x.x.x-1+cuda12.0` with the actual version available in the repository. You can check for the available versions using:
```sh
apt-cache policy libcudnn8
```
5. **Verify the installation**:
Ensure CUDA and cuDNN are installed correctly.
```sh
nvcc --version
```
For cuDNN, you can check the version as follows:
```sh
cat /usr/include/cudnn_version.h | grep CUDNN_MAJOR -A 2
```
參考:
https://chatgpt.com/share/cbe6f18b-d8af-4621-8355-874f205f6a86
In Ubuntu 20.04, How can I use R Shiny to view a math function plot on a web page? function: y = x^2
ChatGPT
ChatGPT
To view a math function plot, such as y=x^2, on a web page using R Shiny in Ubuntu 20.04, follow these steps. I'll guide you through installing R, the necessary packages, and creating a basic Shiny app to display the plot of y=x^2
Ubuntu 20.04 may not come with R pre-installed, so you'll need to install it. Open a terminal and run:
sudo apt update
sudo apt install r-base
Once R is installed, you need to install the Shiny package and ggplot2 for plotting. Start R in the terminal:
R
Then, install the packages by running:
install.packages("shiny")
install.packages("ggplot2")
Shiny apps consist of a UI (User Interface) definition and a server function. You'll create a basic app to plot y=x^2. Create a new directory for your Shiny app and then create two files within that directory: ui.R
and server.R
.
ui.R: This file defines the layout and appearance of your app.
library(shiny)
# Define UI for application
ui <- fluidPage(
# Application title
titlePanel("Plot of y = x^2"),
# Sidebar with a slider input for the range of x
sidebarLayout(
sidebarPanel(
sliderInput("range",
"X Range:",
min = -10,
max = 10,
value = c(-10, 10))
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
)
server.R: This file contains the server logic to generate the plot based on the input range.
library(shiny)
library(ggplot2)
# Define server logic
server <- function(input, output) {
output$distPlot <- renderPlot({
x <- seq(input$range[1], input$range[2], by = 0.1)
y <- x ^ 2
ggplot(data.frame(x, y), aes(x = x, y = y)) +
geom_line() +
labs(title = "Plot of y = x^2",
x = "x",
y = "y")
})
}
Run Your App: Go back to your R session in the terminal. Set your working directory to the folder containing your app, then run:
library(shiny)
runApp()
Shiny will start a web server and give you a URL to access your app. Open this URL in a web browser to see the plot of y=x2 with the ability to adjust the range of xxx via a slider.
This is a simple example to get you started. Shiny is very flexible, allowing you to build highly interactive web applications. You can explore more features and capabilities of Shiny and ggplot2 to enhance your app.
Anonymous
how to show the above in a internet webpage?
ChatGPT
ChatGPT
To display a Shiny app on an internet webpage accessible to others, you would typically need to deploy the app to a server. There are a few common ways to do this:
ShinyApps.io is a platform provided by RStudio for hosting Shiny applications. It's the easiest way to get started with deploying Shiny apps. Here's how you can do it:
Install and Load the rsconnect
Package: First, you need to install and load the rsconnect
package in R, which is used for deploying applications to ShinyApps.io.
install.packages("rsconnect")
library(rsconnect)
Set Up an Account on ShinyApps.io: If you haven't already, go to shinyapps.io and set up an account. After setting up your account, you'll find instructions to authorize your R session to deploy apps to your ShinyApps.io account.
Deploy Your App: Use the deployApp
function from the rsconnect
package. Navigate to your app directory in R (using setwd
) and then deploy your app.
deployApp()
After deployment, you'll be given a URL where your app is hosted and can be accessed by anyone on the internet.
https://chat.openai.com/share/ae482af1-9049-49bd-8a60-e7bf7cd774e7
Test the sites locally
$ bundle exec jekyll serve
到這個網站 https://highlightjs.org/。
copy cdnjs 的幾行程式碼文字
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css"></link>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<!-- and it's easy to individually load additional languages -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/go.min.js"></script>
<script>hljs.highlightAll();</script>
把以上幾行文字放在 blogger 主題 html 的 <head> 下方即可。
在 html 原始碼的 <head> 下方,加上這 2 行:
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
之後寫文章時,用以下的格式寫數學式。