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
module PaperclipMigrations | |
def self.included(base) | |
base.extend ClassMethods | |
end | |
module ClassMethods | |
def add_paperclip_fields(table, prefix) | |
add_column table, "#{prefix}_file_name", :string | |
add_column table, "#{prefix}_content_type", :string |
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
require 'rubygems' | |
require 'hpricot' | |
require 'open-uri' | |
# Extract a list of currently available hotels for SxSWi | |
# and produce a simple list of "name - 1 person price - map URL" | |
# The intention was to then plot them on a map, but I found | |
# what I needed and moved on | |
doc = Hpricot(open("http://www.sxsw.com/hotels")) | |
hotel_list = doc.search("ul#hotel_list li") |
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/ruby | |
# | |
# Facebook allows you to specify an RSS feed to poll to get new 'notes' for personal | |
# profiles, but no similar mechanism to feed a feed in as a group's "news" (possibly | |
# because of the awful data model around groups...) | |
# | |
# This is a quick mechanize script to update the 'news' box for a group you are an | |
# admin of. It's very basic, but works, and could be developed with an RSS reader | |
# or as an activerecord callback to send a new blog entry/news story to facebook, or... | |
# |
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 was a super quick script to turn a text file of links into the structure | |
# I use for my "Saturday Links Summary" posts. | |
# | |
# I've extended it a bit so it will also get posts from delicious that use a | |
# certain tag, and uses trollop to parse command line arguments a bit more | |
# cleanly. | |
# | |
# James Stewart - [email protected] - 27th February 2009 / 6th March 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
require 'html2textile' | |
first_block = <<END | |
<div class="column span-3"> | |
<h3 class="storytitle entry-title" id="post-312"> | |
<a href="http://jystewart.net/process/2007/11/converting-html-to-textile-with-ruby/" rel="bookmark">Converting HTML to Textile with Ruby</a> | |
</h3> | |
<p> | |
<span>23 November 2007</span> |
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
# Superseded by http://github.com/jystewart/wp_ar |
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/ruby -w | |
# | |
# Paypal CSV to QIF | |
# By James Stewart - [email protected] | |
# | |
# A really simple script attempting to get data from my paypal account (multi currency) | |
# into Xero. More adjustment will be needed to handle the multiple currencies, but I've | |
# not found good documentation of how to bake that into the QIF file yet. | |
# | |
# (I know paypal do qif output, but it seems to only send transactions from one currency) |
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
# to move data to drupal | |
require 'activerecord' | |
class ActiveRecord::Drupal < ActiveRecord::Base | |
self.abstract_class = true | |
establish_connection( | |
:adapter => "mysql", | |
:host => "localhost", | |
:username => "root", | |
:password => "", | |
:database => "nm_drupal" |
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
<?php | |
/** | |
* A slightly saner interface for JangoMail Sync than the one they supply | |
* | |
* This is a demonstration of how to produce a more security-aware interface for JangoMail's | |
* web database synchronisation system. It is not guaranteed in any way and is not meant | |
* to be seen as an example of best practice on any level. It does, however, demonstrate how | |
* the flaws in that system can be worked around to build a reasonable JSON-based interface | |
* when working with recent versions of PHP. |
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
SELECT CONCAT('OPTIMIZE TABLE ', TABLE_SCHEMA,'.',TABLE_NAME, ';'), Data_free from information_schema.TABLES where TABLE_SCHEMA NOT IN ('information_schema','mysql') and Data_free > 0 AND ENGINE NOT IN ('INNODB', 'MEMORY'); |
OlderNewer