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 / permutation.c
Created December 28, 2014 18:56
non-recursion n! permutation in C
#include<stdio.h>
#include<time.h>
void roll(int a[],int l,int r){
//roll [l,r) leftward
int tmp=a[l],i;
for(i=l;i<r-1;i++)
a[i]=a[i+1];
a[r-1]=tmp;
}
```flow
st=>start
e=>end
op0=>operation: 辨識畫布
op1=>operation: 辨識/猜測座標軸
cond1=>condition: 是否為函數圖形?
op2cd1=>operation: 函數辨識模型
op3=>operation: 嘗試各類函數
op4=>operation: 嘗試組合各類函數
op2cd2=>operation: 曲線辨識模型
@andy0130tw
andy0130tw / main.py
Created April 14, 2015 17:11
HSNU Calender Scraper
#!python3
import requests
import datetime
import json
URL = "http://www.hs.ntnu.edu.tw/hsnuwp/wp-admin/admin-ajax.php?date=%s&action=hsnu_cal_get_events"
session = requests.Session()
def fetchEvents(dateStr):
return session.get(URL % dateStr).json()
@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 / 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