It's also supposed to snow a lot so school was canceled for today, so I decided to sulk by coding all day. Bletch, take that course 2. Or something. XD; There's a course, 6.170 (no, not your grandmother's 6.170, which was toned down into today's 6.005; this is now software development principles through the view of web app dev apparently) which I might follow along with. It's taught in ruby this year, but it was taught in flask last year so there's some nice material on stellar. http://stellar.mit.edu/S/course/6/sp12/6.170/materials.html
I'm now following this cool step-by-step tutorial, http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world.
*** why isn't this a one-step process. oh holy robots f*** this is a crappy state of affairs that this takes me several hours to set up properly.
=__=''
OKAY.
So.
Starting over.
1) make pretty bash terminal (with colors).
in ~/.bashrc, comment out #force_color_promptthen in ~/.bash_profile, add the line:
source ~/.bashrc
2) make pretty vi.
http://sontek.net/blog/detail/turning-vim-into-a-modern-python-ideI chose not to use the install.sh script *shudders* It's hard to undo and puts an insanely long .vimrc that I can't understand onto my computer. So I followed the instructions
1. make ~/.vim directory
2. download pathogen, I kept forgetting to do this
3. add a gazillion plugins with git submodule add, as directed
3) ugh escape key = caps lock
http://stackoverflow.com/questions/397229/reaching-up-to-hit-the-escape-key-sucks-especially-in-vim4) backup dotfiles on github
http://blog.smalleycreative.com/tutorials/using-git-and-github-to-manage-your-dotfiles/...except, I just want that .vimrc file, so yea. I should stop using install scripts I don't read through. *sigh*
5) update minibufexp
using https://github.com/fholgado/minibufexpl.vim.git
http://stackoverflow.com/questions/14404704/how-do-i-replace-a-git-submodule-with-another-repo
instead of https://github.com/sontek/minibufexpl.vim.git bundle/minibufexpl
note! http://stackoverflow.com/questions/8953777/vim-not-an-editor-command-minibufexplorer
Sometimes window arrangement gets messed up, so use
:vertical resize 20
to get unmaximized tree explorer back.
Now, back to flask
http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world~ note: python run.py doesn't work; have to do ./run.py (?).
part V
http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-v-user-loginsIf you try to run this code, there are import errors
ImportError: No module named openid
Appparently since Grinberg wrote his post, the pip install flask version is >= 0.8, so the syntax is now from
from flask.ext.login import LoginManager
instead of
See http://flask.pocoo.org/docs/extensions/ (I arrived there from this postfrom flaskext.login import LoginManager
https://github.com/mitsuhiko/flask/issues/421)
resetting from zip file
Mm. At this point, I just downloaded the microblog-0.5 zip file, unzipped, did the whole virtualenv / pip install flask ordeal, ran ./db_create.py and ./db_migrate.py, and everything is now dandy.part VI.
I didn't have an image for my email address (well, I'd used plus addressing when signing up for Gravatar but not when signing into the google openID thing, and I didn't feel like restarting my browser to disassociate myself from the google openID thing). The gravatar took a few seconds to update. To check the code was working, I used
flask/bin/pythonThis spits out
u = Users.from app import db, models
n = users[0] #In my case, when I print, I get
'http://www.gravatar.com/avatar/' + md5(n.email).hexdigest() + '?d=mm&s='
'http://www.gravatar.com/avatar/79424cef70fbb561ff50512c2c03334f?d=mm&s'
which worked just fine in the browser, and upon refreshing the app, showed up in the app as well instead of the mystery-man human outline icon.
Well. Now I know why all those silly web-apps make me sign up for gravatar instead of letting me upload pictures. Because it's easier to use someone else's service...
Hmm, speaking of which. Adding facebook is surprisingly not so straightforward. Apparently it doesn't play as nicely with openID (they're not a provider). Drats, time to make more openIDs.
http://stackoverflow.com/questions/10083319/facebook-openid
part vii
http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-vii-unit-testingI was kind of confused by this part (he explains in more detail later), but keeping the None values works and you can enter whatever into the email address for the admins list.
nrw@ubuntu:~/Dropbox/mblog $ sudo python -m smtpd -n -c DebuggingServer localhost:25This is pretty nifty! I'm doing the viewing emails in terminal thing. Sorry all you all pine users, but this is a novelty to me.
---------- MESSAGE FOLLOWS ----------
From: no-reply@localhost
To: you@example.com
Subject: microblog failure
Date: Sat, 09 Feb 2013 15:09:04 -0000
X-Peer: 127.0.0.1
Exception on /edit [POST]
Traceback (most recent call last):
File "/home/nrw/mblog/flask/local/lib/python2.7/site-packages/flask/app.py", line 1687, in wsgi_app
[...]
IntegrityError: (IntegrityError) column nickname is not unique u'UPDATE user SET nickname=?, about_me=? WHERE user.id = ?' (u'dup', u'', 2)
------------ END MESSAGE ------------
...okay I get bored and skip to the section I actually care about, the CSS section.
XII
http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xii-faceliftOr more specifically, https://github.com/miguelgrinberg/microblog/commit/56d1d46326a79d9a3b9b6178ac02fe75c89625ad.
Really? That's all there was to it? The transformation is really nice.
Customizing bootstrap
http://antjanus.com/blog/web-design-tips/user-interface-usability/customize-twitter-bootstrap-into-themes/Final conclusion:
bleah all that, let's just use the internet.http://www.boottheme.com/#generatetheme
==============
holy hexapods, ignore the following,
=============
because I decided to startover. which involved doing the cd ~/dotfiles, ./install.sh restore, then also doing the ls -la and removing all the remaining symlinks, which looked likesudo rm .weechat .Xdefaults .xmonad .screenrc .pythonrc.py .pdbrc .pdbrc.py .mutt .msmtprc .inputrc .hgrc .gimp .fonts .dir_colors
...
oh robutts what is my life. this is why I'm not course 6.
===
vim + python
I had an intermediate step where I realized I should probably fix up vi so, y'know, it actually behaves acceptably with python (like recognizing tabs and such).
http://sontek.net/blog/detail/turning-vim-into-a-modern-python-ide
*blinks* I'm still a bit confused, since I followed the instructions instead of just using the install script. Not actually being course 6, I'm not sure which parts of my ~/.vimrc folder I should put up on a git server (github). *shrug* I can always recreate it now. (I lost my dotfiles after google summer of code '11 and missed them for a while). https://github.com/nouyang/dotfiles
Yuck. Ignore previous paragraph. I can't get the leader key to work. (What is that leader thing? Turns out
The symptoms look like this. also relevant, following this gal's example I just reinstall everything.
So, I end up removing my entire .vim folder and reinstall with the sontek install script. Which requires I install ruby first... Whoops, it says rake: command not found.
later: on the leaderkey (set as a comma) not working
...for some reason,nnoremap : ;
makes the leaderkey not work! wtf ?__? computers.
installing ruby on ubuntu
Conveniently enough, 6.170 sp13 is taught in ruby so I get this link off the slides.curl -Sso ./rails-installer.sh https://raw.github.com/rkjha/RailsOnUbuntu/master/rails-installer.sh(I downloaded the non-raw file first by accident). And following the rest of the instructions, 15 minutes later, after restarting gnome-terminal, I'm set.
rails new helloworldThen I visit http://127.0.0.1:3000/ and see a "welcome to ruby" page. yay.
cd helloworld
rails server
Other notes / things I add...
Okay, excellent, now I have lots of things installed on my computer and insanely long dotfiles I don't understand... Oh well. Some further notes and modifications:(With following tutorials, as usual, I have to remember to
:set pasteOr else each line I paste in with ctrl-shift-v gets indented.
Apparently the reason is that the terminal can't tell pasting from a lot of text being typed in at once.)
http://phuzz.org/vimrc.html
"Common command line typos
cmap W w
cmap Q q
http://stackoverflow.com/questions/164847/what-is-in-your-vimrc
" Swap ; and : Convenient.
nnoremap ; :
nnoremap : ; "NOTE: Holy crap this breaks thekey. take this line out.
" Spaces are better than a tab character
set expandtab
set smarttab
" Who wants an 8 character tab? Not me!
set shiftwidth=4
set softtabstop=4
" This is totally awesome - remap jj to escape in insert mode. You'll never type jj anyway, so it's great!
inoremap jj <Esc>nnoremap JJJJ <Nop>
"{{{ Paste Toggle
let paste_mode = 0 " 0 = normal, 1 = paste
func! Paste_on_off()
if g:paste_mode == 0
set paste
let g:paste_mode = 1
else
set nopaste
let g:paste_mode = 0
endif
returnii
endfunc
"}}}
" Paste Mode! Dang!<silent> <F12>
nnoremap:call Paste_on_off()
set pastetoggle=<F12>
NOTE: If you are in paste mode, the "jj
Sontek mentions buffers versus tabs, and last time I only ever used tabs, so I read up on this here:
http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers/103590#103590
http://nvie.com/posts/how-i-boosted-my-vim/
set hiddenOh, and I turn off line numbers and displaying all the whitespace by commenting out the set list and the set number in ~/.vimrc.
other things to read:
http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim
So now, some of the shortcuts I can use:
:e to open a buffer, and ctrl-6 or :b1 to go to whichever buffer is open.
>> and << for indenting
:x to save and close (NOTE! I have, as mentioned, mapped ; to :)
:nmap to look at my shortcuts
resetting .bashrc for ubuntu, not mac
Meh, as usual with the internet, the .bashrc on sontek's site is for mac osx and not ubuntu. I wanted to color my prompt, so I reverted to the default .bashrchttps://gist.github.com/marioBonales/1637696
Note that thanks to using the install script, I have a bunch of symlinks and the file I actually want to edit is ~/dotfiles/_bashrc ...
and uncommented the "force_color_prompt = yes" line. Then I ran
source ~/.bashrc
to force reload the file and voila! color! yay. See https://help.ubuntu.com/community/CustomizingBashPrompt if you don't know what I'm talking about, although note there are typos in that (e.g. they have color_prompt instead of force_color_prompt)
back to flask / jinja
lol. that took forever and a few inches of snow. It's now... 1900. and snow's supposed to get heavy around 9pm. Okay! Time to get going.==
/note to self: productive = keep door open and headphones in. otherwise, i feel jittery with the door open for some reason, I close it, and then I fall asleep in an unmotivated heap. =__=;; derp hopefully this too will pass with time. also, being productive feels nice, no matter what particular item i choose to finish on #infiniteprojectlist.
Also, an interesting way to keep track of time passing (usually I use onlinevideoclock.com or tomatoi.st), set my netbook to go to sleep every 30 minutes and use it to play music while working on my desktop.
No comments:
Post a Comment