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
Ruby: | |
def divide(n1, n2): | |
if n1 == 0: | |
raise ZeroDivisionError | |
elif n1 == 1: | |
return n2 | |
elif n1 < 0: | |
print ' should be bigger than 0' |
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
package ball; | |
import java.awt.Graphics; | |
import java.awt.Graphics2D; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
import java.awt.event.KeyEvent; | |
import java.awt.event.KeyListener; | |
import java.awt.geom.Ellipse2D; |
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
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"userid": "mohit", "password":"password"}' http://127.0.0.1:8003 |
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
-module(prime). | |
-export([init/1,sieb/1]). | |
init(Number) -> | |
sieb(lists:seq(2, Number)). | |
sieb (List) -> | |
case List of | |
[] -> |
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
primenumbers :: Integer -> [Integer] | |
primenumbers n = sieb [2..n] | |
where | |
sieb [] = [] | |
sieb (p:xs) = p: sieb [k | k<-xs, k `mod` p>0] |
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
require 'sparql/client' | |
sparql = SPARQL::Client.new("http://dbpedia.org/sparql") | |
result = sparql.query(" | |
SELECT * WHERE { | |
?e rdf:type <http://dbpedia.org/ontology/Plant>; |
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 createimgurl(id) | |
url = 'http://ww2.bgbm.org/herbarium/images/' | |
if id.start_with?('BW') | |
url + "B/-W/#{id[(2..3)]}/#{id[(4..5)]}/B_-W_#{id[(2..6)]}%20-#{id[(7..8)]}%20#{id[9]}.jpg" | |
elsif !id.start_with?('BG') | |
url + "B/#{id[(1..2)]}/#{id[(3..4)]}/#{id[(5..6)]}/#{id[(7..8)]}/b_#{id[(1..2)]}_#{id[(3..9)]}.jpg" | |
else | |
"" | |
end | |
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
string = "How are you ? " | |
string = string + " " unless string[string.length-1] == " " | |
array = [] | |
temp = "" | |
for x in (0...string.length) | |
if string[x] != ' ' | |
temp += string[x] |
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
SELECT * WHERE { | |
?e rdf:type <http://dbpedia.org/ontology/Plant>; | |
rdfs:label ?x. | |
FILTER regex(?x, "Avena sativa") | |
} |
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
PREFIX edm: <http://www.europeana.eu/schemas/edm/> | |
PREFIX ore: <http://www.openarchives.org/ore/terms/> | |
PREFIX dc: <http://purl.org/dc/elements/1.1/> | |
SELECT ?image WHERE { | |
?resource ore:proxyFor ?item; | |
dc:title "Cyperus tacnensis". | |
?resource ore:proxyIn ?proxy. | |
?proxy edm:object ?image. | |
} |