Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import os, sys
from pathlib import Path
cwd = os.getcwd()
pip_path = Path("{}/Pipfile".format(cwd))
req_path = Path("{}/requirements.txt".format(cwd))
dev_req_path = Path("{}/requirements-dev.txt".format(cwd))

Keybase proof

I hereby claim:

  • I am kandalf on github.
  • I am k4nd4lf (https://keybase.io/k4nd4lf) on keybase.
  • I have a public key ASDiCAcQJaH8DbmwRNirZdfZqQ7w6_q4uYFXfC9NKeYbxAo

To claim this, I am signing this object:

@kandalf
kandalf / user.go
Last active October 22, 2018 17:25
func SearchUsersLike(terms []string) ([]*UsernameData, error) {
var args = make([]interface{}, len(terms))
var query = `
SELECT DISTINCT username, slug
FROM users u
INNER JOIN submissions s ON s.user_id = u.id
INNER JOIN works w ON w.submission_id = s.id
WHERE u.confirmed_at IS NOT NULL AND
w.discontinued_at IS NULL AND (`
@kandalf
kandalf / nginxproxy.md
Created December 14, 2017 18:21 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@kandalf
kandalf / benchmark+go+nginx.md
Created April 12, 2017 15:31 — forked from hgfischer/benchmark+go+nginx.md
Benchmarking Nginx with Go

Benchmarking Nginx with Go

There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.

So, these are the different settings we are going to compare:

  • Go HTTP standalone (as the control group)
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI
# Contributor: tuxce <tuxce.net@gmail.com>
pkgname=package-query
pkgver=1.5
pkgrel=2
pkgdesc="Query ALPM and AUR"
arch=('i686' 'x86_64' 'mips64el' 'armv6h' 'armv7h' 'arm')
url="https://github.com/archlinuxfr/package-query/"
license=('GPL')
depends=('pacman>=4.1' 'pacman<4.3' curl 'yajl>=2.0')
source=(http://mir.archlinux.fr/~tuxce/releases/$pkgname/$pkgname-$pkgver.tar.gz)
package main
import "log"
func main() {
redisDB := &RedisDB{LogFilePath: "./redis-incr.log"}
redisDB.Connect("127.0.0.1:6379", "1")
redisDB.SetupDB()
for i := 0; i < 3000; i++ {
@kandalf
kandalf / encuestas_init.sh
Created March 17, 2012 02:48 — forked from c0r0nel/encuestas_init.sh
Init script for unicorn using a rvm wrapper
#!/bin/bash
### BEGIN INIT INFO
# Provides: Encuestas
# Required-Start: $all
# Required-Stop: $network $local_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start the Encuestas unicorns at boot
# Description: Enable Encuestas at boot time.
### END INIT INFO