Skip to content

Instantly share code, notes, and snippets.

@LaurMo
LaurMo / "fun with relational databases" first steps
Created May 21, 2013 17:30
First crack at "fun with relational databases" first steps
CREATE TABLE users (
id integer PRIMARY KEY,
name string,
email string
);
CREATE TABLE questions (
id integer PRIMARY KEY,
question varchar,
@LaurMo
LaurMo / gist:6526547
Created September 11, 2013 16:57
is a user is signed in
<% if user_signed_in? %>
Logged in as <%= current_user.username %>
<%= link_to 'Edit profile', edit_user_registration_path %> |
<%= link_to "Logout", destroy_user_session_path, method: :delete %>
<%= link_to 'View Your Collections', collections_path %>
<% link_to 'New Collection', new_collection_path %>
<% else %>
<%= link_to "Sign up", new_user_registration_path %> |
<%= link_to "Login", new_user_session_path %>
<% end %>
@LaurMo
LaurMo / gist:6673196
Created September 23, 2013 16:31
related content erb
<% @related_content.each do |content| %>
<% if content.title.present? %>
<%= content.title %>
<% end %>
<% if content.author.name.present? %>
<%= content.author.name %>
<% end %>
<% if content.published_date.present? %>
@LaurMo
LaurMo / gist:6687558
Created September 24, 2013 16:42
json call for mailer
def email
content = Content.find(params[:id])
ClientMailer.content_send(current_user, content, params[:client_email], params[:client_note]).deliver
if ClientMailer.deliver
render :json => { :status => sent }
else
render :json => { :errors => errors.full_messages }, :status => 401
end
end
@LaurMo
LaurMo / gist:6703154
Created September 25, 2013 17:36
Example of contacts call bak
def contacts_callback
@contacts = request.env['omnicontacts.contacts']
@user = request.env['omnicontacts.user']
puts "List of contacts of #{user[:name]} obtained from #{params[:importer]}:"
@contacts.each do |contact|
puts "Contact found: name => #{contact[:name]}, email => #{contact[:email]}"
end
end
@LaurMo
LaurMo / gist:6813003
Created October 3, 2013 16:46
Metadata
Search Engine Metadata:
<meta name=“title” content=“GlutenFree.com” />
<meta name=“description” content=“GlutenFree.com seeks to provide anyone considering a gluten-free lifestyle the knowledge and confidence to embrace this bountiful life. We cut through the clutter by bringing together timely, credible research, recipes and tips and tools into a single, easy-to-digest resource.” />
<meta name=“keywords” content=“gluten,gluten free,gluten-free,gluten free diet food,celiac disease,about celiac disease,disease celiac,what is celiac disease,gluten sensitivity,gluten intolerance,gluten intolerant,foods for gluten free diet,foods on a gluten free diet,foods for a gluten free diet,gluten free diet food,gluten free claim,living gluten free” />
@LaurMo
LaurMo / gist:7257063
Created October 31, 2013 20:59
Clicking off for mobile.
$(document).off('keyup').on('keyup', function(e) {
view.closeModalOnEsc(e);
});
$('#overlay').show().on('click', function(e) {
view.hideModal(e);
});
$('#overlay').hide().off('click');
@LaurMo
LaurMo / gist:7421355
Created November 11, 2013 22:09
glutenfree
GlutenFree.Views.GlutenFreeMeView = Backbone.View.extend({
'events': {
'click .nav a': 'preventDefault',
'click .button a': 'navigate',
'click .email-menu': 'shareMenuEmail'
},
'initialize': function() {
var view = this;
@LaurMo
LaurMo / gist:9194053
Created February 24, 2014 18:31
instagram api
got it work sans plug in
$.ajax({
type: "GET",
dataType: "jsonp",
cache: false,
url: "https://api.instagram.com/v1/tags/" + 'budlight' + "/media/recent?client_id=" + '41e187d89f4b42b784804e0981f30c11',
success: function(response) {
var length = response.data != 'undefined' ? response.data.length : 0;
var limit = 60 != null && 60 < length ? 60 : length;
@LaurMo
LaurMo / gist:9233543
Created February 26, 2014 16:55
instagram-real-time attempt
var express = require("express");
var app = express();
var port = process.env.PORT || 8080;
var io = require('socket.io').listen(app.listen(port));
var Instagram = require('instagram-node-lib');
var http = require('http');
var request = ('request');
var intervalID;
/**