Skip to content

Instantly share code, notes, and snippets.

@underwhelmed
underwhelmed / .htaccess
Created April 28, 2015 20:34
Redirect all http and https traffic from naked domain to www.
# Redirect HTTP without www to HTTP with www
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Redirect HTTPS without www to HTTPS with www
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
@underwhelmed
underwhelmed / HangfireJobStatusUpdateAttribute.cs
Last active August 29, 2015 14:19
Hangfire v1.4 Windows Server Configuration
public class HangfireJobStatusUpdateAttribute : JobFilterAttribute, IElectStateFilter
{
private IScheduledTasksRepository _repo;
private IScheduledTaskLogRepository _log;
private ITransactionFactory _tranFactory;
private ICronService _cronSvc;
/// <summary>
/// Initializes a new instance of the <see cref="HangfireJobStatusUpdateAttribute"/> class.
/// </summary>
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