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
t = Task(type='resize', arguments=json.dumps({'new_width': width, 'url': url, 'bucket': self.bucket})) | |
try: | |
db.session.add(t) | |
db.session.commit() | |
sys_log.info("Added the resize task to the DB") | |
except IntegrityError as integrityerror: | |
db.session.rollback() | |
sys_log.info("Task is conflicting with another task in the DB") |
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
mapper = { | |
'function1': function1, | |
'function2': function2 | |
} | |
def execute_pending_tasks(): | |
all_pending_tasks = Task.query.all() | |
for t in all_pending_tasks: | |
try: | |
associated_function = mapper.get(t.type, False) |
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 Task(db.Model): | |
__tablename__ = 'task_tb' | |
id = db.Column(db.Integer, primary_key=True) | |
type = db.Column(db.String(SLen.NAME)) | |
arguments = db.Column(db.String(2000)) | |
created_at = db.Column(db.DateTime, default=func.now()) | |
__table_args__ = (UniqueConstraint('type', 'arguments', name='unique_task'),) |
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
create table task_tb | |
( | |
id serial not null | |
constraint task_tb_pkey | |
primary key, | |
type varchar(110), | |
arguments varchar(2000), | |
created_at timestamp, | |
constraint unique_task | |
unique (type, arguments) |
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
daemon off; | |
#Heroku dynos have at least 4 cores. | |
worker_processes <%= ENV['NGINX_WORKERS'] || 4 %>; | |
events { | |
use epoll; | |
accept_mutex on; | |
worker_connections 1024; | |
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
var i = 0; | |
db.getCollection('fs.files').find({}).forEach(function(element){ | |
if (!db.getCollection('_User').find({profilePicture: element.filename}).toArray().length > 0){ | |
i++; | |
db.getCollection('fs.files').remove({filename: element.filename}) | |
} | |
}) | |
print(i) |
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
alias ip="ifconfig | egrep -o '([[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3})[[:space:]]netmask[[:space:]]0x[[:xdigit:]]{8}[[:space:]]broadcast'|egrep -o '([[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3})' | pbcopy" |
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
import re | |
from subprocess import call | |
import sys | |
import os | |
rootdir = '.' | |
dictOfFilms = {} |