Skip to content

Instantly share code, notes, and snippets.

View jbgutierrez's full-sized avatar

Javier Blanco Gutiérrez jbgutierrez

View GitHub Profile
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head></head>
<body>
<script>
document.write(+new Date);
parent.leak();
</script>
@jbgutierrez
jbgutierrez / find-unused-css.rb
Created May 14, 2015 12:00
Linting scss files
#!/usr/bin/env ruby
# coding: UTF-8
require 'deadweight'
dw = Deadweight.new
dw.stylesheets = ["public/css/application.css"]
ignore_selectors = %w[.icon.* #modal-itx]
dw.ignore_selectors = Regexp.compile "(#{ignore_selectors.join('|')})"
dw.root = File.dirname(__FILE__) + '/'
dw.pages = Dir['views/**/*.dust']
@jbgutierrez
jbgutierrez / watch
Last active August 29, 2015 14:25
Hire/fire a webpack watcher after detecting new files in the file system
#!/usr/bin/env coffee
os = require 'os'
chokidar = require './nosync/node_modules/chokidar'
spawn = require('child_process').spawn
watcher = null
debounce = (fn, delay=100) ->
timer = null
->
context = this
@jbgutierrez
jbgutierrez / gist:30122
Created November 28, 2008 22:49
Smart definition of Fibonacci Sequence (http://tinyurl.com/dst6f)
def fib n
case n
when 0..1 then n
else fib(n-1) + fib(n-2)
end
end
# thouth it should be rewritten as a loop to avoid a stackoverflow
begin
response = Net::HTTP.post_form("...")
rescue Timeout::Error,
Errno::EINVAL,
Errno::ECONNRESET,
EOFError,
Net::HTTPBadResponse
Net::HTTPHeaderSyntaxError,
Net::ProtocolError => e
# ...
@jbgutierrez
jbgutierrez / TestThread.java
Created November 29, 2008 14:31
Pregunta de examen
import java.util.*;
public class TestThread extends Thread
{
public static void main(String[] args){
new TestThread().start();
new TestThread().start();
}
public void run(){
Vector<Safe> aList= new Vector<Safe>();
for(Integer i = 0; i<3; i++)
function isArray(o) {
return Object.prototype.toString.call(o) === '[object Array]';
}
@jbgutierrez
jbgutierrez / random_word.rb
Created February 7, 2009 15:52
Magnus Holm’s solution
# Generate a random string of length 4 or more consisting of only the following
set of characters: a-z, A-Z, 0-9
(0..4).map{rand(?z).chr[/[^_\W]/]||redo}.join
sudo env ARCHFLAGS="-arch i386" gem install mysql -- \
--with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib \
--with-mysql-include=/usr/local/mysql/include
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);
}