Skip to content

Instantly share code, notes, and snippets.

View andy0130tw's full-sized avatar
🍌
why no 🍆

Andy Pan andy0130tw

🍌
why no 🍆
View GitHub Profile
@andy0130tw
andy0130tw / boltzmann-factor.md
Last active August 29, 2015 14:19
Boltzmann Factor Example

 

Written by Andy, 2015/4/22 本來想寫Boltzmann Factor是怎麼導出來的,但是...太複雜了而且沒必要,就...。

What(TF) is Boltzmann Factor?

Boltzmann Factor, $e^{-\frac{E}{k_B T}}$, is

  1. An energy distribution function that cause maximized entropy.
  2. The un-normalized probability that you find between energy $E$ and $E+dE$ is the Boltzmann Factor times $dE$ when you pick up a particles randomly in a system of particles at equilibrium.
@andy0130tw
andy0130tw / water-flowing-problem.md
Last active August 29, 2015 14:24
Differential Equation

Water Flowing Problem

Updated with bugs fixed (see https://www.facebook.com/andy0130tw/posts/10203153062786174).

A cylinder is filled with incompressible liquid. The initial volume of the liquid is $V$, and the bottom area of the cylinder is $A$. Now we dig a hole at its bottom, which area is $a$. How much time it will take to drain all the liquid? The acceleration of gravity is $g$. (viscous force and friction are neglected)

Let the volume of the liquid in the cylinder $V$, varying with time. Its differential is (notice the sign) $$ dV = A,dh. $$ The speed $v$ of flowed liquid can be calculated with Bernoulli's principle. Here we simply consider that energy is conserved,

@andy0130tw
andy0130tw / matrix67-blog-archive-maker.py
Created July 31, 2015 19:22
I love this blog. If I have no internet connection I would read this instead of playing mine sweeper. bs4, peewee and requests are used.
from bs4 import BeautifulSoup
import requests
import re
import models as m
root_url = 'http://www.matrix67.com/'
blog_url = root_url + 'blog/'
image_url = root_url + 'blogimage/'
page_template = blog_url + 'page/{}'
@andy0130tw
andy0130tw / parser.html
Created August 9, 2015 14:19
Air Conditioner Cost Calculating in HSNU 1296.
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<script>
/***
*** Programmed by 1296Andy
*** For a/c money processing, in 1296.
***/
@andy0130tw
andy0130tw / monokai.xml
Created August 13, 2015 05:32
Monokai theme in Qt
<?xml version="1.0" encoding="UTF-8"?>
<style-scheme version="1.0" name="Monokai">
<style name="Text" foreground="#ffffff" background="#272822"/>
<style name="Link"/>
<style name="Selection" foreground="#ffffff" background="#9d550f"/>
<style name="LineNumber" foreground="#888888"/>
<style name="SearchResult" foreground="#000000" background="#ffe792"/>
<style name="SearchScope"/>
<style name="Parentheses" foreground="#ffffff" bold="true"/>
<style name="CurrentLine" background="#3e3d32"/>
@andy0130tw
andy0130tw / migration.py
Last active August 29, 2015 14:27
Slack backup migration from CodernityDB3
#!/usr/bin/env python3
import json
from os import listdir
from os.path import isfile, join
from CodernityDB3.database import Database
import archv
import peewee
import models as m
@andy0130tw
andy0130tw / dsnp2015_hw1.cpp
Last active September 22, 2015 16:34
dsnp2015 hw1
#include<cstdio>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#define UNDEF 9999
using namespace std;
class Data {
public:
@andy0130tw
andy0130tw / subtypes.txt
Last active September 3, 2015 06:29
Message subtype of Slack -- notes when coding #slackbackup.
bot_message: A message was posted by an integration
bot_id
username
icons
me_message: A /me message was sent
message_changed: A message was changed
(hidden)
message
@andy0130tw
andy0130tw / codernitydb3.test.log
Created September 5, 2015 14:15
CodernityDB porting status
============================= test session starts ==============================
platform linux -- Python 3.4.0 -- py-1.4.30 -- pytest-2.7.2 -- /usr/bin/python3
rootdir: /home/qbane/codernitydb3, inifile: pytest.ini
plugins: xdist, xdist, xdist
collecting ... collected 402 items
tests/test_db.py::Test_Database::test_update_conflict <- tests/shared.py PASSED
tests/test_db.py::Test_Database::test_wrong_id <- tests/shared.py PASSED
tests/test_db.py::Test_Database::test_open_close <- tests/shared.py PASSED
tests/test_db.py::Test_Database::test_destroy <- tests/shared.py PASSED
@andy0130tw
andy0130tw / stylish.css
Created September 6, 2015 17:21
Fix for BBSFox with Source Han Sans HW.
@namespace url(http://www.w3.org/1999/xhtml);
/**
* Because the text height of Source Han Sans is too tall for a terminal,
* using BBSFox with it would result in a crowding view.
* Thanks to Stylish, we can fix it with some simple CSS,
* whose concept is very simple.
* The position of the cursor should also be shifted after applying this tweak.
*/