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
320
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
240
Railsgirls: Where did my HTML and CSS go
bjelli
0
430
Berufe im World Wide Web
bjelli
0
180
Javascript Closures
bjelli
3
860
Teach (all the) Rails
bjelli
0
430
Other Decks in Programming
See All in Programming
StoreKit2によるiOSのアプリ内課金のリニューアル
kangnux
0
110
[技育CAMPアカデミア]アイディアを形に!【超入門】スマホアプリ開発〜リリースまでの流れをご紹介
teamlab
PRO
0
360
使ってみよう Azure AI Document Intelligence
kosmosebi
2
300
try! Swift Tokyo 初参加報告LT
hinakko2
0
220
Random\Randomizer クラスで日常のあれこれを解決しよう! / Random\Randomizer class solves familiar trouble
cocoeyes02
0
220
PHPの次期バージョンはこの時期どうなっているのか - Internalsの開発体制について - PHPカンファレンス小田原
youkidearitai
PRO
1
190
"config" ってなんだ? / What is "config"?
okashoi
0
240
R言語の環境構築と基礎 Tokyo.R 112
bob3bob3
0
260
ONE WEDGE_company_guide
1wedge_one
0
470
Azure OpenAI Serviceのプロンプトエンジニアリング入門
tomokusaba
3
670
Fragment Composition of GraphQL
quramy
4
730
1BRC--Nerd Sniping the Java Community
gunnarmorling
0
340
Featured
See All Featured
How GitHub Uses GitHub to Build GitHub
holman
468
290k
Designing for Performance
lara
601
67k
Being A Developer After 40
akosma
57
580k
Agile that works and the tools we love
rasmusluckow
325
20k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
19
1.7k
Reflections from 52 weeks, 52 projects
jeffersonlam
345
19k
Building Better People: How to give real-time feedback that sticks.
wjessup
355
18k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3k
Web Components: a chance to create the future
zenorocha
305
41k
Building Effective Engineering Teams - LeadDev
addyosmani
28
1.8k
Designing for humans not robots
tammielis
248
25k
What the flash - Photography Introduction
edds
64
11k
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