Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Ruby One-Liners
Search
bjelli
March 23, 2012
Programming
350
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Ruby One-Liners
A lightning talk at Salzburg Barcamp "The Next Web" in March 2012.
bjelli
March 23, 2012
More Decks by bjelli
See All by bjelli
Intro to Web- and Mobile-Developement
bjelli
0
330
Railsgirls: Where did my HTML and CSS go
bjelli
0
620
Berufe im World Wide Web
bjelli
0
270
Javascript Closures
bjelli
3
910
Teach (all the) Rails
bjelli
0
450
Other Decks in Programming
See All in Programming
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
7.9k
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
490
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
190
Androidだけじゃない、DroidKaigiで広がった私の技術スタック
akkeylab
0
120
パーソナライズPodcastを作った話
repunit11
0
130
GemmaをJevのように使ってみる / Use Gemma like Jev
kishida
5
720
GitHubハンズオン講座 — 実務レベルのチーム開発のフローを身につけよう
junhat6
0
120
APNsからLive Activityを開始する話
yumnumm
0
150
気持ちぃ〜角丸 Squircle
ryu1013
0
120
setup-vp GitLab対応の裏側
naokihaba
0
150
速習iPhone Duo対応
yuukiw00w
2
970
IBM Bob Dojo #1 仕様駆動開発入門
oniak3ibm
PRO
0
350
Featured
See All Featured
Design in an AI World
tapps
1
350
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
740
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
2
6.3k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
260
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1k
Music & Morning Musume
bryan
48
7.4k
Mobile First: as difficult as doing things right
swwweet
225
10k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
550
Mind Mapping
helmedeiros
1
390
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
1
620
Become a Pro
speakerdeck
PRO
31
6.3k
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