Skip to content

Instantly share code, notes, and snippets.

View juanm55's full-sized avatar

JuanManuel LF juanm55

View GitHub Profile
@juanm55
juanm55 / command line
Created March 6, 2012 04:30
a heroku error....
~/Desktop/twitterjm$ git push heroku master
Counting objects: 10, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 725 bytes, done.
Total 7 (delta 5), reused 0 (delta 0)
-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.1.rc.7
@juanm55
juanm55 / error
Created February 26, 2012 23:29
an error i got in an ASPX web page
Server Error in '/' Application.
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
Source Error:
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:
@juanm55
juanm55 / fibonacci.rb
Created February 21, 2012 00:34
fibonacci :D, in ruby, trying to make it smaller and lighter
def fibonacci(n)
a = [1,1]
(n-2).times{ a[a.index(a.min)] = a[0]+a[1]}
a.max
end
@juanm55
juanm55 / pages_controller.rb
Created February 18, 2012 00:18
something I did to avoid using 2 root_paths in my routes
def home
# get 'login', :to => 'devise/sessions#new' in my routes.rb
redirect_to 'login' unless current_user #if not logged in, kick him out of here!
end
@juanm55
juanm55 / gist:1670943
Created January 24, 2012 16:22
interesting way of updating text field in rails... without ajax requests....
<%= select_tag("objective[indicator_id]", options_for_select([["seleccione indicador",0]] + @indicators.map {|u| [u.name,u.id]}, selected = var_indicator ) , html_options = {:onchange => "this.form.elements['objective[criteria]'].value = this.form.elements['tmp_objective[indicator_id]'].options[ this.form.elements['objective[indicator_id]'].selectedIndex ].text "}) %>
<%= text_area_tag "objective[criteria]", var_criteria.to_s , :rows => 5, :cols => 70 %></td>
<div style="display:none;VISIBILITY:none;" >
<%= collection_select("tmp_objective", "indicator_id" , @indicators, "id", "suggested_criteria", options ={:prompt=>""}) %>
</div>
@juanm55
juanm55 / gist:1501335
Created December 20, 2011 11:55
setting up a rails env in ubuntu!
I recommend getting the 10.04 LTS version meanwhile, but if you feel "edgy" you can get the latest one (though I haven't tested how easy it is to install Ruby there)
OS:
http://www.ubuntu.com/download/ubuntu/download
RUBY and everything else using RVM:
http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/
Firefox: 1st uninstall the default one (is not linked to the ones in the repositories -- easily done through Ubuntu Software Center)
then in the terminal =>
@juanm55
juanm55 / gist:1407508
Created November 30, 2011 01:17
a question regarding select tag in rails form helper...
<td>Project<br/ >
<%= f.select :project_id, Project.all.collect{|a| [a.name, a.id]}%></td>
# the idea would be to do something similar to what one can do with text_tag
<%= text_tag :comment, :size => 10 %> # which renders a text_input element,,, with 10 spaces for character input...
@juanm55
juanm55 / ob_evidences_controller.rb
Created November 9, 2011 21:38
How should I do this?
# I want to go from the session information (which contains the current logged in user_id) to his/her assigned EvaluationUser, down to his'/hers EvaluationCategories, down to the objectives associated to those, and finally the evidences related to each one of them....
#the idea is being able to obtain and array of ob_evidences that the user has created.... but the following does not seem to work even though I have the associations which should make everything run swiftly,,,,
def index
@ob_evidences = EvaluationUser.where("user_id = ?", session[:user_id]).first.evaluation_categories.objectives.ob_evidences
end
@juanm55
juanm55 / gist:1324560
Created October 29, 2011 15:06
HTML links with images that aren't underlined
/* the idea here is to create a link with an image AND some text,,,, but ONLY the text gets underlined*/
/* with this setup and CSS it is not possible to take out the underline of the img element (since it is an in-line element)*/
<a href=#><img src="path/to/file" /> some text</a>
/* Because 'a' styling is supposed to have text-decoration:underline; and that affects the image too....
even with:
@juanm55
juanm55 / en.yml
Created September 23, 2011 15:43
Is this possible in i18n???
en:
editing: "editing %{thingy}"
another: "User"
# the idea is that I can call a dict definition from within another one?
#maybe im better off doing something like this:
#in view
t 'editing', :thingy => t('another')