- ubuntu 16.04
- php 7.1
- apache 2.4
- mysql 5.7
- git & composer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This program is an example of how to run a command such as | |
// ps aux | grep root | grep sbin | |
// using C and Unix. | |
#include <stdlib.h> | |
#include <unistd.h> | |
int pid; | |
int pipe1[2]; | |
int pipe2[2]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 新增當地時區的時間物件 | |
function DateTimezone(offset) { | |
// 建立現在時間的物件 | |
d = new Date(); | |
// 取得 UTC time | |
utc = d.getTime() + (d.getTimezoneOffset() * 60000); | |
// 新增不同時區的日期資料 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf8 -*- | |
# Simple RSA Implementation | |
# Authored by Jeremy <jeremy5189(at)gmail.com> | |
# Reference: http://www.ruanyifeng.com/blog/2013/07/rsa_algorithm_part_two.html | |
from fractions import gcd | |
import sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Reference: http://stackoverflow.com/questions/4822471/count-number-of-lines-in-a-git-repository | |
$ git ls-files | xargs wc -l |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ffmpeg -i input.mp4 -vcodec h264 -acodec mp2 output.mp4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* = Recursive descent parser = | |
* | |
* MIT Style License | |
* By Dmitry Soshnikov <[email protected]> | |
* | |
* In this short lecture we'll cover the basic (non-predictive, backtracking) | |
* recursive descent parsing algorithm. | |
* | |
* Recursive descent is an LL parser: scan from left to right, doing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
.axis { | |
font-family: sans-serif; | |
fill: #d35400; | |
font-size: 12px; | |
} | |
.line { | |
fill: none; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![allow(unused_variables)] | |
#![allow(unused_imports)] | |
use std::env; | |
use std::process; | |
use std::thread; | |
use std::io::{self, Read, Write, Error}; | |
use std::net::TcpStream; | |
use std::net::TcpListener; |
本文譯自 [Tokio internals: Understanding Rust's asynchronous I/O framework from the bottom up][tokio-internals]。
Thanks [David Simmons][david-simmons] for this awesome article!
[Tokio][tokio] 是 Rust 的開發框架,用於開發非同步 I/O 程式(asynchronous I/O,一種事件驅動的作法,可實現比傳統同步 I/O 更好的延伸性、效能與資源利用)。可惜的是,Tokio 過於精密的抽象設計,招致難以學習的惡名。即使我讀完教程後,依然不認為自己充分內化這些抽象層,以便推斷實際發生的事情。
從前的非同步 I/O 相關開發經驗甚至阻礙我學習 Tokio。我習慣使用作業系統提供的 selection 工具(例如 Linux epoll)當作起點,再轉移至 dispatch、state machine 等等。倘若直接從 Tokio 抽象層出發,卻沒有清楚了解 epoll_wait()
在何處及如何發生,我會覺得難以連結每個概念。Tokio 與 future-driven 的方法就好像一個黑盒子。
OlderNewer