Skip to content

Instantly share code, notes, and snippets.

View graffic's full-sized avatar

Javier Gonel graffic

View GitHub Profile

Keybase proof

I hereby claim:

  • I am graffic on github.
  • I am graffic (https://keybase.io/graffic) on keybase.
  • I have a public key whose fingerprint is D44E 1E92 061C 54D4 964F 4470 D075 45BC 53D6 9D57

To claim this, I am signing this object:

@graffic
graffic / NetvolutionDuplicates.sql
Created November 24, 2010 07:27
List netvolution duplicates
WITH temp_Pages (pId, pLangId,pParentId, pFriendlyUrl) AS
(
SELECT pId, pLangId,
pParentId,
CONVERT(NVARCHAR(200),
'http://' +
(SELECT e.siteName FROM cms_Sites e WHERE e.siteID=pSiteID) +
'/' +
(SELECT c.langShortName FROM cms_Languages c WHERE c.langID=pLangID) +
'/' +
@graffic
graffic / gist:975190
Created May 16, 2011 19:51
Zabbix proxy item query
mysql> explain select p.id,h.host,i.key_,p.clock,p.timestamp,
p.source,p.severity,p.value,p.logeventid
from hosts h,items i,proxy_history p where h.hostid=i.hostid
and i.itemid=p.itemid and p.id>21824754 order by p.id limit 1000\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: p
type: range
possible_keys: PRIMARY,id
@graffic
graffic / gist:975224
Created May 16, 2011 20:01
Corrected Zabbix proxy query.
mysql> explain select p.id,h.host,i.key_,p.clock,p.timestamp,
p.source,p.severity,p.value,p.logeventid
from hosts h inner join items i on h.hostid=i.hostid
right outer join proxy_history p on i.itemid=p.itemid
where p.id>21824754 order by p.id limit 10\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: p
type: range
@graffic
graffic / gist:1283688
Created October 13, 2011 08:01
Webservices checker script for nagios
#!/usr/bin/python2.7
from random import randrange
from datetime import timedelta,datetime
def prepare_message():
message = """<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
@graffic
graffic / console.py
Created October 18, 2011 11:15
Dummy Flights web services tester
#!/usr/bin/python
import httplib, time
from flights_pb2 import SearchRequest
class FlightsService(object):
"""Basic Flights service implementation with common methods"""
def __init__(self,host="10.0.0.210",port=80):
self.__ws = httplib.HTTPConnection(host,port)
@graffic
graffic / gist:1404782
Created November 29, 2011 13:18
Dictionaries to Map in MessagePack for .NET
if (type.IsMap())
{
Label work = il.DefineLabel();
Label getNext = il.DefineLabel();
Label end = il.DefineLabel();
il.EmitLd(arg_writer);
// 1. Get length of the dictionary
il.EmitLd(arg_obj);
@graffic
graffic / nginx.conf
Created July 16, 2012 11:10
Nginx maintenance snippet
server {
...
# This is a copy&paste snippet to put your server in maintenance mode
error_page 503 @maintenance;
location @maintenance {
rewrite ^(.*)$ /maint.html break;
}
return 503;
@graffic
graffic / fastcgi.sh
Created July 23, 2012 07:08
Django on fastcgi and nginx featuring transifex.
#! /bin/sh
### BEGIN INIT INFO
# Provides: FastCGI servers for Django
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start FastCGI servers with Django.
# Description: Django, in order to operate with FastCGI, must be started
# in a very specific way with manage.py. This must be done
@graffic
graffic / gist:6577063
Created September 16, 2013 05:46
Pyramid bootstrap setting a base_url for the request.
def bootstrap(config_uri, options=None):
"""
Bootstraps a pyramid environment
Differences with the default pyramid bootstrap:
- It handles tasks.base_url
"""
app = get_app(config_uri, options=options)
registry = global_registries.last
base_url = registry.settings.get('tasks.base_url', None)