from ftplib import FTP
from datetime import datetime
start = datetime.now()
ftp = FTP('your-ftp-domain-or-ip')
ftp.login('your-username','your-password')
# Get All Files
files = ftp.nlst()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Plot a PNG using matplotlib in a web request, using Flask." | |
# Install dependencies, preferably in a virtualenv: | |
# | |
# pip install flask matplotlib | |
# | |
# Run the development server: | |
# | |
# python app.py | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""This is just an example of how to provide permissions on a per-object basis in the admin""" | |
from django.contrib import admin | |
from django.contrib.auth.models import Permission | |
from django.contrib.contenttypes import generic | |
from django.contrib.contenttypes.models import ContentType | |
from account.models import ObjectGroupPermission, ObjectUserPermission | |
from myapp.models import MyModel | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- show running queries (pre 9.2) | |
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(clock_timestamp(), query_start), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
More info: | |
http://flask.pocoo.org/docs/patterns/wtforms/ | |
http://pythonhosted.org/Flask-SQLAlchemy/ | |
https://flask-login.readthedocs.org/en/latest/ | |
""" | |
from flask import current_app, request, render_template, redirect, url_for | |
from myapp.models import User |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework import permissions | |
class IsOwner(permissions.BasePermission): | |
""" | |
Custom permission to only allow owners of an object to edit it. | |
""" | |
def has_permission(self, request, view): | |
return request.user and request.user.is_authenticated() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Simple example of Wiener deconvolution in Python. | |
# We use a fixed SNR across all frequencies in this example. | |
# | |
# Written 2015 by Dan Stowell. Public domain. | |
import numpy as np | |
from numpy.fft import fft, ifft, ifftshift |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/libnfc/drivers/acr122_usb.c b/libnfc/drivers/acr122_usb.c | |
index 8a16920..b3df024 100644 | |
--- a/libnfc/drivers/acr122_usb.c | |
+++ b/libnfc/drivers/acr122_usb.c | |
@@ -603,6 +603,7 @@ read: | |
uint8_t attempted_response = RDR_to_PC_DataBlock; | |
size_t len; | |
+ int error, status; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import geopands as gpd | |
from shapely.geometry.polygon import Polygon | |
from shapely.geometry.multipolygon import MultiPolygon | |
def explode(indata): | |
indf = gpd.GeoDataFrame.from_file(indata) | |
outdf = gpd.GeoDataFrame(columns=indf.columns) | |
for idx, row in indf.iterrows(): | |
if type(row.geometry) == Polygon: | |
outdf = outdf.append(row,ignore_index=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# License: CC0 1.0 or newer | |
# https://creativecommons.org/publicdomain/zero/1.0/ | |
# You can download this script here: https://gist.github.com/vazhnov/fcb487e6ea432fec056793ef710b5a28 | |
wget "http://repo.zabbix.com/zabbix/3.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.0-1+xenial_all.deb" | |
sudo dpkg -i zabbix-release_3.0-1+xenial_all.deb | |
sudo apt-get update | |
sudo apt-get install zabbix-server-pgsql zabbix-frontend-php libapache2-mod-php php-bcmath php-mbstring php7.0-xml php-pgsql | |
# Zabbix can't work without password (with ident), so you need to create user with password: |
OlderNewer