This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function random_string($length) { | |
$LETTERS = 'abcdefghijklmnopqrstuvwxyz'; | |
$random_string = ''; | |
for ($i=0; $i < $length; $i++) { | |
$random_string = $random_string.$LETTERS[rand(0, strlen($LETTERS)-1)]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% request.header do |k, v| %> | |
"<%= k %>" => <%= v %><br> | |
<% end %> | |
<% for header in request.env.select {|k,v| k.match("^HTTP.*")} %> | |
"<%=header[0].split('_',2)[1]%>" => <%=header[1]%><br> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Arrays { | |
public static void main(String[] args) { | |
int[] numbers = new int[5]; | |
numbers[0] = 5; | |
int l = numbers.length; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Dice { | |
private int anzahl; | |
private int grenze = 6; | |
private int[] zaehler = new int[6]; | |
Dice(int wuerfeAnzahl){ | |
anzahl = wuerfeAnzahl; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def timestamp | |
Time.now.to_i | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def rand_str length | |
('a'..'z').to_a.shuffle[0..length].join | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sum_to | |
print 'Enter any number greater than 1: ' | |
input = gets.to_i | |
sum = 0 | |
for a in 1..input do | |
sum += a | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sum_or_product | |
print 'Enter any number bigger 1: ' | |
num = gets.to_i | |
print 'sum [s] or product [p]? ' | |
opt = gets.chomp | |
if opt == 's' | |
(1..num).inject :+ | |
elsif opt == 'p' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def tbl max | |
for y in (1..max) do | |
for x in (1..max) do | |
sol = y*x | |
if sol < 10 | |
print "#{sol} " | |
elsif sol < 100 | |
print "#{sol} " | |
else | |
print "#{sol} " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def prime_numbers max | |
for i in (2..max) do | |
for j in (2..i) do | |
break if i%j == 0 | |
end | |
p "#{i} is a prime number." if i == j | |
end | |
end | |
require 'prime' |
OlderNewer