Skip to content

Instantly share code, notes, and snippets.

View leonardoo's full-sized avatar

leonardo orozco leonardoo

  • admios
  • Bogota, Colombia
  • 18:30 (UTC -05:00)
View GitHub Profile
restore db without owner
pg_restore -U user -d db -1 db.sql -O --no-owner
psql -d db -f file.dump -U user -W -h host
sie db
SELECT
nspname || '.' || relname AS "relation",
for offset < count {
for i, _ := range []int{1, 2} {
new_offset := offset + (limit * i)
go doRequest(hostConn, sess, params, clientID, importLog, new_offset, limit, urls, &wg)
}
wg.Wait()
offset = offset + (limit * 2)
}
from moviepy.editor import *
cad = u'98597661-10.jpg'
myclip = ImageClip(cad).fx(vfx.resize, newsize=[1280, 660])
final = CompositeVideoClip([myclip], size=(1280, 720))
final.set_duration(7).write_videofile("test.mp4", fps=30)
import functools
from channels.handler import AsgiRequest
from rest_framework.exceptions import AuthenticationFailed
from rest_framework.settings import api_settings
authenticators = [auth() for auth in api_settings.DEFAULT_AUTHENTICATION_CLASSES]
const InputBox = React.createClass({
getInitialState: function() {
return {data: [], interval: undefined};
},
componentDidMount: function() {
const inverval = setInterval(this.update, 5000);
this.setState({inverval});
},
componentWillUnmount: function() {
clearInterval(this.state.inverval);
import asyncio
from growler import App
from growler.middleware import (Logger, Static, Renderer, Timer)
loop = asyncio.get_event_loop()
# Construct our application with name GrowlerServer
app = App('GrowlerServer', loop=loop)
@leonardoo
leonardoo / arial10.py
Created October 9, 2015 02:04
fitsheet
'''
Character width dictionary and convenience functions for column sizing
with xlwt when Arial 10 is the standard font. Widths were determined
experimentally using Excel 2000 on Windows XP. I have no idea how well
these will work on other setups. For example, I don't know if system
video settings will affect the results. I do know for sure that this
module won't be applicable to other fonts in general.
//John Yeung 2009-09-02
'''
@leonardoo
leonardoo / converter_models.py
Created September 8, 2015 16:38
this mixins convert a model to another, without take id field and only the fields that both models share
class ConvertMixin(object):
def convert(self, obj):
options = obj._meta
for field in sorted(options.get_fields()):
if self.attr_exists(field.name) and field.name not in obj.get_list_remove():
self.__setattr__(field.name,obj.__getattribute__(field.name))
def attr_exists(self, name):
return hasattr(self, name) or hasattr(self,"%s_id" % name)
class InstanceMixin(object):
def add_arguments(self):
return {'empresa':self.request.empresa}
def get_form_kwargs(self):
"""
Returns the keyword arguments for instanciating the form.
"""
kwargs = super(InstanceMixin, self).get_form_kwargs()
import os
from django.conf import settings
from django.shortcuts import render
from django.test.utils import override_settings
@override_settings(STATIC_URL="{}/".format(os.path.abspath(settings.STATIC_ROOT)))
def html_for_print(request, context_object_name, instance, template):
data = {context_object_name: instance}
return render(request, template, data)