Skip to content

Instantly share code, notes, and snippets.

View cstrap's full-sized avatar
🐍

Christian Strappazzon cstrap

🐍
View GitHub Profile
@cstrap
cstrap / services.py
Created August 31, 2017 13:03 — forked from mixxorz/services.py
Django Service Objects
from django import forms
from django.core.exceptions import ValidationError
from django.db import transaction
class InvalidInputsError(Exception):
def __init__(self, errors, non_field_errors):
self.errors = errors
self.non_field_errors = non_field_errors
import asyncio
loop = asyncio.get_event_loop()
async def hello():
await asyncio.sleep(3)
print('Hello!')
if __name__ == '__main__':
loop.run_until_complete(hello())
@cstrap
cstrap / gui_automation_python.md
Last active July 31, 2017 14:01 — forked from diyan/gui_automation_python.md
Desktop GUI automation in Python

Desktop

UI Automation. Desktop. Python

GUI toolkit agnostic

autopy - simple, cross-platform GUI automation toolkit. MIT - https://github.com/msanders/autopy/

  • 432 stars, 102 forks, 2950 monthly downloads at 2015-05-13
@cstrap
cstrap / A slack_logger.py
Created July 28, 2017 09:39 — forked from DominikSerafin/01_info
Django Slack Logger
import requests
import json
import time
import math
from copy import copy
from django.conf import settings
from django.utils.log import AdminEmailHandler
from django.views.debug import ExceptionReporter
class SlackExceptionHandler(AdminEmailHandler):
@cstrap
cstrap / v-cloak.md
Created June 7, 2017 13:09 — forked from adamwathan/v-cloak.md
Useful CSS utilities for Vue.js cloaking

Handy helpers for controlling visibility of elements until Vue has compiled.

Use like:

<div v-cloak>
  <h1>
    <span class="v-cloak--inline">Loading...</span> <!-- Only displayed before compiling -->
    <span class="v-cloak--hidden">{{ post.title }}</span> <!-- Hidden until compiling is finished -->
 
@cstrap
cstrap / progressive-ace.htm
Created February 3, 2017 17:05 — forked from duncansmart/progressive-ace.htm
Integrating ACE Editor in a progressive way
<textarea name="my-xml-editor" data-editor="xml" rows="15"></textarea>
...
<textarea name="my-markdown-editor" data-editor="markdown" rows="15"></textarea>
...
<script src="//d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js"></script>
<script>
// Hook up ACE editor to all textareas with data-editor attribute
$(function () {
@cstrap
cstrap / slack_deploy_bot_template.py
Created August 23, 2016 09:49 — forked from achauve/slack_deploy_bot_template.py
Template of Slack bot for deployment
import logging
import os
import time
import traceback
# pip install slackclient
from slackclient import SlackClient
@cstrap
cstrap / sample_usage.py
Created June 23, 2016 13:00 — forked from luke14free/sample_usage.py
Simple type checked objects in Python
#!/usr/bin/env python
from type_checked_entities import entity_factory
Giraffe = entity_factory( # let's define what is a giraffe!
"giraffe",
name=str, # my name is a string
age=float, # my age is an int
eats=object, # I eat pretty much everything.
)
@cstrap
cstrap / data-uri.py
Created June 6, 2016 16:19 — forked from jsocol/data-uri.py
Give an image, get a data-uri
#!/usr/bin/env python
"""Command line script to convert a file, usually an image, into a data URI
for use on the web."""
import base64
import mimetypes
import os
import sys
@cstrap
cstrap / sudo.py
Created April 21, 2016 09:46 — forked from barneygale/sudo.py
import sys, marshal, functools, subprocess
child_script = """
import marshal, sys, types;
fn, args, kwargs = marshal.load(sys.stdin)
marshal.dump(
types.FunctionType(fn, globals())(*args, **kwargs),
sys.stdout)
"""