Skip to content

Instantly share code, notes, and snippets.

View railsfactory-kumaresan's full-sized avatar

Kumaresan railsfactory-kumaresan

View GitHub Profile
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
# 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
@railsfactory-kumaresan
railsfactory-kumaresan / linkedin_oauth2_sample.rb
Created July 20, 2016 12:02 — forked from kamloops/linkedin_oauth2_sample.rb
Simple LinkedIn OAuth2 authentication
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
@railsfactory-kumaresan
railsfactory-kumaresan / linked_in_people_search_by_company_name.rb
Created July 20, 2016 10:43 — forked from crowdmatt/linked_in_people_search_by_company_name.rb
How to query LinkedIn People Search by Company Name from Ruby with the LinkedIn Gem
# 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']
@railsfactory-kumaresan
railsfactory-kumaresan / Javascript ISO country code to country name conversion
Created March 9, 2016 06:20 — forked from maephisto/Javascript ISO country code to country name conversion
ISO 3166-1 alpha-2 country code to country name conversion with a simple Javascript implementation, an array and a function.
var isoCountries = {
'AF' : 'Afghanistan',
'AX' : 'Aland Islands',
'AL' : 'Albania',
'DZ' : 'Algeria',
'AS' : 'American Samoa',
'AD' : 'Andorra',
'AO' : 'Angola',
'AI' : 'Anguilla',
'AQ' : 'Antarctica',
@railsfactory-kumaresan
railsfactory-kumaresan / angularjs-interceptor.js
Created January 14, 2016 07:12 — forked from gnomeontherun/angularjs-interceptor.js
Intercept XHR/Ajax requests with AngularJS http interceptors. This allows you to globally intercept and modify requests and responses. You don't need to declare all of the methods, just the ones you need. Some example uses would be logging errors, adding extra headers, or triggering 'loading' screens. This intercepts ALL requests/responses, so y…
// 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.
'use strict';
var KEYS = {
enter: 13,
left: 37,
right: 39,
escape: 27,
backspace: 8,
comma: 188,
shift: 16,
@railsfactory-kumaresan
railsfactory-kumaresan / nginx.conf
Created December 10, 2015 08:19 — forked from jeffrafter/nginx.conf
Nginx proxy pass to localhost:3000 for development
worker_processes 1;
error_log /usr/local/var/log/nginx.error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
@railsfactory-kumaresan
railsfactory-kumaresan / detectDataURL.js
Created November 30, 2015 07:41 — forked from bgrins/detectDataURL.js
Detect if a string is a data URL. Doesn't try to parse it or determine validity, just a quick check if a string appears to be a data URL. See http://jsfiddle.net/bgrins/aZWTB/ for a demo.
// 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;
@railsfactory-kumaresan
railsfactory-kumaresan / deploy.rb
Created October 9, 2015 12:34 — forked from reu/deploy.rb
Capistrano deploy recipe for database configuration
# 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