Skip to content

Instantly share code, notes, and snippets.

@nferrari
nferrari / alwaysdata_api_mailbox_patch
Created November 19, 2012 13:58
PATCH a mailbox through alwaysdata API
import json
import requests
API_URL = 'https://api.alwaysdata.com/v1/'
API_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
ACCOUNT_NAME = 'account_name'
# Updating a mailbox
mailbox_id = 12345
from mongoengine import Document, StringField, ReferenceField, BooleanField
class A(Document):
a = StringField()
class B(Document):
b = StringField()
boolfield = BooleanField(default=False)
ref = ReferenceField(A)
@nferrari
nferrari / strategy.py
Last active March 25, 2016 14:36
django-oscar french strategy
# myapp/partner/strategy.py
from decimal import Decimal as D
from oscar.apps.partner import strategy, prices
DEFAULT_RATE = D('0.196')
PRODUCT_CLASSES_RATES = {
'cours': 0,
@nferrari
nferrari / lessc
Last active August 29, 2015 14:06
Install lessc on alwaysdata (to use django_compressor for example)
cd ~
mkdir -p .local
mkdir -p tmp
cd tmp
git clone https://github.com/joyent/node.git .
git checkout v0.10.31
./configure --prefix=~/.local
make LINK=g++ install
@nferrari
nferrari / permissions.py
Created November 4, 2014 11:15
django-rest-framework read-only permission class
from rest_framework import permissions
class IsReadOnly(permissions.BasePermission):
"""
Object-level permission to only allow read-only operations.
"""
def has_permission(self, request, view):
# Read permissions are allowed to any request,
@nferrari
nferrari / api_domain_record.py
Created March 31, 2015 15:34
alwaysdata API post domain record
#!/usr/bin/python
import json
import requests
address = 'http://api.alwaysdata.com/v1/domain/record/'
credentials = ('APIKEY account=batman', '')
response = requests.post(
address,
@nferrari
nferrari / gist:00938d0c6180351848da
Created May 17, 2015 08:07
Python 2.7 + Django 1.8 on alwaysdata
Create our environment directory
$ mkdir .local
Create a temporary directory
$ mkdir tmp
Install Python 2.7
$ cd tmp
$ wget https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz
$ tar zxvf Python-2.7.9.tgz
@nferrari
nferrari / create_domain_record_alwaysdata_api.py
Created October 19, 2015 12:13
Create domain record on alwaysdata API
#!/usr/bin/env python
import json
import requests
address = 'https://api.alwaysdata.com/v1/domain/record/'
credentials = ('APIKEY account=foobar', '')
data = {
'name': '',
@nferrari
nferrari / install_wallabag.py
Last active April 21, 2017 10:59
Install Wallabag on alwaysdata
#!/usr/bin/env python
import argparse
import fileinput
import grp
import json
import urllib.request
import os
import subprocess
import tarfile