Skip to content

Instantly share code, notes, and snippets.

@xr09
xr09 / gitlab-http
Created March 17, 2015 18:30
cache gitlab uploads
# append this to /var/opt/gitlab/nginx/conf/gitlab-http.conf
location ~ ^/(uploads)/ {
expires max;
add_header Cache-Control public;
}
@xr09
xr09 / README.md
Created November 11, 2016 01:28 — forked from magnetikonline/README.md
Setting Nginx FastCGI response buffer sizes.

Nginx FastCGI response buffer sizes

By default when Nginx starts receiving a response from a FastCGI backend (such as PHP-FPM) it will buffer the response in memory before delivering it to the client. Any response larger than the set buffer size is saved to a temporary file on disk. This process is outlined at the Nginx ngx_http_fastcgi_module page document page.

Introduction

Since disk is slow and memory is fast the aim is to get as many FastCGI responses passing through memory only. On the flip side we don't want to set an excessively large buffer as they are created and sized on a per request basis (i.e. it's not shared memory).

@xr09
xr09 / gist:a722368207ca41afc1b17b77076db9da
Created November 21, 2016 17:05
command line for compiling kernel on debian
nice -n19 ionice -c2 -n7 fakeroot make -j5 bindeb-pkg
@xr09
xr09 / example.py
Last active December 27, 2016 20:04
from sandpiper import Domain
# credenciales del dominio windows
windows_config = {
'uri': "192.168.1.10",
'dn': "OU=dominio,DC=hlg,DC=emp,DC=cu",
'user': 'winuser',
'password': 'qwerty',
}
@xr09
xr09 / contextmanager.md
Created December 29, 2016 22:01 — forked from bgilbert/contextmanager.md
Python context managers

Context managers

In Python, a context manager is an object that can be used in a with statement. Here's a context manager that reports the total wall-clock time spent inside a with block:

import time

class Timer(object):
    def __init__(self, msg):
        self._msg = msg
@xr09
xr09 / bobp-python.md
Created December 29, 2016 22:03 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@xr09
xr09 / README.md
Created January 9, 2017 14:54
download alpine repo

generate urls

python3 alpine.py > urls

feed urls to aria2c

aria2c -d main/x86_64/ -i urls

@xr09
xr09 / request_cache.py
Created November 27, 2017 00:06
using shelve as cache for request
import logging
import shelve
import requests
_HEADERS = {'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) '
'AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/53.0.2785.143 Safari/537.36'}
_TIMEOUT = 5
@xr09
xr09 / knocker.py
Last active November 12, 2018 15:41
import csv
import datetime
import subprocess
import logging
from concurrent.futures import ThreadPoolExecutor
WORKERS_FILE = 'workers.csv'
[
{
"target": "buster",
"vulnerabilities": [
{
"package": {
"name": "firefox",
"version": "68",
"format": "rpm"
},