Skip to content

Instantly share code, notes, and snippets.

Avatar

Adrián Arroyo Calle aarroyoc

View GitHub Profile
@aarroyoc
aarroyoc / sparky.py
Created Jan 19, 2020
PySpark example
View sparky.py
# ~/spark-3.0xxxx/bin/spark-submit sparky.py
from pyspark.sql import SparkSession
spark = SparkSession.builder.appName("test").getOrCreate()
sc = spark.sparkContext
# Word Count
inputfile = sc.textFile("input.txt")
counts = inputfile.flatMap(lambda x: x.split(" ")).map(lambda x: (x, 1)).reduceByKey(lambda x,y: x+y)
counts.saveAsTextFile("output")
@aarroyoc
aarroyoc / build-pcc-deb.sh
Created Jan 10, 2020
Debian package for PCC
View build-pcc-deb.sh
#!/bin/bash
wget https://github.com/aarroyoc/pcc/archive/master.zip -O pcc.zip
unzip pcc.zip
mkdir -p pcc-master/debian
cp {compat,install,control,changelog,rules} pcc-master/debian/
cd pcc-master
dpkg-buildpackage -us -uc
@aarroyoc
aarroyoc / README.md
Created Jan 10, 2020
Nix package for PCC
View README.md

Building

nix-build pcc.nix
nix-env -f pcc.nix -i pcc
View README.md

Building

sudo snap install snapcraft --classic
snapcraft --use-lxd
sudo snap install --devmode --dangerous *.snap
@aarroyoc
aarroyoc / termometro.py
Created Nov 25, 2019
Termometro Tkinter
View termometro.py
from tkinter import *
from tkinter import ttk
class Termometro(Tk):
def __init__(self):
Tk.__init__(self)
self.geometry("210x350")
self.title("Termometro")
self.configure(bg="SystemButtonFace")
View keybase.md

Keybase proof

I hereby claim:

  • I am aarroyoc on github.
  • I am aarroyoc (https://keybase.io/aarroyoc) on keybase.
  • I have a public key ASDQ70UeqlYN19lS9UCUQw0x6KE6ofgYZ1R32xmvnYC0Awo

To claim this, I am signing this object:

@aarroyoc
aarroyoc / bitbucket_sync.py
Created Jun 17, 2018
BitBucket Sync Python
View bitbucket_sync.py
from bitbucket.bitbucket import Bitbucket
import os
import subprocess
def cmd(command):
print(command)
args = command.split(" ")
result = subprocess.run(args,stdout=subprocess.PIPE)
out = result.stdout.decode("utf-8").strip()
print(out)
@aarroyoc
aarroyoc / github.py
Last active Jul 2, 2019
GitHub Sync GraphQL Python
View github.py
import requests
import os
import subprocess
url = "https://api.github.com/graphql"
api_token = "PERSONAL_API_TOKEN"
headers = {'Authorization': 'token %s' % api_token}
first_query = { 'query' : '''
{
viewer {
@aarroyoc
aarroyoc / jarras.pl
Created May 21, 2018
Problema de las jarras - PROLOG
View jarras.pl
%%% Algoritmo primero en profundidad con profundidad máxima
% resolver (Id_Problema,PMax,Solucion)
resolver_pmax(Problema,PMax,[Eo|Solucion]) :-
estado_inicial(Problema,Eo),
resolver_pmax_aux(Problema,Eo,PMax,[Eo],Solucion).
% resolver(Id_Problema,Ei,NumPasos,Visitados,Solucion)
resolver_pmax_aux(Problema,En,_,_,[]) :-
estado_final(Problema,En).
@aarroyoc
aarroyoc / sumst.hs
Created Apr 9, 2018
Suma con mónada ST
View sumst.hs
import Data.STRef
import Control.Monad
import Control.Monad.ST
sumST :: Num a => [a] -> a
sumST xs = runST $ do
n <- newSTRef 0
forM_ xs $ \x -> do
modifySTRef n (+x)
You can’t perform that action at this time.