# Usage: `Key: /link/ || icon` # Key is the name of menu item. If the translation for this item is available, the translated text will be loaded, otherwise the Key name will be used. Key is case-sensitive. # Value before `||` delimiter is the target link, value after `||` delimiter is the name of Font Awesome icon. # External url should start with http:// or https:// menu: home:/||fafa-home about:/about/||fafa-user tags:/tags/||fafa-tags categories:/categories/||fafa-th archives:/archives/||fafa-archive #schedule: /schedule/ || fa fa-calendar #sitemap: /sitemap.xml || fa fa-sitemap #commonweal: /404/ || fa fa-heartbeat
# Sidebar Avatar avatar: # Replace the default image and set the url here. url:/images/avatar.png # If true, the avatar will be displayed in circle. rounded:true
Google Analytics
1 2 3 4 5 6 7
# Google Analytics # See: https://analytics.google.com google_analytics: tracking_id:UA-27799979-1 # By default, NexT will load an external gtag.js script on your site. # If you only need the pageview feature, set the following option to true to get a better performance. only_pageview:false
codeblock: # Code Highlight theme # All available themes: https://theme-next.js.org/highlight/ theme: light:stackoverflow-dark dark:stackoverflow-dark prism: light:prism dark:prism-dark # Add copy button on codeblock copy_button: enable:false # Available values: default | flat | mac style:
访客统计、访问次数统计、文章阅读次数统计
1 2 3 4 5 6 7 8 9 10
# Show Views / Visitors of the website / page with busuanzi. # For more information: http://ibruce.info/2015/04/04/busuanzi/ busuanzi_count: enable:true total_visitors:true total_visitors_icon:fafa-user total_views:true total_views_icon:fafa-eye post_views:true post_views_icon:farfa-eye
本地显示的数字是随机的,部署到服务器上面就好了。
站点建立时间
1 2 3
footer: # Specify the year when the site was setup. If not defined, current year will be used. since:2016
# Local search # Dependencies: https://github.com/next-theme/hexo-generator-searchdb local_search: enable: true # If auto, trigger search by changing input. # If manual, trigger search by pressing enter key or search button. trigger: auto # Show top n results per article, show all results by setting to -1 top_n_per_article: 1 # Unescape html strings to the readable one. unescape: false # Preload the search data when the page loads. preload: false
mathjax
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
# Math Formulas Render Support # Warning: Please install / uninstall the relevant renderer according to the documentation. # See: https://theme-next.js.org/docs/third-party-services/math-equations # Server-side plugin: https://github.com/next-theme/hexo-filter-mathjax math: # Default (false) will load mathjax / katex script on demand. # That is it only render those page which has `mathjax: true` in front-matter. # If you set it to true, it will load mathjax / katex script EVERY PAGE. every_page:true
mathjax: enable:true # Available values: none | ams | all tags:none
# URL ## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project' url:http://luohanjie.com permalink::year-:month-:day/:urlname.html permalink_defaults: pretty_urls: trailing_index:true# Set to false to remove trailing 'index.html' from permalinks trailing_html:true# Set to false to remove trailing '.html' from permalinks
# Uri of fonts host, e.g. https://fonts.googleapis.com (Default). host:https://cdn.baomitu.com
# Font options: # `external: true` will load this font family from `host` above. # `family: Times New Roman`. Without any quotes. # `size: x.x`. Use `em` as unit. Default: 1 (16px)
# Global font settings used for all elements inside <body>. global: external:true family:NotoSerifSC size:
# Font settings for site title (.site-title). title: external:true family:NotoSerifSC size:
# Font settings for headlines (<h1> to <h6>). headings: external:true family:NotoSerifSC size:
# Font settings for posts (.post-body). posts: external:true family:NotoSerifSC
# Font settings for <code> and code blocks. codes: external:true family:SourceCodePro
// Font size $font-size-base = (hexo-config('font.enable') and hexo-config('font.global.size') is a 'unit') ? unit(hexo-config('font.global.size'), em) : 1em; $font-size-smallest = .55em; $font-size-smaller = .6125em; $font-size-small = .675em; $font-size-medium = 0.8em; $font-size-large = 0.925em; $font-size-larger = 1.15em; $font-size-largest = 1.7em;
// Headings font size $font-size-headings-step = .125em; $font-size-headings-base = (hexo-config('font.enable') and hexo-config('font.headings.size') is a 'unit') ? unit(hexo-config('font.headings.size'), em) : 1.425em;
using System; using System.Runtime.InteropServices; using UnityEngine;
publicclassPluginImport : MonoBehaviour { [DllImport("unity_api", CallingConvention = CallingConvention.Cdecl)] publicstaticexternfloatAdd(float a, float b); // Start is called before the first frame update voidStart() { Debug.Log(Add(1, 2)); }
using System; using System.Collections; using System.Collections.Generic; using System.IO; using UnityEngine; using UnityEngine.UI; using System.Runtime.InteropServices;
publicclassWebCamera : MonoBehaviour { publicstring cam_name = "FaceTime HD Camera"; publicint cam_width = 1280; publicint cam_heidht = 720; publicint cam_fps = 30; public AspectRatioFitter aspect_fitter; private WebCamTexture web_cam_tex = null; privatebool is_init = false; // Start is called before the first frame update voidStart() { WebCamDevice[] devices = WebCamTexture.devices; for (int i = 0; i < devices.Length; i++) { if (devices[i].name == cam_name) { is_init = true; Debug.Log("Connect camera to " + cam_name); break; } } if (is_init == false) { Debug.Log("Can not find " + cam_name); return; } web_cam_tex = new WebCamTexture(cam_name, cam_width, cam_heidht, cam_fps); if (web_cam_tex == null) { is_init = false; Debug.Log ("Can not new WebCamTexture"); return; } GameObject.FindWithTag("background").GetComponent<RawImage>().texture = web_cam_tex; web_cam_tex.Play(); } voidOnStart (Texture preview) { aspect_fitter.aspectRatio = preview.width / (float)preview.height; }
// Update is called once per frame voidUpdate() { } }
然后将Background节点拖拽到Main Camera节点中,Web Camera (Script)项目下的Aspect_fitter项目上:
using System; using System.Collections; using System.Collections.Generic; using System.IO; using UnityEngine; using UnityEngine.UI; using System.Runtime.InteropServices;
publicclassPluginImport : MonoBehaviour { [DllImport("unity_api", CallingConvention = CallingConvention.Cdecl)] publicstaticexternboolReadImage(string color_img_file, ref IntPtr data, refint width, refint height, refint size); // Start is called before the first frame update voidStart() { IntPtr data = IntPtr.Zero; int width = 0; int height = 0; int size = 0; bool flag = ReadImage("/Users/luohanjie/Downloads/lenna_color.png", ref data, ref width, ref height, ref size); if (!flag || size <= 0) return; byte[] buffer = newbyte[size]; Texture2D tex = new Texture2D(width, height, TextureFormat.RGB24, false, false); System.Runtime.InteropServices.Marshal.Copy(data, buffer, 0, size); tex.LoadRawTextureData(buffer); tex.Apply(); RawImage background = GameObject.FindWithTag("background").GetComponent<RawImage>(); background.texture = tex; } }
using System; using System.Collections; using System.Collections.Generic; using System.IO; using UnityEngine; using UnityEngine.UI; using System.Runtime.InteropServices;
publicclassPluginImport : MonoBehaviour { [DllImport("unity_api", CallingConvention = CallingConvention.Cdecl)] publicstaticexternvoidGetPose([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] float[] pose); // Start is called before the first frame update voidStart() { float[] obj_pose = newfloat[7]; // x, y, z, qw, qx, qy, qz GetPose(obj_pose); //方法1,根据读取的Pose设置Unity中物体的姿态 GameObject obj = GameObject.FindWithTag("obj_tag_name"); obj.transform.position = new Vector3((float)obj_pose[0], (float)obj_pose[1], (float)obj_pose[2]); obj.transform.rotation = new Quaternion((float)obj_pose[4], (float)obj_pose[5], (float)obj_pose[6], (float)obj_pose[3]); //方法2,根据读取的Pose设置Unity中摄像头的姿态 Camera cam_obj = GameObject.FindWithTag("MainCamera").GetComponent<Camera>(); cam_obj.transform.position = new Vector3((float)obj_pose[0], (float)obj_pose[1], (float)obj_pose[2]); cam_obj.transform.rotation = new Quaternion((float)obj_pose[4], (float)obj_pose[5], (float)obj_pose[6], (float)obj_pose[3]); } }
Virtual environments are a great way to separate different dependencies if you need different versions for different projects or if you don’t want to change your system path and its dependencies. One of the most popular packages to accomplish this is Anaconda, but anaconda is bloated and doesn’t always have the right packages for m1. Instead, we use miniforge, a community package that provides a minimalistic Anaconda install and uses the conda-forge branch to install packages. Conda-forge provides community packages for Anaconda which has a much larger library of arm64 compatible packages.[3]
NumPy dropped support for using the Accelerate BLAS and LAPACK at version 1.20.0. According to the release notes for NumPy 1.21.1, these bugs have been resolved and building NumPy from source using the Accelerate framework on MacOS >= 11.3 is now possible again. How to build NumPy from source linked to Apple Accelerate framework
ffmpeg@4 is keg-only, which means it was not symlinked into /opt/homebrew, because this is an alternate version of another formula.
If you need to have ffmpeg@4 first in your PATH, run: echo 'export PATH="/opt/homebrew/opt/ffmpeg@4/bin:$PATH"' >> ~/.zshrc
For compilers to find ffmpeg@4 you may need to set: export LDFLAGS="-L/opt/homebrew/opt/ffmpeg@4/lib" export CPPFLAGS="-I/opt/homebrew/opt/ffmpeg@4/include"
For pkg-config to find ffmpeg@4 you may need to set: export PKG_CONFIG_PATH="/opt/homebrew/opt/ffmpeg@4/lib/pkgconfig"
For the system Java wrappers to find this JDK, symlink it with
sudo ln -sfn /opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk
openjdk@11 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.
If you need to have openjdk@11 first in your PATH, run:
echo ‘export PATH=“/opt/homebrew/opt/openjdk@11/bin:$PATH”’ >> ~/.zshrc
For compilers to find openjdk@11 you may need to set:
export CPPFLAGS=“-I/opt/homebrew/opt/openjdk@11/include”
python Python 3.9.13 | packaged by conda-forge | (main, May 272022, 17:00:33) [Clang 13.0.1 ] on darwin Type"help", "copyright", "credits"or"license"for more information. >>> import torch >>> import math >>> print(torch.backends.mps.is_available()) True >>> print(torch.backends.mps.is_built()) True >>>
To run PyTorch code on the GPU, use torch.device(“mps”) analogous to torch.device(“cuda”) on an Nvidia GPU. Hence, in this example, we move all computations to the GPU[12]:
# Create random input and output data x = torch.linspace(-math.pi, math.pi, 2000, device=device, dtype=dtype) y = torch.sin(x)
# Randomly initialize weights a = torch.randn((), device=device, dtype=dtype) b = torch.randn((), device=device, dtype=dtype) c = torch.randn((), device=device, dtype=dtype) d = torch.randn((), device=device, dtype=dtype)
learning_rate = 1e-6 for t in range(2000): # Forward pass: compute predicted y y_pred = a + b * x + c * x ** 2 + d * x ** 3
# Compute and print loss loss = (y_pred - y).pow(2).sum().item() if t % 100 == 99: print(t, loss)
# Backprop to compute gradients of a, b, c, d with respect to loss grad_y_pred = 2.0 * (y_pred - y) grad_a = grad_y_pred.sum() grad_b = (grad_y_pred * x).sum() grad_c = (grad_y_pred * x ** 2).sum() grad_d = (grad_y_pred * x ** 3).sum()
# Update weights using gradient descent a -= learning_rate * grad_a b -= learning_rate * grad_b c -= learning_rate * grad_c d -= learning_rate * grad_d
print(f'Result: y = {a.item()} + {b.item()} x + {c.item()} x^2 + {d.item()} x^3')
1
Result: y = 0.9504813551902771 + 1.0364974737167358 x + -1.9110007286071777 x^2 + 0.7653123736381531 x^3