This file contains 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 | |
require 'rubygems' | |
require 'json' | |
require 'open-uri' | |
require 'slack-notifier' | |
# use the turtle subreddit | |
turtles = "http://www.reddit.com/r/turtle.json" | |
json = JSON.load(open(turtles)) |
This file contains 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
#!/bin/bash | |
black='\e[47m' | |
red='\e[31;41m' | |
blue='\e[34;44m' | |
blueonred='\e[34;41m' | |
reset='\e[0m' | |
echo -e "${blue}iiiiii${reset} ${blueonred}@@@@@@${red}llllllll${reset} ${red}lllll${blueonred}@@@@@@${red}lllll${reset} ${red}lllll${blueonred}@@@@@@${red}lllll${reset} ${red}lllll${blueonred}@@@@@@${red}lllll${reset}" | |
echo -e "${blue}iiiiii${reset} ${blueonred}@@@@@@${red}llllllll${reset} ${red}lllll${blueonred}@@@@@@${red}lllll${reset} ${red}lllll${blueonred}@@@@@@${red}lllll${reset} ${red}lllll${blueonred}@@@@@@${red}lllll${reset}" |
This file contains 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 | |
# this is a proof-of-concept for reading encrypted data bags | |
# from a ruby script. you only need chef to be installed. | |
require 'rubygems' | |
require 'chef/rest' | |
require 'chef/encrypted_data_bag_item' | |
# prevent chef from trying to contact a server | |
Chef::Config[:solo] = true |
This file contains 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 | |
# this script takes a URL and verifies that | |
# every css file included loads correctly | |
require 'open-uri' | |
require 'nokogiri' | |
require 'pry' if $DEBUG | |
url = ARGV.shift || 'https://ifttt.com' | |
doc = Nokogiri::HTML(open(url).read) |
This file contains 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 don't know if the guide goes on to address these points, | |
# but I thought it might be kinda fun to help you on your path. | |
if 4 > 5 | |
# ruby programmers tend to use 2 spaces instead of 4 for indentation | |
# also, even though it's confusing, you'll generally use "puts" instead of "print" | |
puts "I'm soooo wrong it's painful" | |
# I like to avoid using parentheses to group things, so I'd rewrite what you had as: | |
#elsif 4 > 5 != true |
This file contains 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 | |
puts "Why is the FBI after you?" | |
# optional, but you can chain the downcase here | |
text = gets.chomp.downcase | |
# the default parameter for String#split is ' ', so you can omit it | |
words = text.split | |
# note that since text was only used here, you could have just said: | |
#words = gets.chomp.downcase.split |
This file contains 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 Array | |
# This method reads from the DATA section of this file, which | |
# in Ruby is marked by __END__. It takes each line and pushes | |
# it into the calling array, yields the code block and writes | |
# the array, one element per line, to the end of the file, | |
# starting at the beginning of the DATA block. Idea stolen | |
# from O'Reilly's Perl Cookbook. | |
def tie() | |
DATA.each_line { |line| self.push(line.chomp) } | |
yield |
This file contains 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 -wKU | |
# Ruby Quiz #207: Quine | |
# This week's quiz is to create a quine[1], that is: a program which | |
# receives no input and produces a copy of its own source code as its | |
# only output. | |
# [1]: http://en.wikipedia.org/wiki/Quine_(computing) | |
# Dana Merrick | |
# 5/29/2009 |
This file contains 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 -wKU | |
# This program scans your ethers file to generate a valid dhcpd.conf file | |
# (or at least a segment of one). In addition, it will read your hosts file | |
# to see if there are any known aliases it can add. It then prints the | |
# formatted results to standard out. | |
# | |
# Author:: Dana Merrick (mailto:letterkills+ethers@gmail.com) | |
# Copyright:: Copyright (c) 2009 Dana Merrick | |
# License:: Released under the MIT license |
This file contains 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
Im adding another file to this gist |
OlderNewer