Skip to content

Instantly share code, notes, and snippets.

View tcurvelo's full-sized avatar
🏠

Thiago Curvelo tcurvelo

🏠
View GitHub Profile
@tcurvelo
tcurvelo / energysaver.py
Last active December 28, 2016 17:54
idle time on windows + turn monitor off
#!/usr/bin/env python
#-*- coding: utf-8 -*-
from ctypes import Structure, windll, c_uint, sizeof, byref
from threading import Thread
import time, win32api, win32con
class LastInputInfo(Structure):
_fields_ = [
@tcurvelo
tcurvelo / fibonacci.py
Last active December 3, 2019 18:33
Fibonacci Experiments...
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
def naive_fibonacci(n):
'''Simplest recursive implementation'''
if n == 0:
return 0
@tcurvelo
tcurvelo / aws.py
Last active December 15, 2015 22:29
AWS 'Hello World!'
#!/usr/bin/env python
import time
import hmac
import hashlib
import base64
import urllib
secret_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
@tcurvelo
tcurvelo / no_cache.py
Created April 15, 2013 20:39
Restricted Python script for streaming a file in Zope, avoiding cache.
request = container.REQUEST
response = request.RESPONSE
my_file = context.my_content
response.setHeader('Pragma', 'no-cache')
response.setHeader('Cache-Control', 'max-age=-1,s-maxage=-1, no-cache')
response.setHeader('Content-Type', my_file.content_type)
return my_file.data
@tcurvelo
tcurvelo / indexing.py
Created April 25, 2013 17:41
Indexing an arbitrary content in portal_catalog.
import transaction
from AccessControl.SecurityManagement import newSecurityManager
from DateTime import DateTime
from Testing.makerequest import makerequest
app = makerequest(app)
newSecurityManager(None, app.acl_users.getUserById('admin'))
site = app.plone
@tcurvelo
tcurvelo / test_maps.py
Created July 10, 2013 04:24
Testing some maps API's
#/usr/bin/env python
# -*- encoding: utf-8 -*-
import unittest
import requests
import json
class Distance(object):
def __init__(self):
@tcurvelo
tcurvelo / meg.c
Created May 11, 2014 06:19
Sistemas Lineares: Metodo de Eliminacao de Gauss
/***************************************************
Universidade Federal da Paraiba
Centro de Ciencias Exatas e da Natureza
Disciplina: Calculo Numerico
Thiago Curvelo dos Anjos - Matr.: 010211026
****************************************************
Sistemas Lineares: Metodo de Eliminacao de Gauss
***************************************************/
#include <stdio.h>
@tcurvelo
tcurvelo / dijkstra.c
Last active June 25, 2016 04:38
Dijkstra's shortest path
#include <stdio.h>
#define INFINITO 32766
#define TRUE 1
#define FALSE 0
#define NN 150
typedef unsigned char BOOL;
/* Dijkstra */
@tcurvelo
tcurvelo / belman_ford.c
Created May 11, 2014 06:24
Bellman-Ford's shortest path
#include <stdio.h>
#define INFINITO 32766
#define TRUE 1
#define FALSE 0
#define NN 150
typedef unsigned char BOOL;
@tcurvelo
tcurvelo / numbers_only.js
Last active July 21, 2016 13:30
Restricting keys allowed to an input
document.getElementById('numbersonly').addEventListener(
'keypress',
function() {
var allowed_keys = {
48: true, // 0
49: true, // 1
50: true, // 2
51: true, // 3
52: true, // 4
53: true, // 5