Skip to content

Instantly share code, notes, and snippets.

@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
@underwhelmed
underwhelmed / pain.vb
Created April 19, 2012 16:43
What makes me want to gouge my eyes with a pencil
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents txtSpecialInstructions As Telerik.WebControls.RadEditor
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
@underwhelmed
underwhelmed / AccountController.rb
Created March 13, 2012 19:23
Example with wicked gem on create?
class AccountController < Wicked::WizardController
steps :start, :info, :address, :billing, :review
def show
end
end
@underwhelmed
underwhelmed / _form.html.erb
Created February 4, 2012 03:12
Multiple File Upload In Rails
<% form_for(@album, :html => { :multipart => true }) do |f| %>
<p>
<%= f.label :name %>
<%= f.text_field :name %>
</p>
<h2>Photo(s)</h2>
<div id="photos">
<% if @album.new_record? %>
@underwhelmed
underwhelmed / test.js
Created January 11, 2012 14:26
Javascript Testing
var a = [];
a.constructor;
var numbers = [];
numbers[5] = 4;
numbers.length; //6
@underwhelmed
underwhelmed / tumblr.theme.html
Created January 10, 2012 05:38
Tumblr Follower Display
{block:Following}
<section id="following" class="clearfix">
<div class="grid_12">
<div>
<header>
<h2>Following</h2>
</header>
<ul class="clearfix">
{block:followed}
<li><a title="{FollowedTitle}" href="{FollowedURL}"><img src="{FollowedPortraitURL-40}"></a></li>
@underwhelmed
underwhelmed / ip_check.php
Created October 21, 2011 03:06
Tumblr Psuedo Blocking By IP
<?php
function GetIP()
{
foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key)
{
if (array_key_exists($key, $_SERVER) === true)
{
foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip)
{
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false)
@underwhelmed
underwhelmed / EmailReport.cs
Created July 5, 2011 19:53
Automatically run and email an SSRS Report
protected void btnRuns_Click(object sender, EventArgs e)
{
var rs = new rs2005.ReportingService2005();
var rsExec = new rsExecService.ReportExecutionService();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials;
rs.Url = "http://<ReportServer>/ReportServer/ReportService2005.asmx";
rsExec.Url = "http://<ReportServer>/ReportServer/ReportExecution2005.asmx";
string _reportName = @"/Path/To/Report";
@underwhelmed
underwhelmed / CurlService.php
Created June 14, 2011 16:23
Example of SimpleTest unit test with mock class
<?php
class CurlService {
function __construct($url) {
$this->url = $url;
}
private $url;