Skip to content

Instantly share code, notes, and snippets.

View zeehio's full-sized avatar

Sergio Oller zeehio

View GitHub Profile
@zeehio
zeehio / optiwine.sh
Created November 3, 2012 23:25 — forked from zipizap/hl2_optirun_start.sh
optirun and wine (on Ubuntu precise 12.04 64-bit)
#!/bin/bash
# This is a short script to load applications using bumblebee and wine
# on systems such as Ubuntu precise 12.04 64 bit using the discrete card.
# Usage example (the -opengl would be a parameter of the program "Frozen Throne.exe"):
# optiwine.sh "Frozen Throne.exe" -opengl
# Extra information:
# If you want to load programs with the integrated intel card instead, you may run them this way:
@zeehio
zeehio / crea_matrius.c
Last active December 23, 2015 22:19
Eina per utilitzar matrius bidimensionals en C de manera senzilla. Potser a algú que comenci amb C li resulta util.
/** \file crea_matrius.c
* \copyright No copyright reserved (consider it Public Domain or CC0 as you wish)
*/
#include <stdio.h>
#include <stdlib.h>
typedef double* DVector;
typedef DVector* DMatrix;
/** \fn CreateDVector
@zeehio
zeehio / python-funcions.md
Last active December 27, 2015 12:49
Una analogia de funcions en programació amb funcions a matemàtiques que espero que ajudi als estudiants que comencen a programar.

Funcions: Variables locals

En aquesta pàgina s'explica com s'utilitzen els arguments de funcions i com no s'utilitzen. Primer fem una analogia amb les funcions matemàtiques i després apliquem la mateixa lògica de les funcions matemàtiques a la programació.

La gràcia de fer servir funcions és que divideixes un problema (dibuixar una cara) en petites parts independents entre sí (ulls, nas, boca...).

Com documentar funcions i com aprofitar-ho amb ipython notebook

Com documentar funcions:

Python permet documentar funcions amb docstrings. Un docstring és una cadena de text que va just després de la definició de la funció i que descriu què fa la funció, quins arguments necessita i què retorna per pantalla.

def digueshola():
    """ Aquesta funció imprimeix hola per pantalla."""
    print "hola"
@zeehio
zeehio / buscar_elements.ipynb
Created November 25, 2013 11:32
Buscar elements i índexs a llistes i np.arrays
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@zeehio
zeehio / install-rstudio-server.sh
Last active December 29, 2015 15:19
Install rstudio-server and setup nginx on in order to have http://default_server/rstudio on Ubuntu precise (and other ubuntus probably)
#!/bin/bash -x
# Distribution codename:
which lsb_release >/dev/null|| (echo "Could not find lsb_release" ; exit 1)
which apt-get >/dev/null|| (echo "Could not find apt-get" ; exit 1)
codename=$(lsb_release -cs) # "precise"
# Add R repository:
rsourceslist="/etc/apt/sources.list.d/r_sources.list"
@zeehio
zeehio / gen-statistics.sh
Last active February 17, 2023 08:37
Generate HTML page with CPU, RAM, and disk usage information for several SSH servers.TODO: There are too many SSH connections per server. Fixing that would speed up a lot the HTML generation.
#!/bin/bash
# Shell script to get disk usage, cpu usage, RAM usage,system load,etc.
# from multiple Linux servers and output the information on a single
# server in html format. Read below for usage/installation info
# *--------------------------------------------------------------------*
# * ORIGINAL WORK BY:
# * dig_remote_linux_server_information.bash,v0.1
# * Last updated on 25-Jul-2005*
# * Copyright (c) 2005 nixCraft project *
# * Comment/bugs: http://cyberciti.biz/fb/ *
@zeehio
zeehio / tensors_i_numpy.ipynb
Created December 10, 2013 11:23
Utilitzar tensors i numpy (contracció de tensors i indexat)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@zeehio
zeehio / resolucio_producte_matrius.ipynb
Created December 10, 2013 17:33
Resolucio exercici producte matrius
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@zeehio
zeehio / extract_moodle_files.py
Created October 16, 2015 10:09
Copy files from moodle mbz into an ordered directory tree.
#!/usr/bin/env python3
"""
Moodle provides a backup system for courses offering an mbz file. This is a zip file with
all the resources and files included and the needed metadata about the files encoded in XML.
This script gets an unzipped mbz directory and copies all the files from the course into
a directory tree with the same layout than the original moodle course.
unzip my_moodle_backup.zip
extract_moodle_files.py --source my_moodle_backup_FILES --destination sorted_course