Skip to content

Instantly share code, notes, and snippets.

View richardsondx's full-sized avatar

Richardson Dackam richardsondx

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.29.1"></script>
<style type="text/css">
html, body, #map {
width: 100%;
@richardsondx
richardsondx / gist:4239133
Created December 8, 2012 07:30
trying to add a 404 error to rack::static
use Rack::Static,
:urls => ["/css", "/images", "/fonts", "/js", "/robots.txt"],
:root => "public"
run lambda { |env|
[
200,
{
'Content-Type' => 'text/html',
'Cache-Control' => 'public, max-age=86400'
$.getJSON "http://localhost:3000/tags.json", (data) ->
items = []
$.each JSONObject.results.bindings, (i, obj) ->
items.push [obj.place.value, obj.lat.value, obj.long.value, obj.page.value]
$("#post_tag_ids").select2({
tags: items,
tokenSeparators: [",", " "]
});
@richardsondx
richardsondx / current_try
Created October 17, 2012 21:48
File to import not found or unreadable: compass/css3
/*
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
* the top of the compiled file, but it's generally better to create a new file per style scope.
*= require_self
*= require bootstrap_and_overrides
*= require week_template
*/
@import "base_recipes.css.scss";
@richardsondx
richardsondx / convert.rb
Created October 9, 2012 01:42
Convert html tag img to image_tag
# This project is a fork from https://gist.github.com/1254319 that I updated
# ~ (http://richardsondx.github.com)
#!/usr/bin/env ruby -Ku
require "nokogiri"
require "iconv"
# opens every file in the given dir tree and converts any html img tags to rails image_tag calls
@richardsondx
richardsondx / current set up
Created September 21, 2012 20:16
Validation always appear even when i fill up the field
validates :image_or_image_url_is_present, :presence => true
def image_or_image_url_is_present
errors.add(:image_url, "Image url must be present") if !image_url.blank?
end
@richardsondx
richardsondx / _step.rb
Created September 7, 2012 14:42
cucumber capybara steps
Then /^I fill in Sign Up Form$/ do
user = FactoryGirl.attributes_for(:user)
fill_in 'user[name]', :with => user[:name]
fill_in 'user[email]', :with => user[:email]
fill_in 'user[password]', :with => user[:password]
fill_in 'user[password_confirmation]', :with => user[:password]
click_on "Next"
end
@richardsondx
richardsondx / Web_steps.rb
Created August 30, 2012 20:21
Cucumber Web steps
# Note: This is not the old cucumber-rails web_steps.rb
# It is a subset of the useful steps that aren't terrible
require 'uri'
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
When /^(?:|I )go to the (.+)(?: page)?$/ do |page_name|
visit path_to(page_name)
end
@richardsondx
richardsondx / ordercontroller.rb
Created August 17, 2012 22:48
Writting a test for Paypal Adaptive Payement and OrderController
class OrdersController < ApplicationController
include ActiveMerchant::Billing::Integrations
before_filter :get_buyer_info, :get_theme, :initializer
def initializer
app_paypal_email("example_007_biz_api1.gmail.com")
setup_seller_profit(75)
setup_receivers("[email protected]", "[email protected]")
get_buyer_info
get_theme
@richardsondx
richardsondx / config.rb
Created August 7, 2012 06:55
Sequel::DatabaseError - PG::Error: ERROR: invalid input syntax for integer: ""
require 'sequel'
require 'sequel/extensions/pagination'
# ...
DB = Sequel.connect(ENV['DATABASE_URL'] || 'postgres://localhost/wind.db')
# ...