Skip to content

Instantly share code, notes, and snippets.

View cyraxjoe's full-sized avatar

Joel Rivera cyraxjoe

View GitHub Profile
import sys
import socket
def client(*bparams):
s = socket.socket()
s.connect(bparams)
return s
def server(*bparams):
s = socket.socket()
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../paper-item/paper-item.html">
@cyraxjoe
cyraxjoe / BadButtons.py
Created April 15, 2011 21:53
Pyjamas button bug in webkit
from pyjamas.ui.SimplePanel import SimplePanel
from pyjamas.ui.FormPanel import FormPanel
from pyjamas.ui.Button import Button
from pyjamas.ui.VerticalPanel import VerticalPanel
from pyjamas.ui.RootPanel import RootPanel
from pyjamas.ui.TextBox import TextBox
from pyjamas import Window
class BadButtons(FormPanel):
@cyraxjoe
cyraxjoe / cp_multihandler.py
Created December 22, 2012 00:41
Idea of multiple objects embedded in one class to use a particular handler depending on the Accept header.
import cherrypy
class MultiViewHandler(object):
def __new__(cls):
"""Do something to be able to use the right view to the
right Accept header
"""
class SpecialDispatcher(cherrypy.dispatcher.Dispatcher)
"""Custom dispatcher to use the special properties of the
@cyraxjoe
cyraxjoe / cp_multiview_demo.py
Last active December 10, 2015 01:34
Sample code to implement multiple views/handlers depending on the Accept and Content-Type headers.
from contextlib import contextmanager
import cherrypy
from cherrypy.lib import cptools
class View(object):
__mime__ = 'text/html'
def __init__(self, controller):
@cyraxjoe
cyraxjoe / cp_execute_in_main_thread.py
Created March 12, 2016 02:40
Execute a callable on the MainThread from a CherryPy application.
import threading
import functools
import cherrypy as cp
class MainExecutor:
"""Wrap a callable to ensure that the execution takes place on the
MainThread based on the cherrypy.engine and the 'main' channel.
from __future__ import print_function
class BaseA(object):
def __init__(self):
self.a = "A"
class BaseB(object):
@cyraxjoe
cyraxjoe / lines_in_code.py
Last active February 19, 2018 19:56
Lines in code demo for potential use un flake8 plugin
import ast
func_code = """
def test():
foo = 1
bar = 2
return foo + bar
"""
tree = ast.parse(func_code)
#!/usr/bin/env bash
#
# Descarga el zip con los certificados raiz del SAT de:
# http://omawww.sat.gob.mx/informacion_fiscal/factura_electronica/Paginas/certificado_sello_digital.aspx
#
# Para usar el script ponlo en la raiz del directorio extraido de Cert_Prod.zip.
#
# Ejecuta con:
# bash ./create-hashes.sh <TARGET-DIR>
#

Keybase proof

I hereby claim:

  • I am cyraxjoe on github.
  • I am cyraxjoe (https://keybase.io/cyraxjoe) on keybase.
  • I have a public key ASBk1dRF0gdkIcVFORqKWwSqxVUZKBge92AgSFRPqNwwfAo

To claim this, I am signing this object: