Skip to content

Instantly share code, notes, and snippets.

View boechat107's full-sized avatar

Andre Boechat boechat107

View GitHub Profile
@boechat107
boechat107 / write-data-to-file.clj
Created July 4, 2012 20:44
Write a Clojure data to a file
;; Write a map structure to a file.
(spit "filename.txt" (prn-str {:a 10, :b 20}))
;; Read the map structure from the same file.
(read-string (slurp "filename.txt"))
@boechat107
boechat107 / numpy_termshow.py
Last active August 29, 2015 14:07 — forked from natekupp/gist:2954743
Script created by Nicolas P. Rougier to visualize 2D numpy arrays on terminal
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Terminal visualization of 2D numpy arrays
# Copyright (c) 2009 Nicolas P. Rougier
#
# 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.
@boechat107
boechat107 / technical_books.md
Last active June 3, 2016 11:47
Technical reference books

Data Science

  • The Elements of Statistical Learning: Data Mining, Inference, and Prediction, free PDF text on the book's website.
  • Data Clustering: Algorithms and Applications, Charu C. Aggarwal

Bayesian Methods

  • Probabilistic Programming and Bayesian Methods for Hackers, open source book hosted on Github.
  • Spatial and Spatio-temporal Bayesian Modeling with R
@boechat107
boechat107 / pandas_numpy_reference.md
Last active June 14, 2016 15:35
Coding with Pandas, Numpy and other related Data Science libs

Numpy / Pandas

import pandas as pd
import numpy as np

Reshape:

@boechat107
boechat107 / some_git_commands.md
Last active May 9, 2016 09:18
Useful git commands to remember

Interactive rebase of a branch. Among many options and actions, it allows the removal of specific commits. Useful for release branches or to submit PRs.

git rebase -i SHA-OF-FIRST-COMMIT-IN-BRANCH

Command to fetch a remote branch, creating a local branch with a different name (reference).

@boechat107
boechat107 / github_stars.py
Last active April 29, 2016 13:53
Simple script to fetch information about a Github user's repositories
#!/usr/bin/python
import argparse
import urllib2
import json
import pprint
def sort_by(dictlist, k, **kwargs):
return sorted(dictlist, key=(lambda d: d[k]), **kwargs)
@boechat107
boechat107 / tricks.md
Last active September 26, 2016 21:57
Markdown tricks

Footnotes

Suppose that I have a text and I want to have a footnote 1.

[1]: Footnote content goes here.

@boechat107
boechat107 / keybase.md
Created April 16, 2019 18:02
keybase identity proof

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@boechat107
boechat107 / multiple_knapsacks_problem.py
Last active March 17, 2022 21:35
Multiple knapsacks problem
"""
Knapsacks have weight capacity; items have weight and value.
We want to find the allocation of items which maximizes the total
carried value.
"""
from typing import List, Set, Tuple
@boechat107
boechat107 / git-mr-cherry-pick.sh
Last active February 15, 2022 16:22
Bash function to update a branch based on a just merged to "master" branch
#!/bin/bash
# This script is useful to update branches that are based on a branch
# that was just merged to "master".
#
# As an example, suppose you have an open Merge Request based on branch "B1"
# and, while you are waiting for reviews, you start working on another
# branch, "B2", which is created directly from "B1".
# After a few commits on "B2", your MR gets reviewd and "B1" is merged to
# "master".
# Now your code on "B2" is ready for review and you want to create a new