I hereby claim:
- I am Achillefs on github.
- I am magus (https://keybase.io/magus) on keybase.
- I have a public key whose fingerprint is 2956 6B17 6EB2 1F74 D63A 4EEA 3A7A 7022 8708 136C
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
class String | |
def links | |
self.scan /<a href\=\"[^"]*\"[^>]*>[^<]*<\/a>/ | |
end | |
def images | |
self.scan /<img src\=\"[^"]*\"[^>]*>/ | |
end | |
end |
require 'rubygems' | |
require 'open-uri' | |
require 'json' | |
require 'net/http' | |
# Please note that the vanilla wp-json-api plugin does not support user authentication for create_post. | |
# Check out my fork for authentication support: https://github.com/Achillefs/wp-json-api | |
class Article | |
API_URI = 'http://mywpblog.com/api/' | |
API_USER = 'my_wp_username' |
class SitemapGenerator | |
# For Rails 3.*, replace with include Rails.application.routes.url_helper | |
include ActionController::UrlWriter | |
def initialize model_name, options = {} | |
@host = options.delete(:host) || default_url_options[:host] | |
@model_name = model_name | |
@file = options.delete(:file) || model_name.to_s.pluralize | |
@changefreq = options.delete(:changefreq) || 'daily' | |
@lastmod = options.delete(:lastmod_method) || :updated_at |
%W[rubygems anemone].each {|r| require r} | |
site_root = "http://www.whatever.org/" | |
# Create the root folder | |
folder = URI.parse(site_root).host | |
FileUtils.mkdir_p(File.join(".",folder)) | |
Anemone.crawl(site_root) do |anemone| | |
anemone.on_every_page do |page| |
# Single edit line#20 | |
begin | |
require "active_support" | |
rescue LoadError | |
require "rubygems" | |
require "active_support" | |
end | |
module PermalinkFu |
el: | |
i18n: | |
transliterate: | |
rule: | |
α: a | |
ά: a | |
Α: a | |
Ά: a | |
β: v | |
Β: v |
require "uri" | |
require "active_support" | |
# Get auth token from Googles | |
auth_uri = "https://www.google.com/accounts/ClientLogin" | |
params = { | |
"accountType" => "HOSTED_OR_GOOGLE", | |
"Email" => "yer_gmail", | |
"Passwd" => "yer_gpass", | |
"source" => "organization-appname-version", |
require "net/http" | |
module Net | |
class HTTP | |
alias :old_connect :connect | |
def connect | |
D "opening connection to #{conn_address()}..." | |
begin # HACK START | |
s = timeout(@open_timeout) do | |
TCPSocket.open(conn_address(), conn_port(), App.available_ip_addresses.rand) | |
end |
Dir[File.join(%w[test fixtures files *.xml])].each do |file| | |
xml = File.read(file) | |
matches = xml.scan("\n") | |
if !matches or matches.size < 3 | |
puts "#{file}: Not enough line brakes, adding them now..." | |
File.open(file,"w") do |f| | |
f.puts(xml.gsub(/(<[^\/]*>)/,"\n\\1")) | |
end | |
end | |
end |