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
570
Berufe im World Wide Web
bjelli
0
260
Javascript Closures
bjelli
3
900
Teach (all the) Rails
bjelli
0
440
Other Decks in Programming
See All in Programming
CSC307 Lecture 03
javiergs
PRO
1
470
[AtCoder Conference 2025] LLMを使った業務AHCの上⼿な解き⽅
terryu16
6
1k
Basic Architectures
denyspoltorak
0
180
AI Agent Tool のためのバックエンドアーキテクチャを考える #encraft
izumin5210
6
1.6k
2年のAppleウォレットパス開発の振り返り
muno92
PRO
0
180
Vibe codingでおすすめの言語と開発手法
uyuki234
0
160
CSC307 Lecture 04
javiergs
PRO
0
620
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
0
420
GISエンジニアから見たLINKSデータ
nokonoko1203
0
190
ZJIT: The Ruby 4 JIT Compiler / Ruby Release 30th Anniversary Party
k0kubun
1
310
Spinner 軸ズレ現象を調べたらレンダリング深淵に飲まれた #レバテックMeetup
bengo4com
1
210
副作用をどこに置くか問題:オブジェクト指向で整理する設計判断ツリー
koxya
1
330
Featured
See All Featured
GraphQLの誤解/rethinking-graphql
sonatard
74
11k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
0
110
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
120
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
38
Measuring & Analyzing Core Web Vitals
bluesmoon
9
730
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.1k
It's Worth the Effort
3n
188
29k
Accessibility Awareness
sabderemane
0
33
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
65
35k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
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