Skip to content

Instantly share code, notes, and snippets.

View abidanBrito's full-sized avatar

Abidán Brito abidanBrito

View GitHub Profile
StringBuilder jsonData = new StringBuilder();
jsonData.Append("[");
for (int i = 0; i < dt.Rows.Count; ++i)
{
jsonData.Append("{");
jsonData.Append("\"" + "DNI" + "\":" + "\"" + dt.Rows[i][0] + "\"" + "," + "\"" + "Name" + "\":" + "\"" + dt.Rows[i][1] + "\"" + ",");
jsonData.Append("\"" + "Telephone" + "\":" + "\"" + dt.Rows[i][2] + "\"" + "," + "\"" + "Observations" + "\":" + "\"" + dt.Rows[i][3] + "\"");
if (i == dt.Rows.Count - 1) { jsonData.Append("}"); }
else { jsonData.Append("},"); }

I sometimes run into issues when setting up a local repo because of the new main default branch name on GitHub. Let's rename the local branch and set its upstream properly.

git branch -m master main
git fetch origin
git branch -u origin/main main
git remote set-head origin -a

NOTE: git remote set-head origin -a fetches and sets origin/HEAD, so that the local repository has a local reference of what the remote repository considers to be the default branch.

/////////////////////////////////////
// APPROACH #1
/////////////////////////////////////
// In the Fragment
val textView: TextView = activity!!.findViewById(R.id.custom_toolbar_title) as TextView
viewModel.fragmentName.observe(viewLifecycleOwner, {
textView.text = it
})
/////////////////////////////////////
@abidanBrito
abidanBrito / build-emacs.sh
Last active October 25, 2024 01:57
Build GNU Emacs from source.
#!/usr/bin/env bash
## Author: Abidán Brito
## This script builds GNU Emacs 29.1 with support for native elisp compilation,
## tree-sitter, libjansson (C JSON library), pure GTK and mailutils.
# Exit on error and print out commands before executing them.
set -euxo pipefail
# Let's set the number of jobs to something reasonable; keep 2 cores

GIT CHEATSHEET

Basic Concepts

  • Distributed Version Control System.
  • Working Directory.
  • Staging Area.
  • Local Repository.
  • Remote Repository.
  • Origin.
  • Upstream.
# Install minimal prerequisites (Ubuntu 18.04 as reference)
sudo apt update && sudo apt install -y cmake g++ wget unzip
# Download and unpack sources
wget -O opencv.zip https://github.com/opencv/opencv/archive/4.x.zip
unzip opencv.zip
# Create build directory
mkdir -p build && cd build

Conda Cheatsheet

Set up

Installing miniconda

Linux / WSL

curl -LO https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

Windows