Skip to content

Instantly share code, notes, and snippets.

View Alquimista's full-sized avatar

Roberto Gea Alquimista

  • Querétaro, Qro, México
View GitHub Profile
@rshipp
rshipp / update_sums.sh
Created June 25, 2014 01:25
A terrible one-liner for in-place updating of PKGBUILD checksums.
oldsums=$(sed -n '/^.*sums=(.*/,/.*)/p' PKGBUILD); newsums=$(makepkg -g); sed -i "/^.*sums=(.*/,/.*)$/y/${oldsums/$'\n'/\\n}/${newsums/$'\n'/\\n}/" PKGBUILD
@LuqueDaniel
LuqueDaniel / PyQt_custom_context_menu.py
Last active September 20, 2021 20:15
PyQt custom context menu
# -*- coding: utf-8 -*-
#PyQt4.QtGui imports
from PyQt4.QtGui import QApplication
from PyQt4.QtGui import QMainWindow
from PyQt4.QtGui import QTextEdit
from PyQt4.QtGui import QMenu
from PyQt4.QtGui import QCursor
#PyQt4.QtGui imports
@mumumu
mumumu / sqlalchemy_snippet.py
Created January 7, 2014 11:13
sqlalchemy snippet.
#!/usr/bin/env python
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String
from sqlalchemy.orm import sessionmaker
engine = create_engine('sqlite:///:memory:', echo=True)
Session = sessionmaker(bind=engine)
Base = declarative_base()
@kokardy
kokardy / matplotlib_image_flowable.py
Created July 10, 2013 16:14
How to use reportlab.platypus.Image with PNG that is created by matplotlib.pyplot.save_figure function
from StringIO import StringIO
from PIL import ImageFileIO
import matplotlib.pyplot as plt
from reportlab.platypus import Image
buf = StringIO()
#plot your graphs
plt.save_figure(buf, format="png")
@harvimt
harvimt / alchemical_model.py
Created February 2, 2013 20:41
SQLAlchemy to/from PyQt Adapters
#!/usr/bin/env python2
#-*- coding=utf-8 -*-
# © 2013 Mark Harviston, BSD License
from __future__ import absolute_import, unicode_literals, print_function
"""
Qt data models that bind to SQLAlchemy queries
"""
from PyQt4 import QtGui
from PyQt4.QtCore import QAbstractTableModel, QVariant, Qt
import logging # noqa
@cgoldberg
cgoldberg / get_image_info.py
Last active August 18, 2023 02:05
validate and analyze dimensions of [PNG, JPG, GIF], image files in Python.
#!/usr/bin/env python
#
# Corey Goldberg, 2013
#
# Python 2.7
"""validate and analyze dimensions of image files. Supports: PNG, JPG, GIF."""
@okaram
okaram / blogroll.py
Created November 16, 2012 01:27
Python Blogroll
import feedparser
f=open('blogroll.html','w')
f.write("<html>\n<head>\n<title>Blogroll</title>\n</head>\n<body>");
blogs=["http://programminggenin.blogspot.com/feeds/posts/default","http://djangolearner.blogspot.com/feeds/posts/default"];
for blog in blogs :
feed=feedparser.parse(blog)
f.write('<a href="%s">%s</a>\n'% (feed.feed.link,feed.feed.title));
f.write('<ul>\n');
for e in feed.entries:
@chikuzen
chikuzen / vsenc.py
Last active March 27, 2016 21:06
vapoursynth sample
#vsenc.py
#coding: utf-8
import sys
from subprocess import Popen, PIPE
import vapoursynth as vs
x264_binary_path = 'D:/tools/x86/x264.exe'
avconv_binary_path = 'D:/tools/x86/avconv.exe'
@cgoldberg
cgoldberg / timer.py
Created June 16, 2012 23:06
Python Timer Class - Context Manager for Timing Code Blocks
#!/usr/bin/env python
#
# Python Timer Class - Context Manager for Timing Code Blocks
# Corey Goldberg - 2012
#
from timeit import default_timer
@mattupstate
mattupstate / app.py
Created March 15, 2012 19:08
Flask application configuration using an environment variable and YAML
os
from flask_extended import Flask
app = Flask(__name__)
app.config.from_yaml(os.join(app.root_path, 'config.yml'))