Skip to content

Instantly share code, notes, and snippets.

View lolobosse's full-sized avatar

Lolobosse (old JN) lolobosse

View GitHub Profile
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")
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)
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'),)
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)
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.
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)
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"
@lolobosse
lolobosse / gist:6ce504ff3b53427defe0
Created December 24, 2015 17:11
To regroup x avis files which have been splitted
import re
from subprocess import call
import sys
import os
rootdir = '.'
dictOfFilms = {}