Skip to content

Instantly share code, notes, and snippets.

@juanpabloaj
juanpabloaj / Makefile
Created October 12, 2012 13:40
cosmopmc wget & patch
url=http://www2.iap.fr/users/kilbinge/CosmoPMC
cosmopmc=CosmoPMC_v1.11
patch=patch_pmclib_1.01_1.1
pmclib=pmclib_v1.01
all:
tar xfz $(cosmopmc).tar.gz
tar xfz $(patch).tar.gz
tar xfz $(pmclib).tar.gz
cp $(patch)/maths.c $(pmclib)/pmctools/src
@juanpabloaj
juanpabloaj / hello_mpi.c
Created October 16, 2012 16:34
hello mpi
#include <mpi.h>
#include <stdio.h>
int main(int argc, char *argv[]){
int nprocs, rank;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
@juanpabloaj
juanpabloaj / 001.txt
Created November 21, 2012 12:55
matplotlib pyplot
2
4
1.1
5
10
3.2
1.4
0.2
@juanpabloaj
juanpabloaj / numpy_matplotlib_ipython.sh
Created November 26, 2012 01:09
numpy_matplotlib_ipython
#!/bin/bash
virtualenv venv --no-site-packages
source venv/bin/activate
pip install numpy
pip install matplotlib
easy_install readline
pip install ipython
@juanpabloaj
juanpabloaj / columns.py
Last active December 11, 2015 03:09
numpy para archivos y columnas
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import numpy as np
import matplotlib.pyplot as plt
files = {}
# almacenar nombres de archivo y contenido
dname = 'input/'
@juanpabloaj
juanpabloaj / query.js
Created January 26, 2013 15:35
Google Apps script and fusion table query example
function readFacName(fac, city){
// public fusion table
// https://www.google.com/fusiontables/DataSource?docid=1tL67aacGcCyMfAg9PUo_-gp4qm74GDtFiCMtFg
var select = "select FACNAME from 1tL67aacGcCyMfAg9PUo_-gp4qm74GDtFiCMtFg ";
var where = "where FAC_ZIP5 = '" + fac + "' AND FAC_CITY = '" + city +"'";
var query = encodeURIComponent(select + where);
var url = "http://www.google.com/fusiontables/api/query?sql=" + query;
var response = UrlFetchApp.fetch(url, {method: "get"});
return response.getContentText();
}
@juanpabloaj
juanpabloaj / DriveUpload.js
Last active May 13, 2020 22:17 — forked from skauk/DriveUpload.gs
xls attached to google spreadsheet
function uploadXls(file) {
authorize();
var key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // <-- developer key
var metadata = { title: file.getName() }
var params = {method:"post",
oAuthServiceName: "drive",
oAuthUseToken: "always",
contentType: "application/vnd.ms-excel",
contentLength: file.getBytes().length,
payload: file.getBytes()
@juanpabloaj
juanpabloaj / beginEndEvent.js
Created January 31, 2013 04:09
AppsScript: get calendar events with same name.
function authorize() {
var oauthConfig = UrlFetchApp.addOAuthService("calendar");
var scope = "https://www.googleapis.com/auth/calendar";
oauthConfig.setConsumerKey("anonymous");
oauthConfig.setConsumerSecret("anonymous");
oauthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope="+scope);
oauthConfig.setAuthorizationUrl("https://accounts.google.com/OAuthAuthorizeToken");
oauthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
}
@juanpabloaj
juanpabloaj / hoursSameName.js
Last active March 19, 2022 06:14
AppsScript: total hours of events with same name.
// add menu
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [{name:"Calcular Horas", functionName: "calculateHours"}];
ss.addMenu("Hours", menuEntries);
// calcular al iniciar
calculateHours();
}
function count_hours(cal_id, event_name){
syntax on
set backspace=eol,start,indent
set nu
set ai
set background=dark
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab