Skip to content

Instantly share code, notes, and snippets.

@raphamorim
raphamorim / solution.exs
Created March 10, 2017 20:34
Input SUM
defmodule Solution do
defp sum(a, b), do: a + b
def main() do
a = IO.gets("") |> String.strip |> String.to_integer
range = 1..a
Enum.reduce(range, 0, fn(x, acc) -> sum(acc, IO.gets("") |> String.strip |> String.to_integer) end)
|> IO.puts
end
#!/bin/sh
# Parts of this file come from:
# http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started#Create_clj_Script
BREAK_CHARS="\(\){}[],^%$#@\"\";:''|\\"
CLOJURE_DIR=/usr/local/lib/clojure
CLOJURE_JAR=$CLOJURE_DIR/clojure.jar
CLASSPATH="$CLOJURE_DIR/*:$CLOJURE_JAR"
while [ $# -gt 0 ]
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Some Random Page</title>
<style>
body {
border: 1px solid black;
background: white;
}
p {
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Some Random Page</title>
<link href="style.css" rel="stylesheet">
<script src="jquery.js" async></script>
</head>
<body>
<div><img src="polemic-photo.jpg"></div>
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Some Random Page</title>
<link href="style.css" rel="stylesheet">
<script src="jquery.js"></script>
</head>
<body>
<div><img src="polemic-photo.jpg"></div>
/* reset */
* {
padding: 0;
margin: 0;
border: 0;
outline: 0;
font-size: 100%;
line-height: 1em;
list-style: none;
text-decoration: none;
@raphamorim
raphamorim / webgl-init.js
Created May 15, 2016 22:58
WebGL Boilerplate
function createShaders(gl) {
var vertexShaderSrc = String(); // fill it with shader string or Script Text
var vertexShader = gl.createShader(gl.VERTEX_SHADER);
gl.shaderSource(vertexShader, vertexShaderSrc);
gl.compileShader(vertexShader);
var success = gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS);
if (!success) {
throw "could not compile shader:" + gl.getShaderInfoLog(vertexShader);
}
// From QUnit.js
function objectType( obj ) {
if ( typeof obj === "undefined" ) {
return "undefined";
}
// Consider: typeof null === object
if ( obj === null ) {
return "null";
}
@raphamorim
raphamorim / promisesBlueBird.js
Last active August 29, 2015 14:17
Promise Example
// using bluebird
var Servico = {
listarUsuarios: function(callback) {
setTimeout(function(){ callback(null, [{nome:"Gabriel"}, {nome:"Raphael"}]) }, 100);
},
listarFavoritos: function(usuario, callback) {
if (usuario.nome === "Gabriel") {
setTimeout(function(){ callback(null, ["http://www.google.com.br"]) }, Math.random() * 100);
@raphamorim
raphamorim / firstExercise.py
Created September 27, 2014 03:33
First exercise from a sequence of challenges
#!/usr/bin/python
import numpy as np
print "1 = Faca um algoritmo que troque o valor de duas variaveis. Por exemplo, o algoritmo le n1 igual a 3 e n2 a 17, e mostra n1 igual a 17 e n2 a 3."
print "2 = Faca um algoritmo para calcular a media de duas notas digitadas pelo usuario."
print "3 = Faca um algoritmo que calcule a area de um quadrado, sendo que o comprimento do lado e informado pelo usuario. A area do quadrado e calculada elevando-se o lado ao quadrado."
exerc = int(raw_input("Defina qual o numero do exercicio: "))
if exerc == 1: