Skip to content

Instantly share code, notes, and snippets.

View mauriciofierrom's full-sized avatar
💻
Bit by bit

Mauricio Fierro mauriciofierrom

💻
Bit by bit
View GitHub Profile
@mauriciofierrom
mauriciofierrom / gist:1489885
Created December 17, 2011 10:25
ujs problem
def create
@cart = current_cart
product = Product.find(params[:product_id])
@line_item = @cart.add_product(product.id)
respond_to do |format|
if @line_item.save
format.html { redirect_to(store_url)}
format.js { @current_item = @line_item }
format.xml { render :xml => @line_item, :status => :created, :location => @line_item }
@mauriciofierrom
mauriciofierrom / RobotTest.java
Created May 21, 2012 19:28
Este código permite cambiar de ventana a Google Chrome, entrar a google y buscar algo. Usa la clase de testing Robot de Java
import java.awt.Robot;
import java.awt.AWTException;
import java.awt.event.KeyEvent;
public class robo_test
{
Robot rob;
public robo_test() throws AWTException
@mauriciofierrom
mauriciofierrom / _form.html.erb
Created June 8, 2012 22:37
Nested Form Issues
<%= form_for(@person) do |f| %>
<% if @person.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@person.errors.count, "error") %> prohibited this person from being saved:</h2>
<ul>
<% @person.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
class User < ActiveRecord::Base
belongs_to :person
belongs_to :user_type
end
class Person < ActiveRecord::Base
belongs_to :company
has_one :user
accepts_nested_attributes_for :user
end
Error:
Error mounting: mount exited with exit code 1: helper failed with:
mount: wrong fs type, bad option, bad superblock on /dev/sdb1,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so
dmesg | tail output:
@mauriciofierrom
mauriciofierrom / vote.rb
Created August 14, 2012 11:32
This little code logs in to Wowlatinoamerica's web site and then votes on every page automatically. It also checks for an internet connection 20 times before shutting down because I set it to run on boot in my machine.
require 'rubygems'
require 'mechanize'
require 'open-uri'
def internet_connection?
begin
true if open("http://www.google.com")
rescue
false
end
@mauriciofierrom
mauriciofierrom / class.wp-publication-archive.php
Created August 22, 2012 01:56
Plugin Wordpress Publication Archive Españolizado
<?php
class WP_Publication_Archive {
public static $mimetypes = array(
'application/pdf' => 'pdf',
'application/postscript' => 'pdf',
'application/zip' => 'zip',
'audio/basic' => 'audio',
'audio/mp4' => 'audio',
@mauriciofierrom
mauriciofierrom / gist:4524522
Created January 13, 2013 15:10
glxinfo output
name of display: :0
display: :0 screen: 0
direct rendering: Yes
server glx vendor string: SGI
server glx version string: 1.4
server glx extensions:
GLX_ARB_multisample, GLX_EXT_import_context, GLX_EXT_texture_from_pixmap,
GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_MESA_copy_sub_buffer,
GLX_OML_swap_method, GLX_SGI_swap_control, GLX_SGIS_multisample,
GLX_SGIX_fbconfig, GLX_SGIX_pbuffer, GLX_SGIX_visual_select_group,
@mauriciofierrom
mauriciofierrom / application.js
Created April 3, 2013 21:10
my application.js file
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD