Skip to content

Instantly share code, notes, and snippets.

View IuryAlves's full-sized avatar

Iury Alves de Souza IuryAlves

View GitHub Profile
@IuryAlves
IuryAlves / mocking_condition.py
Last active February 10, 2017 20:20
Mock something only if condition applies.
# coding: utf-8
import functools
def _mock_condition(condition, *args, **kwargs):
return condition(*args, **kwargs)
def mock_condition(condition):
@IuryAlves
IuryAlves / name_mangling.py
Last active December 11, 2016 23:41
Simple example to explain name mangling in python.
# coding: utf-8
class Image(object):
def __format(self):
return 'PNG'
image = Image()
# -*- coding: utf-8 -*-
# django command to check if a url return a status != 2xx
import sys
import json
import aiohttp
import asyncio
from django.core.management.base import NoArgsCommand
@IuryAlves
IuryAlves / vlc.py
Last active December 5, 2016 14:58
# coding: utf-8
import os
import sys
import commands
import codecs
import time
import subprocess
musica_process_output = subprocess.check_output("tasklist /V /FO list /FI \"IMAGENAME eq vlc.exe\"", shell=False)
#!/usr/bin/env python
# coding: utf-8
### REQUIREMENTS ###
# * python 3.5+
# * aiohttp (pip install aiohttp)
import argparse
import os
.frontend {
margin: nelson
}
# coding: utf-8
'''
Para rodar
python3 markdown_to_json.py file1 file2
'''
import json
import sys
from flask.ext.login import current_user
@api.resource('/user/logged')
class Logged(Resource):
def get(self):
try:
return {"logged": current_user.to_dict()}
except AttributeError:
{"id": 1}
# coding: utf-8
"""
Instale:
pip install sounddevice
pip install soundfile
baixe esse arquivo de audio e renomeie para: audio.ogg
https://upload.wikimedia.org/wikipedia/en/9/9f/Sample_of_%22Another_Day_in_Paradise%22.ogg
"""