Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Ruby One-Liners
Search
bjelli
March 23, 2012
Programming
1
340
Ruby One-Liners
A lightning talk at Salzburg Barcamp "The Next Web" in March 2012.
bjelli
March 23, 2012
Tweet
Share
More Decks by bjelli
See All by bjelli
Intro to Web- and Mobile-Developement
bjelli
0
320
Railsgirls: Where did my HTML and CSS go
bjelli
0
560
Berufe im World Wide Web
bjelli
0
240
Javascript Closures
bjelli
3
890
Teach (all the) Rails
bjelli
0
440
Other Decks in Programming
See All in Programming
Go Conference 2025: Goで体感するMultipath TCP ― Go 1.24 時代の MPTCP Listener を理解する
takehaya
9
1.7k
階層構造を表現するデータ構造とリファクタリング 〜1年で10倍成長したプロダクトの変化と課題〜
yuhisatoxxx
3
1k
Go言語の特性を活かした公式MCP SDKの設計
hond0413
1
230
デミカツ切り抜きで面倒くさいことはPythonにやらせよう
aokswork3
0
230
Server Side Kotlin Meetup vol.16: 内部動作を理解して ハイパフォーマンスなサーバサイド Kotlin アプリケーションを書こう
ternbusty
3
180
あなたとKaigi on Rails / Kaigi on Rails + You
shimoju
0
140
Go言語はstack overflowの夢を見るか?
logica0419
0
270
オープンソースソフトウェアへの解像度🔬
utam0k
15
2.8k
Devvox Belgium - Agentic AI Patterns
kdubois
1
120
CSC509 Lecture 04
javiergs
PRO
0
300
Introducing ReActionView: A new ActionView-Compatible ERB Engine @ Kaigi on Rails 2025, Tokyo, Japan
marcoroth
3
1k
Range on Rails ―「多重範囲型」という新たな選択肢が、複雑ロジックを劇的にシンプルにしたワケ
rizap_tech
0
130
Featured
See All Featured
Art, The Web, and Tiny UX
lynnandtonic
303
21k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
The Art of Programming - Codeland 2020
erikaheidi
56
14k
Git: the NoSQL Database
bkeepers
PRO
431
66k
Typedesign – Prime Four
hannesfritz
42
2.8k
Designing Experiences People Love
moore
142
24k
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.7k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.6k
Build your cross-platform service in a week with App Engine
jlugia
232
18k
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
Balancing Empowerment & Direction
lara
4
690
Transcript
Ruby One-Liner
mit -e Programmcode angeben ruby -e ' puts "hello" '
ruby -e 'puts "Hello"' mit -e Programm angeben
ruby -e 'puts 24 * 60 * 60 ' mein
Taschenrechner
ruby -p -e '' langer.txt -p print-schleife über datei
ruby -p -e 'puts' langer.txt leerzeile nach jeder zeile
ruby -p -e 'puts $_.length' langer.txt $_ enthält die Zeile
ruby -p -e 'puts "#{$.}.Zeile hat länge #{$_.length} " '
langer.txt $. enthält die Zeilennummer
Korrektur • es geht nicht um Zeilen • sondern um
"Records" • default: Record-Separator ist "\n" • deswegen wird zeilenweise gelesen • Der Separator ist in der Variable $/
ruby -00 -p -e 'puts "#{$.}.Absatz hat länge #{$_.length} "
' l.txt -00 verwende doppelten separator Absatz statt Zeile
ruby -p -e 'puts "."' index.html -n schleif, nicht ausgeben
ruby -n -e 'puts if /Schokolade/' index.html Finden grep
ruby -p -e 'gsub(/Game/, "Web")' index.html Ersetzen
ruby -i.bak -p -e 'gsub(/Game/, "Web")' index.html Ersetzen in der
Datei neu in index.html, alt in index.html.bak
ruby -i.bak -p -e 'gsub(/Game/, "Web")' *.html Ersetzen in vielen
Dateien
ruby command line switches + ruby one-liners + unix |
Learn More