Skip to content

Instantly share code, notes, and snippets.

def object_messages(obj = nil)
if !obj.nil? && !obj.errors.blank?
str_msg = '<div id="message" class="error"><span>' + obj.errors.full_messages.join('<br/>') + '</span></div>'
elsif !flash[:error].blank?
str_msg = '<div id="message" class="error"><span>' + flash[:error] + '</span></div>'
elsif !flash[:notice].blank?
str_msg = '<div id="message" class="notice"><span>' + flash[:notice] + '</span></div>'
elsif !flash[:success].blank?
str_msg = '<div id="message" class="success"><span>' + flash[:success] + '</span></div>'
else
ActionMailer::Base.default_charset = 'utf-8'
ActionMailer::Base.default_content_type = 'text/html'
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:enable_starttls_auto => true,
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => "user@gmail.com",
:password => "password",
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<provinciasResponse xmlns="http://www.sanitas.es/services/GuiaMedica">
<return type="guiamedica.pojo.Provincia">
<controlError/>
<descripcionProvincia>A Coruña</descripcionProvincia>
<idProvincia>15</idProvincia>
</return>
<return type="guiamedica.pojo.Provincia">
<controlError/>
# Development
sudo apt-get install bash-completion autoconf tig meld curl subversion git-core git-svn git-cola gitg xchat postfix
# Chrome
http://google.com/chrome
# Sun Java
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo apt-get update
sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk
def sequence_proc_generator
value = 0
lambda { value += value }
end
sequencer = power_proc_generator
#sequencer.call => 1
#sequencer.call => 2
#sequencer.call => 3
@eLafo
eLafo / gist:999092
Created May 30, 2011 16:08 — forked from arsduo/gist:997914
Euruko demo code (Koala & Facebook)
# demo from Euruko lightning talk 2011
# links:
# * http://github.com/arsduo/koala (code/wiki documentation)
# * http://oauth.twoalex.com (easy access tokens)
# * http://developers.facebook.com/docs/coreconcepts/ (FB docs)
# the person I hang out with most
people = g.fql_query("select tagged_uids from checkin where author_uid = me()")
bestfriend = people.collect {|c| c["tagged_uids"]}.flatten.group_by {|u| u}.values.max_by(&:length).first
Koala::Facebook::GraphAPI.batch do
@eLafo
eLafo / jazzfonica.rb
Created June 14, 2011 17:48 — forked from javier/jazzfonica.rb
jazzfonica
#!/usr/bin/env ruby
# jazzfonica.rb for Mac OS X
# Scans the visible networks for JAZZTEL_XXXX or WLAN_XXXX and calculates the password
# Ported from PHP example at http://kz.ath.cx/wlan/codigo.txt
# Download and execute with ruby (e.g. ruby jazzfonica.rb) from a Terminal
#ported to ubuntu from https://gist.github.com/1024587
#it will ask for sudo privileges.
#if your wlan card is not "wlan0" change the "my_wifi_card" variable
@eLafo
eLafo / video_thumbnails_in_ubuntu
Created July 26, 2011 10:43
Video thumbnails in ubuntu 10.10
sudo aptitude install ffmpeg ffmpegthumbnailer gstreamer0.10-ffmpeg gstreamer0.10-plugins-ugly
@eLafo
eLafo / colored_ssh.sh
Created August 4, 2011 15:49
Colored ssh
#!/bin/bash
BACK=$3
FORE=$4
setterm -term linux -back ${BACK:='default'} -fore ${FORE:='default'} -clear
ssh -l ${1} ${2};setterm -term linux -back default -fore default;clear
@eLafo
eLafo / colored_ssh_example.ssh
Created August 4, 2011 15:52
Colored ssh example
colored_sh.sh elafo elafo-machine red white