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
290
Railsgirls: Where did my HTML and CSS go
bjelli
0
480
Berufe im World Wide Web
bjelli
0
190
Javascript Closures
bjelli
3
870
Teach (all the) Rails
bjelli
0
430
Other Decks in Programming
See All in Programming
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
0
120
qmuntal/stateless のススメ
sgash708
0
110
PagerDuty を軸にした On-Call 構築と運用課題の解決 / PagerDuty Japan Community Meetup 4
horimislime
1
100
讓數據說話:用 Python、Prometheus 和 Grafana 講故事
eddie
0
320
『ドメイン駆動設計をはじめよう』のモデリングアプローチ
masuda220
PRO
4
150
Dev ContainersとGitHub Codespacesの素敵な関係
ymd65536
1
120
offers_20241022_imakiire.pdf
imakurusu
2
310
GCCのプラグインを作る / I Made a GCC Plugin
shouth
1
140
Workflow automationによるインシデント原因調査の自動化
showwin
1
120
#pixiv小説画像メーカー はこうしてできた / The Making of the pixiv Novel Image Maker
roiban
0
220
ピクシブ百科事典のWebフロントエンドパフォーマンス改善
higara
0
230
とにかくAWS GameDay!AWSは世界の共通言語!.pdf / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
0
160
Featured
See All Featured
Building Adaptive Systems
keathley
38
2.2k
10 Git Anti Patterns You Should be Aware of
lemiorhan
653
59k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.1k
The Cost Of JavaScript in 2023
addyosmani
45
6.2k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
3
360
Visualization
eitanlees
143
15k
Being A Developer After 40
akosma
86
590k
[RailsConf 2023] Rails as a piece of cake
palkan
51
4.8k
Product Roadmaps are Hard
iamctodd
PRO
48
10k
Side Projects
sachag
452
42k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
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