Add some color.
This commit is contained in:
parent
5a617e3cfd
commit
a75b36f5a3
|
@ -9,6 +9,7 @@ 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)_:
|
||||
|
||||
~~~yaml
|
||||
paginate: 5
|
||||
permalink: pretty
|
||||
exclude: Rakefile
|
||||
|
@ -20,7 +21,7 @@ This is my current _[_config.yml](https://github.com/badboy/fnordig.de/blob/mast
|
|||
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:
|
||||
|
||||
~~~ruby
|
||||
module CodeRay
|
||||
def about
|
||||
[self.name.downcase, 'rocks!'].join(" ")
|
||||
end
|
||||
module_function :about
|
||||
end
|
||||
{:lang="ruby"}
|
||||
~~~
|
||||
|
||||
And that's it.
|
||||
|
||||
|
|
|
@ -14,12 +14,12 @@ 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:
|
||||
|
||||
~~~ruby
|
||||
proxy do |data|
|
||||
next if data.size < 9
|
||||
v, c, port, o1, o2, o3, o4, user = data.unpack("CCnC4a*")
|
||||
|
@ -31,7 +31,7 @@ Pipe the following into a text file:
|
|||
:data => data[idx+9..-1]
|
||||
}
|
||||
end
|
||||
{:lang="ruby"}
|
||||
~~~
|
||||
|
||||
and start it with
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ And now for some code examples:
|
|||
|
||||
#### Basic interface:
|
||||
|
||||
~~~ruby
|
||||
bill = BadBill.new "billo", "18e40e14"
|
||||
# => #<BadBill:0x00000001319d30 ...>
|
||||
bill.get 'settings'
|
||||
|
@ -41,10 +42,11 @@ And now for some code examples:
|
|||
# {"invoice_intro"=>"",
|
||||
# "invoice_note"=>"",
|
||||
# ...}}
|
||||
{:lang="ruby"}
|
||||
~~~
|
||||
|
||||
#### Using defined resources classes:
|
||||
|
||||
~~~ruby
|
||||
BadBill.new "billo", "18e40e14"
|
||||
|
||||
BadBill::Invoice.all
|
||||
|
@ -61,8 +63,7 @@ And now for some code examples:
|
|||
# "base64file"=>"JVBERi0xLjM..."}
|
||||
invoice.delete
|
||||
# => true
|
||||
{:lang="ruby"}
|
||||
|
||||
~~~
|
||||
|
||||
[repo]: https://github.com/badboy/badbill
|
||||
[apidocu]: http://www.billomat.com/en/api/
|
||||
|
|
|
@ -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:
|
||||
|
||||
~~~ruby
|
||||
irb> "❤".codepoints
|
||||
=> [10084]
|
||||
~~~
|
||||
|
||||
Got some codepoints and need to map it back to it's symbol? Easy:
|
||||
|
||||
~~~ruby
|
||||
irb> [10084, 10003].pack("U*")
|
||||
=> "❤✓"
|
||||
~~~
|
||||
|
||||
Oh, of course the usual `\uXYZ` syntax works aswell, but you need the hexstring for that:
|
||||
|
||||
~~~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:
|
||||
|
||||
~~~ruby
|
||||
irb> "❤".bytes
|
||||
=> [226, 157, 164]
|
||||
~~~
|
||||
|
||||
There is documentation on these things:
|
||||
|
||||
|
|
Loading…
Reference in a new issue