View add_date_to_posts.rb
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
Dir.glob("source/_posts/*.markdown").each do |filename| | |
formatted_date = filename.split("/").last[0..9] | |
puts "Adding date #{formatted_date} to file #{filename}" | |
lines = [] | |
IO.readlines(filename).map do |line| | |
lines << line | |
lines << "date: #{formatted_date}" if line =~ /^title: / | |
end |
View class_variables.rb
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 Superclass | |
@@var1 = "var 1 Superclass" | |
@var2 = "var 2 Superclass" | |
def self.var1 | |
@@var1 | |
end | |
def self.var2 | |
@var2 |
View textile_to_markdown.rb
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
def process_file oldfilename | |
markdown_content = textile_to_markdown(File.read(oldfilename)) | |
filename = oldfilename.split("/").last.split(".").first.gsub("-", "_") | |
File.open("doc_src/content/#{filename}.md", "w") do |f| | |
f.write <<-CONTENT | |
--- | |
title: #{filename.capitalize} | |
group: Base | |
--- |
View textile_to_md.sed
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
# sed -f textile_to_md.sed original.textile > destination.md | |
s/"\([^"]*\)":\([^\. ]*\.html\)/[\1](\2)/g | |
s/^h3[^.]*\./###/ | |
s/^h4\./####/ | |
s/^h5\./#####/ | |
s/^<js>$/~~~json/ | |
s/^<\/js>$/~~~/ | |
s/^<plain>$/~~~sh/ | |
s/^<\/plain>$/~~~/ |
View capybara_list_requested_domains.rb
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
page.driver.network_traffic.map do |req| | |
req.url.gsub(/^(https?:\/\/[^\/]+)\/.*$/, '\1') | |
end.uniq |
View block_test.rb
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
def test1(params) | |
p "test1 #{params}" | |
end | |
def test2(&block) | |
if block_given? | |
p "test2 with block" | |
yield | |
else | |
p "test2 without block" |
View find_replace.sed
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
oldstring="describe" | |
newstring="RSpec.describe" | |
path=path/to/files | |
grep -rl $oldstring $path/* | xargs sed -i '' s/$oldstring/$newstring/g |
View onemanga_downloader.rb
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 | |
# | |
# Put this script in your PATH and download from onemanga.com like this: | |
# onemanga_downloader.rb Bleach [chapter number] | |
# | |
# You will find the downloaded chapters under $HOME/Documents/OneManga/Bleach | |
# | |
# If you run this script without arguments, it will check your local manga downloads | |
# and check if there are any new chapters | |
# |
View tga-to-jpg.sh
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 | |
# Batch conversion from tga to jpg | |
# Author: Guilherme Garnier - http://blog.guilhermegarnier.com | |
# Adapted from: | |
# http://linux.strangegamer.com/index.php?title=Converting_A_directory_of_TGA%27s_To_JPG | |
# http://www.cyberciti.biz/tips/handling-filenames-with-spaces-in-bash.html | |
SAVEIFS=$IFS | |
IFS=$(echo -en "\n\b") |
OlderNewer