From d21a381e9c727967c5f7af485ff30ca6c293ad2e Mon Sep 17 00:00:00 2001 From: Dan Steadman Date: Tue, 4 Feb 2014 06:09:08 -0800 Subject: [PATCH] added some posts --- readme.md | 2 +- sass/_syntax.scss | 26 ++-- sass/screen.scss | 2 +- .../_posts/2013-12-13-ngx-pagespeed.markdown | 115 ++++++++++++++++++ ...lling-oracle-instantclient-on-osx.markdown | 56 +++++++++ .../2013-12-18-shell-plus-primer.markdown | 56 +++++++++ 6 files changed, 242 insertions(+), 15 deletions(-) create mode 100644 source/_posts/2013-12-13-ngx-pagespeed.markdown create mode 100644 source/_posts/2013-12-14-installing-oracle-instantclient-on-osx.markdown create mode 100644 source/_posts/2013-12-18-shell-plus-primer.markdown diff --git a/readme.md b/readme.md index ae203b8..c3e2625 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -#dansteadman.com +# dansteadman.com Running Octopress ([Docs](http://octopress.org/docs/blogging/)) diff --git a/sass/_syntax.scss b/sass/_syntax.scss index 156c81f..4b80e3b 100644 --- a/sass/_syntax.scss +++ b/sass/_syntax.scss @@ -92,19 +92,19 @@ h3.filename { } p, li { - code { - @extend .mono; - display: inline-block; - white-space: no-wrap; - background: #fff; - font-size: .6em; - color: #555; - border: 1px solid #ddd; - @include border-radius(.4em); - padding: 0 .3em; - margin: -1px 0; - } - pre code { font-size: 1em !important; background: none; border: none; } + //code { + // @extend .mono; + // display: inline-block; + // white-space: no-wrap; + // background: #fff; + // font-size: .6em; + // color: #555; + // border: 1px solid #ddd; + // @include border-radius(.4em); + // padding: 0 .3em; + // margin: -1px 0; + //} + //pre code { font-size: 1em !important; background: none; border: none; } } .pre-code { diff --git a/sass/screen.scss b/sass/screen.scss index 637f1c4..05902b2 100644 --- a/sass/screen.scss +++ b/sass/screen.scss @@ -10,4 +10,4 @@ @import "solarized"; @import "syntax"; @import "quotes"; -@import "custom/styles"; \ No newline at end of file +@import "custom/styles"; diff --git a/source/_posts/2013-12-13-ngx-pagespeed.markdown b/source/_posts/2013-12-13-ngx-pagespeed.markdown new file mode 100644 index 0000000..5700910 --- /dev/null +++ b/source/_posts/2013-12-13-ngx-pagespeed.markdown @@ -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 diff --git a/source/_posts/2013-12-14-installing-oracle-instantclient-on-osx.markdown b/source/_posts/2013-12-14-installing-oracle-instantclient-on-osx.markdown new file mode 100644 index 0000000..008e023 --- /dev/null +++ b/source/_posts/2013-12-14-installing-oracle-instantclient-on-osx.markdown @@ -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 format for includes (`#include `). 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 + + + + + + + + + + + + diff --git a/source/_posts/2013-12-18-shell-plus-primer.markdown b/source/_posts/2013-12-18-shell-plus-primer.markdown new file mode 100644 index 0000000..8ec1675 --- /dev/null +++ b/source/_posts/2013-12-18-shell-plus-primer.markdown @@ -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 --auto +