Skip to content

Instantly share code, notes, and snippets.

((SELECT
t.tablename as TableName,
n.nspname AS TableSchema,
a.attname as ColumnName,
pg_catalog.format_type(a.atttypid, NULL) AS DbDataType,
pg_catalog.col_description(a.attrelid, a.attnum) AS ColumnComment,
(a.attnotnull = FALSE) AS IsNullable,
p.conname AS PrimaryKeyConstraintName,
f.conname AS ForeignKeyConstraintName,
@snzip
snzip / docker-compose.yaml
Created April 8, 2020 08:04 — forked from rbq/docker.yaml
Install Docker CE on Ubuntu using Ansible
---
- hosts: all
tasks:
- name: Install prerequisites
apt:
name: ['python3-pip', 'python3-setuptools', 'virtualenv']
update_cache: yes
- name: Install docker-compose
pip:
@snzip
snzip / RecursiveWatcherService.java
Created February 6, 2020 11:23 — forked from fabriziofortino/RecursiveWatcherService.java
Java 8 Recursive WatchService
package com.keepithttps;
import com.sun.nio.file.SensitivityWatchEventModifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.File;
@snzip
snzip / stream_to_youtube.sh
Created January 30, 2020 14:31 — forked from olasd/stream_to_youtube.sh
Stream video to youtube via ffmpeg
#! /bin/bash
#
# Diffusion youtube avec ffmpeg
# Configurer youtube avec une résolution 720p. La vidéo n'est pas scalée.
VBR="2500k" # Bitrate de la vidéo en sortie
FPS="30" # FPS de la vidéo en sortie
QUAL="medium" # Preset de qualité FFMPEG
YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2" # URL de base RTMP youtube
@snzip
snzip / bluetooth-raspberry-pi-communication.py
Created December 14, 2019 08:41 — forked from keithweaver/bluetooth-raspberry-pi-communication.py
Sending information with bluetooth on Raspberry Pi (Python)
# Uses Bluez for Linux
#
# sudo apt-get install bluez python-bluez
#
# Taken from: https://people.csail.mit.edu/albert/bluez-intro/x232.html
# Taken from: https://people.csail.mit.edu/albert/bluez-intro/c212.html
import bluetooth
def receiveMessages():
@snzip
snzip / BU-restore functions in postgresql
Created October 24, 2019 14:33 — forked from denitram/BU-restore functions in postgresql
Postgresql: backup and restore functions
# First, make a dump of the database without data (-s)
$ pg_dump -h localhost -U username -Fc -s -f db_dump dbName
# Create a list of the functions
$ pg_restore -l db_dump | grep FUNCTION > function_list
# Restore the functions in an other database
$ pg_restore -h localhost -U username -d other-dbName -L function_list db_dump
@snzip
snzip / itchat_mail_QR
Last active September 30, 2019 01:55
itchat QR mail
发送邮件的例子
import time
import itchat
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
def sendmail(data):
@snzip
snzip / tornado_temp_json_post.py
Created September 30, 2019 01:54 — forked from joshmarshall/tornado_temp_json_post.py
JSON to Arguments POST in Tornado
import tornado.ioloop
import tornado.web
import tornado.httpserver
import tornado.httputil
import json
class MainHandler(tornado.web.RequestHandler):
def post(self):
# do something useful
name = self.get_argument('foo')
@snzip
snzip / gist:5405a5fd0de8ef16b0df658879333492
Created September 28, 2019 11:05 — forked from t3chnoboy/gist:8322246
Convert all files in folder to utf-8 using iconv
# http://stackoverflow.com/questions/4544669/batch-convert-latin-1-files-to-utf-8-using-iconv
find . -type f -exec bash -c 'iconv -f iso-8859-1 -t utf-8 "{}" > /path/to/destination/"{}"' \;
@snzip
snzip / xss
Last active June 5, 2019 06:26
alert(1);