Skip to content

Instantly share code, notes, and snippets.

@juanpabloaj
juanpabloaj / moda_media.py
Created May 30, 2012 02:13
ejemplo python: moda y mediana
#!/usr/bin/python
# -*- coding: utf-8 -*-
# http://docs.python.org/tutorial/datastructures.html
l = [ 1, 10, 4, 2, 4, 3, 3, 1, 1, 3]
print l
promedio = sum(l)/len(l)
@juanpabloaj
juanpabloaj / datos.txt
Created June 12, 2012 22:40
ejemplo python: suma columna
dato1 1 10
dato2 2 20
dato3 3 30
# dasadads
dato4 4 40
dato5 5 50
# dads
dato6 6 60
dato7 7 70
dato8 8 80
@juanpabloaj
juanpabloaj / BufferIsEmpty.vim
Created June 18, 2012 15:53
if vim BufferIsEmpty
fun! BufferIsEmpty() "{{{
if line('$') == 1 && getline(1) == ''
return 1
else
return 0
endif
endf "}}}
@juanpabloaj
juanpabloaj / operaciones.py
Created June 21, 2012 13:57
python captura de entrada
#!/usr/bin/python
# -*- coding: utf-8 -*-
# escoger opcion
def opciones():
print 's : sumar'
print 'r : restar'
print 'q : salir'
function archiveNotification() {
var threads = GmailApp.getInboxThreads();
for ( var i = 0 ; i < threads.length; i++){
var subject = threads[i].getFirstMessageSubject();
if ( subject == "Notification Subject" ){
//Logger.log(subject);
GmailApp.moveThreadToArchive(threads[i])
}
@juanpabloaj
juanpabloaj / calendarHours.gs
Created June 30, 2012 03:15
weekly hours in google calendar to spreadsheet
function ymd(date){
return Utilities.formatDate(date,"CLT","yyyy-MM-dd");
}
function calendarsColors(){
var colors = {};
var cals = CalendarApp.getAllOwnedCalendars();
for ( var c = 0 ; c < cals.length ; c++){
colors[cals[c].getName()] = cals[c].getColor();
}
return colors;
@juanpabloaj
juanpabloaj / buscar.py
Created July 5, 2012 03:06
busqueda del 10000 en varios archivos
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import shutil
import random
def verificar(path):
# verificar que el archivo tiene un 10000
archivo = open(path,'r')
for linea in archivo:
" http://vim.wikia.com/wiki/HTML_entities
" http://www.bigbaer.com/sidebars/entities/
" FIXME: you don't know how to use the -range argument! (doesn't work)
command! -range HtmlEncode <line1>,<line2>call HtmlEntities('encode')
command! -range HtmlDecode <line1>,<line2>call HtmlEntities('decode')
" TODO: only accept full lines as a range; would be nice for arbitrary selection
function! HtmlEntities(action) range
" & -> &amp; should be the first substitution
let entities = [
@juanpabloaj
juanpabloaj / Makefile
Created September 15, 2012 03:11
compile *.cpp
sources = $(wildcard *.cpp)
files = $(sources:.cpp=)
all: $(files)
%: %.cpp
g++ -o $@ $<
clean:
rm $(files)
@juanpabloaj
juanpabloaj / itunes
Created October 7, 2012 19:17 — forked from rkumar/itunes.sh
control iTunes from command line
#!/bin/bash
#
####################################
# iTunes Command Line Control v1.0
# written by David Schlosnagle
# created 2001.11.08
# TODO add -v for echo message
####################################
showHelp () {