Skip to content

Instantly share code, notes, and snippets.

@subuk
subuk / gist:72740e021cb16c54a3bb
Last active August 29, 2015 14:22
Распределение элементов по группам без пересечений.
#!/usr/bin/env python
from __future__ import print_function
import collections
GROUPS_COUNT = 7
cleaned_words = set()
#
@subuk
subuk / example.sh
Created July 15, 2015 17:29
Nginx pypi cache
#!/bin/sh
pip install -t /tmp/test_install -i http://localhost:5555/simple/ django
@subuk
subuk / chat.go
Last active August 29, 2015 14:27
Simple go chat
package main
import (
"net"
)
type Chat struct {
clients []*Client
joins chan net.Conn
}
@subuk
subuk / nginx.conf
Last active August 27, 2015 12:53 — forked from dctrwatson/nginx.conf
Caching PyPi packages locally with nginx
user www-data;
worker_processes 4;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
package main
import (
"bytes"
"crypto/tls"
"crypto/x509"
"encoding/json"
"fmt"
"io"
"io/ioutil"
func QuotedSplit(input string) []string {
runedParts := [12][]rune{}
runedPartsEl := 0
quoteActive := false
for _, r := range input {
if r == '"' && !quoteActive {
quoteActive = true
continue
}
if r == '"' && quoteActive {
#!/usr/bin/env python
import requests
from requests.auth import HTTPBasicAuth
URL_TEMPLATE = (
"https://api.bintray.com"
"/packages/{subject}/{repo}/{package}/files"
)
@subuk
subuk / gnupg.py
Last active February 2, 2017 16:21
Ansible module for managing gpg keyring
#!/usr/bin/env python
# - gnupg: "keyring=/srv/packages/trusted.gpg state=present content='{{ lookup('file', 'userkeys/'+item+'.gpg') }}'"
# with_items: trusted_users
def get_key_id(module):
gnupg = module.get_bin_path('gpg', True)
armored_key = module.params['content']
result = module.run_command([gnupg, "-"], data=armored_key, check_rc=True)
out = result[1]
@subuk
subuk / Makefile
Last active February 5, 2017 00:34
Simple debian repository
default:
mkdir -p main/binary-amd64
dpkg-scanpackages -a amd64 pool/ /dev/null dists/trusty/ >main/binary-amd64/Packages
cat main/binary-amd64/Packages | gzip -c9 >main/binary-amd64/Packages.gz
cat main/binary-amd64/Packages | bzip2 -c9 >main/binary-amd64/Packages.bz2
cat Release.in > Release
PACKAGES=main/binary-amd64/Packages /usr/local/bin/make-debian-release-file >> Release
rm -f Release.gpg
import random
import hashlib
_generated = set()
def rand_ip_part():
return random.randint(0, 255)