Skip to content

Instantly share code, notes, and snippets.

@rubenafo
rubenafo / reqs.txt
Last active May 24, 2023 08:29
PyDataBCN 2023 - requirements
Requirements
============
1. A laptop with Python 3.10 installed - https://www.python.org/
2. Install JupyterLab - https://jupyter.org/install
3. Open a free account in HuggingFace to be able to use the latest models - https://huggingface.co/
public class MySampleClient extends TextWebSocketHandler {
@Getter
private WebSocketSession clientSession;
public MySampleClient () throws ExecutionException, InterruptedException {
var webSocketClient = new StandardWebSocketClient();
this.clientSession = webSocketClient.doHandshake(this, new WebSocketHttpHeaders(), URI.create("wss://echo.websocket.org")).get();
}
import requests
import datetime
from bs4 import BeautifulSoup
wiki_url = "https://en.wikipedia.org/wiki/List_of_S%26P_500_companies"
def getConstituents():
urlContent = requests.get(wiki_url).text
soup = BeautifulSoup(urlContent, "html.parser")
@rubenafo
rubenafo / ProcessingScala.scala
Last active February 22, 2016 16:24
Simplest script to show how to run Processing from Scala code
import processing.core._
class ScalaProcessingExample extends PApplet
{
override def settings ()
{
size(200, 200)
}
override def setup() {
@rubenafo
rubenafo / ProcessingJava.java
Last active February 22, 2016 15:57
Simplest Processing script
import processing.core.PApplet;
public class SimpleDrawSketch extends PApplet {
@Override
public void settings () {
size(200,200);
}
@Override
@rubenafo
rubenafo / yfm-os.cli.py
Last active December 25, 2015 10:19
This scripts setups an instance of yfinanceMongo to run it inside a Openshift using system-provided MongoDB access variables (user, password, host and port)
#!/usr/bin/env python
#
# Script to run yfinanceMongo (see http://www.github.com/figurebelow) inside a OpenShift cartdrige
#
import sys
import os
from yfinanceCli import *
@rubenafo
rubenafo / ibex35.json
Last active December 21, 2015 00:28
A list of current IBEX35 stock ids (always comes handy)
{ "date": "13/08/2013",
"symbols": [ {"id": "ABE.MC", "desc": "Abertis Infraestructuras SA"},
{"id": "ACS.MC", "desc": "ACS Actividades de Construccion y Servicios SA"},
{"id": "ACX.MC", "desc": "Acerinox, S.A"},
{"id": "AMS.MC", "desc": "Amadeus IT Holding SA"},
{"id": "ANA.MC", "desc": "Acciona,S.A"},
{"id": "BBVA.MC", "desc": "Banco Bilbao Vizcaya Argentaria SA"},
{"id": "BKT.MC", "desc": "Bankinter SA"},
{"id": "BME.MC", "desc": "Bolsas y Mercados Espanoles"},
{"id": "CABK.MC", "desc": "CAIXABANK"},
@rubenafo
rubenafo / checkTicker.sh
Created August 2, 2013 06:53
Bash line to fetch yahoo tickers from Spanish stock symbols
#!/bin/bash
# example: ./checkTicker.sh san.mc tef.mc
for ticker in "$@"; do
echo -n $ticker " "
curl -s 'http://es.finance.yahoo.com/q?s='$ticker | grep -o "<span id=\"yfs_l.*"$ticker"\">.*</span>" | grep -oEi '>[0-9,]+<' | sed s/'[<>]'//g
done
@rubenafo
rubenafo / EclipseDeps2CSV.sh
Last active December 20, 2015 00:58
A bash script to printout a list of CSV of the dependencies between plugins inside a Eclipse workspace.
#!/bin/bash
for myfile in `find $1 | grep MF$`; do
source=`echo $myfile | awk -F/ '{ print $(NF-2) }'`
for dep in `cat $myfile | tr '\n' ' ' | grep -o "Require-Bundle:[[:print:]]*Bundle-RequiredExecutionEnvironment" | grep -iEo '[a-z]+[0-9]*[a-z]+.[a-z.|0-9]*' | grep '\.' | tr '\n' ' '`; do
echo $source,$dep
done
done