Skip to content

Instantly share code, notes, and snippets.

View digitalpardoe's full-sized avatar
💭
¯\_(ツ)_/¯

Alex Pardoe digitalpardoe

💭
¯\_(ツ)_/¯
View GitHub Profile
@digitalpardoe
digitalpardoe / contact.html.erb
Created July 16, 2011 17:02
An Email Form with Ruby on Rails
<% form_for :email, :url => { :controller => 'contact', :action => 'send_mail' } do |f| %>
<%= f.label :name %><br />
<%= f.text_field :name, :size => 60 %><br />
<%= f.label :address %><br />
<%= f.text_field :address, :size => 60 %><br />
<%= f.label :subject %><br />
<%= f.text_field :subject, :size => 60 %><br />
<%= f.label :body %><br />
<%= f.text_area :body, :rols => 10, :cols => 60 %><br />
<%= submit_tag "Send Email "%>
@digitalpardoe
digitalpardoe / application_helper.rb
Created July 16, 2011 17:12
Textilize Alternative
def custom_text(text)
if text.blank?
""
else
text = RedCloth.new(text).to_html
if text[0..2] == "<p>" then text = text[3..-1] end
if text[-4..-1] == "</p>" then text = text[0..-5] end
text = text.gsub("<p>", "")
text = text.gsub("</p>", "")
return text
@digitalpardoe
digitalpardoe / ControllerName.m
Created July 16, 2011 17:16
Rich Text File (RTF) Into NSTextView, Cocoa & Obj-C
- (void)awakeFromNib
{
NSBundle * myMainBundle = [NSBundle mainBundle];
NSString * rtfFilePath = [myMainBundle pathForResource:@"file" ofType:@"rtf"];
[controller_Out_TextView readRTFDFromFile:rtfFilePath];
}
@digitalpardoe
digitalpardoe / compile_no_run.sh
Created July 16, 2011 17:23
TextMate, Java & Compiling
echo "<h2>Compiling $TM_FILENAME</h2>"
cd "$TM_DIRECTORY"
javac -encoding UTF8 "$TM_FILENAME" &> >("${TM_RUBY:-ruby}" -rtm_parser -eTextMate.parse_errors)
cp /tmp/flickr.cache /your/rails/application/config/flickr.cache
rm /tmp/flickr.cache
@digitalpardoe
digitalpardoe / copy_file.sh
Created July 16, 2011 20:25
Setting Hard Drive Icons In OS X
sudo cp -f /Path_to_Icon/icon_file.icns /Path_to_Drive_Root/.VolumeIcon.icns
@digitalpardoe
digitalpardoe / new.rb
Created July 16, 2011 20:28
rFlickr And Rails 2.0
def self.from_xml(xml,photo=nil)
@digitalpardoe
digitalpardoe / additional_require.rb
Created July 16, 2011 20:35
Caching Your Photographs
require 'open-uri'
@digitalpardoe
digitalpardoe / bbcode
Created July 16, 2011 20:42
Flickr BBCode
[flickr=<a href="http://www.flickr.com/photos/digitalpardoe/2900618617/" title="Isolation by digital:pardoe, on Flickr"> <img src="http://farm4.static.flickr.com/3095/2900618617_26bc8abc12.jpg" width="500" height="334" alt="Isolation" /></a>][/flickr]
@digitalpardoe
digitalpardoe / CalculateDuration.java
Created July 16, 2011 20:47
Calculating Work Days In Java
public static int calculateDuration(Date startDate, Date endDate)
{
Calendar startCal = Calendar.getInstance();
startCal.setTime(startDate);
Calendar endCal = Calendar.getInstance();
endCal.setTime(endDate);
int workDays = 0;