Bitcoin playground

使用 Blockchain 的服务进行比特币交易

Use blockchain bitcoin service to transfer bitcoins

Wallet api

1
2
3
4
5
6
7
8
https://blockchain.info/merchant/$guid/payment
?password=$main_password
&second_password=$second_password
&to=$address
&amount=$amount
&from=$from
&fee=$fee
&note=$note

Request tips:

The My Wallet API provides a simple interface Merchants can use interact with their wallet. Blockchain.info will decrypt the wallet on our server manipulate it as necessary and re-save. HTTP GET and POST are supported. However, if a POST request is sent without “Content-Type: application/x-www-form-urlencoded” header, some endpoints may not work correctly.

Read More

Using FFmpeg to do some simple video process.

Tip:

zsh doesn’t support letters like ‘[‘, ‘]’ etc. so we need to add a Back Slash(\)

rake new_post\[“kicking the ffmpeg”\]

###Because

FFmpeg can’t concatenate .mp4 videos directly, but .ts is ok.

###So

We need to convert all .mp4 files to .ts, then concatenate them together.

####Convert

1
2
3
ffmpeg -i 1.mp4 -c:v copy -c:a copy -vbsf h264_mp4toannexb 1.ts
ffmpeg -i 2.mp4 -c:v copy -c:a copy -vbsf h264_mp4toannexb 2.ts
...
  1. -c:a copy to tell FFmpeg to copy the audio stream, -c:v copy has the same mean.
  2. -vbsf h264_mp4toannexb a encoder use to convert videos to .ts.
  3. -i input file

####Concatenate

1
ffmpeg -i "concat:1.ts|2.ts|3.ts|4.ts" -c:v copy -c:a copy -absf aac_adtstoasc output.mp4

###To simplify this, we need a script as a little program.

1
#Not implement yet

Rocking Rasperry Pi

##Keep in mind

  • Use sudo nmap -sP -T4 10.0.30.1-254 to detect connected devices.
  • Then use sudo nmap -v -A -T4 10.0.30.1 get all opened port and services on this machine.
  • Start a vnc server on raspi. vncserver :1 -geometry 1200x700 -depth 24
  • apt update use goagent proxy. sudo apt-get -o Acquire::http::proxy="http://10.42.0.1:8087/" update
  • Statistic folder size: du -h --max-depth=1

##View the video over mplayer
Install mplayer: sudo apt-get install mplayer

Rasperry Pi: raspivid -t 999999 -o | omxplayer

##Stream video over a network (Official Doc)
Install related tool (both client & raspi): sudo apt-get install mplayer netcat

Some Linux : nc -l -p 5001 | mplayer -fps 31 -cache 1024 -
(Record on the other side: nc -l -p 5001 | ffmpeg -r 31 -i - out.avi)

Rasperry Pi: raspivid -t 999999 -o - | nc 10.42.0.1 5001

##Camera Error

1
2
3
4
5
$ raspistill -o haha.jpg
mmal: mmal_vc_component_enable: failed to enable component: ENOSPC
mmal: camera component couldn't be enabled
mmal: main: Failed to create camera component
mmal: Failed to run camera app. Please check for firmware updates

Fixed by: Kernels >= 3.10: w1_gpio destroys i2c bus 0, raspicam doesn’t work anymore

##Connect to Wifi

  1. ifconfig: Enable your wireless device.
  2. iwlist: List the available wireless access points.
  3. iwconfig: Configure your wireless connection.
  4. dhclient: Get your IP address via dhcp.
  5. /etc/network/if-up.d/upstart
1
2
3
iwlist wlan0 scan
sudo iwconfig wlan0 essid rk_mint key s:password123
sudo dhclient wlan0

##Load Camera to /dev/video0 HELP

1
uv4l --driver raspicam --auto-video_nr

##Motion detect HELP

1
LD_PRELOAD=/usr/lib/uv4l/uv4lext/armv6l/libuv4lext.so motion -c ./motion.conf

Python Learning on

###Knowledge Points

####list

creates lists from iterables.

####else Clauses on Loops (python doc equals if no break else do)

When used with a loop, the else clause has more in common with the else clause of a try statement than it does that of if statements: a try statement’s else clause runs when no exception occurs, and a loop’s else clause runs when no break occurs.

for n in range(2, 10):
  for x in range(2, n):
    if n % x == 0:
      print(n, '=', x, '*', n // x)
      break
  else:
    print(n, '是素数')

####varible scope (view in python doc)

The execution of a function introduces a new symbol table used for the local variables of the function. More precisely, all variable assignments in a function store the value in the local symbol table; whereas variable references first look in the local symbol table, then in the local symbol tables of enclosing functions, then in the global symbol table, and finally in the table of built-in names. Thus, global variables cannot be directly assigned a value within a function (unless named in a global statement), although they may be referenced.

####default values in function definition (Default Argument Values)

The default values are evaluated(and evaluated only once) at the point of function definition in the defining scope, so that

i = 5

def f(arg=i):
    print(arg)

i = 6
f()

will print 5.

透明网络

###目录:

  1. youtube下载视频(包括1080p).
  2. 翻墙.
  3. 不翻墙使用Google Search.
  4. 关于本文.
  5. 解释

###youtube下载视频

  1. 翻墙并打开youtube网站,
  2. 找到要看的视频,
  3. 点击浏览器地址栏,并复制该网址,
  4. 准备解析源地址
    1. Chrome下,简单下载720p视频 (推荐)
      1. 打开Ultimate YouTube Downloader的网站:Ultimate YouTube Downloader
      2. 点击下面的Download (New vx.x.x.x)下载这个扩展,
      3. 依次点击Chrome的设置–>扩展程序,再点击开发者模式打开开发者模式,
      4. 把Chrome浏览器窗口化(点击右上角叉叉左边的按钮),再打开文件管理器,在自己电脑的下载目录,找到刚刚下载的Ultimate_YouTube_xxxx.crx,把它拖到这边浏览器的扩展程序这个页面,松手,安装成功。然后就不用管了,以后会自动升级的。
      5. 现在打开Youtube的视频页面,后边多出来个下载下拉框,点击MP4 720p以720p级别的清晰度下载这个视频。
    2. 仅需要下载720p以下的视频
      1. 使用FLVCD的下载器: 打开flvcd downloader,并点击硕鼠Youtube专用下载器下载硕鼠的下载器,接下来就比较简单了,打开软件书如地址点击下载一气呵成(要记得设置http代理噢)——不推荐
    3. 需要下载1080p级别的高清视频(2013-11-25测试可用)
      1. 使用Kej’s FLV Retriever
        1. 打开它们的网站:Kej’s FLV Retriever
        2. 粘贴刚刚复制的网址到输入框中,然后retrieve now!注意要开着代理,一定要全开,使用VPN全局代理,如果是http代理,goAgent类的,要设置代理程序对所有网址都使用代理,不要使用pac自动识别的方式。
        3. 然后麻烦一点,点击下载页面中的下载此档案指向的文件,然后用记事本打开这个文件,复制所有内容,然后粘贴到下面的文本框中,
        4. 然后更麻烦一点,看到下面的Download (MP4(H.264), 1920 x 1080, no audio)了吧,这个视频下载下来是没有声音的,不过下面还是有audio only格式的音频供下载,有视频和音频,自然有办法合并音视频流。
        5. 点击那个Download (MP4(H.264), 1920 x 1080, no audio)下载视频。
        6. 然后再点击Download (M4A, 256 kbit/s audio only)下载音频。
        7. 注意下载的音视频的格式,两个文件是同名的,都叫videoplayback,但下载的时候一前一后,后者嘛肯定是有个(1)字样结尾的。
        8. 下载一个ffmpeg下来,Windows版已经编译好了的下载地址是:Zeranoe FFmpeg builds。注意自己的电脑版本,打开网页之后就找醒目的32-bit Downloads64-bit Downloads32位看左边,64位看右边,点第一个黑块Download FFmpeg git-xxxxxxx xx-bit Static就会开始下载了。
        9. 解压得到一个ffmpeg.exe,复制当前目录的路径,并看看当前目录在什么盘符下,然后打开命令行,切换到该目录(同时按win+r,输入cmd,按回车,输入cd,鼠标右键粘贴刚刚复制的路径,按回车,如果刚刚的ffmpeg.exe没解压到C盘,cd完了是没效果的,再输入刚刚记下来的盘符:,回车),命令行不要关。
        10. 调用ffmpeg.exe来合并视频,把刚刚下载的两个视频啊音频啊都拷贝到ffmpeg.exe下面来,然后在命令行输入ffmpeg -i "第一个文件的名字" -i "第二个文件的名字" -c:v copy video.mp4,然后回车。
        11. 然后就得到视频了。

Read More