Skip to content

Instantly share code, notes, and snippets.

@javiertoledo
javiertoledo / README.md
Last active February 1, 2019 18:17
SCRIPT-8
@javiertoledo
javiertoledo / Keybase.md
Created August 25, 2018 12:30
Keybase verification

Keybase proof

I hereby claim:

  • I am javiertoledo on github.
  • I am javiertoledo (https://keybase.io/javiertoledo) on keybase.
  • I have a public key ASCDIlKaLxPaUrSFWjq4WnmcliYadThRYH0zk5s8RzgVGAo

To claim this, I am signing this object:

@javiertoledo
javiertoledo / update_ip.sh
Created July 30, 2018 18:56
Script to update a DNSimple record with your computer's current public IP
#!/bin/bash
TOKEN="XXXXXXXXXXXXXXXXXXXXXXX" # Replace with a domain access token
DOMAIN_ID="theam.io" # Replace with your domain name
RECORD_ID="1234" # Replace with the Record ID
ACCOUNT_ID="1234" # Replace with the Account ID
IP=`curl -s http://icanhazip.com/`
curl -H "Authorization: Bearer $TOKEN" \
-H "Accept: application/json" \
@javiertoledo
javiertoledo / get_magento_product.rb
Created March 28, 2014 11:51
Little snippet to get a Magento product as a Ruby Hash
# Getting a Magento product in Ruby
require 'savon'
client = Savon.client(wsdl: "http://magentohost.com/api/v2_soap?wsdl")
session_id = client.call(:login,
message: {
username: "soapusername",
api_key: "soappassword"
}).body[:login_response][:login_return]
@javiertoledo
javiertoledo / positive_ipsum.rb
Created October 3, 2013 20:52
A positive text generator for blasphemy gem :-)
module Faker
class PositiveIpsum < CustomIpsum
def initialize
@wordlist = %w(help hope children saving life people good water justice peace schools books well save provide serve health care sustain aid encourage guide support provide warm food improve protect)
@paragraph_list = [
"Our prime purpose in this life is to help others. And if you can't help them, at least don't hurt them.",
"The best way to not feel hopeless is to get up and do something. Don’t wait for good things to happen to you. If you go out and make some good things happen, you will fill the world with hope, you will fill yourself with hope.",
"The purpose of life is not to be happy. It is to be useful, to be honorable, to be compassionate, to have it make some difference that you have lived and lived well.",
"The best antidote I know for worry is work. The best cure for weariness is the challenge of helping someone who is even more tired. One of the great ironies of life is this: He or she w
@javiertoledo
javiertoledo / Preferences.sublime-settings
Created October 26, 2012 13:28
The Agile Monkeys default Sublime Text config
{
"color_scheme": "Packages/Color Scheme - Default/Twilight.tmTheme",
"font_face": "Bitstream Vera Sans Mono",
"font_size": 14.0,
"translate_tabs_to_spaces": true,
"tab_size": 2,
"trim_trailing_white_space_on_save": true,
"ensure_newline_at_eof_on_save": true,
"save_on_focus_lost": true
}
@javiertoledo
javiertoledo / README.txt
Created September 7, 2012 03:40
Hack to allow unions on ActiveRecord models
Add union_hack.rb to your project, for example at lib folder and ensure you're loading it on your application.rb file:
# You'll need to add something like that
config.autoload_paths += %W(#{config.root}/lib)
Then extend your favourite model with the module and you'll be able to do unions with unique records, sorted by any fields and limited in number of records (see my_timeline_method):
class Profile < ActiveRecord::Base
extend UnionHack
@javiertoledo
javiertoledo / securerandom_hack.rb
Created July 17, 2012 10:13
Hack to avoid gem compatibility nightmare
# If you're having this exception in Rails >=3.2.X, on Ruby >1.9.X..
#
# uninitialized constant ActiveSupport::SecureRandom
#
# ..and you don't want to debug half dozen of gems until you
# find which one is causing the error, you can use this hack
# as Ruby's SecureRandom API is 100% compatible with the
# Rails <3.2 ActiveSupport::SecureRandom API.
#
# This is absolute uglyness, but works and I wont tell nobody
@javiertoledo
javiertoledo / gist:3049910
Created July 4, 2012 22:40
Completely remove MySQL from Mac OS X
# Originally found at http://steveno.wordpress.com/2009/03/26/uninstall-mysql-on-mac-os-x/
# Saved here for the record
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
sudo vi /etc/hostconfig # and remove the line MYSQLCOM=-YES-
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /var/db/receipts/com.mysql.*
@javiertoledo
javiertoledo / _the_slides.html.haml
Created February 13, 2012 23:13
A simple multi-instance slideshow with jQuery
.photos
- @photos.each do |photo|
.photo=image_tag photo.url(:medium)