This document has been moved to https://selenium-python.readthedocs.org
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
# If you work with git, you've probably had that nagging sensation of not knowing what branch you are on. Worry no longer! | |
export PS1="\\w:\$(git branch 2>/dev/null | grep '^*' | colrm 1 2)\$ " | |
# This will change your prompt to display not only your working directory but also your current git branch, if you have one. Pretty nifty! | |
# ~/code/web:beta_directory$ git checkout master | |
# Switched to branch "master" | |
# ~/code/web:master$ git checkout beta_directory | |
# Switched to branch "beta_directory" |
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
class MyInline(admin.TabularInline): | |
model = MyModel | |
extra = 0 | |
template = 'admin/edit_inline/list.html' | |
def get_formset(self, request, obj=None, **kwargs): | |
FormSet = super(ActivationKeyInline, self).get_formset(request, obj, **kwargs) | |
class NewFormSet(FormSet): | |
def _construct_forms(self, *args, **kwargs): | |
qs = self.get_queryset() |
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
-module(fileop). | |
-export([write_file/3]). | |
-compile({parse_transform,do}). | |
%% Uses an error monad to neatly compose a bunch of failing functions. | |
%% | |
%% Everything being composed returns ok|{ok,Result}|{error,Reason}. At | |
%% the first error, the reason term is returned. The monad factors out | |
%% the behaviour of piping all possible errors to the output (via a | |
%% try-throw or case tree) if they occur. |
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
====================================== | |
Setting up Nginx, uWSGI and Python3 | |
====================================== | |
First off, I'm traditionally a PHP developer, but am looking at moving across to Python. I really struggled to find decent documentation on how to get a server up and running for deploying Python web applications from the point of view of someone coming from PHP. The main problems I came across with documentation were: | |
1) Only showed you how to run the server for a single web application. | |
2) Only showed you how to configure the app, not the server it was running on. | |
My preferred workflow for development is by setting up a new VM in VMware Fusion and then forwarding through all requests to that VM via /etc/hosts. This might not be the optimal way to get things up and running, but it works for me. |
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
'use strict'; | |
angular.module('foo', []) | |
.filter('substring', function() { | |
return function(str, start, end) { | |
return str.substring(start, end); | |
}; | |
}) |
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
""" | |
Usage: python remove_output.py notebook.ipynb [ > without_output.ipynb ] | |
Modified from remove_output by Minrk | |
""" | |
import sys | |
import io | |
import os | |
from IPython.nbformat.current import read, write |
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
#!/bin/bash | |
# Source: http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/ | |
# Install stuff # | |
################# | |
# Install development tools and some misc. necessary packages | |
yum -y groupinstall "Development tools" | |
yum -y install zlib-devel # gen'l reqs |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> | |
<title>Stripe Getting Started Form</title> | |
<!-- The required Stripe lib --> | |
<script type="text/javascript" src="https://js.stripe.com/v2/"></script> | |
<!-- jQuery is used only for this example; it isn't required to use Stripe --> |
When you use $resource within a service, you don't need to impose mocking $httpBackend on your controller. If you want tests for the $resource, those should be in the unit tests for the service.
The controller should only test things directly under its control, which means testing the service directly.
The examples below show how to mock a $resource service factory, in the simplest way I could come up with.
TODO:
- These are real-world examples and it might be helpfule to visitors if I removed all the extra junk that isn't directly related to testing $resource.
- Should this be updated to be a better example of utilizing promises?
OlderNewer