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
int ledPin = 13; | |
int fib(int n){ | |
return (n <= 1) ? 1 : (fib(n-1) + fib(n-2)); | |
} | |
void blink(int interval){ | |
digitalWrite(ledPin, HIGH); | |
delay(interval); | |
digitalWrite(ledPin, LOW); |
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
#!/usr/bin/python | |
import math | |
import sys | |
def is_prime(n): | |
""" | |
Tells if a number is a prime | |
This uses the fact that prime numbers greater than 2 and 3 can always | |
be written in the form 6k+1 or 6k-1. That is, they are always 'next' |
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
# Implementation of the sieve of Eratostenes. | |
# Calculates all the prime numbers in a range up to the specified limit. | |
import math | |
import sys | |
def process(squareRoot, list): | |
"""This function calculates all the prime numbers in a range (from 2 to the | |
limit you specify). | |
Takes as arguments: | |
squareRoot - the square root of the highest number rounded down |
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
#!/usr/bin/python3 | |
#-*- coding: utf-8 -*- | |
import sys | |
import re | |
import urllib.request | |
from html.parser import HTMLParser | |
def usage(): | |
sys.stderr.write("usage: {0} <url>\n".format(sys.argv[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
find . -type d | while read DIR | |
do | |
echo "$DIR" | |
find "$DIR" -maxdepth 1 -type f -exec wc -l {} \; | awk '{loc += $1} END {print loc}' | |
done |
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
for FILE in `ls -1 *.jpg`; | |
do | |
touch -m -d "`exiftool -s3 -CreateDate "$FILE" -dateFormat "%Y-%m-%d %H:%M:%S"`" "$FILE" | |
done |
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
#!/usr/bin/python3 | |
#-*- coding: utf-8 -*- | |
# Pega nome do filme, do diretor, e a sinopse de uma página do imdb. | |
# Não tem tratamento de erros decente, e provavelmente não vai ter. | |
import sys | |
from bs4 import BeautifulSoup | |
import urllib.request |
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/bash | |
find . -name '*.CR2' -print0 | while read -r -d '' FILE | |
do | |
BASENAME=$(basename -s ".CR2" "$FILE") | |
exiftool -b -previewImage -ext .CR2 -w .JPG "$FILE" | |
exiftool -tagsFromFile "$FILE" "$BASENAME".JPG | |
done |
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
import unittest | |
def fizzbuzz(numero): | |
resultado = "" | |
if numero%3 == 0: | |
resultado += 'fizz' | |
if numero%5 == 0: | |
resultado += 'buzz' | |
if resultado == "": | |
resultado = numero |
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
dicionario = {'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000} | |
def eh_o_ultimo_caractere(indice,romano): | |
return indice == (len(romano) - 1) | |
def retorna_o_valor_do_proximo_caractere(indice, romano): | |
if eh_o_ultimo_caractere(indice,romano): | |
valor_do_proximo_caracter = 0 | |
else: | |
valor_do_proximo_caracter = dicionario[romano[indice + 1]] |
OlderNewer