Skip to content

Instantly share code, notes, and snippets.

View jbgutierrez's full-sized avatar

Javier Blanco Gutiérrez jbgutierrez

View GitHub Profile
<script>
var toggle = function(){
alert("She loves me!");
var that = toggle;
toggle = function(){
alert("She loves me not!");
toggle = that;
}
}
@jbgutierrez
jbgutierrez / gist:214669
Created October 20, 2009 22:14
RAILS SHELL APPLICATION IN 10 STEPS
RAILS SHELL APPLICATION IN 10 STEPS !!!
1.- rails shell -d mysql
2.- cd shell
3.- Edit config/database.yml
4.- rake db:create
5.- ruby script\generate scaffold Command execute:string
6.- rake db:migrate
7.- Delete public/index.html
8.- Edit config/routes.rb
map.resources :commands
@jbgutierrez
jbgutierrez / gist:211888
Created October 16, 2009 16:46
Solution for the Rubylearning Challenge #2 (http://tinyurl.com/ydyc2kv)
require 'time'
def average_time_of_day(args)
sum = 0
args.each do |arg|
sum += Time.parse(arg).to_i
sum += 60 * 60 * 24 unless arg =~ /^1[01].*pm$/ # My friend arrival is scheduled at 10pm so any time outside 10:00pm and 11:59pm means he arrived on the very next day
end
average = sum / args.length
Time.at(average).strftime("%l:%M%p").strip.downcase
end
@jbgutierrez
jbgutierrez / migrateSVNwithGIT.sh
Created September 24, 2009 07:13
Migrate SVN repository with git-svn
git config --global svn.addAuthorFrom true
git config --global svn.useLogAuthor true
git svn clone NEW_URL new
git svn clone ORIGINAL_URL original
cd original
git push ../new/.git master:refs/heads/original
cd ../new
git filter-branch --msg-filter 'sed -e /^git-svn-id:/d' original
echo `git rev-list original | tail -1` `git rev-list master | tail -1` >> .git/info/grafts
git merge original
@jbgutierrez
jbgutierrez / rm_empty_folders.sh
Created June 24, 2009 22:13
Borra directorios vacíos de un repositorio de subversion
#!/bin/bash
# init
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
# look for empty dir
for SUBDIR in `find . -type d | grep -v .svn`; do
if [ ! "$(ls $SUBDIR)" ]; then
rm -rf $SUBDIR
echo "$SUBDIR is Empty"
@jbgutierrez
jbgutierrez / CheckItunesLibrary.java
Created June 7, 2009 17:24
Así es como tenía consistente el catálogo de iTunes antes de conocer http://dougscripts.com/itunes/
import com.sun.org.apache.bcel.internal.classfile.JavaClass;
import java.util.Arrays;
import javax.xml.xpath.*;
import java.io.File;
import java.io.FileInputStream;
import org.xml.sax.InputSource;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.util.HashSet;
import java.net.URLDecoder;
@jbgutierrez
jbgutierrez / export_somethings_data.js
Created May 10, 2009 22:14
Exportador de tareas de Somethings
// ==UserScript==
// @name export_somethings_data.js
// @namespace jbgutierrez.info
// @description Export "Somethings" data
// @include http://thn.gs/
// ==/UserScript==
// Add jQuery
var GM_JQ = document.createElement('script');
GM_JQ.src = 'http://jquery.com/src/jquery-latest.js';
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'
killall Dock
ActiveRecord::Base.logger = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}_database.log")
config.action_controller.relative_url_root = "/<sub-uri>"
public class StringTest
{
public static void main (String [] args)
{
String a = "Esto no se va a imprimir";
String b = "Esto se va a imprimir";
a = b;
b = "Esto parece que se va a imprimir, pero NO!";
System.out.println(a);
}