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
350
1
Share
Ruby One-Liners
A lightning talk at Salzburg Barcamp "The Next Web" in March 2012.
bjelli
March 23, 2012
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
600
Berufe im World Wide Web
bjelli
0
270
Javascript Closures
bjelli
3
900
Teach (all the) Rails
bjelli
0
450
Other Decks in Programming
See All in Programming
Transactional Change Stream Processing With Debezium and Apache Flink
gunnarmorling
1
150
Why Laravel apps break—Mastering the fundamentals to keep them maintainable
kentaroutakeda
1
330
RTSPクライアントを自作してみた話
simotin13
0
420
AIエージェントの隔離技術の徹底比較
kawayu
0
450
プラグインで拡張される Context をtype-safe にする難しさと設計判断
kazupon
2
540
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
2
960
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
7
3k
関係性から理解する"同一性"の型用語たち
pvcresin
2
630
Signal Forms: Beyond the Basics @ngBaguette 2026 in Paris
manfredsteyer
PRO
0
200
JJUG CCC 2026 Spring: JSpecify で実現する Kotlin フレンドリーな Java API 設計
ternbusty
1
130
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
410
dRuby over BLE
makicamel
1
270
Featured
See All Featured
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
540
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
220
Color Theory Basics | Prateek | Gurzu
gurzu
0
320
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
460
Being A Developer After 40
akosma
91
590k
KATA
mclloyd
PRO
35
15k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
150
Paper Plane (Part 1)
katiecoart
PRO
0
8.1k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
30 Presentation Tips
portentint
PRO
1
310
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
590
WCS-LA-2024
lcolladotor
0
610
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