Skip to content

Instantly share code, notes, and snippets.

View lolobosse's full-sized avatar

Lolobosse (old JN) lolobosse

View GitHub Profile
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) => {
@lolobosse
lolobosse / legacy.sql
Created February 20, 2021 11:02
Legacy Query
SELECT data.id
FROM (select j1.id as id,
j1.title,
b1.company,
case
when active_job.location isnull
then :radius
when l1.location isnull
then :radius
else st_distance(l1.location, active_job.location) end as dist,
create materialized view similar_mv as (select j.id,
j.title,
j.source,
j.created_at,
j.updated_at,
j.category_id,
b2bt.company,
lt.location
from job_tb j
join b2b_tb b2bt on j.b2b_id = b2bt.id