Skip to content

Instantly share code, notes, and snippets.

View liuyxpp's full-sized avatar

Yi-Xin Liu liuyxpp

View GitHub Profile
# Credit: leandromartinez98@https://discourse.julialang.org
# This code is adapted from https://discourse.julialang.org/t/seven-lines-of-julia-examples-sought/50416/41
# Perform a particle simulation with periodic boundary conditions, a langevin thermostat, and a quadratic potential between the particles, and produce an animation in 15 lines.
using Plots ; ENV["GKSwstype"]="nul"
const N, τ, Δt, λ, T, k = 100, 1000, 0.01, 1e-3, 0.26, 1e-6
const x, v, f = -0.5 .+ rand(3,N), -0.01 .+ 0.02*randn(3,N), zeros(3,N)
wrap(x,y) = (x-y) > 0.5 ? (x-y)-1 : ( (x-y) < -0.5 ? (x-y)+1 : (x-y) )
@liuyxpp
liuyxpp / mathsymbol.jl
Last active August 31, 2020 01:09
List/Display all math constants and operators defined as Unicode symbols in Julia Base
# Credit of `math_symbols`: Tom Kwong (@tomkwong)
# Credit of `unicodesymbol2string`, `display_math_symbols`: Yi-Xin Liu (@lyxfudan)
# 2020.08.31
using REPL: symbol_latex
function math_symbols()
allnames = names(Base)
name_length = [allnames length.(String.(allnames))]
syms = filter(!(isascii ∘ String), name_length[name_length[:,2].==1, 1])
@liuyxpp
liuyxpp / README.md
Created April 28, 2020 04:31
Scripts based on `ffmpeg` to ease the make of course videos by iPad screen recording.

Scripts based on ffmpeg to ease the make of course videos by iPad screen recording.

Usage

  1. Screen recording on iPad results multiple mp4 files. These files have extension .MP4. Note the extension is capitalized.
  2. If needed, edit the video by iPad Photo App. Note that the edited file's extension is .mov.
  3. Airdrop these files to MacBook Pro.
  4. Rename all files to either ###.mp4 or ###.mov, where ### is $n$ digits where $n$ is determined by the number of files. ### should start with 001 and the numbering shall follow the order of the videos.
  5. Convert all mov files to mp4 files using script mov2mp4.
  6. Combine all mp4 files using script combinemp4.
@liuyxpp
liuyxpp / parser.js
Created April 16, 2020 01:16
VS Code Markdown Preview Enhanced: Extend Parser for syntax highlight of Jekyll/Liquid code blocks
// For Markdown Preview Enhanced
// In VS Code, press Cmd+shift+p, select Markdown Preview Enhanced
// file path (MacOS): ~/.mume/parser.js
// Convert {% highlight lang option %} [code blocks] {% endhighlight %}
// to ```julia [code blocks] ```
module.exports = {
onWillParseMarkdown: function(markdown) {
return new Promise((resolve, reject)=> {
markdown = markdown.replace(
#!/bin/bash
# Install sleepwatcher
cd /tmp
curl -O http://www.bernhard-baehr.de/sleepwatcher_2.2.tgz
tar -zxvf sleepwatcher_2.2.tgz
cd sleepwatcher_2.2
sudo mkdir -p /usr/local/sbin /usr/local/share/man/man8
sudo cp sleepwatcher /usr/local/sbin
sudo cp sleepwatcher.8 /usr/local/share/man/man8
sudo cp config/de.bernhard-baehr.sleepwatcher-20compatibility.plist /Library/LaunchAgents
@liuyxpp
liuyxpp / flaskplotlib.py
Created September 29, 2011 09:33 — forked from wilsaj/flaskplotlib.py
Example of rendering a matplotlib image directly to Flask view
from flask import Flask, make_response, render_template
app = Flask(__name__)
@app.route("/")
def index():
render_template("index.html")
@app.route("/simple.png")
def simple():
import datetime