Skip to content

Instantly share code, notes, and snippets.

View fmelihh's full-sized avatar
💢
Beast Mode

Furkan Melih Ercan fmelihh

💢
Beast Mode
View GitHub Profile
@IrSent
IrSent / celery.py
Created November 12, 2016 19:12
Celery Best Practices
# Safe Queue Celery App Settings
from __future__ import absolute_import, unicode_literals
from celery import Celery
app = Celery('some_project',
broker='amqp://',
backend='amqp://',
include=['some_project.tasks'])
@sdavids13
sdavids13 / block_join_filter_example.txt
Last active March 22, 2023 10:57
Solr block join filtering example
$ cd <solr distribution>
$ bin/solr start
$ bin/solr create -c demo
$ curl http://localhost:8983/solr/demo/update?commitWithin=3000 -d '{delete:{query:"*:*"}}'
$ curl http://localhost:8983/solr/demo/update?commitWithin=3000 -d '
[
{id : book1, type_s:book, title_t : "The Way of Kings", author_s : "Brandon Sanderson",
cat_s:fantasy, pubyear_i:2010, publisher_s:Tor, bin_s: bar,
_childDocuments_ : [
@bhtucker
bhtucker / upsert.py
Last active February 17, 2025 15:08
A demonstration of Postgres upserts in SQLAlchemy
"""
Upsert gist
Requires at least postgres 9.5 and sqlalchemy 1.1
Initial state:
[]
Initial upsert:
@malexer
malexer / sqlalchemy_upsert.py
Last active January 26, 2024 14:09
Modelling UPSERT in SQLAlchemy (well actually it is not upsert but speed improvement is significant in comparison with simple session.merge)
# Note: it is a copy of great answer by "mgoldwasser" from Stackoverflow
# Check the original answer here: http://stackoverflow.com/a/26018934/1032439
# Imagine that post1, post5, and post1000 are posts objects with ids 1, 5 and 1000 respectively
# The goal is to "upsert" these posts.
# we initialize a dict which maps id to the post object
my_new_posts = {1: post1, 5: post5, 1000: post1000}
for each in posts.query.filter(posts.id.in_(my_new_posts.keys())).all():
@chenjianjx
chenjianjx / start-celery-for-dev.py
Created March 10, 2016 10:45
A python script which starts celery worker and auto reload it when any code change happens.
'''
A python script which starts celery worker and auto reload it when any code change happens.
I did this because Celery worker's "--autoreload" option seems not working for a lot of people.
'''
import time
from watchdog.observers import Observer ##pip install watchdog
from watchdog.events import PatternMatchingEventHandler
import psutil ##pip install psutil
import os
@calderonroberto
calderonroberto / chainofresponsibility.py
Created July 8, 2015 06:28
Chain of responsibility in python (Design Patterns - Gamma, Helm, Johnson, Vlissides)
PRINT_TOPIC = 1
PAPER_ORIENTATION = 2
APPLICATION_TOPIC = 3
NO_HELP_TOPIC = -1
class HelpHandler (object):
def __init__(self, successor=0, topic=NO_HELP_TOPIC):
self._successor = successor
self._topic = topic
def HasHelp(self):
@tuxdna
tuxdna / schema.xml
Last active February 10, 2023 11:03
Apache Solr sample schema configuration
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0