Let's say you want to host domains first.com
and second.com
.
Create folders for their files:
alias changefileperms='find . -type d -perm 777 -exec chmod 755 {} \; && find . -type f -perm 777 -exec chmod 644 {} \;' |
import random | |
adjectives = ['ashy', 'black', 'blue', 'gray', 'green', 'icy', 'lemon', 'mango', 'orange', 'purple', 'red', 'salmon', 'white', 'yellow', 'aggressive', 'agreeable', 'ambitious', 'brave', 'calm', 'delightful', 'eager', 'faithful', 'gentle', 'happy', 'jolly', 'kind', 'lively', 'nice', 'obedient', 'polite', 'proud', 'silly', 'thankful', 'victorious', 'witty', 'wonderful', 'zealousangry', 'bewildered', 'clumsy', 'defeated', 'embarrassed', 'fierce', 'grumpy', 'helpless', 'itchy', 'jealous', 'lazy', 'mysterious', 'nervous', 'obnoxious', 'panicky', 'pitiful', 'repulsive', 'scary', 'thoughtless', 'uptight', 'worried'] | |
nouns = ['antelope', 'badger', 'mastif', 'bear', 'beaver', 'bobcat', 'chipmunk', 'coyote', 'deer', 'mule', 'elk', 'fox', 'gopher', 'lion', 'mouse', 'cactus', 'pinyon', 'pocket', 'muskrat', 'otter', 'porcupine', 'rabbit', 'cottontail', 'jack', 'raccoon', 'rat', 'kangaroo', 'pack', 'wood', 'ringtail', 'vagrant', 'skunk', 'hooded', 'striped', 'spotted', 'squirrel'] | |
def random_name(): | |
adj |
from click import command, option, Option, UsageError | |
class MutuallyExclusiveOption(Option): | |
def __init__(self, *args, **kwargs): | |
self.mutually_exclusive = set(kwargs.pop('mutually_exclusive', [])) | |
help = kwargs.get('help', '') | |
if self.mutually_exclusive: | |
ex_str = ', '.join(self.mutually_exclusive) | |
kwargs['help'] = help + ( |
You must use the magic method %save
:
In [1]: %save?
Type: Magic function
String Form:<bound method CodeMagics.save of <IPython.core.magics.code.CodeMagics object at 0x7fb5d25bb1d0>>
Namespace: IPython internal
File: /usr/lib/python2.7/dist-packages/IPython/core/magics/code.py
Hi Nicholas,
I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I led the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:
The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can't
from django.utils.http import urlencode | |
def reverse_querystring(view, urlconf=None, args=None, kwargs=None, current_app=None, query_kwargs=None): | |
'''Custom reverse to handle query strings. | |
Usage: | |
reverse('app.views.my_view', kwargs={'pk': 123}, query_kwargs={'search': 'Bob'}) | |
''' | |
base_url = reverse(view, urlconf=urlconf, args=args, kwargs=kwargs, current_app=current_app) | |
if query_kwargs: | |
return '{}?{}'.format(base_url, urlencode(query_kwargs)) |
I ran into an issue today where I had to perform a bulk insert into a postgres DB. I was already using SQLAlchemy and Flask-SQLAlchemy to manage the connections to the db and I didn't want to have to use things like psycopg2
directly.
Note: SQLAlchemy provides an ORM. It isn't just an ORM. That is an important thing to be kept in mind. This means that you can bypass choose to not use the ORM layer when you don't want it. The idea with an ORM is to track changes to objects and when you have a case like that is when you'd use the ORM. In a bulk upload scenario, you don't need to track changes to objects. All you care is that everything be pushed into the DB.
(function() { | |
$('a.button').click(function(e) { | |
var $form = $("#form"); | |
$('#error').hide(); | |
$('input').removeClass('error'); | |
var handleError = function() { | |
$('#error').show(); | |
} |
{% if messages %} | |
{% for message in messages %} | |
<div class="alert {% if message.tags %} alert-{{ message.tags }}{% endif %}">{{ message|safe }}</div> | |
{% endfor %} | |
{% endif %} | |
{% if form.errors %} | |
<div class="alert alert-error"> | |
<h4>Please fix the following errors</h4> | |
<ul> |