Skip to content

Instantly share code, notes, and snippets.

View haohailong's full-sized avatar
🏠
Working from home

Hailong Hao haohailong

🏠
Working from home
View GitHub Profile
{"sig":"1b5bdffaac86f98b4de8d87a10f56bca22c6082dba0cc55ad51d483e13323e6af6b86d84f2dc99379957cbdb3c95e6bfb31ed662b896f366f402b66525243c510","msghash":"8fe96d45d86391f1bb7855aba60087d21d25155bfe1756aa263e09f9b4a91c56"}
@haohailong
haohailong / play_button.ex
Last active November 24, 2016 01:29
Play a movie randomly in a directory
defmodule PlayButton do
@default_path "/Volumes/My\ Passport/Movie" # 使用模块属性定义默认路径
@minimum_size 50 * 1000000 # 确定文件最小值 50m (使用 1K = 1000 为标准)
def list(path \\ @default_path, acc \\ []) do # 定义函数 list,两个参数 path 为路径,acc 是用来存储文件路径 accumulator。
case File.stat(path) do # case 语句用 File.stat(path) 去做模式匹配
{:ok, stat} -> # 当 File.stat(path) == {:ok, stat} 时,去做下面的匹配
case {stat.size, stat.type} do
{_size, :directory} -> # 当 {stat.size, stat.type} == {_size, :directory} 时,去做下面的匹配,我想 "_size" 当中的下划线表示此处可以忽略这个变量,此句用来解决路径是目录的问题
case File.ls(path) do
{:ok, ls} -> # 这句会匹配并且把 ls 与 File.ls(path) 的结果中有用的部分绑定
@haohailong
haohailong / test_gist
Created April 29, 2014 05:04
test file, 测试文件
function mine()
{
while(true)
{
longestChain = getLongestValidChain()
-- A number that changes every time, so that you don't waste time
-- trying to calculate a valid blockHash with the same input.
nonce = getNewNonce()
---
layout: post
title: "Post Title"
date: yyyy-mm-dd hh:mm:ss
comments: true
categories: ""
---