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
580
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
Grafana:建立系統全知視角的捷徑
blueswen
0
320
AI & Enginnering
codelynx
0
110
Package Management Learnings from Homebrew
mikemcquaid
0
200
humanlayerのブログから学ぶ、良いCLAUDE.mdの書き方
tsukamoto1783
0
180
AI時代の認知負荷との向き合い方
optfit
0
140
ZJIT: The Ruby 4 JIT Compiler / Ruby Release 30th Anniversary Party
k0kubun
1
400
[KNOTS 2026登壇資料]AIで拡張‧交差する プロダクト開発のプロセス および携わるメンバーの役割
hisatake
0
250
Fragmented Architectures
denyspoltorak
0
150
Basic Architectures
denyspoltorak
0
660
今こそ知るべき耐量子計算機暗号(PQC)入門 / PQC: What You Need to Know Now
mackey0225
3
370
Honoを使ったリモートMCPサーバでAIツールとの連携を加速させる!
tosuri13
1
170
MUSUBIXとは
nahisaho
0
130
Featured
See All Featured
Everyday Curiosity
cassininazir
0
130
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Writing Fast Ruby
sferik
630
62k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
0
130
Discover your Explorer Soul
emna__ayadi
2
1.1k
Scaling GitHub
holman
464
140k
The Curious Case for Waylosing
cassininazir
0
230
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.2k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
180
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.7k
Six Lessons from altMBA
skipperchong
29
4.1k
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