Skip to content

Instantly share code, notes, and snippets.

require 'docx'
d = Docx::Document.open('example.docx')
d.each_paragraph do |p|
puts d
end
# for the docx file stored on s3 amazon.
Docx::Document.open(open('http://S3-URL/original.docx',:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE))
@underwhelmed
underwhelmed / extension.cs
Created December 7, 2012 16:49
Convert a relative URL into an Absolute URL in .NET
public string ConvertRelativeUrlToAbsoluteUrl(string relativeUrl)
{
if (Request.IsSecureConnection)
return string.Format("https://{0}{1}", Request.Url.Host, Page.ResolveUrl(relativeUrl));
else
return string.Format("http://{0}{1}", Request.Url.Host, Page.ResolveUrl(relativeUrl));
}
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
@underwhelmed
underwhelmed / filter.txt
Created June 28, 2012 14:36
My Tweetdeck Global Filter
surface, kardashian, tebow, bracketology, facebook, guillen, pandora, mvp12, snooki, sql2012, ozzie, castro, santorum, zuckerberg, wp7, silverlight, cnn, healthcare, supreme court, republican, obamacare
@underwhelmed
underwhelmed / facepalm.vb
Created June 19, 2012 19:34
ugh, legacy code
Public Class CustomerLogo
Public Sub New()
Me.New("")
End Sub
Public Sub New(ByVal url As String)
Me._url = url
End Sub
@underwhelmed
underwhelmed / error.txt
Created June 6, 2012 16:24
Error Generating Report In Background Thread
Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
at System.IO.IsolatedStorage.IsolatedStorageFile.nGetRootDir(IsolatedStorageScope scope)
at System.IO.IsolatedStorage.IsolatedStorageFile.InitGlobalsNonRoamingUser(IsolatedStorageScope scope)
at System.IO.IsolatedStorage.IsolatedStorageFile.GetRootDir(IsolatedStorageScope scope)
at System.IO.IsolatedStorage.IsolatedStorageFile.GetGlobalFileIOPerm(IsolatedStorageScope scope)
at System.IO.IsolatedStorage.IsolatedStorageFile.Init(IsolatedStorageScope scope)
at System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(IsolatedStorageScope scope, Type domainEvidenceType, Type assemblyEvidenceType)
at MS.Internal.IO.Packaging.PackagingUtilities.ReliableIsolatedStorageFileFolder.GetCurrentStore()
alias b='bundle exec'
b rake
@underwhelmed
underwhelmed / letter.txt
Created April 27, 2012 04:09
letter to Congressman Durbin
Congressman Durbin,
Now that the bill known as CISPA has passed the house, I sincerely urge you to vote NO against it.
I am a web developer from Illinois and work with other web developers across the United States. If this bill passes, it could jeopardize peoples lives and the way we/they do business. Not only that, but they may quit doing business with the US completely. I have heard that if there are any restrictions like CISPA, they will no longer do business with United States patrons. There are plenty of businesses that have roots in the US that can take their business to other countries and still thrive.
I agree that there needs to be a better way to handle copyright infringement in the UNITED STATES, but giving the government full access to all data, regardless of origin, is a very dangerous proposition. Another solution, one that DOES NOT INVOLVE ANY CORPORATE SPONSORSHIP, is possible and needs to be sought instead of being bought.
The peoples privacy is one that has been fought for since the r
@underwhelmed
underwhelmed / letter.txt
Created April 27, 2012 03:46
Short But Sweet
Mr. Hultgren,
Due to your short-sightedness regarding the rules governing the Internet security bill, CISPA, I will be voting for another candidate in the next election.
Thank you for your service.
Sincerely,
Stephen Wright
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session