Skip to content

Instantly share code, notes, and snippets.

@pvsune
pvsune / concurrent.kafka.consumer.py
Last active April 22, 2025 14:17
A multiprocess multithreaded Kafka consumer
#!/usr/bin/env python
import logging
import os
import threading
import time
from multiprocessing import Process
from queue import Queue
from confluent_kafka import Consumer
@koreyou
koreyou / bm25.py
Created November 1, 2019 05:26
Implementation of OKapi BM25 with sklearn's TfidfVectorizer
""" Implementation of OKapi BM25 with sklearn's TfidfVectorizer
Distributed as CC-0 (https://creativecommons.org/publicdomain/zero/1.0/)
"""
import numpy as np
from sklearn.feature_extraction.text import TfidfVectorizer
from scipy import sparse
class BM25(object):
@BetsuNo
BetsuNo / centrifugo
Last active May 10, 2022 15:29
nginx, php-fpm, memcached and centrifugo rc.d scripts for CentOS 7
#!/bin/bash
#
# /etc/init.d/centrifugo
#
# Startup script for centrifugo
#
# chkconfig: 2345 20 80
# description: Starts and stops centrifugo
# Source function library.
@rivo
rivo / serve.go
Created November 26, 2017 12:28
Graceful stop and restart for HTTP servers in Go
package main
import (
"context"
"fmt"
"net"
"net/http"
"os"
"os/exec"
"os/signal"
@jimorsm
jimorsm / pyenv.sh
Last active November 15, 2018 21:57 — forked from bylatt/pyenv.sh
install python3.6.0 on centos 7
#!/bin/sh
# install pyenv on centos 7
yum install -y gcc gcc-c++ make git patch openssl-devel zlib-devel readline-devel sqlite-devel bzip2-devel
curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> .zshrc
echo 'eval "$(pyenv init -)"' >> .zshrc
echo 'eval "$(pyenv virtualenv-init -)"' >> .zshrc
@erikbern
erikbern / use_pfx_with_requests.py
Last active December 23, 2025 13:58
How to use a .pfx file with Python requests – also works with .p12 files
import contextlib
import OpenSSL.crypto
import os
import requests
import ssl
import tempfile
@contextlib.contextmanager
def pfx_to_pem(pfx_path, pfx_password):
''' Decrypts the .pfx file to be used with requests. '''
@aaronvanston
aaronvanston / form.html
Created May 7, 2016 11:01
Bootstrap 4 + Parsley JS
$("#parsleyForm").parsley({
errorClass: 'has-danger',
successClass: 'has-success',
classHandler: function(ParsleyField) {
return ParsleyField.$element.parents('.form-group');
},
errorsContainer: function(ParsleyField) {
return ParsleyField.$element.parents('.form-group');
},
errorsWrapper: '<span class="text-help">',
@guigmaster
guigmaster / parsley.cnpj-validator.js
Last active January 30, 2020 17:18
Custom's Parsley Validator's
'use strict';
(function($) {
window.ParsleyValidator
.addValidator('validcnpj', function (value, requirement) {
var cnpj = value.replace(/[^0-9]/g, '')
, len = cnpj.length - 2
, numbers = cnpj.substring(0,len)
, digits = cnpj.substring(len)
, add = 0
@adamwathan
adamwathan / v-cloak.md
Last active November 6, 2024 14:28
Useful CSS utilities for Vue.js cloaking

Handy helpers for controlling visibility of elements until Vue has compiled.

Use like:

<div v-cloak>
  <h1>
    <span class="v-cloak--inline">Loading...</span> <!-- Only displayed before compiling -->
    <span class="v-cloak--hidden">{{ post.title }}</span> <!-- Hidden until compiling is finished -->
 
@tahajahangir
tahajahangir / example-mod-wsgi.py
Last active April 22, 2024 00:37 — forked from branneman/example-mod-wsgi.py
Python (2&3 compatible) Equivalent to phpinfo()
def application(environ, start_response):
from pyinfo import pyinfo
output = pyinfo()
# or pyinfo([('custom key', 'custom value'), ...])
start_response('200 OK', [('Content-type', 'text/html')])
return [output]