Skip to content

Instantly share code, notes, and snippets.

View AdrienLemaire's full-sized avatar

Adrien Lemaire AdrienLemaire

View GitHub Profile
// 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
//
@peterbe
peterbe / base_forms.py
Created February 22, 2011 11:17
Use these instead of django.forms.Form or django.forms.ModelForm
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
@SachaG
SachaG / intl_directive.js
Last active December 11, 2020 08:49
GraphQL Intl Directive
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`];
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active March 8, 2024 02:11
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
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