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
560
Berufe im World Wide Web
bjelli
0
250
Javascript Closures
bjelli
3
890
Teach (all the) Rails
bjelli
0
440
Other Decks in Programming
See All in Programming
CloudflareのSandbox SDKを試してみた
syumai
0
130
知られているようで知られていない JavaScriptの仕様 4選
syumai
0
480
Promise.tryで実現する新しいエラーハンドリング New error handling with Promise try
bicstone
2
260
MCPサーバー「モディフィウス」で変更容易性の向上をスケールする / modifius
minodriven
7
1.4k
業務でAIを使いたい話
hnw
0
260
自動テストのアーキテクチャとその理由ー大規模ゲーム開発の場合ー
segadevtech
2
950
アーキテクチャと考える迷子にならない開発者テスト
irof
5
1.3k
AIの弱点、やっぱりプログラミングは人間が(も)勉強しよう / YAPC AI and Programming
kishida
8
3.6k
Private APIの呼び出し方
kishikawakatsumi
2
830
歴史から学ぶ「Why PHP?」 PHPを書く理由を改めて理解する / Learning from History: “Why PHP?” Rediscovering the Reasons for Writing PHP
seike460
PRO
0
140
Bakuraku E2E Scenario Test System Architecture #bakuraku_qa_study
teyamagu
PRO
0
680
Core MIDI を勉強して作曲用の電子ピアノ作ってみた!
hypebeans
0
100
Featured
See All Featured
The Invisible Side of Design
smashingmag
302
51k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
118
20k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.3k
Six Lessons from altMBA
skipperchong
29
4.1k
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
The World Runs on Bad Software
bkeepers
PRO
72
12k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
Why You Should Never Use an ORM
jnunemaker
PRO
60
9.6k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
Building a Scalable Design System with Sketch
lauravandoore
463
33k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.2k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
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