This file contains hidden or 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 IntlDirective extends SchemaDirectiveVisitor { | |
visitFieldDefinition(field, details) { | |
const fieldName = field.name; | |
field.resolve = async function (...args) { | |
// get document, GraphQL arguments, and query context | |
const [ doc, graphQLArguments, context ] = args; | |
// get the locale either from the query's arguments, or from the context | |
const locale = graphQLArguments.locale || context.locale; | |
// get the field containing translations | |
const intlField = doc[`${name}_intl`]; |
This file contains hidden or 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 _BaseForm(object): | |
def clean(self): | |
cleaned_data = super(_BaseForm, self).clean() | |
for field in cleaned_data: | |
if isinstance(cleaned_data[field], basestring): | |
cleaned_data[field] = \ | |
cleaned_data[field].replace('\r\n','\n')\ | |
.replace(u'\u2018',"'").replace(u'\u2019',"'").strip() | |
return cleaned_data | |
This file contains hidden or 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
// Scraping Made Easy with jQuery and SelectorGadget | |
// (http://blog.dtrejo.com/scraping-made-easy-with-jquery-and-selectorga) | |
// by David Trejo | |
// | |
// Install node.js and npm: | |
// http://joyeur.com/2010/12/10/installing-node-and-npm/ | |
// Then run | |
// npm install jsdom jquery http-agent | |
// node numresults.js | |
// |
This file contains hidden or 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
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
. ~/.bashrc | |
mkdir ~/local | |
mkdir ~/node-latest-install | |
cd ~/node-latest-install | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
./configure --prefix=~/local | |
make install # ok, fine, this step probably takes more than 30 seconds... | |
curl https://www.npmjs.org/install.sh | sh |