Skip to content

Instantly share code, notes, and snippets.

Laurent Meyer lolobosse

Block or report user

Report or block lolobosse

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@lolobosse
lolobosse / ebay-impressions.js
Created Jun 24, 2019
See all your impressions on eBay
View ebay-impressions.js
// Paste that in Google console
$$('#meb-items-cnt > section.active-page__list > div > div > div > div > div.col-3 > div.me-item-activity > div:nth-child(1) > span.me-item-activity__column-count').reduce((a, c)=>a+parseInt(c.innerHTML), 0)
View create_task.py
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")
View manager.py
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)
View task_sql_alchemy.py
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'),)
View task_db.sql
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)
@lolobosse
lolobosse / gist:4dcbc39373709cbd56be0e22e138dbe7
Created Feb 4, 2019
Airline Manager Plane combination calculator
View gist:4dcbc39373709cbd56be0e22e138dbe7
import math
# from constraint import *
#
# problem = Problem()
#
# problem.addVariable("Q400 Eco", [80, 0, 0])
# problem.addVariable("Q400 Aff", [0, 44, 0])
# problem.addVariable("Q400 First", [0, 0, 19])
# problem.addVariable("ORY", [368, 107, 19, 4.25])
View gist:127b767a5ba14c5dcaea1bb09f601642
daemon off;
#Heroku dynos have at least 4 cores.
worker_processes <%= ENV['NGINX_WORKERS'] || 4 %>;
events {
use epoll;
accept_mutex on;
worker_connections 1024;
}
View Jobninja_red logo.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View Jobninja logo.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View Cleanup Parse Direct from Mongo
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)
You can’t perform that action at this time.