Skip to content

Instantly share code, notes, and snippets.

$.ajax({
type: "POST",
url: "/asdf.php",
data: $("form").serialize(),
error: function() {console.log("aggh")},
success: function(f) { console.log(f)}
})
@hexgnu
hexgnu / method.rb
Created January 10, 2012 05:13
Method
# Scope to order by a column header in a view's table.
# Direction can also be passed as argument (defaults to 'DESC').
# NOTE: Do not use #includes, instead use #joins. See not at CSVExporter.
def self.ordered_by_viewable_column(view_column_name, direction = 'DESC')
# Direction must be either asc or desc. Default to DESC
dir = direction =~ %r{^(asc|desc)$}i ? direction.upcase : 'DESC'
case view_column_name
when /account/i then joins(:network).order("networks.name #{dir}")
when /author/i then joins(:author).order("users.last_name #{dir}, users.first_name #{dir}")
when /brand/i then joins(:brand).order("brands.name #{dir}")
@hexgnu
hexgnu / haml.haml
Created January 17, 2012 00:30
Hrm haml
- if network.is_a?(TwitterNetwork)
%span{:class => network.class.to_s.downcase}
= truncate(network.name.to_s, :length => 20)
%br
%span
%a.network_url{:href => "http://twitter.com/#{network.name}"}
= "twitter.com/#{network.name}"
- elsif network.is_a?(FacebookNetwork)
%span{:class => network.class.to_s.downcase}
= truncate(network.name.to_s, :length => 20)
%li{:class => (network == n && request.path != '/timeline' ? "active #{n.class.to_s.downcase}" : n.class.to_s.downcase)}
- if n.is_a?(TwitterNetwork)
-#= link_to "@#{n.name}", networks_twitter_url(n)
- url = networks_twitter_url(n)
-#= link_to "@#{n.name}", networks_twitter_url(n)
- else
-#= link_to n.name, networks_facebook_url(n)
- url = networks_facebook_url(n)
%a{:href => url}
-#%label.network{:class => "#{n.class.to_s.downcase}", :for => "sn#{n.class.to_s}"}
expose(:current_brand) do
# REFACTOR THIS PLEASE :(
if params[:current_brand_id]
session[:qp_status] = nil
session[:qp_shared_image_ids] = nil
brand_id = if current_organization.brands.exists?(:id => params[:current_brand_id])
session[:current_brand_id] = params[:current_brand_id]
params[:current_brand_id]
1) PostsController deliver_notifications delivers emails to notifiable users
Failure/Error: controller.send(:deliver_notifications, true)
<ReviewerNotificationMailer (class)> received :notification_email with unexpected arguments
expected: (#<RSpec::Mocks::Mock:0x8707bd90 @name="User">, #<RSpec::Mocks::Mock:0x870816f0 @name=nil>)
got: (#<RSpec::Mocks::Mock:0x8707bd90 @name="User">, #<RSpec::Mocks::Mock:0x871a1a30 @name=nil>)
# ./app/controllers/posts_controller.rb:177:in `block in deliver_notifications'
# ./app/controllers/posts_controller.rb:176:in `each'
# ./app/controllers/posts_controller.rb:176:in `deliver_notifications'
# ./spec/controllers/posts_controller_spec.rb:361:in `block (3 levels) in <top (required)>'
@hexgnu
hexgnu / selectors.csv
Created January 19, 2012 04:49
Unused Selectors
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
"http://localhost:5400/assets/application.css?body=1"
"2970 unused selectors:"
applet
object
h1
h2
h3
h4
h5
@hexgnu
hexgnu / Crazytown.js
Created January 21, 2012 02:07
How did we ever get so terrible at writing code?
function initSpinner() {
var opts = {
lines: 16, // The number of lines to draw
length: 0, // The length of each line
width: 2, // The line thickness
radius: 7, // The radius of the inner circle
color: '#fff', // #rgb or #rrggbb
speed: 0.9, // Rounds per second
trail: 25, // Afterglow percentage
@hexgnu
hexgnu / linkedin.yml
Created January 23, 2012 17:00
REsponse from Rinked Rin
---
is_commentable: true
is_likable: true
is_liked: false
num_likes: 0
timestamp: 1324610418712
update_comments:
total: 0
update_content:
person:
---
api_standard_profile_request:
headers:
total: 1
all:
- !ruby/hash:LinkedIn::Mash
name: x-li-auth-token
value: name:mm60
url: http://api.linkedin.com/v1/people/Z6BGkDADoB
first_name: Christopher