This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Marshalling error for key '_my_session:1243f4a7a0c8d1dba363bc2ca7a246e8': singleton can't be dumped | |
You are trying to cache a Ruby object which cannot be serialized to memcached. | |
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/dalli-2.7.0/lib/dalli/server.rb:398:in `dump' | |
#Controller problem | |
session[:telefones] = Cliente.telefones | |
#Solution | |
session[:telefones] = Cliente.telefones.entries |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Be sure to save your config files. Optional but I do: | |
sudo cp /etc/postgresql/9.3/main/postgresql.conf ~ | |
sudo cp /etc/postgresql/9.3/main/pg_hba.conf ~ | |
# Package repo (for apt-get) | |
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - | |
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" >> /etc/apt/sources.list.d/postgresql.list' | |
# Also probably optional but I like to update sources and upgrade | |
sudo apt-get update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'oauth2' | |
require 'net/http' | |
require 'uri' | |
API_KEY = 'XXXXXXXXX' #Your app's API key | |
API_SECRET = 'XXXXXXXXXXXXX' #Your app's API secret | |
REDIRECT_URI = 'http://localhost:3000/accept' #Redirect users after authentication to this path | |
#Instantiate your OAuth2 client object | |
def client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Call me with linked_in_by_company('Disney') | |
LINKEDIN = { | |
api_key: ENV['LINKEDIN_API_KEY'], | |
secret_key: ENV['LINKEDIN_SECRET_KEY'], | |
consumers: { | |
test_person: { | |
consumer_token: ENV['LINKEDIN_TESTPERSON_CONSUMER_TOKEN'], | |
consumer_secret: ENV['LINKEDIN_TESTPERSON_CONSUMER_SECRET'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isoCountries = { | |
'AF' : 'Afghanistan', | |
'AX' : 'Aland Islands', | |
'AL' : 'Albania', | |
'DZ' : 'Algeria', | |
'AS' : 'American Samoa', | |
'AD' : 'Andorra', | |
'AO' : 'Angola', | |
'AI' : 'Anguilla', | |
'AQ' : 'Antarctica', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Intercepting HTTP calls with AngularJS. | |
angular.module('MyApp', []) | |
.config(function ($provide, $httpProvider) { | |
// Intercept http calls. | |
$provide.factory('MyHttpInterceptor', function ($q) { | |
return { | |
// On request success | |
request: function (config) { | |
// console.log(config); // Contains the data about the request before it is sent. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var KEYS = { | |
enter: 13, | |
left: 37, | |
right: 39, | |
escape: 27, | |
backspace: 8, | |
comma: 188, | |
shift: 16, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
worker_processes 1; | |
error_log /usr/local/var/log/nginx.error.log; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include mime.types; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Detecting data URLs | |
// data URI - MDN https://developer.mozilla.org/en-US/docs/data_URIs | |
// The "data" URL scheme: http://tools.ietf.org/html/rfc2397 | |
// Valid URL Characters: http://tools.ietf.org/html/rfc2396#section2 | |
function isDataURL(s) { | |
return !!s.match(isDataURL.regex); | |
} | |
isDataURL.regex = /^\s*data:([a-z]+\/[a-z]+(;[a-z\-]+\=[a-z\-]+)?)?(;base64)?,[a-z0-9\!\$\&\'\,\(\)\*\+\,\;\=\-\.\_\~\:\@\/\?\%\s]*\s*$/i; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bundler Integration | |
require "bundler/capistrano" | |
# Application Settings | |
set :application, "yourapplicationname" | |
set :user, "serveruser" | |
set :deploy_to, "/home/#{user}/rails-applications/#{application}" | |
set :rails_env, "production" | |
set :use_sudo, false | |
set :keep_releases, 3 |
NewerOlder