Skip to content

Instantly share code, notes, and snippets.

View rscarvalho's full-sized avatar

Rodolfo Carvalho rscarvalho

View GitHub Profile
def eh_primo(x):
fator = 2
while x % fator != 0 and fator <= x / 2:
fator = fator + 1
if x % fator == 0:
return False
else:
return True
def maio_primo(n):
#-*- coding:UTF-8 -*-
from tkinter import *
root=Tk()
class Principal:
def __init__(self, window):
window.geometry("800x600")
window.overrideredirect(True) # Maximiza a janela sem bordas
title_logo = Label(window, text="Tela Principal", bg="white")
title_logo.place(x=0, y=0, width=800, height=22)
@rscarvalho
rscarvalho / despesas.csv
Created January 7, 2018 16:59
Exemplo de uso de um SAX parser para manipulação de arquivo XML
Deputado Matricula Ano Mes Tipo CNPJ Fornecedor Valor
Deputado A 021345 2017 5 Alimentacao 003.222.111/0001-23 Bar do Joao 122.30
Deputado A 021345 2017 5 Alimentacao 003.222.111/0001-23 Bar do Joao 122.30
Deputado B 021345 2017 5 Alimentacao 003.222.111/0001-23 Bar do Joao 122.30
Deputado D 021345 2017 5 Alimentacao 003.222.111/0001-23 Bar do Joao 122.30
Deputado B 021345 2017 5 Alimentacao 003.222.111/0001-23 Bar do Joao 122.30
@rscarvalho
rscarvalho / vscode_extensions.md
Last active November 11, 2017 21:06
Visual Studio Code essential extensions for development
Creative Commons Legal Code
CC0 1.0 Universal
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
@rscarvalho
rscarvalho / git-cleanup-pr
Last active April 12, 2017 17:38
Git extensions
#!/usr/bin/env bash
FEATURE_BRANCH=$(git rev-parse --abbrev-ref HEAD| xargs echo -n)
TARGET_BRANCH=${1:-master}
echo "Cleaning feature branch ${FEATURE_BRANCH} (coming back to ${TARGET_BRANCH})"
git checkout ${TARGET_BRANCH}
git fetch -ap
git pull --rebase
import { combineEpics } from 'redux-observable';
/*
* Let's assume each configuration has the following:
* {
* type: String|Array<String>,
* url: String,
* method: String,
* body: String|Function<Action, String|Object>,
* process: Function<ActionObservable, ActionObservable>,
@rscarvalho
rscarvalho / App.jsx
Last active March 14, 2017 11:21
KeyUp handler using RxJS + React
const store = createStore();
ReactDOM.mount(
<Provider store={store}>
<WindowWrapper>
<GameCanvas />
</WindowWrapper>
</Provider>
)
import React from 'react';
import ReactDOM from 'react-dom';
import Redux from 'redux';
import { createStore } from 'redux';
import { connect, Provider } from 'react-redux';
class MyComponent extends React.Component {
render() {
const { active, toggle } = this.props;
@rscarvalho
rscarvalho / cmd.applescript
Created June 10, 2016 16:11
Afred - run shell command in current open terminal window
on write_to_file(this_data, target_file, append_data)
try
set the target_file to the target_file as string
set the open_target_file to open for access file target_file with write permission
if append_data is false then set eof of the open_target_file to 0
write this_data to the open_target_file starting at eof
close access the open_target_file
return true
on error
try