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
#!/bin/sh | |
cd /home/amanda/Downloads | |
rm -rf /opt/jvm | |
rm -rf jre1.8.0_45 | |
mkdir /opt/jvm | |
tar -zxf jre-8u45-linux-i586.tar.gz -C /opt/jdk |
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 numeros (range 0 10000)) | |
(def vetor (into-array Long/TYPE numeros)) | |
(defmacro benchmark [code] | |
`(time (first (doall (repeatedly 1000 (fn [] ~code)))))) | |
(benchmark (reduce + numeros)) | |
; "Elapsed time: 123.946807 msecs" |
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
(defn random-number [_] | |
(rand-int 22)) | |
(defn a-validate [valor] | |
(> valor 10)) | |
(defn a-errorhandler [ag ex] | |
(println "Error: " (.getMessage ex))) | |
(defn a-watcher [ref chave antigo novo] |
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
;; Primeiro criamos um agent a | |
(def a (agent 1)) | |
;; A função watch deve ter quatro parâmetros: uma chave única, | |
;; a referência ao próprio agent, o valor antigo e o valor novo. | |
(defn a-watch [key ref old new] | |
(println "Watching" key ref old new)) | |
;; vamos criar uma função que dobra o valor recebido e informa | |
;; quando está sendo executada |
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
;; aqui eu crio um agent com o valor 1 e chamo de x | |
(def y (agent 1)) | |
;; nossa função vai levar dez segundos a cada processamento | |
(defn triple [c] | |
(println "valor inicial:" c) | |
(Thread/sleep 10000) | |
(println "terminei") | |
(* c 3)) |
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
(dispatch-reader-macro \X xml-reader) | |
#X" | |
<compras> | |
<item> | |
<batata> | |
<preco>1.23</preco> | |
</batata> | |
</item> | |
</compras>" |
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
;; criei um arquivo chamado gen.clj | |
(ns capitulo08.gen | |
(:gen-class | |
:name "capitulo08.Uia" | |
:methods [[hello [] void]])) | |
(defn -hello [this] | |
(println "Olá!")) | |
;; agora no REPL: |
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
if(localStorage["demo.isRunning"] !== "true") { | |
alert("Let's write something on the local storage"); | |
localStorage["demo.isRunning"] = true; | |
localStorage["demo.value"] = "It works!"; | |
window.location.reload(); | |
} else { | |
alert("Value of stored value is '" + localStorage["demo.value"] + "'"); |
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
private void btnCalcular_Click(object sender, EventArgs e) | |
{ | |
// maior | |
if (txtNota0.Value > txtNota1.Value && txtNota0.Value > txtNota2.Value && txtNota0.Value > txtNota3.Value) | |
{ | |
lblMaior.Text = txtNota0.Value.ToString(); | |
} | |
else if (txtNota1.Value > txtNota0.Value && txtNota1.Value > txtNota2.Value && txtNota1.Value > txtNota3.Value) | |
{ | |
lblMaior.Text = txtNota1.Value.ToString(); |
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
private void btnCalcular_Click(object sender, EventArgs e) | |
{ | |
decimal maior = 0; | |
decimal menor = 99; | |
if (txtNota0.Value < menor) menor = txtNota0.Value; | |
if (txtNota1.Value < menor) menor = txtNota1.Value; | |
if (txtNota2.Value < menor) menor = txtNota2.Value; | |
if (txtNota3.Value < menor) menor = txtNota3.Value; |