古琴F调按音图

古琴F调按音图
古琴F调按音图

各弦音域(散音加徽内按音)

  • 一弦: 5– 到 5+
  • 二弦: 6– 到 6+
  • 三弦: 1- 到 1++
  • 四弦: 2- 到 2++
  • 五弦: 3- 到 3++
  • 六弦: 5- 到 5++
  • 七弦: 6- 到 6++

所以古琴的音域是很广的,从5–到6++,总共4个八度多一点。
每根弦的按音最高就是一徽按音,一徽是弦长的 1/8,所以一徽按音比散音高3个8度。

各个音的位置

  • 5– : 一弦散音
  • 6– : 二弦散音,一弦十三徽
  • 7– : 二弦十三徽, 一弦十徽八分
  • 1- : 三弦散音, 二弦十二徽, 一弦十徽
  • 2- : 四弦散音, 三弦十三徽, 二弦十徽, 一弦九徽
  • 3- : 五弦散音, 四弦十三徽, 三弦十徽八分, 二弦九徽, 一弦七徽九分
  • 4- : 四弦十二徽, 三弦十徽, 二弦八徽五分, 一弦七徽六分
  • 5- : 六弦散音, 五弦十二徽, 四弦十徽, 三弦九徽, 二弦七徽六分, 一弦七徽
  • 6- : 七弦散音, 六弦十三徽, 五弦十徽, 四弦九徽, 三弦七徽九分, 二弦七徽, 一弦六徽四分
  • 7- : 七弦十三徽, 六弦十徽八分, 五弦九徽, 四弦七徽九分, 三弦七徽三分, 二弦六徽四分, 一弦六徽
  • 1 : 七弦十二徽, 六弦十徽, 五弦八徽五分, 四弦七徽六分, 三弦七徽, 二弦六徽二分, 一弦五徽六分
  • 2 : 七弦十徽, 六弦九徽, 五弦七徽六分, 四弦七徽, 三弦六徽四分, 二弦五徽六分, 一弦五徽
  • 3 : 七弦九徽, 六弦七徽九分, 五弦七徽, 四弦六徽四分, 三弦六徽, 二弦五徽, 一弦四徽六分
  • 4 : 七弦八徽五分, 六弦七徽六分, 五弦六徽七分, 四弦六徽二分, 三弦五徽六分, 二弦四徽八分, 一弦四徽四分
  • 5 : 七弦七徽六分, 六弦七徽, 五弦六徽二分, 四弦五徽六分, 三弦五徽, 二弦四徽四分, 一弦四徽
  • 6 : 七弦七徽, 六弦六徽四分, 五弦五徽六分, 四弦五徽, 三弦四徽六分, 二弦四徽, 一弦三徽四分
  • 7 : 七弦六徽四分, 六弦六分, 五弦五分, 四弦六徽四分, 三弦四徽二分, 二弦三徽四分, 一弦三徽
  • 1+ : 七弦六徽二分, 六弦五徽六分, 五弦四徽八分, 四弦四徽四分, 三弦四徽, 二弦三徽二分, 一弦二徽六分
  • 2+ : 七弦五徽六分, 六弦五徽, 五弦四徽四分, 四弦四徽, 三弦三徽四分, 二弦二徽六分, 一弦二徽
  • 3+ : 七弦五徽, 六弦四徽六分, 五弦四徽, 四弦三徽四分, 三弦三徽, 二弦二徽, 一弦一徽六分
  • 4+ : 七弦四徽八分, 六弦四徽四分, 五弦三徽八分, 四弦三徽二分, 三弦二徽六分, 二弦一徽八分, 一弦一徽四分
  • 5+ : 七弦四徽四分, 六弦四徽, 五弦三徽二分, 四弦二徽六分, 三弦二徽, 二弦一徽四分, 一弦一徽
  • 6+ : 七弦四徽, 六弦三徽四分, 五弦二徽六分, 四弦二徽, 三弦一徽六分, 二弦一徽
  • 7+ : 七弦三徽四分, 六弦三徽, 五弦二徽, 四弦一徽六分, 三弦一徽二分
  • 1++ : 七弦三徽二分, 六弦二徽六分, 五弦一徽八分, 四弦一徽四分, 三弦一徽
  • 2++ : 七弦二徽六分, 六弦二徽, 五弦一徽四分, 四弦一徽
  • 3++ : 七弦二徽, 六弦一徽六分, 五弦一徽
  • 4++ : 七弦一徽八分, 六弦一徽四分
  • 5++ : 七弦一徽四分, 六弦一徽
  • 6++ : 七弦一徽

Cron

Cron在Linux系统中用于计划任务。

举个例子

0 */2 * * * date >> /var/log/date.log

这将在每2小时往date.log里记录下date命令的结果。

格式说明

前面5位数,分别代表的是 分钟 小时 日 月 星期几, 然后后面就是条件满足时候运行的命令。
这前面5位数,可取值的范围是:
逗号 (‘,’) 分开的值,例如:“1,3,4,7,8”
连词符 (‘-‘) 制定值的范围,例如:“1-6”,意思等同于“1,2,3,4,5,6”
星号 (‘‘) 代表任何可能的值。例如,在“小时域” 里的星号等于是“每一个小时”
斜杠 (‘/’) 代表整除,例如”
/2″表示所有的偶数

参考

http://zh.wikipedia.org/wiki/Cron

十二平均律

简介

十二平均律是音乐定调的基本方法,是指将一个八度,(频率相差1倍),的范围,平均分成12分(等比)。每一段叫做一个半音,两个叫做全音。然后将我们常见的do, re, mi, fa, so, la, xi分布在这上面。
除了mi-fa和xi到高八度的do两个半音以外,其它间距都是全音,这样正好凑成12个半音。
半音的频率比就是 2^(1/12)
现在的钢琴就是这么调的,相邻键之间是半音。

?

为什么这么搞呢?因为这样定调之后,无论do的频率是多少,演奏出来的感觉是旋律不会变。

参考

百度百科的解释,后面的部分看着比较有意思,不想重复了。

Using VCR with WebMock in Rails Rspec Tests

If the application need interaction with another web service, it’s convenience to using VCR with WebMock to test the application, rather than doing the request to another web service every time.

Setup

Modify Gemfile

group :test do
  gem 'webmock'
  gem 'vcr'
end

and don’t forget to run

bundle install

Config VCR

The following code can be placed in the spec_helper.rb

VCR.configure do |c|
  c.allow_http_connections_when_no_cassette = true
  c.cassette_library_dir = 'spec/cassettes' #this specified the directory for placing the record files
  c.hook_into :webmock
  c.configure_rspec_metadata!
  c.default_cassette_options = {
    :record => :once,
    :erb => true,
    :match_requests_on => [:method, :uri, :host, :path, :headers]
  }
end

Using VCR

Then you can using VCR when write the rspec test like:

describe 'Some api call tests', :vcr => true do
#write normal api call tests here
end

Re-record

Sometimes we need to re-record the cassettes, because maybe the request params changed in our app or the response is updated from third-party server.

It’s very easy to do that, just modify your VCR.config block, set record: all instead of :once.

:record => :all

and run your rspec tests related to that cassettes, then the cassettes files will be updated.

And you can specify the matchers per test:

describe 'Something', :vcr => {match_requests_on:[:method, :uri]} do
  # Some tests
end

The following method can tell whether vcr is recording, it’s very useful in some scenarios:

VCR.current_cassette.recording?

[Repost] Here Document in Ruby

This is repost from http://log.gmarik.info/2007/12/rubys-here-document-heredoc-mini.html , good post!

Basics

Here Document(or HereDoc) is a way to declare String literal in Ruby programming language:

some_text = <<END_OF_STRING
 You can write any text here for your document that's why such
 statement is called - HereDoc
END_OF_STRING

That’s it! Now some_text variable points to the string object containing the text going between END_OF_STRING
As you may know HereDoc isn’t a unique Ruby feature, rather it’s a common construct(with some distinctions) for scripting languages “brewed” in Unix environment.

The terminator

By Ruby convention a variable starting with capital letter is a constant. But that’s not a case for the END_OF_STRING from previous example, because terminator is just a string which parser treats as the end of HereDoc.
Well if a terminator is a string then can i use arbitrary(say put spaces within) string as the terminator like end of string? The answer is – yes you can!
<<heredoc is interpreted same as <<"heredoc" (please note double quotes around latter heredoc).
But explicit notation(with quotes) is a bit more powerful.

String interpolation

By explicitly enclosing terminator with quotes you may have:

a_text = <<"Ruby, please end my HereDoc once you find this terminator string"
Hello world!
Ruby, please end my HereDoc once you find this terminator string

or

fuzzy_names = <<">>"
foo, baz, bar
>>

Wow, if i can use double quoted string, then probably i can use single quoted string as well:

puts <<'end of string'
 1+1=#{1+1}
end of string
prints
1+1=#{1+1}

as single quoted strings aren’t interpolated unlike double quoted:

puts <<"end of string"
 1+1=#{1+1}
end of string
prints
1+1=2

Indent modifier

By default HereDoc terminator is expected to be placed on the very beginning of the separate line
By using – on HereDoc declaration, you may indent end terminator arbitrary:

greeting = <<-"here document ends"
                 Hello world
               here document ends

Keep in mind that leading spaces are kept.

Advanced usages

a, b = <<'EOA', <<-EOB
string_a
EOA
string_b
   EOB
is equal to
a, b = "string_a\n", "string_b\n"

At this point i’m thinking about HereDoc as “placeholder” that gets substituted with the string itself. Why is that important? Because you may then treat HereDoc declaration as the actual string and send messages(call methods):

<<'heredoc'.reverse == "\n!dlrow olleH"
Hello world!
heredoc

is a true statement!

[Repost]How to kill a dragon with various programming languages

Repost from How to kill a dragon with various programming languages


This funny text comes from Ibon from the dream team who got it from a Spanish blog.

There’s a beautiful princess, prisoner in the highest tower of a castle, guarded by a mighty dragon, and a fearless knight must rescue her…

This is how each language would manage to rescue the princess from the hands of the dragon

Java – Gets there, finds the dragon, develops a framework for dragon anihilation with multiple layers, writes several articles about the framework… But doesn’t kill the dragon.
.NET – Gets there, sees the idea of the Java developer and copies it. Tries to kill the dragon, but the monster eats him.
C – Arrives, looks down at the dragon, pulls out his sword, beheads the dragon, finds the princess… And ignores her to see the last checkins of linux kernel cvs.
C++ – Creates a basic needle, and gathers funcionality until he has a complex sword that he can barely understand… He kills the dragon, but gets stuck crossing the bridge because of memory leaks.
COBOL – Arrives, sees the dragon and thinks that he is too old to kill a monster that big and rescuing the princess, so he leaves.
Pascal – He prepares for 10 years to create a dragon anihilation system… When the moment comes, he discovers the program can only take lizards as an entry.
VB – Builds a dragon destruction weapon based on several components, jumps to the back of the dragon and in the most critical time he discovers that the sword works only on rainy nights…
PL/SQL – Gets data from other dragon slayers, creates tables with n ternary complexity relations, tridimensional data, OLAP, takes 15 years to process the information… And by then, the princess became a lesbian.
Ruby – Arrives with massive fame, saying he is the best at anything and when he faces the dragon, he shows a lame motion picture of himself killing a dragon… The dragon eats him out of boredom.
Smalltalk – Arrives, analyzes the dragon and princess, turns around and leaves, they are way too inferior.
shell – Creates a very powerful dragon slaying weapon… But in the moment of truth, he can’t remember how to use it.
shell(2)- The guy approaches the dragon with a two line script that kills, cuts, disembowels, impales, chops to pieces and packs the beast, but when he runs it the script grows, it fattens, irritates and puts alcohol in the fire of the dragon…
Assembler – He thinks he’s doing the right and most efficient things… But he writes an A instead of a D and kills the princess to end up f***ing the dragon.
Fortran – Arrives and develops a 45-thousand-code-line-solution, kills the dragon, meets the princess… But she calls him a weakling and runs after the Java programmer who was elegant, and also rich.
FOX PRO – Develops a dragon killing system. It’s gorgeous and works on the outside, but it’s really patched inside, so when he runs the dragon anihilator, he realizes he forgot to index the DBFs.
PROCESS ANALYST – Approaches the dragon with two tons of documentation, develops the unified dragon-killing process, he develops a DFD to free the princess and marry her, convinces the dragon that it’s the best for him and it won’t hurt. When he executes the process, he estimates the effort and the damage he will cause with a plan signed by the Pope, Buddha and Michael Jackson. Then he buys a couple of nukes, 45 cannons, an aircraft carrier and hires 300 heavily armed men… When all he needed was the sword he was holding in his hand in the beginning…
CLIPPER: Sets up a routine that loads a codeblock array to insult the dragon, serenade the princess, load the sword in memory, beat the crap out of the dragon, clean the mess, prepare a raspberry milkshake for the princess, make love to her, take a bath, start the car, put it some gas and come back home. When he runs it, he gets a “Bound Error: Array Access” and the dragon eats him with fries.
Lisp, where the famous knight-errant, after speaking with numerous experts in dragon-killing, and modeling the knowledge they posess, he programs the system, and when he runs it he realizes he forgot a bracket (bender the offender).
HTML: Mounts a web on famous swords used to kill dragons, but he ignores the W3C standards. When he meets the dragon, he finds out the code isn’t compatible with his browser, so he’s left swordless. The dragon eats him as an appetizer.
Prolog: Thinks he needs a weapon to kill the dragon. Searches in a catalog for 182014 weapons. By the time the princess dies of her age, he’s achieved to know how to make every weapon starting with A: Atomic Bombs, Anti-Air Weapons, Arches, Ammunition, Axes…
PHP: Creates a web page that when he executes it would eliminate the $dragon selecting from a weapons databese in MySQL over an Apache server. Nevertheless he forgot the WHERE in the DELETE query and kills the princess, the dragon, the peasants, the witch, the sorceror and the programmer himself.
JavaScript: The programmer tries to kill the great green dragon that spits fire throug his mouth. He creates a script that will delete the dragon when he loads a webpage, to create seconds after, some damsels to throw him flowers and make clapping sounds. Unfortunately he didn’t take into account the DOM structure of the lizard, also known as Mozilla, and the only thing he gets is to fill his console of errors and that the Book of Mozilla tells how he was devoured.
ActiveX: The programmers create a tunnel to enter the dragon’s lair from the castle and run a program that will kil the dragon from a safe and prudential distance. The dragon discovers the tunnel, eats the workers who dug, the dragon slayers, and enslaves every servant in the castle. The castle becomes a dragon-breeding place, full of little dragons that the dragon sends in pop-ups to other castles. The untasty remains of the knights are put in cans of Spam and sent to other castles as well as a warning. (aquelquesiente)
Basic. He creates a weapon able to kill paper dragons, but no matter how they improve it, they discover it’s not good enough to kill any dragon bigger than a baby poodle.
Matlab: They create a loop that calculates the trajectories to shoot a giant arrow at the dragon. The program works flawlessly. What they need now are the voluntaries caoable to launch tha arrow with the necessary strength and accuracy.
Videogame Programmer : Spends two years programming a state-of-the-art sword with shaders and all. When the time comes to kill the dragon, he finds that half the knights aren’t strong enough to raise the sword. Then someone programs a patch that reveals the sex scenes with the princess and Hillary Clinton makes it a scandal.