Skip to content

Instantly share code, notes, and snippets.

from fuzzywuzzy import process
from fuzzywuzzy.utils import full_process
def processor(choice):
return full_process(choice['name'])
res = process.extractOne(poblacio, poblacions_list, processor)
if not res:
print "Població no trobada: %s" % poblacio
continue
@guilleJB
guilleJB / locs.sql
Last active December 21, 2015 08:28 — forked from ecarreras/locs.sql
\x
select
locked.pid AS locked_pid,
locker.pid AS locker_pid,
locked_act.usename AS locked_user,
locker_act.usename AS locker_user,
locked.virtualtransaction,
locked.transactionid as locked_transactionid,
locker.transactionid as locker_transactionid,
locked.locktype,
#!/bin/sh
VPN_PATH="/etc/openvpn/porta/[email protected]"
VPN_CONFIG="[email protected]"
case "$1" in
start)
echo "Connecting to GISCE VPN"
openvpn --client --config $VPN_PATH/$VPN_CONFIG >$VPN_PATH/logfile &
;;

Adding SFTP-only user to Ubuntu Server

To add a SFTP-only user, you'll need to make sure your SSH config settings are correct, add a new user/group and set permissions for your new user. For step-by-step directions, see below. Omit sudo if you're logged in as root.

Directions

  1. Edit /etc/ssh/sshd_config and make sure to add the following at the end of the file:

     Match group filetransfer
    

ChrootDirectory %h

mike@rbci:~$ psql -U postgres
psql (9.0.3)
Type "help" for help.
postgres=# update pg_database set datallowconn = TRUE where datname = 'template0';
UPDATE 1
postgres=# \c template0
You are now connected to database "template0".
template0=# update pg_database set datistemplate = FALSE where datname = 'template1';
UPDATE 1
@guilleJB
guilleJB / x11vnc.md
Created December 30, 2015 14:53 — forked from tinogis/x11vnc.md
x11vnc screen and program sharing

Screen sharting with x11vnc

Share desktop screen

x11vnc -display :0

Share only one screen on a dual screeen desktop for multiples (-shared) clients

@guilleJB
guilleJB / cast.py
Created December 5, 2016 21:13 — forked from duggan/cast.py
Using pychromecast to headlessly stream youtube videos
#!/usr/bin/env python
"""
Requires pychromecast.
Install with `pip install pychromecast`
usage: cast.py [-h] -d DEVICE -v VIDEO
Cast YouTube videos headlessly.
@guilleJB
guilleJB / example.py
Created December 13, 2016 08:44 — forked from schlamar/example.py
mplog: Python advanced multiprocessing logging.
import logging
import multiprocessing
import time
import mplog
FORMAT = '%(asctime)s - %(processName)s - %(levelname)s - %(message)s'
logging.basicConfig(level=logging.DEBUG, format=FORMAT)
existing_logger = logging.getLogger('x')
@guilleJB
guilleJB / git-squash.sh
Created January 4, 2018 16:04 — forked from favila/git-squash.sh
git-squash: script to create a squashed patch from a branch.
#! /bin/sh
# Produce a squash-commit patch from a branch of changes
MASTER=$1
PATCHBRANCH=$2
SQUASHBRANCH="$PATCHBRANCH-squash"
MESSAGE=$3
git checkout -b $SQUASHBRANCH $MASTER &&
git merge --squash $PATCHBRANCH &&
git commit -a -m "$MESSAGE" &&
@guilleJB
guilleJB / Directions for creating PEM files
Created October 25, 2018 10:54 — forked from dain/Directions for creating PEM files
Create Java KeyStore from standard PEM encoded private key and certificate chain files
# To regenerate the test key and certificates
# Generate an RSA private key and convert it to PKCS8 wraped in PEM
openssl genrsa 2048 | openssl pkcs8 -topk8 -inform pem -outform pem -nocrypt -out rsa.key
# Generate a certificate signing request with the private key
openssl req -new -key rsa.key -out rsa.csr
# Sign request with private key
openssl x509 -req -days 10000 -in rsa.csr -signkey rsa.key -out rsa.crt