Skip to content

Instantly share code, notes, and snippets.

@cannapages
cannapages / gist:5358916
Last active December 16, 2015 01:59
A simple mention able model
class Post < ActiveRecord::Base
..
def content_for_view
content.html_safe
end
before_save :create_mentionable_links_in_post
def create_mentionable_links_in_post
@cannapages
cannapages / gist:5359221
Created April 10, 2013 23:04
Concerning an example
module Reversable
extend ActiveSupport::Concern
module ClassMethods
def do_it
puts "holly molly this is how to bootstrap"
all.each do |post|
post.revers_content
end
end
@cannapages
cannapages / header.css.scss
Created April 15, 2013 22:21
Fixed nav html and css
$header_height: 100px;
.header {
position: fixed;
width: 100%;
height: $header_height;
background-color: $light_blue;
.container {
position: relative;
width: 950px;
height: $header_height;
@cannapages
cannapages / gist:5392466
Last active December 16, 2015 06:38
Leaflet
jQuery ->
if $("#map").size() > 0
map = L.map('map').setView([30, 0], 3)
map.fitBounds([[-90, -180],[90, 180]])
cloud_made =
api_key: 'thekey'
style_id: '92877'
tile_size: '256'
minZoom: 3
class OvsmSoundManager
constructor: ->
@sounds = []
sound: (id, sound) ->
{ id: id, sound: sound }
add_sound: ( id, url ) ->
sound = soundManager.createSound({}, url)
@sounds.push( @sound(id, sound) )
sound_for_id: (id) ->
@sounds.filter( (sound) ->
@cannapages
cannapages / gist:11298577
Last active August 29, 2015 14:00
Bjarne Stroustrup Exerpt
#include <iostream>
using namespace std;
int count_x(char* p, char x) {
if (p==nullptr) return 0;
int count = 0;
for (; *p!=0; ++p)
if(*p==x)
++count;
return count;
:s#_\(\l\)#\u\1#g
@cannapages
cannapages / transaction.rb
Created January 22, 2015 23:57
Transaction Model for hemptemps
class Transaction < ActiveRecord::Base
attr_accessor :card_number, :card_expiration_date, :card_cvv, :card_street_address, :card_city, :card_state, :card_zipcode, :is_online_cc
has_one :student_cart
belongs_to :student
belongs_to :user
include PayPal::SDK::REST
def submit_to_paypal
@payment = Payment.new({
:intent => "sale",
:payer => {
@cannapages
cannapages / gist:6639300f922cd5ea1b1b
Created January 23, 2015 00:05
Paypal payment object inspect at error point
#<PayPal::SDK::REST::DataTypes::Payment:0x00000008053310 @error=nil, @intent="sale", @payer=#<PayPal::SDK::REST::DataTypes::Payer:0x00000008052f78 @error=nil, @payment_method="credit_card", @funding_instruments=[#<PayPal::SDK::REST::DataTypes::FundingInstrument:0x0000000804ee28 @error=nil, @credit_card=#<PayPal::SDK::REST::DataTypes::CreditCard:0x0000000804ece8 @error=nil, @type="visa", @number="4111111111111111", @expire_month=1, @expire_year=2017, @cvv2="123", @first_name="Tyrel", @last_name="Richey", @billing_address=#<PayPal::SDK::REST::DataTypes::Address:0x0000000804dff0 @error=nil, @line1="12345 Fake St.", @city="Denver", @state="Colorado", @postal_code="80229", @country_code="US">>>]>, @transactions=[#<PayPal::SDK::REST::DataTypes::Transaction:0x0000000804d398 @error=nil, @amount=#<PayPal::SDK::REST::DataTypes::Amount:0x0000000804d258 @error=nil, @total="458.00", @currency="USD">, @description="Online course payment">], @request_id="5d0f973c-cdd6-435a-830b-67e10027e6e3", @header={}>
@cannapages
cannapages / gist:5a60907952a79d54c0df
Created May 8, 2015 08:42
Fresh Ubuntu/Ruby Todo
sudo apt-get update
sudo apt-get upgrade
\curl -sSL https://get.rvm.io | bash -s stable --rails
rvm install ruby 1.9 --default
sudo apt-get install build-essential libsdl2-dev libsdl2-ttf-dev libpango1.0-dev libgl1-mesa-dev libfreeimage-dev libopenal-dev libsndfile-dev libiconv-hook-dev libxml2-dev freeglut3 freeglut3-dev ImageMagick libmagickwand-dev
gem install faster_xml_simple
gem install gosu releasy texplay ashton gamebox chipmunk ruby-opengl rmagick