Skip to content

Instantly share code, notes, and snippets.

from re import findall
from time import time
from datetime import datetime
from csv import writer
from pprint import pformat
from requests import get
### <CONFING>
package main
import (
"encoding/json"
"fmt"
)
type APIResponse struct {
Satus int `json:"status"`
Body *APIResponseBody `json:"body"`
# python -m enelcine.cms.manage shell
from enelcine.cms.models import Theater
vip_names = {1: 'VIP', 2: 'Premier', 7: 'Platino', 14: 'Premiere'}
vip_theaters = Theater.objects.filter(is_vip=1)
mislabeled_theaters = [t for t in vip_theaters if t.theater.find(vip_names[t.chain_id]) < 0]
for t in mislabeled_theaters:
print '%s\t%s' % (t.theater_id, t.url)
@ernestom
ernestom / ubuntu-PIL-corrupt-image-fix.sh
Created February 22, 2013 00:04
Fixes PIL's "corrput image" errors in ubuntu.
sudo ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib/
sudo ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib/
sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/
sudo apt-get remove libjpeg-dev -y
sudo rm -rf /usr/local/lib/python2.7/dist-packages/PIL
sudo rm -rf /usr/local/lib/python2.7/dist-packages/PIL.pth
sudo apt-get install libjpeg-dev -y
sudo pip install PIL
@ernestom
ernestom / fixgifs.sh
Created February 10, 2013 08:54
Fix imgur mistakes :( These one liners rename files with jpg extension to gif extension if their mime type is image/gif, after replacing spaces with underscores and jpeg with jpg.
#!/bin/bash
# depends on `brew install rename`
cd ~/Pictures/pics
find . | rename 's/\ /_/g'
find . -iname '*.jpeg' | rename 's/jpeg$/jpg/g'
find . -iname '*.jpg' -exec file -F '' --mime {} \; \
| grep -i 'image/gif' | awk '{print $1}' \
| while read file; do bn=`basename -s .jpg $file`; mv $bn.jpg $bn.gif; done
@ernestom
ernestom / runexample.sh
Last active December 10, 2015 16:18
Script para llenar una tabla de mysql con los logs de Akamai para TE.
#!/bin/bash
FINDPATH="/Users/ernesto/Desktop/te/logs/";
FINDSEARCH="www_171150.esclf_waf*";
DB="test"
TABLE="te_logs_www";
TMPFILE="/tmp/uwslog_www.txt"
LOGFILE="/tmp/parsed_www.log"
for file in $(find $FINDPATH -name $FINDSEARCH ! -size 0); do
#!/bin/bash
# count duplicate entries in application log files
TMPDIR="/tmp/duplicates/"
APPDIR="/usr/local/sitios/"
cd $APPDIR
FILES=$(find ./ -path '*logs/2012*log' | sort -t '/' -k 5 | tail -n 1000);
rm -r $TMPDIR
mkdir $TMPDIR
@ernestom
ernestom / Vagrantfile
Last active October 14, 2015 01:07
Vagrantfile base entutele
# -*- mode: ruby -*-
# vi: set ft=ruby :
#
# This file should be one directory above.
#
# Example:
#
# $ pwd
# /Users/ernesto/Code/Menta/enlatele <-- This is the vagrant project
@ernestom
ernestom / flickr-api.php
Created December 5, 2012 23:03
Simple PHP Flickr API Client
<?php
/***************************************************************************************************
USAGE
<?php
include 'flickrapi.php';
$apiKey = 'XXXXXXXXXXXXXXXXXXXXXXXX';
$userId = 'XXXXXX@XXX';
@ernestom
ernestom / delete_documents_from_view_result.rb
Created October 4, 2012 00:55 — forked from KlausTrainer/delete_documents_from_view_result.rb
Delete all documents whose id appears in a given view result.
#!/usr/bin/env ruby
require 'rubygems'
require 'rest_client'
require 'json'
require 'cgi'
def bye
abort("Usage: #{$0} [view_url]\nExample: #{$0} http://admin:[email protected]:5984/db/_design/ddoc/_view/recent-posts")