Skip to content

Instantly share code, notes, and snippets.

View rochacbruno's full-sized avatar
🛠️
Working on Galaxy_ng and Dynaconf

Bruno Cesar Rocha rochacbruno

🛠️
Working on Galaxy_ng and Dynaconf
View GitHub Profile
@JacobCallahan
JacobCallahan / cache.py
Created February 14, 2020 15:07
poc for a new caching system
from collections import defaultdict
from functools import lru_cache
CACHE = Cache()
class Cache:
_free = defaultdict(lambda: defaultdict(list))
_active = defaultdict(lambda: defaultdict(list))
@ongun-kanat
ongun-kanat / 00-overrides.conf
Last active April 11, 2024 13:12
Make ~~cancer~~ emoji work on Linux
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<alias>
<family>Arial</family>
<prefer>
<family>Arial</family>
<family>Liberation Sans</family>
<family>sans-serif</family>
</prefer>
@niuware
niuware / django_stream_queryset_to_csv.md
Created October 18, 2019 03:41
How to stream a CSV file from a large QuerySet using Django's StreamingHttpResponse

Stream a CSV file from a QuerySet using StreamingHttpResponse

This is a sample on how to stream the results of a large QuerySet into a CSV file using Django StreamingHttpResponse class.

  1. Add the CSVStream class in your project, for example a writers.py file:
import csv
from django.http import StreamingHttpResponse
@rochacbruno
rochacbruno / download_images.sh
Created August 7, 2019 18:41
Download Multiple Sequential Images on Bash
# A web server having files named /file00001.jpg to /file00138.jpg
BASE_URL=https://xyzkonjdnfsdf.rackcdn.com/file00
for i in $(seq 001 138); do wget $BASE_URL$(printf "%.3d" "$i").jpg ; done
@Nasdin
Nasdin / image_to_grid_knitting_pattern.py
Last active October 28, 2019 01:41
Takes an image and converts it to a grid knitting pattern as an excel file with colors and labelled with numbers. Arguments are 1. image path 2. desired height of grid 3. excel output path
import sys
import cv2
import numpy as np
import xlsxwriter
if len(sys.argv) != 4:
print("That's not how it works")
sys.exit(404)
@rohanpm
rohanpm / remove-duplicate-test
Last active March 27, 2019 15:31
Improving remove_unit_duplicate_nevra performance
#!/usr/bin/env python
"""Benchmark script showing difference between current remove_unit_duplicate_nevra
and implementation with adjusted queries.
Logs for running this over real data:
2019-03-11 03:52:15,745 Testing queries for repo: rhel-7-server-release-e2e-test-1-rpms__x86_64
2019-03-11 03:52:15,752 Start improved for rhel-7-server-release-e2e-test-1-rpms__x86_64 (1584 units)
2019-03-11 03:52:15,755 End improved for rhel-7-server-release-e2e-test-1-rpms__x86_64
2019-03-11 03:52:15,755 Start original for rhel-7-server-release-e2e-test-1-rpms__x86_64 (1584 units)
import asyncio
import logging
import os
import signal
from aiohttp import web
log = logging.getLogger(__name__)
@strongbugman
strongbugman / SwaggerMethodView.py
Created July 30, 2018 04:05
A way parse and validate request data in flask
import os
from functools import wraps
from collections import defaultdict
import yaml
from flask.views import MethodView, MethodViewType, http_method_funcs
from flask import jsonify, request, Response, abort
from flasgger import swag_from
from flask_restful.reqparse import RequestParser
from jsonschema import validate, ValidationError, FormatChecker
@joaomoreno
joaomoreno / README.md
Last active February 1, 2024 22:19
VS Code Insiders Updater for Linux

VS Code Insiders Updater for Linux

This script will download and replace ~/Applications/VSCode-linux-x64 with the latest VS Code Insiders.

gif

Install

  1. Install jq: https://stedolan.github.io/jq/download/
  2. Place update-code somewhere in your PATH
@danilobellini
danilobellini / example.py
Created May 13, 2018 18:08
A really simple/incomplete bottle/flask-like "single blocking worker thread" web server implementation (Python 2)
from server import WebServer
app = WebServer()
@app.route("/")
def root():
return "Hello World!"
@app.route("/file")
def file_route():
with open("server.py", "rb") as f: