Skip to content

Instantly share code, notes, and snippets.

View restrepo's full-sized avatar

Diego Restrepo restrepo

View GitHub Profile
def get_institutions(q):
page=1
if q:
url=f'https://inspirehep.net/api/institutions?q={q}&size=250&page={page}'
else:
url=f'https://inspirehep.net/api/institutions?size=250&page={page}'
r=requests.get(url)
time.sleep(sleep)
i=r.json()['hits']['hits']
total=r.json().get('hits').get('total')
@restrepo
restrepo / dictionarize_array.py
Created May 23, 2012 05:12
Assigns a dictionary keys to the columns of a numpy array
def dictionarizearray(x,list_of_columns):
"""
Assigns a dictionary key to each of the m-columns
of the (n,m) x array
EXAMPLE in some code which loads this function:
>>> names=['var1','var2',...,'varN']
>>> xnames=dictionarizearray(x,names)
>>> xmask=x[xnames['var1']<xnames['var2']]
#instead of
@restrepo
restrepo / ubuntu.sh
Last active November 16, 2021 03:25
Ubuntu postinstall
#!/usr/bin/env bash
#Postinstall for Ubuntu 9.10 -- 14.04
#Install as root!
#after sudo su
echo "================================================================"
echo "Update and upgrade the system"
sudo apt-get install aptitude
sudo aptitude update
sudo aptitude -y safe-upgrade
echo "================================================================"
@article{Alloul:2013bka,
author = "Alloul, Adam and Christensen, Neil D. and Degrande,
Céline and Duhr, Claude and Fuks, Benjamin",
title = "{FeynRules 2.0 - A complete toolbox for tree-level
phenomenology}",
journal = "Comput. Phys. Commun.",
volume = "185",
year = "2014",
pages = "2250-2300",
doi = "10.1016/j.cpc.2014.04.012",
import re
def split_names(s,exceptions=['Gil', 'Lew', 'Liz', 'Paz', 'Rey', 'Rio', 'Roa', 'Rua', 'Sus', 'Zea'],
nacionality='Colombiana'):
"""
Extract the parts of the full name `s` in the format ([] → optional):
[SMALL_CONECTORS] FIRST_LAST_NAME [SMALL_CONECTORS] [SECOND_LAST_NAME] NAMES
If len(s) == 3 → Not Ibero-America name is asked
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@restrepo
restrepo / h-index.py
Last active July 1, 2020 17:14
Simple formula to calculation of the h-index
def hIndex(citations):
"""
https://github.com/kamyu104/LeetCode/blob/master/Python/h-index.py
:type citations: List[int]
:rtype: int
# Given an array of citations (each citation is a non-negative integer)
# of a researcher, write a function to compute the researcher's h-index.
#
# According to the definition of h-index on Wikipedia:
@restrepo
restrepo / covid_lat.ipynb
Created March 25, 2020 21:57
covid_lat.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@restrepo
restrepo / COCOVID-19.ipynb
Last active March 23, 2020 23:07
Datos oficiales COVID-19 Colombia de @MinSaludCol en https://infogram.com/covid-2019-ins-colombia-1hnq41zg9ord63z
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@restrepo
restrepo / COCOVID-19.py
Created March 23, 2020 22:57
Datos oficiales COVID-19 Colombia de @MinSaludCol en https://infogram.com/covid-2019-ins-colombia-1hnq41zg9ord63z
import requests
import pandas as pd
r=requests.get('https://infogram.com/covid-2019-ins-colombia-1hnq41zg9ord63z')
head='"data":[[["ID de caso",'
tail=']]]'
js='{}{}{}'.format( head.split(':')[-1],
r.text.split(head)[-1].split(tail)[0],
tail