Skip to content

Instantly share code, notes, and snippets.

View lehrblogger's full-sized avatar

Steven Lehrburger lehrblogger

View GitHub Profile

Keybase proof

I hereby claim:

  • I am lehrblogger on github.
  • I am lehrblogger (https://keybase.io/lehrblogger) on keybase.
  • I have a public key whose fingerprint is 0399 7EF1 E40D 3851 E43C 9C64 3358 452F FD86 E1CE

To claim this, I am signing this object:

@lehrblogger
lehrblogger / MVPython.py
Last active August 29, 2015 13:56
Following the tweets all the way down...
import urllib2
import BeautifulSoup
def follow_tweet(url):
print url
f = urllib2.urlopen(url).read()
s = BeautifulSoup.BeautifulSoup(f)
next = s.find('p', {'class': 'js-tweet-text tweet-text'}).find('a', {'class': 'twitter-timeline-link'}).get('data-expanded-url')
try:
follow_tweet(next)
def readAllFiles(fileNames: List[String]): Map[String, Map[String, Int]] = {
val wordsInFiles: List[(String, String)] = for {
filename <- fileNames
line <- filename.toFile.readLines()
word <- line.split("\\W+|\\d+")
} yield (word.toLowerCase.trim, filename)
val emptyMap: Map[String, Map[String, Int]] = Map.empty.withDefaultValue(Map.empty.withDefaultValue())
wordsInFiles.foldLeft(emptyMap) { case (map, (word, filename)) =>
@lehrblogger
lehrblogger / email to ejabberd list
Last active December 17, 2015 20:29
unicode troubles in ejabberd_xmlrpc
Hi,
I'm having trouble using unicode characters in roster item nicknames set
from Python using ejabberd_xmlrpc. Those nicknames work fine if I set them
from the command line using ejabberdctl add_rosteritem, but if
use add_rosteritem via xmlrpc, then the command returns as if it
succeeded... but the roster item is somehow corrupt. ejabberd throws errors
if I try to view the data using get_roster or the web admin interface, and
the user with the corrupt roster is also unable to log in.
@lehrblogger
lehrblogger / gist:4756566
Created February 11, 2013 18:45
XMPP stanzas sent to/from Adium when inviting two Gchat users to a group chat from a third Gchat user.
<presence to='private-chat-8eeeaa68-f541-4988-9c0f-f6c84120c3bf@groupchat.google.com/Steven Lehrburger'>
<c xmlns='http://jabber.org/protocol/caps' node='http://pidgin.im/' hash='sha-1' ver='VUFD6HcFmUT2NxJkBGCiKlZnS3M='/>
<x xmlns='http://jabber.org/protocol/muc'/>
</presence>
<presence xmlns='jabber:client' from='private-chat-8eeeaa68-f541-4988-9c0f-f6c84120c3bf@groupchat.google.com/Steven Lehrburger' to='adium_user@gmail.com/Adium1A4C7DC5'>
<user:x xmlns:user='http://jabber.org/protocol/muc#user'>
<user:item affiliation='owner' role='moderator' jid='adium_user@gmail.com/Adium1A4C7DC5'/>
<user:status code='100'/>
{hosts, ["example.com"]}.
{listen,
[
{5222, ejabberd_c2s, [
{access, c2s},
{shaper, c2s_shaper},
{max_stanza_size, 65536},
%%zlib,
starttls, {certfile, "/etc/ejabberd/ejabberd.pem"}
@lehrblogger
lehrblogger / xmlrpc_broken.py
Last active December 10, 2015 17:58
httplib error with gevent, and xmlrpclib (update: no longer requires sleekxmpp to repro)
# from geventhttpclient import httplib
# httplib.patch()
from gevent import monkey; monkey.patch_all()
import gevent
from time import sleep
import logging
import xmlrpclib
server = 'dev.vine.im'
logging.basicConfig(level=logging.DEBUG, format='%(asctime)-15s %(levelname)-7s - %(message)s')
service "supervisor" do
service_name "supervisor"
start_command "supervisord -c #{node['dirs']['supervisor']}/supervisord.conf"
stop_command "supervisorctl -c #{node['dirs']['supervisor']}/supervisord.conf stop"
status_command "supervisorctl -c #{node['dirs']['supervisor']}/supervisord.conf status"
restart_command "supervisorctl -c #{node['dirs']['supervisor']}/supervisord.conf restart"
reload_command "supervisorctl -c #{node['dirs']['supervisor']}/supervisord.conf reread && supervisorctl -c #{node['dirs']['supervisor']}/supervisord.conf update"
supports ({
:start => true,
:stop => true,
In my Chef cookbook:
["/home/vagrant/test", "/home/vagrant/test/subtest"].each do |dir|
Chef::Log.info(dir)
directory dir do
owner "vagrant"
group "vagrant"
mode 0644
recursive true
action :create
end
Expected process to exit with [0], but received '128'
---- Begin output of git ls-remote git@github.com:lehrblogger/myrepo.git mybranch ----
STDOUT:
STDERR: Warning: Permanently added 'github.com,207.97.227.239' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
---- End output of git ls-remote git@github.com:lehrblogger/myrepo.git mybranch ----
Ran git ls-remote git@github.com:lehrblogger/myrepo.git mybranch returned 128