Skip to content

Instantly share code, notes, and snippets.

View wichert's full-sized avatar

Wichert Akkerman wichert

View GitHub Profile
@wichert
wichert / iq_roster.go
Created December 19, 2019 09:26
go-xmpp roster
package stanza
import (
"encoding/xml"
"gosrc.io/xmpp/stanza"
)
const NSRoster = "jabber:iq:roster"
@wichert
wichert / xmppjs-rn.js
Last active December 4, 2019 08:29
React Native / xmppjs test
import React, { useEffect, useState } from "react";
import { AppState, StyleSheet, Text, View, Button } from "react-native";
import { client } from "@xmpp/client/react-native";
import xml from "@xmpp/xml";
const CREDENTIALS = [
{
name: "Arwen",
username: "4h9rd2yd3t58fbwxe257rvjd6",
password: "S7yZBsDIe7boi6ruVhhioGHzM6YW6vboMnmlguS5BUU="
import logging
import os
from pyramid.httpexceptions import WSGIHTTPException
from pyramid.tweens import EXCVIEW
from raven import Client
from raven import fetch_package_version
from raven.utils.wsgi import get_environ
try:
from raven.contrib.celery import register_signal, register_logger_signal
import celery # NOQA
@wichert
wichert / celery.py
Last active March 23, 2018 12:51
Pyramid / celery integration example
import os
import sys
import venusian
import jzoo.tasks as jzoo_tasks
from celery import Celery
from celery import signals
from celery.bin import Option
from pyramid.paster import bootstrap, get_appsettings
from pyramid.scripting import prepare
import transaction
@wichert
wichert / ably.js
Created November 21, 2017 10:39
Ably connection setup
// @flow
import * as Ably from 'ably'
import type Channel from 'ably/common/lib/client/channel'
import type ConnectionStateChange from 'ably/common/lib/client/connectionstatechange'
// import type ErrorInfo from 'ably/common/lib/types/errorinfo'
import winston from 'winston'
import EventEmitter from 'events'
type AuthHeaders = {[string]: string}
@wichert
wichert / README.md
Created March 3, 2017 17:01
python async subprocess test

To run the example:

python3 server.py &
python3 client.py

I would expect the output to look like this:

@wichert
wichert / mac.py
Created January 25, 2016 12:44
Python example for http://macvendors.co/
>>> import pprint
>>> import requests
>>> MAC_URL = 'http://macvendors.co/api/%s'
>>> r = requests.get(MAC_URL % 'BC:92:6B:A0:00:01')
>>> pprint.pprint(r.json())
{'result': {'address': '1 Infinite Loop Cupertino CA US 95014 ',
'company': 'Apple, Inc.',
'mac_prefix': 'BC:92:6B'}}
@wichert
wichert / cookie.py
Created May 19, 2016 12:07
Better cookie handling for Pyramid
@wichert
wichert / form-example.html
Created November 30, 2012 09:55
WTForms and pyramid integration
<form id="loginForm" method="post" action="${request.route_url('login')}">
<input type="hidden" name="csrf_token" value="${request.session.get_csrf_token()}"/>
<fieldset class="concise">
<metal:field tal:define="name 'came_from'" use-macro="snippets['hidden']"/>
<metal:field tal:define="name 'login'" use-macro="snippets['text']"/>
<metal:field tal:define="name 'password'" use-macro="snippets['password']"/>
</fieldset>
<div class="buttonBar">
<button type="submit" class="default" i18n:translate="">Login</button>
</div>
@wichert
wichert / pqxx.cc
Last active December 17, 2015 16:09
Minimal uuid and HSTORE support for pqxx
#include <boost/algorithm/string/join.hpp>
#include <boost/format.hpp>
#include <boost/regex.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <stylist/private/pqxx.hh>
using namespace std;