This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cool_dude(arg1="Miles", arg2="Coltrane", arg3="Roach") | |
"#{arg1}, #{arg2}, #{arg3}." | |
end | |
p cool_dude | |
p cool_dude("Bart") | |
p cool_dude("Bart", "Elwood") | |
p cool_dude("Bart", "Elwood", "Linus") | |
file = File.size("regex.rb") | |
p File.size("regex.rb") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#thursday-08-2017 | |
#@41studio | |
#Muhammad Yana Mulyana | |
#regex in ruby | |
#Operator =~ membandingkan string yg sama dan menghitung jumlah regex | |
# p /cat/ =~ "Dog and cat" | |
# p /cat/ =~ " ! # cat" | |
puts /aa/.class |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# handling exception | |
#======save page into html======= | |
require 'open-uri' | |
# web_page = open("http://indoexchanger.co.id/home") | |
# output = File.open("index.html", "w") | |
# while line = web_page.gets | |
# output.puts line | |
# end | |
# output.close |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#thursday-08-2017 | |
#@41studio | |
#Muhammad Yana Mulyana | |
#regex in ruby | |
# require 'net/http' | |
# image = Net::HTTP.get_response(URI.parse("http://www.indoexchanger.co.id/private/rest/indoExchanger/amountBitcoin")).body | |
# | |
# puts image |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#thursday-08-2017 | |
#@41studio | |
#Muhammad Yana Mulyana | |
#R/W File in ruby | |
File.open("sample.txt", "r") do |f| | |
f.each_line do |line| | |
puts line | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#require 'socket' | |
require 'net/http' | |
require 'open-uri' | |
require 'nokogiri' | |
client = TCPSocket.open('indoexchanger.co.id', 'www') | |
client.send("OPTIONS /~dave/ HTTP/1.0\n\n", 0) | |
puts client.readlines | |
client.close |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#take every sentence | |
counts = Hash.new(0) | |
File.foreach("sample.txt") do | |
|line| | |
line.scan(/\w+/) do | |
|word| | |
word = word.downcase | |
counts[word] += 1 | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -w -s | |
# -*- coding: utf-8 -*- | |
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib" | |
#```ruby | |
require 'axlsx' | |
examples = [] | |
examples << :basic | |
examples << :custom_styles | |
examples << :wrap_text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"always_show_minimap_viewport": true, | |
"bold_folder_labels": true, | |
"color_scheme": "Packages/User/Color Highlighter/themes/Monokai-Soft-MD (Colorcoded).tmTheme", | |
"font_options": | |
[ | |
"gray_antialias", | |
"subpixel_antialias" | |
], | |
"ignored_packages": |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
gem 'carrierwave' | |
gem 'fog', '~> 1.0.0' # Need to specify version, as carrierwave references older (0.9.0) which doesn't allow configuration of Rackspace UK Auth URL |