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
330
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
310
Railsgirls: Where did my HTML and CSS go
bjelli
0
540
Berufe im World Wide Web
bjelli
0
230
Javascript Closures
bjelli
3
890
Teach (all the) Rails
bjelli
0
440
Other Decks in Programming
See All in Programming
GoのGenericsによるslice操作との付き合い方
syumai
3
690
DroidKnights 2025 - 다양한 스크롤 뷰에서의 영상 재생
gaeun5744
3
320
たった 1 枚の PHP ファイルで実装する MCP サーバ / MCP Server with Vanilla PHP
okashoi
1
190
Haskell でアルゴリズムを抽象化する / 関数型言語で競技プログラミング
naoya
17
4.9k
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
240
Go1.25からのGOMAXPROCS
kuro_kurorrr
1
800
Is Xcode slowly dying out in 2025?
uetyo
1
190
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
46
31k
PHPでWebSocketサーバーを実装しよう2025
kubotak
0
160
プロダクト志向ってなんなんだろうね
righttouch
PRO
0
160
つよそうにふるまい、つよい成果を出すのなら、つよいのかもしれない
irof
1
300
ASP.NETアプリケーションのモダナイズ インフラ編
tomokusaba
1
410
Featured
See All Featured
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
It's Worth the Effort
3n
185
28k
How to Ace a Technical Interview
jacobian
277
23k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.3k
Being A Developer After 40
akosma
90
590k
Stop Working from a Prison Cell
hatefulcrawdad
270
20k
Raft: Consensus for Rubyists
vanstee
140
7k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
35
2.3k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
930
Into the Great Unknown - MozCon
thekraken
39
1.9k
Typedesign – Prime Four
hannesfritz
42
2.7k
Testing 201, or: Great Expectations
jmmastey
42
7.5k
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