Skip to content

Instantly share code, notes, and snippets.

@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
@cannapages
cannapages / gist:8c5af0c761e3d1e94c1a
Created August 19, 2015 16:17
Font Awesome Classes as array Aug 19th 2015
["bars", "flag", "caret-down", "flag", "diamond", "camera-retro", "hand-spock-o", "ship", "venus", "file-image-o", "spinner", "check-square", "credit-card", "pie-chart", "won", "file-text-o", "arrow-right", "play-circle", "github", "medkit", "caret-down", "flag", "envelope", "search", "glass", "music", "search", "envelope-o", "heart", "star", "star-o", "user", "film", "th-large", "th", "th-list", "check", "times", "search-plus", "search-minus", "power-off", "signal", "cog", "trash-o", "home", "file-o", "clock-o", "road", "download", "arrow-circle-o-down", "arrow-circle-o-up", "inbox", "play-circle-o", "repeat", "refresh", "list-alt", "lock", "flag", "headphones", "volume-off", "volume-down", "volume-up", "qrcode", "barcode", "tag", "tags", "book", "bookmark", "print", "camera", "font", "bold", "italic", "text-height", "text-width", "align-left", "align-center", "align-right", "align-justify", "list", "outdent", "indent", "video-camera", "picture-o", "pencil", "map-marker", "adjust", "tint", "pencil-square-o",
upstream ht_front_end {
server 0.0.0.0:3000;
server 0.0.0.0:3001;
server 0.0.0.0:3002;
server 0.0.0.0:3003;
}
server {
listen 80;
server_name hemptemps.com;
@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;