Skip to content

Instantly share code, notes, and snippets.

View japaz's full-sized avatar
🏠
Tired of ...

Alberto Paz Jimenez japaz

🏠
Tired of ...
View GitHub Profile
@japaz
japaz / test.jsp
Created March 3, 2011 15:41
Example jsp include from other context
<%@page import="javax.servlet.ServletContext" %>
<%@page import="javax.servlet.RequestDispatcher" %>
<%
ServletContext servletcontext = pageContext.getServletContext();
ServletContext servletcontext1 = servletcontext.getContext("/testAPP/v/a.jsp");
if (servletcontext1 != null) {
out.println("SC is not null");
RequestDispatcher requestdispatcher = servletcontext1.getRequestDispatcher("/v/a.jsp");
if (requestdispatcher != null){
out.println("RD is not null");
@japaz
japaz / moving_box.html
Created September 26, 2011 20:22 — forked from francisco-perez-sorrosal/moving_box.html
My html containing the moving box Javascript example implemented in class with Carlos Benítez (Madrid, 14/Sep/2011)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style type="text/css">
body{background-color:#ccc}
#box{
width:100px;
@japaz
japaz / 7L7W_Ruby_Day_1.rb
Created September 29, 2011 17:13
7L7W Ruby - Day 1
#!/usr/bin/env ruby
# Print the string “Hello, world.”
puts 'Hello, world'
# For the string “Hello, Ruby,” find the index of the word “Ruby.”
'Hello, Ruby.'.index('Ruby')
# Print your name ten times
10.times do
@japaz
japaz / day2_do.rb
Created October 3, 2011 07:31
7L7W Ruby - Day 2
=begin
Print the contents of an array of sixteen numbers, four numbers
at a time, using just each.
=end
i=0
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16].each do |x|
i=i+1
print "#{x} "
puts "" if i%4==0
@japaz
japaz / ruby_day3.rb
Created October 3, 2011 07:35
7L7W Ruby - Day 3
=begin
Modify the CSV application to support an each method to return a
CsvRow object. Use method_missing on that CsvRow to return the value
for the column for a given heading.
For example, for the file:
one, two
lions, tigers
allow an API that works like this:
csv = RubyCsv.new
@japaz
japaz / answer.io
Created October 4, 2011 21:09
7L7W Io - Day 1
// Evaluate 1 + 1 and then 1 + "one". Is Io strongly typed or weakly typed? Support your answer with code.
// It seems strongly typed to me
1+1
// ==> 2
1+"one"
// Exception: argument 0 to method '+' must be a Number, not a 'Sequence'
// ---------
// message '+' in 'Command Line' on line 1
// But you can do think like this
Vehicle := Object clone
@japaz
japaz / 7L7W_Io_Day2.io
Created October 9, 2011 21:22
7L7W Io - Day 2
// A Fibonacci sequence starts with two 1s. Each subsequent number
// is the sum of the two numbers that came before: 1, 1, 2, 3,
// 5, 8, 13, 21, and so on. Write a program to find the nth Fibonacci
// number. fib(1) is 1, and fib(4) is 3. As a bonus, solve the problem
// with recursion and with loops.
fib := method(a, if(a==1, 1, if (a==2, 1, fib(a-1)+fib(a-2))))
fib(15)
@japaz
japaz / builder.io
Created October 12, 2011 07:34
7L7W Io - Day 3
Builder := Object clone
Builder addIndent := method(
for(i, 1, indent*2, " " print)
)
Builder indent := 0
Builder forward := method(
self addIndent
writeln("<", call message name, ">")
indent = indent +1
call message arguments foreach(
@japaz
japaz / do.prolog
Created October 14, 2011 21:30
7L7W Prolog - Day 1
% Make a simple knowledge base. Represent some of your favorite
% books and authors.
author(apprenticeship, dave_hoover).
author(getting_real, jason_fried).
author(rework, jason_fried).
% Find all books in your knowledge base written by one author.
author(Book, jason_fried).
% Make a knowledge base representing musicians and instruments.
@japaz
japaz / factorial.prolog
Created October 14, 2011 22:07
7L7W Prolog - Day 2
% Some implementations of a Fibonacci series and factorials. How
% do they work?
% La sintaxis es factorial(N, F) -> Factorial de N es F (el resultado se guarda en F)
factorial(0, 1).
factorial(N, F) :- N>0, N1 is N - 1, factorial(N1, F1), F is N*F1.
%el factorial se llama recursivamente dejando el resultado en F