Skip to content

Instantly share code, notes, and snippets.

View Achillefs's full-sized avatar

Achilles Charmpilas Achillefs

  • Athens, GR
View GitHub Profile
@Achillefs
Achillefs / sitemap_generator.rb
Created October 26, 2011 17:21
Sitemap Generator
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
@Achillefs
Achillefs / article.rb
Created December 9, 2011 16:17
Sample Article class posting to a Wordpress blog via wp-json-api
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'
@Achillefs
Achillefs / string.rb
Created December 3, 2012 23:56
Lightweight html extraction
class String
def links
self.scan /<a href\=\"[^"]*\"[^>]*>[^<]*<\/a>/
end
def images
self.scan /<img src\=\"[^"]*\"[^>]*>/
end
end

Keybase proof

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: