forked from alexgaribay/octoflat
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
242 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#dansteadman.com | ||
# dansteadman.com | ||
|
||
Running Octopress ([Docs](http://octopress.org/docs/blogging/)) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,4 @@ | |
@import "solarized"; | ||
@import "syntax"; | ||
@import "quotes"; | ||
@import "custom/styles"; | ||
@import "custom/styles"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
--- | ||
layout: post | ||
title: "installing ngx_pagespeed" | ||
date: 2013-12-13 11:23 | ||
comments: true | ||
categories: | ||
--- | ||
|
||
I recently gave the ngx_pagespeed module a whirl. Installation was on a RHEL5 server | ||
|
||
###RESOURCES | ||
|
||
- [Github](1) | ||
- [Google Developers](2) | ||
- [Passenger][3] (Building nginx from source with Passenger module) | ||
|
||
**WARNING:** Instructions cite old versions of passenger/nginx. | ||
|
||
- Latest nginx version : [here][6] | ||
- Latest passenger version : gem install passenger | ||
|
||
- [NGINX Docs][4] (for installing third party modules) | ||
|
||
###Instructions (paraphrasing from above sources) | ||
|
||
1. Download ngx_pagespeed: | ||
|
||
$ cd ~ | ||
$ wget https://github.com/pagespeed/ngx_pagespeed/archive/v1.7.30.1-beta.zip | ||
$ unzip v1.7.30.1-beta.zip # or unzip v1.7.30.1-beta$ cd ngx_pagespeed-1.7.30.1-beta/ | ||
$ wget https://dl.google.com/dl/page-speed/psol/1.7.30.1.tar.gz | ||
$ tar -xzvf 1.7.30.1.tar.gz # expands to psol/ | ||
|
||
2. Download and build nginx: | ||
|
||
$ # check http://nginx.org/en/download.html for the latest version | ||
$ wget http://nginx.org/download/nginx-1.4.3.tar.gz | ||
$ tar -xvzf nginx-1.4.3.tar.gz3) | ||
|
||
3. Set PASSENGER_NGINX_DIR env variable | ||
|
||
export PASSENGER_NGINX_DIR=\`passenger-config --root\`/ext/nginx | ||
4. Install Passenger gem (compiler uses this to build nginx with the passenger module) | ||
|
||
$ gem install passenger && gem clean # gem clean to remove older versions of passenger. | ||
|
||
5. Set build flags | ||
|
||
$ cd nginx-1.4.3/ | ||
$ ./configure --add-module=$HOME/ngx_pagespeed-1.7.30.1-beta —add-module=$PASSENGER_NGINX_DIR5. | ||
explore more potential modules [here][4]. | ||
|
||
If you add more modules you’ll have to include them with —add-module=XXXX in your ./configure command. | ||
There are more options for ./configure which you’ll have to figure out for your specific build | ||
|
||
#####Example: | ||
__WARNING: Don’t just copy/paste this block!__ | ||
|
||
$ ./configure \ | ||
--prefix=/usr/local \ | ||
--sbin-path=/usr/local/sbin \ | ||
--conf-path=/etc/nginx/nginx.conf \ | ||
--error-log-path=/var/log/nginx/error.log \ | ||
--http-log-path=/var/log/nginx/access.log \ | ||
--with-http_ssl_module \ --with-http_gzip_static_module \ | ||
--add-module=$PASSENGER_NGINX_DIR \ --with-pcre=$PCRE_DIR \ | ||
--with-http_sub_module | ||
|
||
|
||
After you get all your modules figured out, | ||
|
||
$ make && make install | ||
|
||
Since I already had a version of passenger installed (from source) at /opt/nginx, I shutdown the current nginx `sudo /etc/init.d/nginx stop` moved the entire directory `mv nginx nginx_old` and set the `--prefix=/opt/nginx` build flag. | ||
|
||
After compilation | ||
|
||
mv /opt/nginx/conf /opt/nginx/clean_conf # (our newly built nginx) | ||
cp -r /opt/nginx_old/conf /opt/nginx | ||
|
||
Since we're using the same location, our `/etc/init.d/nginx` script doesn't need to be updated. | ||
|
||
### Post-Installation | ||
|
||
1. Add [ngx_pagespeed options][5] to your nginx.conf | ||
|
||
pagespeed on; | ||
pagespeed FileCachePath /var/ngx_pagespeed_cache; # Use tmpfs for best results. | ||
2. In every server block where pagespeed is enabled add: | ||
|
||
# Ensure requests for pagespeed optimized resources go to the pagespeed | ||
# handler and no extraneous headers get set. | ||
|
||
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { add_header "" ""; } | ||
location ~ "^/ngx_pagespeed_static/" { } | ||
location ~ "^/ngx_pagespeed_beacon$" { } | ||
location /ngx_pagespeed_statistics { allow 127.0.0.1; deny all; } | ||
location /ngx_pagespeed_global_statistics { allow 127.0.0.1; deny all; } | ||
location /ngx_pagespeed_message { allow 127.0.0.1; deny all; } | ||
location /pagespeed_console { allow 127.0.0.1; deny all; } | ||
|
||
To confirm that the module is loaded, fetch a page and check that you see the X-Page-Speed header: | ||
|
||
$ curl -I 'http://localhost:8050/some_page/' | grep X-Page-Speed # => X-Page-Speed: 1.7.30.1-... | ||
|
||
[1]: https://github.com/pagespeed/ngx_pagespeed | ||
[2]: https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source | ||
[3]: http://extralogical.net/articles/howto-compile-nginx-passenger.html | ||
[4]: http://wiki.nginx.org/3rdPartyModules | ||
[5]: https://github.com/pagespeed/ngx_pagespeed#how-to-use | ||
[6]: http://nginx.org/en/download.html |
56 changes: 56 additions & 0 deletions
56
source/_posts/2013-12-14-installing-oracle-instantclient-on-osx.markdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
layout: post | ||
title: "Installing Oracle InstantClient on OSX" | ||
date: 2013-12-14 01:09 | ||
comments: true | ||
categories: | ||
--- | ||
|
||
This was done on Mac OSX 10.9 Mavericks using XCode 5.0.2. Some parts paraphrased from [here](http://www.cs.utexas.edu/~mitra/csSpring2012/cs327/cx_mac.html) | ||
|
||
###Download and prepare Oracle Instant Client | ||
|
||
[Download](http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html) Instant client and SDK | ||
|
||
- instantclient-basiclite-macos.x64-11.2.0.3.0.zip (25,674,645 bytes) | ||
- instantclient-sdk-macos.x64-11.2.0.3.0.zip (460,550 bytes) | ||
|
||
**NOTE :** They both unzip to the same file name. Depending on which order you unzip in you'll get two directories called | ||
`instantclient_11_2` and `instantclient_11_2 2`. Rename them to something less confusing. I renamed to `instantclient` and `instantclient_sdk` respectively. | ||
|
||
Create environment variables in .bashrc || .zshrc || .profile || .wherever | ||
|
||
export ORACLE_HOME=/Users/[your-username]/oracle/instantclient_11_2 | ||
export DYLD_LIBRARY_PATH=$ORACLE_HOME | ||
export LD_LIBRARY_PATH=$ORACLE_HOME | ||
$ source ~/.bashrc | ||
$ echo $ORACLE_HOME # => /Users/[your-username]/oracle/instantclient_11_2 | ||
|
||
###Download and prepare cx_Oracle | ||
|
||
Download cx_Oracle [Source Code only](http://prdownloads.sourceforge.net/cx-oracle/cx_Oracle-5.1.2.tar.gz?download) package. (version 5.1.2 as of this writing) | ||
|
||
Other versions can be found [here](http://cx-oracle.sourceforge.net/) | ||
|
||
$ tar xf cx_Oracle-5.1.2.tar.gz # => yields cx_Oracle-5.1.2/ | ||
$ cp -r instantclient_sdk/sdk/include cx_Oracle-5.1.2 | ||
$ cd cx_Oracle-5.1.2 # should have all the *.c files from sdk in here | ||
|
||
If you open any of these files you'll notice that headers follow the <angles> format for includes (`#include <whatever.c>`). Mavericks/XCode uses the clang compiler, which requires double-quoted includes (`#include "whatever.c"`), so we need to do a global find/replace on all the required C files, changing include lines to this format. I used TextMates search/replace feature. | ||
|
||
**FIND :** include <(.*)> | ||
**REPLACE :** include "$1" | ||
|
||
$ python setup.py build install | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
layout: post | ||
title: "shell_plus primer" | ||
date: 2013-12-18 02:33 | ||
comments: true | ||
categories: | ||
--- | ||
|
||
* Import a model and give it an alias | ||
|
||
from apps.news.models import Article as NewsArticle | ||
|
||
* Print all attributes of an object | ||
|
||
authors = article.authors_set.values_list('name', flat=True) | ||
|
||
* Get object with all relations | ||
|
||
props = Property.objects.select_related().all() | ||
|
||
|
||
_this will get all properties and join all foreign keys to them so you don't have to hit the database again for a nested relation_ | ||
[There are Caveats](http://timmyomahony.com/blog/misconceptions-select_related-in-django/) | ||
|
||
* Inspect anything | ||
|
||
help(object) | ||
_pretty prints all stuff about an object_ | ||
|
||
* Returning collections (as opposed to single records) | ||
|
||
Property.objects.filter(p_type="O") | ||
|
||
* Inspect the SQL that fetched the queryset | ||
[more info](http://stackoverflow.com/questions/4720079/django-query-filter-with-variable-column) | ||
|
||
units = Unit.objects.filter(is_available=True, **{'u_property__p_type':'p_type_abbr'}) | ||
print units.query | ||
* The double __ syntax | ||
|
||
u_property__p_type == u_property.p_type | ||
_this is equivalent to the '.' in ActiveRecord, which is great for filtering based on assications_ | ||
_NOTE: Make sure to load the associations so you don't trigger an N+1 query_ | ||
|
||
* Pretty Printing in Shell | ||
|
||
>>> import pprint | ||
>>> pp = pprint.PrettyPrinter(indent=4) | ||
>>> pp.pprint(stuff) | ||
* Migrations [docs](http://south.readthedocs.org/en/latest/commands.html) | ||
|
||
python manage.py schemamigration <app_name> --auto | ||
|