有人提醒我 SSL 证书过期,于是我想起来,我还有一个博客。

或许是因为 acme.sh 更新,或是什么变化,总之就是挂了,十分遗憾。但挂在 GitHub pages 上的主页大多数情况下都不会挂,所以可以去那里看一看。

回不来的时间

新年的冬风,今年也是格外的刺骨。虽然没有新闻里芝加哥那么冷,但至少晚间在回去的路上,不穿上厚外衣,戴上手套,捂紧帽子,是免不了要瑟瑟发抖一番的。

农夫冻得手脚冰凉,在与蛇的战斗中,两手僵硬,有劲无处使,落得一个被蛇咬的下场。

元月27日或许是一切混乱的起点。

这一天,弄到了一个卖手机亏损的公司生产的家用主机。于是 Jirga Para Lhao 被拯救了。但 30 个小时就这样过去了。

青鸟不会做杀人的梦

我有时候会思考应该如何写一篇感想。

客观性是我试图避免的:我想写一些主观的、个人的感受,而不是所有人都会感受到、都可以表达出来的东西。我想写的是我个人的感想,而不是所有人的感想。之前的尝试在这一方面都不算是令人满意——大多时刻只是事实的罗列,或者是单纯的侃侃而谈。

聊天倒是也不坏。蔡康永的情商书(为什么我会看这么大众的书,不过转念一想,倒也有种别样的趣味)里就有“分身”这一说法。人每时每刻都需要和他人交流,但往往会忽视与自己的交流。与自己的交流听起来好像很奇怪。尝试培养另外一个不同的自己,跟这个自己对话。这可以说是一种审视自己的方式,也可以是一种批判性思考的方式。从这一个方向用尽九牛二虎之力也推不开的门,说不定换个方向就能轻松打开。

回到侃侃而谈。可能变成侃侃而谈也能从侧面说明,想从心灵这个湖里,捞出感想的鱼,不是件容易的事情,把捞上来的鱼卖给他人,也不是件容易的事情。不过鱼还没有捞上来,就想着销路,算是有点眼高手低了。

不过鱼有大的鱼和小的鱼,就像苹果有甜的苹果和不甜的苹果。大的鱼属于那种容易发现的。比如看完《活着》,感受到悲伤、无奈、沉重。不过转念一想,悲伤和喜悦都只是游在表面上的鱼,而在深水里的,是那种达观、顽强、活下去的力量,是这股力量支撑着人走下去。活着才有酸甜苦辣,活着才有风雨彩虹。

结果又变成万人都能说出的感想了。我大概不适合这差事。

同学聚会

参加了高中的同学聚会。令我惊奇的是,我没那么快活。

用一句大俗话来说,就是感觉少了点什么。

我曾经不止一次梦到过和高中同学搞事——建车站、开组会,无所不为。这或许这是我高中过于安分的反作用。搞事的时候我是快乐的,虽然在梦里的事都说不清楚,但大概的确是这样。

所以一个很大的可能就是,因为没怎么搞事。

灰姑娘是不是因为穿上了水晶鞋,所以不能自由奔跑了呢?

我翻遍了卡拉 OK 的歌单,翻遍了火锅的锅底,但都没有找到答案。

冬天来了,冬天还会远吗

在严寒中,在风雪里,食堂一个接着一个地关门了。有的等春暖花开之际会像燕子一般归来,有的则永远也不会回来了。

可我仍然没有吃到藤椒口味的浇汁饭。

Comment and share

rec-4-12-2018

in life

Artificial Intelligence

Resolution

If $l_i \Leftrightarrow \neg m_j$, then:

$\frac{l_1 \vee \cdots l_k \ \ \ \ m_1 \vee \cdots \vee m_n}{l_1 \vee \cdots \vee l_{i-1} \vee l_{i+1} \cdots \vee l_k \vee m_1 \vee \cdots \vee m_{j-1} \vee m_{j+1} \cdots \vee m_n}$

If there is a empty clause after a resolution, it means there are conflicts.

$$
\frac{p\ \ \ \neg p}{\square}
$$

Resolution algorithm to prove $\alpha$ within KB:

  1. Generate CNF of the knowledge base $KB\wedge\neg\alpha$
    • CNF: $(l_{1,1}\vee l_{1,2} \vee \cdots \vee l_{1,n_1}) \wedge (l_{2,1}\vee \cdots \vee l_{2,n_2})\vee\cdots \vee (l_{m,1}\vee\cdots\vee l_{m,n_m})$
    • Also called k-CNF if $n_1 = n_2 = \cdots = n_m = k$
  2. Repeat resolution process for every new rule
    1. If there is no new rule, $\alpha$ cannot be proved.
    2. If there is an empty literal, then stop and $\alpha$ is proved

Complexity: exponential

Expressiveness: better (not restricted to Horn clauses)

Propositional logic

Jargons

Use functions, predicates to represent relationships:

  • A is a person -> $Person(A)$, Person: predicate
  • Person a has a crippled left leg -> $Crippled(LeftLegOf(a))$, LeftLegOf: function (it’s OK since a human has only one left leg)
    Formally,

Term ::= Function ( Term {, Term}* )
AtomicSentence ::= predicate ( Term {, Term}* )

Model

Forgot that.

Networking

Cisco’s proprietary software, packettracer, couldn’t be downloaded without enrolling in its network course.

IOS

  • use enable to enable the thing
  • show interfaces to have a look at all interfaces, show interface [interface].
  • show vlan to show vlan
  • configure terminal to open the configuration in terminal
  • (config) interface [interface] to select an interface

Dynamic Trunking Protocol

A proprietary protocol invented by Cisco to negotiate trunking on a link between two VLAN-aware switches.

There is several modes for it:

  • access: puts the ethernet port into non-trunking mode and negotiates to convert the link to a nontrunk one, disregarding the neigboring port
  • trunk: puts the ethernet port into trunking mode and negotiates to convert the link to a trunk one, disregarding the neigboring port
  • dynamic auto: willing to trunk, will be trunk if the neighboring port is dynamic desirable or trunk
  • dynamic desirable: actively willing to trunk
  • nonegotiate: disable DTP. No wonder, it is not compatible with dynamic modes.

Except nonegotiate, all modes are triggered by (config-if) switchport mode [mode]. Switch to no-negotiate mode using (config-if) switchport nonegotiate.

Use a no before the statement to do the opposite thing, like:

(config-if) no shutdown: set up the link
(config-if) no switchport nonegotiate: turn on DTP

Computer Graphics

Blurring is often used in computer graphics, like, to create HDR(high dynamic range) bloom, depth of field or other post process effects.

HDR bloom: since the real-world camera cannot focus perfectly, so it will convolve the incoming image with an Airy disk. What about the Airy disk? Know what a spot of light looks like in our eyes? That would be one. A perfect lens with a circular aperture would make it because the diffraction of light.

This effect is not noticeable when it is not so bright. However, with more light we can see the blurred edge of the bright part of the image, taken by a camera. And computer graphics tries to reproduce the same effect by blurring.

You can think up an approach instantly: take the average of neighboring blocks, like below:

$$
\begin{bmatrix}
1/9&1/9&1/9 \\
1/9&1/9&1/9 \\
1/9&1/9&1/9 \\
\end{bmatrix}
$$
By all means this is bad. It will seem block-ish.

A better one is Gaussian blur. It uses the Gaussian distribution as the weight of neighboring pixels to calculate the average, or more accurately, do the convolution. The weight matrix, like the one above, is called kernel.

A 3x3 Gaussian kernel is like:

$$
\begin{bmatrix}
1/16 & 1/8 & 1/16 \\
1/8 & 1/4 & 1/8 \\
1/16 & 1/8 & 1/16 \\
\end{bmatrix}
$$

Some other kernels are here).

It also can be used before downsampling: Gaussian blur gets rid of the sharp edges in the image, thus after downsampling, it will free the image from aliasing like moire patterns. Aliasing happens because of the poor sampling makes different signals indistinguishable, and some high frequency signals might get in the way after sampling. So a low pass filter need to be applied before sampling.

Task: sample => downscale image
Reason of problem: high freq. signal => ?
Problem: aliasing => moire pattern
Solution: low pass filter => blurring

And yes, Gaussian blur is also a low pass filter, with a Bode plot like a parabola. Possibly it seems obvious at first sight: Gaussian distribution has a factor $e^{-\frac{x^2+y^2}{2\sigma^2}}$, which is stable through Fourier transforms.

We can calculate it out. Let’s put the basic calculus into practice.
$$
\begin{aligned}
&\iint e^{i\omega x}\cdot\frac{e^{-\frac{x^2+y^2}{2\sigma^2}}}{2\pi\sigma^2}\ dxdy\
=&e^{-2\sigma^2\omega^2}\iint \frac{e^{-\frac{(x-2\sigma^2\omega i)^2+y^2}{2\sigma^2}}}{2\pi\sigma^2}\ dxdy\
=&e^{-2\sigma^2\omega^2}
\end{aligned}
$$
So the amplification is:
$$
\begin{aligned}
dB&=20\log{e^{-2\sigma^2\omega^2}}\
&=-\frac{40}{\ln 10}\cdot \sigma^2\omega^2
\end{aligned}
$$
Perfect! It is a parabola after all.

Leave Kawase to the next day.

Misc

マシンガンでも壊せなくて
キャタピラーでも潰せなくて

Comment and share

Notes for 4-10

in life

Database

PL/SQL

Anonymous and named PL/SQL block

  • Anonymous PL/SQL block
    • Need to compile every time
    • Not stored
  • Named PL/SQL block
    • Can be stored in DB

Stored Procedure

Grammar:

Procedure ::= CREATE [OR REPLACE] PROCEDURE ProcedureName '(' Parameters ')' (AS|IS) RETURN ReturnType DECLARE Declaration BEGIN Body END ';'
Parameters ::= Nothing | Parameter {, Parameter}
Parameter ::= ParameterName (IN|OUT|IN OUT) Type ':=' DefaultValue
  • Note:
    • In the parameter list, varchar cannot be specified with a length.
    • MySQL has no AS|IS in the procedure, and IN/OUT is put before the parameter name.
    • In MySQL ,one has to change the delimiter before defining a procedure or function.

Loop statement

  • for x in [Reverse] 1..20 loop … end loop;
  • while … loop … end loop;
    To escape from a loop:
  • exit when …;

Conditional statement

  • if … then … elseif … end if;

Cursor

  • Used to process a set of records. PL/SQL record variable can only store one record at a time.
  • Technically, it acts like an iterator, which means one cannot process multiple records at the same time(though we can store them as a whole).
  • In declaration, a cursor is declared with a SELECT statement, and we can use this cursor to access the data returned by that SELECT statement
  • A cursor is bind to one specific SELECT clause, that is, one cannot bind it to another SELECT statement
  • The SELECT statement is and only is executed when the cursor is OPENed(see below).
  • CLOSE the cursor to free the memory space.
    Synopsis:
  1. Declaration

    cursor cursor_name is select statement;

  2. Open cursor

    OPEN cursor_name;

  3. Get the data

    FETCH cursor_name into variable;

  • The cursor will move forward, just like python’s next function do.
  1. Check if there is no more entry

    IF NOT cursor_name%FOUND THEN …;

  2. Close the cursor

    CLOSE cursor_name;

  3. For loop
    Unique to Oracle.
    No need to open, close, or fetch from a cursor.

    FOR variable in cursor_name LOOP
    – do something to the variable
    END LOOP;

Artificial Intelligence

Knowledge base && Inferrence

* Truth table

* Brute force search

* Forward chaining
    * reliable
    * completeness
        * -> only have these two properties for the knowledge bases able to be expressed with Horn clauses
        * Horn clause: a disjunction of literals with at most one unnegated literal
            * E.g. $\neg x_1 \vee \neg x_2 \vee \cdots \vee x_n \vee u$

* Backward chaining
    * To prove q, with p->q now prove p
    * Avoid repeating by check if a clause is already proved or disproved

Misc

Panning derives from panorama.

4/11 Record

Programming Languages

Polymorphic Functions

  • Static: cost grows exponentially with parameters
  • Dynamic:
    • supply a tag when calling the function

Example: Overloading Equality

  1. Equality was overloaded as an operator
  2. Make type of equality fully polymorphic
  3. Make equality polymorphic in a limited way
    • (==) :: ''t -> ''t -> Bool, ''t is a type t with equality
    • will be a static error if t is not Eq type

Type Classes

  1. Merchanism in Haskell
  2. Dictionary-passing style implementation [ESOP1988]
    • Type class declaration – dictionary
    • Name of a type class method – label in the dictionary
    • Parametric overloading – passing the dictionary to the function
class Show a where
show :: a -> String

instance Show Bool where
show True = "True"
show False = "False"

print :: Show a => a -> IO ()
print x = putStrLn $ show x
type 'a show = {show: 'a -> string}
let show_bool : bool show =
{
show = function
| true -> "True"
| false -> "False"
}

let print : 'a show -> 'a -> unit =
fun {show=show} x -> print_endline (show x)

Smalltalk: subtyping

  • Object -> super class

    -> method table
    
  • If interface A contains all of interface B, then A objects can also be used as B objects

    • need to look up all instances(members) at runtime

Javascript has the same problem

  • v8 engine: hidden class
    function Person(first_name, last_name) {
    this.first_name = first_name;
    this.last_name = last_name;
    }

    var potus = new Person('D.', 'Trump');
    var potrf = new Person('V.', 'Putin');

Computer Architecture

Optimizing cache

Merging write cache

DRAM and SRAM

Misc

最低だ 最低だ 最低だ

Comment and share

  • page 1 of 1
Author's picture

NoirGif

A progamer.


Student(probably)