React + D3 exploration with the force layout:
- React for structure
- D3 for data calculation
- D3 for rendering
Pro:
- The viz scales!
- Use all the d3 functions!
Con:
| # | |
| # https://gist.github.com/663503 | |
| # | |
| # Use this to clean your repo by removing old branches. | |
| # It will remove the branch on local and on origin. | |
| # | |
| # Usage: | |
| # $ nuke_branch some_old_branch_you_dont_need | |
| # | |
| # Note we use -d not -D for teh safety. |
| def activate_virtualenv(name): | |
| """Activate given virtualenv. | |
| Virtualenv home folder is given by environment variable ``WORKON_HOME`` or | |
| ``~/Envs`. | |
| """ | |
| if 'WORKON_HOME' in os.environ: | |
| home = os.environ['WORKON_HOME'] | |
| else: | |
| home = os.path.expanduser(os.path.join('~', 'Envs')) |
| import os | |
| from PIL import Image | |
| ''' | |
| I searched high and low for solutions to the "extract animated GIF frames in Python" | |
| problem, and after much trial and error came up with the following solution based | |
| on several partial examples around the web (mostly Stack Overflow). | |
| There are two pitfalls that aren't often mentioned when dealing with animated GIFs - |
| /* Polyfill indexOf. */ | |
| var indexOf; | |
| if (typeof Array.prototype.indexOf === 'function') { | |
| indexOf = function (haystack, needle) { | |
| return haystack.indexOf(needle); | |
| }; | |
| } else { | |
| indexOf = function (haystack, needle) { | |
| var i = 0, length = haystack.length, idx = -1, found = false; |
| /** @jsx React.DOM */ | |
| // d3 chart function | |
| // note that this is a higher-order function to | |
| // allowing passing in the component properties/state | |
| update = function(props) { | |
| updateCircle = function(me) { | |
| me | |
| .attr("r", function(d) { return d.r; }) | |
| .attr("cx", function(d) { return 3 + d.r; }) |
| # Ask for the user password | |
| # Script only works if sudo caches the password for a few minutes | |
| sudo true | |
| # Install kernel extra's to enable docker aufs support | |
| # sudo apt-get -y install linux-image-extra-$(uname -r) | |
| # Add Docker PPA and install latest version | |
| # sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 | |
| # sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list" |
React + D3 exploration with the force layout:
Pro:
Con:
| #!/bin/bash | |
| tail -n0 -F "$1" | while read LINE; do | |
| (echo "$LINE" | grep -e "$3") && curl -X POST --silent --data-urlencode \ | |
| "payload={\"text\": \"$(echo $LINE | sed "s/\"/'/g")\"}" "$2"; | |
| done |
Hopefully this will answer "How do I setup or start a Django project?" I was trying to set up my own website, and there was a lot to read, learn and digest! Therefore, I put this together which is a collection of all the guides/blog posts/articles that I found the most useful. At the end of this, you will have your barebones Django app configured and ready to start building :)
NOTE: This guide was built using Django 1.9.5, NodeJS 4+ with NPM 3+
| """Base class for implementing Lambda handlers as classes. | |
| Used across multiple Lambda functions (included in each zip file). | |
| Add additional features here common to all your Lambdas, like logging.""" | |
| class LambdaBase(object): | |
| @classmethod | |
| def get_handler(cls, *args, **kwargs): | |
| def handler(event, context): | |
| return cls(*args, **kwargs).handle(event, context) | |
| return handler |