1
Fork 0

Add some color.

This commit is contained in:
Jan-Erik Rediger 2013-11-06 12:46:19 +01:00
parent 5a617e3cfd
commit a75b36f5a3
4 changed files with 76 additions and 65 deletions

View file

@ -9,18 +9,19 @@ With [jekyll][] as my static site generator it is easy to enable it. Just get th
This is my current _[_config.yml](https://github.com/badboy/fnordig.de/blob/master/_config.yml)_:
paginate: 5
permalink: pretty
exclude: Rakefile
markdown: kramdown
kramdown:
~~~yaml
paginate: 5
permalink: pretty
exclude: Rakefile
markdown: kramdown
kramdown:
use_coderay: true
coderay:
coderay_line_numbers:
coderay_tab_width: 2
coderay_css: class
{:lang="yaml"}
~~~
If you use `coderay_css: class` make sure to include a CSS file on your page (see my [coderay.css](/coderay.css)).
@ -34,13 +35,14 @@ Adding syntax-highlighted code in your post now works like this:
And now some real highlighting to show it in action:
module CodeRay
~~~ruby
module CodeRay
def about
[self.name.downcase, 'rocks!'].join(" ")
end
module_function :about
end
{:lang="ruby"}
end
~~~
And that's it.

View file

@ -14,13 +14,13 @@ It's called [proxymachine](https://github.com/mojombo/proxymachine), made by [@m
Get it with:
gem install proxymachine
{:lang="text"}
and you're nearly done.
Pipe the following into a text file:
proxy do |data|
~~~ruby
proxy do |data|
next if data.size < 9
v, c, port, o1, o2, o3, o4, user = data.unpack("CCnC4a*")
return { :close => "\x0\x5b\x0\x0\x0\x0\x0\x0" } if v != 4 or c != 1
@ -30,8 +30,8 @@ Pipe the following into a text file:
:reply => "\x0\x5a\x0\x0\x0\x0\x0\x0",
:data => data[idx+9..-1]
}
end
{:lang="ruby"}
end
~~~
and start it with

View file

@ -34,35 +34,36 @@ And now for some code examples:
#### Basic interface:
bill = BadBill.new "billo", "18e40e14"
# => #<BadBill:0x00000001319d30 ...>
bill.get 'settings'
# => {"settings"=>
# {"invoice_intro"=>"",
# "invoice_note"=>"",
# ...}}
{:lang="ruby"}
~~~ruby
bill = BadBill.new "billo", "18e40e14"
# => #<BadBill:0x00000001319d30 ...>
bill.get 'settings'
# => {"settings"=>
# {"invoice_intro"=>"",
# "invoice_note"=>"",
# ...}}
~~~
#### Using defined resources classes:
BadBill.new "billo", "18e40e14"
~~~ruby
BadBill.new "billo", "18e40e14"
BadBill::Invoice.all
# => [#<BadBill::Invoice:0x000000024caf98 @id="1" @data={...}>], ...]
invoice = BadBill::Invoice.find(1)
invoice.pdf
# => {"id"=>"1",
# "created"=>"2012-09-17T13:58:42+02:00",
# "invoice_id"=>"322791",
# "filename"=>"Invoice 322791.pdf",
# "mimetype"=>"application/pdf",
# "filesize"=>"90811",
# "base64file"=>"JVBERi0xLjM..."}
invoice.delete
# => true
{:lang="ruby"}
BadBill::Invoice.all
# => [#<BadBill::Invoice:0x000000024caf98 @id="1" @data={...}>], ...]
invoice = BadBill::Invoice.find(1)
invoice.pdf
# => {"id"=>"1",
# "created"=>"2012-09-17T13:58:42+02:00",
# "invoice_id"=>"322791",
# "filename"=>"Invoice 322791.pdf",
# "mimetype"=>"application/pdf",
# "filesize"=>"90811",
# "base64file"=>"JVBERi0xLjM..."}
invoice.delete
# => true
~~~
[repo]: https://github.com/badboy/badbill
[apidocu]: http://www.billomat.com/en/api/

View file

@ -10,25 +10,33 @@ I ❤ Unicode. Atleast most of the time. That's why I have things like ✓, ✗
But sometimes you need not only the symbol itself, but maybe the codepoint as well. That's easy in ruby:
irb> "❤".codepoints
=> [10084]
~~~ruby
irb> "❤".codepoints
=> [10084]
~~~
Got some codepoints and need to map it back to it's symbol? Easy:
irb> [10084, 10003].pack("U*")
=> "❤✓"
~~~ruby
irb> [10084, 10003].pack("U*")
=> "❤✓"
~~~
Oh, of course the usual `\uXYZ` syntax works aswell, but you need the hexstring for that:
irb> 10084.to_s 16
=> "2764"
irb> "\u{2764}"
=> "❤"
~~~ruby
irb> 10084.to_s 16
=> "2764"
irb> "\u{2764}"
=> "❤"
~~~
Sometimes you may need to see the actual bytes. This is easy in ruby aswell:
irb> "❤".bytes
=> [226, 157, 164]
~~~ruby
irb> "❤".bytes
=> [226, 157, 164]
~~~
There is documentation on these things: