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
300
Railsgirls: Where did my HTML and CSS go
bjelli
0
510
Berufe im World Wide Web
bjelli
0
210
Javascript Closures
bjelli
3
880
Teach (all the) Rails
bjelli
0
440
Other Decks in Programming
See All in Programming
PHPとAPI Platformで作る本格的なWeb APIアプリケーション(入門編) / phpcon 2024 Intro to API Platform
ttskch
0
390
ErdMap: Thinking about a map for Rails applications
makicamel
1
650
Simple組み合わせ村から大都会Railsにやってきた俺は / Coming to Rails from the Simple
moznion
3
2.1k
Alba: Why, How and What's So Interesting
okuramasafumi
0
210
“あなた” の開発を支援する AI エージェント Bedrock Engineer / introducing-bedrock-engineer
gawa
4
220
DevFest - Serverless 101 with Google Cloud Functions
tunmise
0
140
Lookerは可視化だけじゃない。UIコンポーネントもあるんだ!
ymd65536
1
130
rails newと同時に型を書く
aki19035vc
5
710
asdf-ecspresso作って 友達が増えた話 / Fujiwara Tech Conference 2025
koluku
0
1.4k
『改訂新版 良いコード/悪いコードで学ぶ設計入門』活用方法−爆速でスキルアップする!効果的な学習アプローチ / effective-learning-of-good-code
minodriven
28
4.2k
ATDDで素早く安定した デリバリを実現しよう!
tonnsama
1
1.9k
AWSのLambdaで PHPを動かす選択肢
rinchoku
2
390
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
79
8.8k
Raft: Consensus for Rubyists
vanstee
137
6.7k
Side Projects
sachag
452
42k
The Cult of Friendly URLs
andyhume
78
6.1k
Optimising Largest Contentful Paint
csswizardry
33
3k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
3
360
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
230
52k
Six Lessons from altMBA
skipperchong
27
3.6k
Practical Orchestrator
shlominoach
186
10k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Designing for Performance
lara
604
68k
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