Skip to content

Instantly share code, notes, and snippets.

Avatar

Ruben Berenguel rberenguel

View GitHub Profile
@rberenguel
rberenguel / pushToTalk.js
Last active Feb 27, 2020
Push to talk (space bar when Safari's Meet is under focus) bookmarklet for Google Meet, working under Mac OS in Safari. Code modified from https://gist.github.com/caseywatts/561bc498b6feec3d419b29a65d916663
View pushToTalk.js
javascript: (() => {const toggles = tip => ({ key }) => key === '' && document.querySelectorAll('[data-tooltip]').forEach(el => el.dataset.tooltip === tip && el.click());document.body.onkeyup = toggles('Turn off microphone (⌘ + D)');document.body.onkeydown = toggles('Turn on microphone (⌘ + D)');})();
@rberenguel
rberenguel / pushToTalk.js
Created Feb 27, 2020
Push to talk bookmarklet for Mac OS in Safari
View pushToTalk.js
javascript: (() => {const toggles = tip => ({ key }) => key === '' && document.querySelectorAll('[data-tooltip]').forEach(el => el.dataset.tooltip === tip && el.click());document.body.onkeyup = toggles('Turn off microphone (⌘ + D)');document.body.onkeydown = toggles('Turn on microphone (⌘ + D)');})();
@rberenguel
rberenguel / pyspark-workshop-requirements.md
Last active Nov 14, 2019
Quick writeup of the requirements for my PySpark workshop at PyDay 2019, Barcelona (https://pybcn.org/pyday-bcn-2019/)
View pyspark-workshop-requirements.md

To take full advantage of the workshop you'll need

  • PySpark installed (anything more recent than 2.3 should be fine)
  • Jupyter installed
  • Pandas and Arrow installed
  • All able to talk to each other
  • One or more datasets

You can clone this repository to have the notebook and slides (some things may still change until Saturday, like uploading and upgating the compiled slides, but the notebook is essentially finished).

@rberenguel
rberenguel / Lavaurs.lsp
Created Aug 24, 2019
Code I wrote around 2009 for rendering Lavaurs chords (an abstract Mandelbrot set). Blame my old self for my poor Lisp
View Lavaurs.lsp
;; Copyright 2009 Rubén Berenguel
;; ruben /at/ maia /dot/ ub /dot/ es
;; This program is free software: you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation, either version 3 of the
;; License, or (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
@rberenguel
rberenguel / Koch.ps
Created Aug 24, 2019
Koch snowflake in PostScript
View Koch.ps
%!PS-Adobe-2.0
%%% Start of L-system definition
/STARTK { FK +K +K FK +K +K FK} def
/FK {
dup 0 eq
{ DK } % if the recursion order ends, draw forward
{
1 sub % recurse
@rberenguel
rberenguel / postcard2008.ps
Created May 31, 2019
Christmas Postcard 2008 in PostScript
View postcard2008.ps
%!PS-Adobe-3.0
%%BeginFeature: *PageSize A4
<< /PageSize [595 842] >> setpagedevice
%%EndFeature
%/PageSize A4
/CoordX 595 def
/CoordY 842 def
/RadiMax 95 def
@rberenguel
rberenguel / mand.ps
Created May 31, 2019
Simple Mandelbrot set generator in PostScript
View mand.ps
%!PS-Adobe-2.0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% Mandelbrot set via PostScript code. Not optimized %
% in any way. Centered in A4 paper. Escape time, B&W %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/fun {
@rberenguel
rberenguel / wat.scala
Created Mar 8, 2019
Weird companion object issue in Scala 2.11 vs 2.12
View wat.scala
case class Country(name: String) {
private val ThreeLetterValidCountries = List("FOO", "BAR")
def valid: Option[Country] =
if (ThreeLetterValidCountries.contains(name.toUpperCase)) Some(this) else None
}
object Country {
def apply(name: String): Country = new Country(name.toUpperCase)
}
@rberenguel
rberenguel / primes.py
Created Sep 24, 2018 — forked from vegard/primes.py
Prime factorisation diagram
View primes.py
# -*- coding: utf-8 -*-
#
# Author: Vegard Nossum <vegard.nossum@gmail.com>
import math
import os
import sys
import cairo
View wtf.scala
case class Foo(id: String, value: Int)
case class Bar(theId: String, value: Int)
val ds = List(Foo("Alice", 42), Foo("Bob", 43)).toDS
import org.apache.spark.sql.{DataFrame, Dataset}
val renamedDF: DataFrame = ds.select($"id".as("theId"), $"value")
val renamedDS: Dataset[Bar] = renamedDF.toDF("theId", "value").as[Bar]
You can’t perform that action at this time.