Skip to content

Instantly share code, notes, and snippets.

View avenet's full-sized avatar

Andy Venet avenet

  • Bioinnovation
  • Santiago de Chile
View GitHub Profile
@avenet
avenet / pgbouncer_realtime
Last active August 29, 2015 13:58
Realtime moitoring pgbouncer
#!/bin/bash
# -*- ENCODING: UTF-8 -*-
dbname="db_name"
username="db_user"
host="localhost"
port="6432"
available_commands=("lists" "pools" "servers")
if [[ $# -eq 0 ]] ; then
echo 'realtime_monitoring [lists][pools][servers]'
Dim freeSpace
Dim boundarySpace
Set objWMIService = GetObject("winmgmts:")
Set objLogicalDisk = objWMIService.Get("Win32_LogicalDisk.DeviceID='c:'")
freeSpace = Round(objLogicalDisk.Freespace/1048576)
boundarySpace = 5120
Wscript.Echo "Free space (in MB): " & freeSpace
@avenet
avenet / exc_traceback.py
Last active August 29, 2015 14:00
Get exception traceback
import traceback
try:
raise Exception("This is the exception text")
except Exception, e:
exception_traceback = traceback.format_exc()
print exception_traceback
@avenet
avenet / django_extensions_profile_server.bat
Last active August 29, 2015 14:01
Run django extensions profiler server
manage.py runprofileserver --kcachegrind --prof-path="."
@avenet
avenet / profiler_stats.py
Created May 16, 2014 21:19
Print Python profiler debug stats
filename = "profiling_data.pyprof"
import pstats
p = pstats.Stats(filename)
p.strip_dirs().sort_stats(-1).print_stats()
@avenet
avenet / python_profiler.bat
Created May 16, 2014 21:21
Run django server in profiling mode
python -m cProfile -o your_profile_file.pyprof manage.py runserver
@avenet
avenet / scraping.cs
Last active August 29, 2015 14:02
Uses the HttpClient library for .NET
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Http;
using System.IO;
using System.Net;
using System.Net.Http.Headers;
namespace Avenet.Utils
@avenet
avenet / OffsetHours.cs
Last active August 29, 2015 14:03
Retrieves the local offset hours based on the current date
using System;
namespace Avenet.Utils
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(GetLocalOffsetHours());
}
@avenet
avenet / qr_generator.html
Created August 18, 2014 21:08
QR Generator using Google Chart API
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Google QR Generator</title>
<meta name="description" content="">
@avenet
avenet / outlook_periodic_items.py
Created August 26, 2014 22:24
Generating Outlook periodic items via Python Dateutil
from datetime import datetime
from itertools import islice
from dateutil.rrule import rrule, DAILY, WEEKLY, MONTHLY, YEARLY, SU, MO, TU, WE, TH, FR, SA
#Every two days from now on
rule_day = rrule(DAILY, dtstart=datetime.today(), interval=2)
#Every two weeks (Monday, Tuesday and Wednesday) starting from now
rule_week = rrule(WEEKLY, dtstart=datetime.today(), interval=2, byweekday=(MO, TU, WE))