Skip to content

Instantly share code, notes, and snippets.

print("Hello, World!")
@jonathanagustin
jonathanagustin / colab2pdf.py
Created November 7, 2023 22:51
Convert your Colab notebook to a PDF. One-minute install. Zero configuration.
# Colab2PDF v1.0.0 by Drengskapur (github.com/drengskapur/colab2pdf) (License: GPL-3.0-or-later)
# @title {display-mode:"form"}
# @markdown ⬇️ Download PDF
def colab2pdf():
ENABLE=True # @param {type:"boolean"}
if ENABLE:
import os, datetime, json, pathlib, urllib, requests, werkzeug, nbformat, google, yaml, warnings
NAME = pathlib.Path(werkzeug.utils.secure_filename(urllib.parse.unquote(requests.get(f"http://{os.environ['COLAB_JUPYTER_IP']}:{os.environ['KMP_TARGET_PORT']}/api/sessions").json()[0]["name"])))
TEMP = pathlib.Path("/content/pdfs") / f"{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}_{NAME.stem}"; TEMP.mkdir(parents=True, exist_ok=True)
NB = [cell for cell in nbformat.reads(json.dumps(google.colab._message.blocking_request("get_ipynb", timeout_sec=30)["ipynb"]), as_version=4).cells if "--Colab2PDF" not in cell.source]
@jonathanagustin
jonathanagustin / colab2pdf.py
Last active April 2, 2024 06:29
Convert Google Colab Notebook to PDF
# @title Convert Notebook to PDF. Save Notebook to: `/content/drive/MyDrive/Colab Notebooks'
NOTEBOOK_NAME = "notebooke.ipynb" # @param {type:"string"}
#------------------------------------------------------------------------------#
from google.colab import drive
drive.mount("/content/drive/", force_remount=True)
NOTEBOOKS = "/content/drive/MyDrive/Colab Notebooks"
NOTEBOOK_PATH = f"{NOTEBOOKS}/{NOTEBOOK_NAME}"
assert os.path.exists(NOTEBOOK_PATH), f"NOTEBOOK NOT FOUND: {NOTEBOOK_PATH}"
!apt install -y texlive-xetex texlive-fonts-recommended texlive-plain-generic
!jupyter nbconvert "$NOTEBOOK_PATH" --to pdf
@jonathanagustin
jonathanagustin / crumbcutter.json
Created September 21, 2023 08:14
crumbcutter-index
{
"project_name": "Index",
"author": "Anonymous"
}
@jonathanagustin
jonathanagustin / _readme.md
Created June 8, 2022 06:19 — forked from maxivak/_readme.md
Vagrant with Ubuntu 16.04 in VirtualBox

Setup Ubuntu 16.04 to be used with Vagrant and Virtualbox

Prepare Vagrant box with Ubuntu 16.04

We will use official box "ubuntu/xenial64" and modify it to work with Vagrant.

  • Vagrantfile
@jonathanagustin
jonathanagustin / Vagrantfile
Created June 8, 2022 04:35 — forked from akrabat/Vagrantfile
Example Vagrantfile for Windows
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Base box: https://github.com/akrabat/packer-templates
Vagrant.configure("2") do |config|
config.vm.box = "19ft/windows2016"
config.vm.guest = :windows
config.vm.boot_timeout = 600

progrium/bashstyle

Bash is the JavaScript of systems programming. Although in some cases it's better to use a systems language like C or Go, Bash is an ideal systems language for smaller POSIX-oriented or command line tasks. Here's three quick reasons why:

  • It's everywhere. Like JavaScript for the web, Bash is already there ready for systems programming.
  • It's neutral. Unlike Ruby, Python, JavaScript, or PHP, Bash offends equally across all communities. ;)
  • It's made to be glue. Write complex parts in C or Go (or whatever!), and glue them together with Bash.

This document is how I write Bash and how I'd like collaborators to write Bash with me in my open source projects. It's based on a lot of experience and time collecting best practices. Most of them come from these two articles, but here integrated, slightly modified, and focusing on the most bang for buck items. Plus some ne

@jonathanagustin
jonathanagustin / scrolling_tmux.md
Created January 11, 2022 23:42
Scrolling in tmux 2.1

Create ~/.tmux.conf

touch ~/.tmux.conf

Enter:

set -g mouse on
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e; send-keys -M'"
@jonathanagustin
jonathanagustin / log_status_python3_and_python2.md
Created April 10, 2021 04:12 — forked from takurx/log_status_python3_and_python2.md
On Ubuntu 20.04 it is status of python3 and python2.

0. Default

  • python
sharo@kirima:~$ python

Command 'python' not found, did you mean:

  command 'python3' from deb python3
  command 'python' from deb python-is-python3
@jonathanagustin
jonathanagustin / SpartanDFS.py
Created October 11, 2020 08:14
Python Spartan DFS Example
'''
https://leetcode.com/problems/serialize-and-deserialize-binary-tree/discuss/74259/Recursive-preorder-Python-and-C%2B%2B-O(n)
'''
class Codec:
def serialize(self, root):
def doit(node):
if node:
vals.append(str(node.val))
doit(node.left)