Skip to content

Instantly share code, notes, and snippets.

View agalera's full-sized avatar
🐍
Good luck! 👍

Alberto Galera agalera

🐍
Good luck! 👍
View GitHub Profile
@agalera
agalera / cloudSettings
Last active October 11, 2019 12:15
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-10-11T12:15:48.249Z","extensionVersion":"v3.4.3"}
@agalera
agalera / split_video.py
Created February 6, 2017 09:32
split video with moviepy
from moviepy.editor import *
from multiprocessing import Process, Semaphore
import sys
segment_length = float(sys.argv[1])
frames = float(sys.argv[2])
original_video = VideoFileClip("original.mp4")
duration = original_video.duration
clip_start = 0
@agalera
agalera / proposal_decorators.py
Last active January 31, 2017 23:00
Proposal decorators to japronto
from japronto import Application
app = Application()
def get(url):
def wrap_function(func):
app.router.add_route(url, func, method='GET')
return wrap_function
import falcon
api = falcon.API()
def get(url):
def wrap_function(func):
print(url)
api.add_route(url, type('Dummie', (object, ), {'on_get': func}))
return func
@agalera
agalera / test.py
Created September 23, 2016 09:21
test.py
import ipdb
class Clase2:
pass
class Clase1:
def __init__(self):
self.example = {}
@agalera
agalera / launcher.py
Created May 22, 2016 18:54
launcher ld48-desmadrestudio
import urllib2
import hashlib
import os
import json
download_base = "http://desmadrestudio.com/static/ld48/"
# obtain find images/* -exec md5sum {} +
j = urllib2.urlopen(download_base + 'update.json')
j_obj = json.load(j)
list_download = j_obj['files']
@agalera
agalera / tornado_upload.py
Created May 3, 2016 07:34
tornado upload
from tornado.httpserver import HTTPServer
import tornado.ioloop
import tornado.web
import uuid
from tornado.concurrent import run_on_executor
from concurrent.futures import ThreadPoolExecutor
@tornado.web.stream_request_body
class MainHandler(tornado.web.RequestHandler):
executor = ThreadPoolExecutor(max_workers=400)
@agalera
agalera / many_connection.py
Last active March 9, 2016 07:28
Many connection
from threading import Thread
import sys
import socket
host, port = sys.argv[1], int(sys.argv[2])
connect_per_thread = int(sys.argv[4])
def many_connection():
while True:
sockets = []
@agalera
agalera / product.c
Last active June 28, 2016 08:59
Product.c
#include <Python.h>
#include <stdio.h>
#include <string.h>
typedef struct {
PyObject_HEAD
char* trans;
int len_letters;
char* letters;
int repeat;
@agalera
agalera / test.c
Created February 1, 2016 10:42
Test threads in C
#include <stdio.h>
#include <pthread.h>
void* calculate()
{
int i = 0;
int b = 0;
for(i=0; i<100000000; i++){
b = i+b;
}