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/USUARI@porta.gisce.net"
VPN_CONFIG="USUARI@porta.gisce.net.ovpn"
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 / frames.sh
Last active September 21, 2015 14:57
Extract frames from videos
#Extract frames every 25 frames
#start second
#duration 4
ffmpeg -ss 00:00:25 -t 00:00:00.04 -i YOURMOVIE.MP4 -r 25.0 YOURIMAGE%4d.jpg
#Extract all frames
ffmpeg -i "YOURMOVIE.MP4" -t 5 -ss 00:00:09 /tmp/frames_%04d.png
@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 / fabfile.py
Created April 30, 2016 15:23
Install packages computer using fabric and fabtools
import os
@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')