Skip to content

Instantly share code, notes, and snippets.

@jamesgecko
jamesgecko / log.txt
Created December 1, 2011 17:54
Blather traceback
D, [2011-12-01T11:52:43.152594 #19862] DEBUG -- : NEW JID: status@ais/blather
D, [2011-12-01T11:52:43.154074 #19862] DEBUG -- : SENDING: (/home/james/.rvm/gems/ruby-1.9.2-p290/gems/blather-0.5.9/lib/blather/stream/client.rb:21:in `start') <stream:stream to='ais' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en' >
D, [2011-12-01T11:52:43.157814 #19862] DEBUG -- :
------------------------------
D, [2011-12-01T11:52:43.157916 #19862] DEBUG -- : STREAM IN: <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='9b3094cb-0b64-4eda-9779-cbec3b26b5b7' from='ais' version='1.0' xml:lang='en'><stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism></mechanisms><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/><auth xmlns='http://jabber.org/features/iq-auth'/></stream:features>
D, [2011-12-01T11:52:43.158968 #19862] DEBUG -- : RECEIVING (str
@jamesgecko
jamesgecko / comet_clock.py
Created December 5, 2011 19:48
Twisted long polling
from twisted.internet import reactor, task
from twisted.web.server import Site
from twisted.web import server
from twisted.web.resource import Resource
import time
class ClockPage(Resource):
isLeaf = True
def __init__(self):
self.presence=[]
@jamesgecko
jamesgecko / sscce.py
Created December 8, 2011 20:45
Feed list
Unhandled Error
Traceback (most recent call last):
File "sscce.py", line 32, in <module>
reactor.run()
File "/usr/lib/python2.7/dist-packages/twisted/internet/base.py", line 1162, in run
self.mainLoop()
File "/usr/lib/python2.7/dist-packages/twisted/internet/base.py", line 1171, in mainLoop
self.runUntilCurrent()
--- <exception caught here> ---
File "/usr/lib/python2.7/dist-packages/twisted/internet/base.py", line 766, in runUntilCurrent
@jamesgecko
jamesgecko / winmanager.rb
Created January 30, 2012 16:06 — forked from mdnmdn/winmanager.rb
ironruby ActiveDirectory access
require 'System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
include System::DirectoryServices
class WinManager
attr_accessor :connection_string
if !defined? FLAG_CANNOT_CHANGE_PASSWORD
FLAG_CANNOT_CHANGE_PASSWORD = 0x40
FLAG_PASSWORD_NEVER_EXPIRES = 0x10000
@jamesgecko
jamesgecko / application.js
Created February 28, 2012 04:44 — forked from trevorturk/application.js
Ajax forms
$('.submittable').live('change', function() {
$(this).parents('form:first').submit();
});
<%= form_for([@customer, @phone]) do |f| %>
<% if @phone.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@phone.errors.count, "error") %> prohibited this phone from being saved:</h2>
<ul>
<% @phone.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
# app/models/phone.rb
class Phone < ActiveRecord::Base
# t.integer "customer_id"
# t.integer "number"
# t.integer "number_type"
belongs_to :customer
Number_type_choices = {0 => 'Home', 1 => 'Work', 2 => 'Cell'}
@jamesgecko
jamesgecko / attr.rake
Created March 5, 2012 18:16
Attribute visibility task
# TODO: this will fail when run on a project that uses namespaced models
desc "Show visibility of attributes"
task :attr => :environment do
require 'set'
models = Dir['**/models/**/*.rb'].map {|f| File.basename(f, '.*').camelize.constantize }
models.each do |m|
all = Set.new m.attribute_names
accessible = Set.new m.accessible_attributes.to_a
protected_ = Set.new m.protected_attributes.to_a
<%= semantic_form_for([@customer, @phone]) do |f| %>
<%= f.semantic_errors :state %>
<%= f.inputs do %>
<%= f.input :number, as: :string, input_html: { maxlength: 18 }%><br />
<%= f.input :extension, as: :number %><br />
<%= f.input :number_type, as: :select, collection: Phone.number_type_name_options %>
<% end -%>
<%= f.actions %>
<% end %>
@jamesgecko
jamesgecko / error
Created March 9, 2012 21:04
Vagrant permissions error
vagrant@lucid32:/vagrant$ rails new sample
create
/home/vagrant/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:247:in `mkdir': Permission denied - /vagrant/sample (Errno::EACCES)
from /home/vagrant/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:247:in `fu_mkdir'
from /home/vagrant/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:221:in `block (2 levels) in mkdir_p'
from /home/vagrant/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:219:in `reverse_each'
from /home/vagrant/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:219:in `block in mkdir_p'
from /home/vagrant/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:205:in `each'
from /home/vagrant/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:205:in `mkdir_p'
from /home/vagrant/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/actions/empty_directory.rb:51:in `block in invoke!'