Skip to content

Instantly share code, notes, and snippets.

@rwc9u
rwc9u / gist:745337
Created December 17, 2010 17:37
Getting before_validations to run
# added a new before_validation
PhoneNumber.all { |p| p.save! }
# doesn't resave the data... silly me
ActiveRecord::Base.partial_updates = false
PhoneNumber.all { |p| p.valid?; p.save! }
klass = Paperclip::Storage::Filesystem
klass.module_eval do
def flush_writes #:nodoc:
logger.info("[paperclip-hack] Writing files for #{name}")
@queued_for_write.each do |style, file|
file.close
FileUtils.mkdir_p(File.dirname(path(style)))
logger.info("[paperclip-hack] -> #{path(style)}")
FileUtils.cp(file.path, path(style))
this is a test
foo foo foo.This is a test
html {
background: none;
}
body {
margin: 0px;
background: none;
}
<div id="tools">
<ul class="toolbar" id="left">
<li>Testing</li>
</ul>
<ul class="toolbar" id="right">
<li id="close_button"><a id="close" href="#">Close</a></li
</ul>
</div>
<div id="disclaimer">
<h1> Disclaimer</h1>
RewriteEngine on
RewriteRule ^/s/(.*)$ http://eyestreet.com.shortswitch.com/$1 [R,L]
@rwc9u
rwc9u / sample.html
Created January 22, 2010 22:10
Example of how to use javascript and ajax calls to the ShortSwitch service to create a shortened URL on your own customized URL shortening service.
<style type="text/css" media="screen">
#shortswitch-it .box {
border:1px solid #999;
text-align:center;
margin:20px 60px;
padding: 10px;
}
.shortswitch-response-box {
background-color:#aaa;
margin:10px auto;
javascript:(
function(){var s=document.createElement("script");
s.charset="UTF-8";
s.type="text/javascript";
s.src="http://shortswitch.com/admin/marklet/tweetie/APIKEY";
document.body.appendChild(s);})();
set the ClipURL to urlencode(the clipboard as string)
set curlCMD to ¬
"curl --stderr /dev/null \"http://api.shortswitch.com/shorten?apiKey=YOUR_API_KEY&url=" & ClipURL & "\""
do shell script curlCMD
set theResult to the result