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
490
Berufe im World Wide Web
bjelli
0
200
Javascript Closures
bjelli
3
880
Teach (all the) Rails
bjelli
0
430
Other Decks in Programming
See All in Programming
macOS でできる リアルタイム動画像処理
biacco42
9
2.4k
ローコードSaaSのUXを向上させるためのTypeScript
taro28
1
610
型付き API リクエストを実現するいくつかの手法とその選択 / Typed API Request
euxn23
8
2.2k
見せてあげますよ、「本物のLaravel批判」ってやつを。
77web
7
7.7k
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
520
OSSで起業してもうすぐ10年 / Open Source Conference 2024 Shimane
furukawayasuto
0
100
みんなでプロポーザルを書いてみた
yuriko1211
0
260
初めてDefinitelyTypedにPRを出した話
syumai
0
400
Remix on Hono on Cloudflare Workers
yusukebe
1
280
役立つログに取り組もう
irof
28
9.6k
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
1.5k
Arm移行タイムアタック
qnighy
0
320
Featured
See All Featured
Designing the Hi-DPI Web
ddemaree
280
34k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
10 Git Anti Patterns You Should be Aware of
lemiorhan
654
59k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
How to Ace a Technical Interview
jacobian
276
23k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
25
1.8k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Building Applications with DynamoDB
mza
90
6.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