Skip to content

Instantly share code, notes, and snippets.

@agustincl
agustincl / controllers.achievements.py
Created December 10, 2019 10:03 — forked from raphox/controllers.achievements.py
Upload with Flask, Flask-WTF, WTForms and WTForms-Alchemy
import os
from app import app
from app.database import db_session
from app.models.achievement import Achievement
from app.forms.achievement import AchievementForm
from flask import Blueprint, render_template, abort, request, redirect, flash, url_for
from werkzeug import secure_filename
@agustincl
agustincl / vm-backup.sh
Created September 7, 2017 04:01 — forked from cabal95/vm-backup.sh
I use this script to backup my QEMU/KVM/libVirt virtual machines. The script requires KVM 2.1+ since it uses the live blockcommit mode. This means the data in the snapshot disk is rolled back into the original instead of the other way around. Script does NOT handle spaces in paths.
#!/bin/bash
#
BACKUPDEST="$1"
DOMAIN="$2"
MAXBACKUPS="$3"
if [ -z "$BACKUPDEST" -o -z "$DOMAIN" ]; then
echo "Usage: ./vm-backup <backup-folder> <domain> [max-backups]"
exit 1
@agustincl
agustincl / bng_to_latlon.py
Created May 20, 2017 10:09 — forked from lfigueira/bng_to_latlon.py
Python script to convert British National grid coordinates (OSGB36 Eastings, Northings) to WGS84 latitude and longitude. The code from this script was copied/adapted from Hannah Fry's blog; the original code and post can be found here: http://www.hannahfry.co.uk/blog/2012/02/01/converting-british-national-grid-to-latitude-and-longitude-ii, toghe…
#
# Converts eastings and northings (British national grid coordinates) to Lat/Long
#
# Original code author: Hannah Fry; see code/comments here:
# http://www.hannahfry.co.uk/blog/2012/02/01/converting-british-national-grid-to-latitude-and-longitude-ii
#
from math import sqrt, pi, sin, cos, tan, atan2 as arctan2
import csv
# SYNTAX:
var pattern = new RegExp(pattern, attributes); # attributes: g (global); i (case-sensitive); m (multiline matches)
var pattern = /pattern/attributes; # same as above
# BRACKETS:
[...]: Any one character between the brackets.
[^...]: Any one character not between the brackets.
@agustincl
agustincl / 1-1000.txt
Created May 11, 2017 15:29 — forked from deekayen/1-1000.txt
1,000 most common US English words
the
of
to
and
a
in
is
it
you
that
# !/usr/bin/env python
# -*- coding: utf-8 -*-
import read
from flask import Flask
from flask_cors import CORS, cross_origin
app = Flask(__name__)
CORS(app)
<html>
<head>
<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.charts.load('current', {'packages':['corechart']});
@agustincl
agustincl / streamingTweet2CB.py
Created March 31, 2017 11:58
Insert tweets into couchbase
from __future__ import absolute_import, print_function
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream
from couchbase.bucket import Bucket
from couchbase.n1ql import N1QLQuery
import json
@agustincl
agustincl / GeoIPCountryWhois.csv
Last active March 31, 2017 10:57 — forked from Luavis/GeoIPCountryWhois.csv
GeoIpCountryWhois with header
We can't make this file beautiful and searchable because it's too large.
StartIP,EndIP,StartIPInt,EndIpInt,CountryCode,Country
"1.0.0.0","1.0.0.255","16777216","16777471","AU","Australia"
"1.0.1.0","1.0.3.255","16777472","16778239","CN","China"
"1.0.4.0","1.0.7.255","16778240","16779263","AU","Australia"
"1.0.8.0","1.0.15.255","16779264","16781311","CN","China"
"1.0.16.0","1.0.31.255","16781312","16785407","JP","Japan"
"1.0.32.0","1.0.63.255","16785408","16793599","CN","China"
"1.0.64.0","1.0.127.255","16793600","16809983","JP","Japan"
"1.0.128.0","1.0.255.255","16809984","16842751","TH","Thailand"
"1.1.0.0","1.1.0.255","16842752","16843007","CN","China"
#!/usr/bin/env python
import sys, os, time, atexit
from signal import SIGTERM
class Daemon:
"""
A generic daemon class.
Usage: subclass the Daemon class and override the run() method