Skip to content

Instantly share code, notes, and snippets.

View lolobosse's full-sized avatar

Lolobosse (old JN) lolobosse

View GitHub Profile
@lolobosse
lolobosse / gist:4dcbc39373709cbd56be0e22e138dbe7
Created February 4, 2019 07:34
Airline Manager Plane combination calculator
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])
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)
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'),)
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)
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")
@lolobosse
lolobosse / ebay-impressions.js
Created June 24, 2019 16:28
See all your impressions on eBay
// 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)
const name = $("#buyercontactname").val();
const address1 = $('#buyeraddress1').val();
const address2 = $('#buyeraddress2').val();
const zip = $('#buyerzip').val();
const city = $('#buyercity').val();
const country = $('#buyercountry').children("option:selected").attr('id');
let big_table = $('#ERSShipnHand').find("table");
let all_articles = []
<html>
<body>
<form id="form">
<input type="number" id="rnr" placeholder="Rechnungsnummer" style="margin-bottom: 10px">
<input type="submit" value="Rechnung Erstellen">
</form>
<script type="text/javascript" src="popup.js"></script>
</body>
</html>
// var app = chrome.runtime.getBackgroundPage();
document.addEventListener('DOMContentLoaded', function () {
debugger;
console.log("the doc loaded")
var form = document.getElementById("form")
console.log(form)
form.addEventListener('submit', function (e) {
e.preventDefault()
console.log("added to the form")
Number.prototype.pad = function (size) {
var s = String(this);
while (s.length < (size || 2)) {
s = "0" + s;
}
return s;
}
function run() {
chrome.storage.sync.get(['name', 'address1', 'address2', 'zip', 'city', 'country', 'articles', 'buyDateString', 'payDateString', 'rnr', 'shipping', 'invoiceFileDate'], (result) => {