Install Python
$ brew install readline sqlite gdbm
$ brew install python --universal --framework
$ python --version
Python 2.7
Symlinks...
Install Python
$ brew install readline sqlite gdbm
$ brew install python --universal --framework
$ python --version
Python 2.7
Symlinks...
Some of Django's choices on how to handle data integrity are wrong, or at the very least, unexpected to the uninitiated developers. I'm not here to pass judgement; like many people, I'd just like to get back to doing real work. Some notes on how to stay safe in Django:
is_valid()
performs model validation automaticallyfull_clean()
is never actually called by Django (see ticket #13100)Carrierwave recommends overriding store_dir
in the uploader, but it only gives you a way to modify the directory name, not the whole path with the file name. Overriding store_path
let's you modify the entire path.
def store_path(for_file = filename)
self.model.class.name.underscore.pluralize + "/" + self.model.slug + "/" + (version_name || :original).to_s + ".jpg"
end
This is the original:
<!doctype html > | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title></title> | |
</head> | |
<body> | |
<nav></nav> | |
</body> | |
</html> |
require 'flog' | |
require 'flog_task' | |
require 'flay' | |
require 'flay_task' | |
require 'roodi' | |
require 'roodi_task' | |
FlogTask.new :flog, SOME_NUMBER_HERE, %w[app lib] | |
FlayTask.new :flay, OTHER_NUMBER_HERE, %w[app lib] | |
RoodiTask.new 'roodi', ['app/**/*.rb', 'lib/**/*.rb'] |
require 'active_record' | |
require "#{Rails.root}/app/models/user" | |
describe User do | |
it "does something sweet" | |
it "does something cool" | |
end |
// jQuery Headers support for $.ajax | |
$.ajax({ | |
beforeSend: function(xhrObj){ | |
xhrObj.setRequestHeader("Content-Type","application/json"); | |
xhrObj.setRequestHeader("Accept","application/json"); | |
} | |
type: "POST", | |
url: "/article", | |
processData: false, |
One time: | |
git remote add upstream [email protected]:foo/bar.git | |
git fetch upstream | |
git checkout -b upstream upstream/master | |
Each time you want to update: | |
git checkout upstream | |
git pull |
#!/bin/sh | |
brew install python scons boost exiv2 | |
curl -O http://launchpadlibrarian.net/83595798/pyexiv2-0.3.2.tar.bz2 | |
tar xjvf pyexiv2-0.3.2.tar.bz2 | |
cd pyexiv2-0.3.2 | |
# https://answers.launchpad.net/pyexiv2/+question/140742 | |
echo "env['FRAMEWORKS'] += ['Python']" >> src/SConscript |
# Do you ever define #method_missing and forget #respond_to? I sure | |
# do. It would be nice if we could do them both at the same time. | |
module MatchMethodMacros | |
def match_method(matcher, &method_body) | |
mod = Module.new do | |
define_method(:method_missing) do |method_name, *args| | |
if matcher === method_name.to_s | |
instance_exec(method_name, *args, &method_body) | |
else |