Skip to content

Instantly share code, notes, and snippets.

@cgarbin
cgarbin / 1.learning-haystack.md
Last active July 19, 2023 19:49
Learning how to use Haystack for retrieval-augmented generation
"""A simple logger to share logging configuration across the project.
- Info and debug messages go to stdout.
- Error and warning messages go to stderr.
Note that use a module-level logger is not the best practice. It's enough for hobbyist projects. Use the logging module
configuration file for more complex projects (https://docs.python.org/3/howto/logging.html#configuring-logging).
Usage:
@cgarbin
cgarbin / golearn.md
Last active June 11, 2023 15:40
Learning Go

Learning Go

Good sources, organized in a logical sequence (simpler to more complex)

  1. The Go Programming Language and Environment: Written by the creators of Go, it explains the principles and design decisions that went into creating Go and its environment. Read this first to understand the motivation behind language features, tools, and environment.
  2. A Tour of Go: Learn the important language features in bite-sized explanations. Part of the official documentation.
  3. How to Write Go Code: Write a simple Go program to learn the environment and tools. Part of the official documentation. The program is simple. The goal is to teach the mechanics of getting a Go program to run.
  4. Learn Go in ten minutes: Now that we are familiar with the language we can use this page as a quick reminder of the Go syntax and features
@cgarbin
cgarbin / latexdiff.md
Created February 10, 2021 13:06
Comparing and annotating version of LaTex documents
@cgarbin
cgarbin / add-latex-markdown.md
Created October 2, 2019 01:34
Add LaTeX to markdown

Go to https://www.codecogs.com/latex/eqneditor.php

Edit the equation as needed

Go to the bottom of the page and choose "URL Encoded"

Add URL to markdown page as an external image:

![equation](https://latex.codecogs.com/svg.latex?dx_i%20%3D%20x_i%20-%20%5Cbar%7Bx%7D)
@cgarbin
cgarbin / filtering.py
Last active September 16, 2019 22:35
Showing the steps Pandas executes when filtering
# Based on https://colab.research.google.com/github/jakevdp/PythonDataScienceHandbook/blob/master/notebooks/03.08-Aggregation-and-Grouping.ipynb#scrollTo=uwsvvB3-s0yO
import numpy as np
import pandas as pd
rng = np.random.RandomState(0)
df = pd.DataFrame({'key': ['A', 'B', 'C', 'A', 'B', 'C'],
'data1': range(6),
'data2': rng.randint(0, 10, 6)},
columns=['key', 'data1', 'data2'])
@cgarbin
cgarbin / ImagesSideBySide.tex
Last active December 10, 2018 12:47
Showing images side-by-side in Latex
\begin{figure}
\centering
\begin{subfigure}[t]{0.45\columnwidth}
\centering
\includegraphics[width=\linewidth]{figures/figures_other/MnistExamples.png}
\caption{Generic} \label{fig:timing1}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.45\columnwidth}
\centering
@cgarbin
cgarbin / GoogleCloudMachineLearningEnvironment.md
Last active December 13, 2018 23:28
Setting a development environment for machine learning in Google Cloud

Instructions to create a Google Cloud account and set up an environment for machine learning on it.

NOTE: the command line examples assume a Linux environment.

Setting up the cloud environment

Google Cloud environment

At this time (November 2018) Google gives a U$300 credit when opening an account. It may ask for a credit card number when creating the account, but it won't be billed until the credits are used up.

@cgarbin
cgarbin / simple.neuralnet.mlbench.circle.R
Last active October 27, 2018 14:22
A simple R neuralnet for mlbnech::circle
# Always start with a clean environment to avoid subtle bugs
rm(list = ls())
# To get repeatable results with random numbers (easier to debug multiple runs)
set.seed(123)
# Create a circle data set, change labels to -1/1, convert to data.frame
library(mlbench)
circle <- mlbench.circle(500, 2)
labels <- sign(as.numeric(circle$classes) - 1.5)
@cgarbin
cgarbin / Example.png
Last active October 25, 2018 01:37
Draws the decision boundaries for a neural network classifier
Example.png