Skip to content

Instantly share code, notes, and snippets.

View fabiocerqueira's full-sized avatar

Fabio Cerqueira fabiocerqueira

View GitHub Profile
@fabiocerqueira
fabiocerqueira / main.py
Last active March 2, 2018 11:45
environment variables
import subprocess
import os
os.environ['MY_SECRET'] = 'oi :D'
ret = subprocess.run(["python3.6", "sub.py"], stdout=subprocess.PIPE)
if 'MY_SECRET' in ret.stdout.decode('utf-8'):
print('pwned!')
@fabiocerqueira
fabiocerqueira / mymap.py
Last active February 6, 2018 22:56
example how map works(python3)
class mymap:
def __init__(self, func, seq):
self.func = func
self.seq = iter(seq)
def __iter__(self):
return self
def __next__(self):
@fabiocerqueira
fabiocerqueira / example2.py
Created January 17, 2017 22:53
Using splitted views
from django.template import engines
from django.http import HttpResponse
from PIL import Image
def image_view(request):
image = Image.new("RGB", (200, 200))
response = HttpResponse(content_type="image/png")
image.save(response, "PNG")
@fabiocerqueira
fabiocerqueira / example.py
Last active January 17, 2017 22:54
Example PIL image on template
import base64
import StringIO
from django.template import engines
from django.http import HttpResponse
from PIL import Image
def example(request):
{{ [].__class__.__base__.__subclasses__()[40]('app/views.py').read() }}
@fabiocerqueira
fabiocerqueira / ircbot_pyqt.py
Last active January 5, 2017 23:00
Example running bot on pyqt events
import asyncio
import sys
import logging
from pathlib import Path
from PyQt5 import QtWidgets, uic
from quamash import QEventLoop
from PyIRC.signal import event
from PyIRC.io.asyncio import IRCProtocol
@fabiocerqueira
fabiocerqueira / irc_echo_bot.py
Created January 5, 2017 15:41
Simple example running an echo bot on IRC using asyncio and quamash
import asyncio
import sys
import signal
import logging
from PyQt5.QtWidgets import QApplication
from quamash import QEventLoop
from PyIRC.signal import event
from PyIRC.io.asyncio import IRCProtocol
import sys
import asyncio
from PyQt5.QtWidgets import QApplication
from quamash import QEventLoop
app = QApplication(sys.argv)
loop = QEventLoop(app)
asyncio.set_event_loop(loop)
import asyncio
from collections import namedtuple
from functools import wraps
tasks = []
loop = asyncio.get_event_loop()
PeriodicTask = namedtuple('PeriodicTask', ['task', 'interval', 'start'])
@fabiocerqueira
fabiocerqueira / periodic.py
Created January 3, 2017 16:17
Simple example running python periodic python functions
import asyncio
from collections import namedtuple
from functools import wraps
tasks = []
loop = asyncio.get_event_loop()
PeriodicTask = namedtuple('PeriodicTask', ['task', 'interval', 'start'])