Skip to content

Instantly share code, notes, and snippets.

View pjz's full-sized avatar

Paul Jimenez pjz

View GitHub Profile
"""
Using a class decorator
Usage:
@Actorize
class Hello(Actor):
@handle(SomeMessageClass)
def somemethod(self, msg, sender):
"""
Replaced by https://github.com/godaddy/Thespian/blob/master/contrib/websocket.py
"""
import random
def tosses_until(s):
tosses = ''
while not tosses.endswith(s):
tosses += random.choice('HT')
return len(tosses)
TRIALS = 10000
@pjz
pjz / RegistryActor.py
Created March 11, 2016 15:38
Another take on message handler registration
"""
RegistryActor - a dict-based dispatcher for actors
Usage:
from .actors import RegistryActor
class Hello(RegistryActor):
def __init__(self):
super(self.__class__, self).__init__()
@pjz
pjz / actors.py
Last active March 10, 2016 16:30
ActorHandler helper module
"""
ActorHandler - class-based dispatch for actors
Usage:
from thespian.actors import Actor
handler = ActorHandler()
class Hello(Actor):
#!./goscript
package main
import (
"fmt"
"os"
)
func main() {
fmt.Println("hello");
@pjz
pjz / gist:166b28ef0b7b2b782cf2
Last active August 29, 2015 14:11
lwip httpclientfetch url hack
static char* ICACHE_FLASH_ATTR findUrlPathStart(char *url) {
int i = 7; // skip 'http://'
while (url[i] != '/') { i++; }
return &url[i];
}
void ICACHE_FLASH_ATTR httpClientFetch(char *url, int retbufsz, void (*cb)(char*)) {
static struct espconn conn;
static ip_addr_t ip;
char *hcserver = url[7]; // skip 'http://'

Keybase proof

I hereby claim:

  • I am pjz on github.
  • I am pjz (https://keybase.io/pjz) on keybase.
  • I have a public key whose fingerprint is 6B5E E345 00C0 73D0 2B56 55C4 1F2F D328 D987 D2AE

To claim this, I am signing this object:

@pjz
pjz / docker-start-huginn
Last active February 12, 2021 03:17
An idempotent start script for huginn under docker
#!/bin/bash
## these need to be set
# initial account credentials
SEED_USER=admin
SEED_PASS=password
# required for new users to be able to sign up ; default to something random
INVITATION_CODE=`dd if=/dev/urandom bs=1024 count=1 | md5sum -`
@pjz
pjz / fakemoduletest.py
Created May 11, 2013 03:47
make something show up as a module to some supplied code you're going to exec
src = """
from fakemodule import fakefunc
fakefunc()
print dir()
"""
def call_with_fakemodule(usersrc):
class fmod(object):
@staticmethod