Skip to content

Instantly share code, notes, and snippets.

@pepetox
pepetox / app_controllers_application_controller.rb
Last active August 29, 2015 14:10
Changes to make on rails 4 to can use as an api for angularjs, cordova ...
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :null_session
end
@pepetox
pepetox / login.html
Last active August 29, 2015 14:10
Translation from screatch in angularjs para ionic
angular.module('starter.controllers', [])
.controller('LogginCtrl', ['$scope', '$rootScope', function($scope, $rootScope) {
$rootScope.prop = {};
$rootScope.prop.language = 'es';
$rootScope.prop.strings = {};
$rootScope.prop.strings['title'] = { es: "Calendar K", en: "Canlendar K", jp: "カレンダーケイ" };
$rootScope.prop.strings['name'] = { es: "Nombre", en: "Name", jp: "名前" };
$$rootScope.prop.strings['hola'] = { es: "hola", en: "hello", jp: "こんにちは" };
@pepetox
pepetox / Gemfile
Created December 6, 2014 10:37
Link rails with tumblr
gem ‘tumblr_client’
gem ‘simple_oauth’, ‘0.2.0’
@pepetox
pepetox / config:sunspot.yml
Created December 6, 2014 10:38
Cucumber and Sunspot
test: &TEST
solr:
hostname: localhost
port: 8981
log_level: WARNING
cucumber:
<<: *TEST
@pepetox
pepetox / mymodel.rb
Created December 6, 2014 10:40
Rails default value in a model
after_initialize :mimetodo
def mimeotdo
self.atributo ||= 0.0 #seting default
end
@pepetox
pepetox / index.erb.html
Created December 6, 2014 10:42
Setting the son element in a rails relation
.... in a form tag
<%= f.collection_select(:category_id, Category.all, :id, :name, {:include_blank => true}) %>
@pepetox
pepetox / Gemfile
Created December 6, 2014 10:44
Rails chart in the views
gem ‘gruff’
gem ‘rmagick’
@pepetox
pepetox / gist:48952d7855a8161754fe
Last active August 29, 2015 14:13
shorting an array of hash by hash prop
sorted_array = myarray.sort{|p1,p2| p1[:diferencia] <=> p2[:diferencia]}
Change p1 and p2 to sort in the other order
sorted_array = myarray.sort{|p1,p2| p2[:diferencia] <=> p1[:diferencia]}
@pepetox
pepetox / code.gs
Created May 21, 2017 06:57
Drive-gas-vision-api-clasificator
//The next recipe shows how to use cloud vision api https://cloud.google.com/vision/ in order to classify images in one drive folder
//process configuration
var api_key = "AIzaSyXXXXXXXXXXXX" //api key of a cloud project with vision api enabled
var origin_folder_id = "0B4_0XXXXXXXXXXXXE" //Drive id of the origin folder
var clasification_tag_one = 'printer'; //first label to classify
var clasification_tag_two = 'cat'; //second label to classify
var clasification_tag_three = 'laptop';//third label to classify
var result_folder_one_id = "0B4_0XXXXXXXXXXXX" //Drive id of the folder to put in the first label images
@pepetox
pepetox / google-map-url-queries
Created May 24, 2017 19:51
examples to use maps with urls
//based in https://maps-apis.googleblog.com/2017/05/get-your-users-where-they-need-to-go-on.html
<!DOCTYPE html>
<html>
<body>
<p><a href="https://www.google.com/maps/search/?api=1&query=pizza+near+rome">See pizza restaurante near roma</a> </p>
<p><a href="https://www.google.com/maps/search/?api=1&query=pizza">See pizza restaurante near you</a> </p>