Skip to content

Instantly share code, notes, and snippets.

@daddz
daddz / admin.py
Created Aug 29, 2014
Django custom AUTH_USER_MODEL password as plaintext
View admin.py
## customauth/admin.py
from django.contrib import admin
from customauth.models import MyUser
admin.site.register(MyUser)
View models.py
class Foo(Model):
bars = ManyToManyField(Bar, related_name='foos', blank=True, null=True)
class Bar(Model):
name = CharField(unique=True)
# The process I know currently:
foo = Foo()
foo.save()
View Traceback
Traceback (most recent call last):
File "fail.py", line 10, in <module>
m_fail = MultipartEncoderMonitor.from_fields(fields=fields_fail)
File "/opt/active_version/lib/python2.7/site-packages/requests_toolbelt/multipart/encoder.py", line 297, in from_fields
encoder = MultipartEncoder(fields, boundary, encoding)
File "/opt/active_version/lib/python2.7/site-packages/requests_toolbelt/multipart/encoder.py", line 89, in __init__
self._prepare_parts()
File "/opt/active_version/lib/python2.7/site-packages/requests_toolbelt/multipart/encoder.py", line 171, in _prepare_parts
self.parts = [Part.from_field(f, enc) for f in fields]
File "/opt/active_version/lib/python2.7/site-packages/requests_toolbelt/multipart/encoder.py", line 383, in from_field
View user.rb
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
require 'rubygems'
require 'sinatra'
get '/' do
"Hello World"
end
@daddz
daddz / gist:215878
Created Oct 22, 2009
Rack::Lint::LintError at / rack.input #<StringIO:0x000000024c7348> does not have ASCII-8BIT as its external encoding
View gist:215878
# /usr/lib/ruby/gems/1.9.1/gems/rack-1.0.1/lib/rack/lint.rb: in assert
11.
12. # :stopdoc:
13.
14. class LintError < RuntimeError; end
15. module Assertion
16. def assert(message, &block)
17. unless block.call
View gist:215903
module Foo
get '/foo' do
"Hello from Foo"
end
end
class Bar < Sinatra::Base
include Foo
get '/' do
View System
Ubuntu 10.04
Kernel Linux 2.6.32-21-generic
View datamapper gems
data_mapper (1.0.2)
data_objects (0.10.2)
datamapper (1.0.2)
dm-aggregates (1.0.2)
dm-constraints (1.0.2)
dm-core (1.0.2)
dm-do-adapter (1.0.2)
dm-migrations (1.0.2)
dm-serializer (1.0.2)
dm-sqlite-adapter (1.0.2)
View gist:778713
CURLM *curl;
static void foo_cb(const char *data, const char *moredata) {
struct curl_httppost *post = NULL;
struct curl_httppost *last = NULL;
CURL *handle;
handle = curl_easy_init();
curl_formadd(&post, &last,
View config.ru
require './rack_auth_digest'
run Protected.app