Skip to content

Instantly share code, notes, and snippets.

View jsmolina's full-sized avatar

Jordi Sesmero jsmolina

  • Barcelona
View GitHub Profile
@jsmolina
jsmolina / celerybeat_howto_launch
Created May 9, 2018 16:58
Celery cron (beat) service learned things
Executing a new task periodically in celery like in java quartz, is as simple as:
0) Define your tasks in a dictionary (function check_users in background_tasks module will execute every half an hour):
beat_schedule = {
'check_users': {
task: 'backoffice.blueprints.users.background_tasks.check_users'
schedule: 1800.0
}
}
@jsmolina
jsmolina / gutter_example.py
Created May 9, 2018 10:30
Example of feature enable/disable in gutter
from distutils.version import StrictVersion
class User(object):
def __init__(self, version='2.0.0'):
self.app_version = version
class UserArgument(User):
COMPATIBLE_TYPE=User
def __init__(self, input):
self.applies = 1
@jsmolina
jsmolina / pathautojs.js
Last active January 3, 2016 10:59
This js script simulates Drupal pathauto module that generates an automatic url based on a node title. It is useful for web crawling, testing, ...
String.stopWords = 'a,an,as,at,before,but,by,for,from,is,in,into,like,of,off,on,onto,per,since,than,the,this,that,to,up,via,with';
String.escapeRegExp = function(str) {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
};
String.prototype.replaceAll = function (find, replace) {
return this.replace(new RegExp(String.escapeRegExp(find), 'g'), replace);
};
@jsmolina
jsmolina / README.txt
Created June 21, 2012 12:14
BrowserId bug number: 1605790
Welcome to BrowserId.
This module provides a 'Login' button inside login form and a configurable block.
It also defines a Permission called 'log in using browserid', which needs to be enabled for anonymous role in order to show the Login buttons.