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
| stdin, stdout, stderr, pid = Open4::popen4 "pgp --key-list" | |
| pgps = stderr.select {|x| x.chomp if x =~ /0x/ } | |
| # to parse Key list | |
| @orgs = pgps.inject([]){|enum, pgp| enum << {:hex_id =>pgp[29..38], :org_id => pgp[40..pgp.length].chomp} } | |
| @orgs.each.with_index{ |org, index| puts "#{index}. #{org[:hex_id]} belongs to #{org[:org_id]}" } |
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 'win32ole' | |
| email = "[email protected]" | |
| image1 = "/home/user/images/image1.jpg" | |
| image2 = "/home/user/images/image2.jpg" | |
| outlook = WIN32OLE.new('Outlook.Application') | |
| message = outlook.CreateItem(0) | |
| message.To = email | |
| message.Subject = "My Subject" | |
| message.attachments.add(image1) |
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
| 1.upto(100) do |num| | |
| if num % 3 == 0 || num % 5 == 0 | |
| if num % 3 == 0 | |
| print "Fizz" | |
| end | |
| if num % 5 == 0 | |
| print "Buzz" | |
| end | |
| else | |
| print num |
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
| public class FizzBuzzer { | |
| public static void main(String[] args) { | |
| for(int num=1; num<=100; num++){ | |
| if (num % 3 == 0 || num % 5 == 0){ | |
| if (num % 3 == 0) | |
| System.out.print("Fizz"); | |
| if (num % 5 == 0) | |
| System.out.print("Buzz"); | |
| } | |
| else |
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
| songs = [ | |
| "The Magnetic Fields - 69 Love Songs - Parades Go By", | |
| "The Magnetic Fields - Get Lost - Smoke and Mirrors", | |
| "The Magnetic Fields - Get Lost - You, Me, and the Moon", | |
| "The Magnetic Fields - 69 Love Songs - The Book of Love", | |
| "Neutral Milk Hotel - In An Aeroplane Over the Sea - Holland 1945", | |
| "Neutral Milk Hotel - In An Aeroplane Over the Sea - The King of Carrot Flowers" | |
| ] | |
| music = Hash.new {|k,v| k[v] = (Hash.new {|k,v| k[v] = []})} |
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
| class Artist | |
| attr_accessor :name, :songs, :genres | |
| @@artists = [] | |
| def initialize | |
| @@artists << self | |
| @songs = [] | |
| @genres = [] | |
| 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
| class Artist | |
| attr_accessor :name, :songs, :genres | |
| @@artists = [] | |
| def initialize | |
| @@artists << self | |
| @songs = [] | |
| @genres = [] | |
| 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
| # 5 songs of the following lengths in seconds | |
| class Song | |
| attr_accessor :duration | |
| def initialize(duration=0) | |
| @duration = duration | |
| 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
| # I wanted to create a class with lowercase name | |
| my_class = Class.new(Object) do | |
| attr_accessor :why_do_i_work | |
| def initialize | |
| puts "WTF" | |
| 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
| class Cart | |
| def confirm | |
| "Your order is being processed" | |
| end | |
| end | |
| cart = Cart.new | |
| # then reopen the class | |
| class Cart |
OlderNewer