Skip to content

Instantly share code, notes, and snippets.

View olveirap's full-sized avatar

Paulo Olveira olveirap

View GitHub Profile
@olveirap
olveirap / bochs_macos.txt
Last active July 3, 2019 16:13
How to compile bochs for MacOS
Modify iodev/hdimage/cdrom_osx.cc:194 for line: if ((devname = (char *) strrchr(devpath, '/')) != NULL) {
brew install sdl pkg-config
./configure --with-sdl
change Makefile: prefix = ~/bochs
do mkdir ~/bochs before doing make install
@olveirap
olveirap / gist:454d24e713c0c0bacbbf75752a6be4d2
Created April 9, 2019 13:53
DVC - Expired Token Stack Trace
Traceback (most recent call last):
File "/Users/polveira/Projects/dvc/dvc/command/status.py", line 54, in do_run
with_deps=self.args.with_deps,
File "/Users/polveira/Projects/dvc/dvc/repo/status.py", line 88, in status
all_tags=all_tags,
File "/Users/polveira/Projects/dvc/dvc/repo/status.py", line 52, in _cloud_status
used, jobs, remote=remote, show_checksums=show_checksums
File "/Users/polveira/Projects/dvc/dvc/data_cloud.py", line 167, in status
targets, jobs=jobs, remote=cloud, show_checksums=show_checksums
File "/Users/polveira/Projects/dvc/dvc/remote/local.py", line 604, in status
@olveirap
olveirap / README.md
Last active August 22, 2017 13:28 — forked from eduardocereto/README.md
Calculates Traffic Source

Calculates Traffic Source

Still a work in progress, not ready for usage.

Tries to mim Classic Google Analytics methodology to calculate traffic source client side.

On Universal Analytics all this is calculated server side, so it's unavailable in case you need it client side.

@olveirap
olveirap / Streaming Algorithms.md
Last active May 4, 2017 02:11 — forked from debasishg/gist:8172796
A collection of links for streaming algorithms and data structures
  1. General Background and Overview
@olveirap
olveirap / debugger pause beforeunload
Created March 13, 2017 17:42 — forked from carcinocron/debugger pause beforeunload
Chrome: pause before redirect
// Run this in the F12 javascript console in chrome
// if a redirect happens, the page will pause
// this helps because chrome's network tab's
// "preserve log" seems to technically preserve the log
// but you can't actually LOOK at it...
// also the "replay xhr" feature does not work after reload
// even if you "preserve log".
window.addEventListener("beforeunload", function() { debugger; }, false)
@olveirap
olveirap / formatPrice.js
Created February 15, 2017 04:02
Price formatter function
//http://stackoverflow.com/questions/149055/how-can-i-format-numbers-as-money-in-javascript
function formatPrice(aPrice){
var n = aPrice;
var i = String(parseInt(n = Math.abs(Number(n) || 0).toFixed(2)));
var j = (j = i.length) > 3 ? j % 3 : 0;
return (j ? i.substr(0, j) + "." : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + ".") + (2 ? "," + Math.abs(n - i).toFixed(2).slice(2) : "");
}
@olveirap
olveirap / proteinMass.js
Created February 15, 2017 02:22
Protein Mass Calculator
function proteinMass(protein){
var aminoWeightDict =
{
"A":71.03711,
"C":103.00919,
"D":115.02694,
"E":129.04259,
"F":147.06841,
"G":57.02146,
"H":137.05891,
@olveirap
olveirap / RNAtoProtein.js
Created February 15, 2017 01:30
A implementation of a RNA to Protein translator
function RNAtoProtein(str){
var protein = [];
var codons = str.match(/.{3}/g); //http://stackoverflow.com/questions/6259515/javascript-elegant-way-to-split-string-into-segments-n-characters-long
var codonDict = {"UUU": "F",
"CUU": "L",
"AUU": "I",
"GUU": "V",
"UUC": "F",
"CUC": "L",
"AUC": "I",
@olveirap
olveirap / combinatorics.js
Created February 15, 2017 00:48
Javascript implementation of Heap's Algorithm for combinatorics
//http://stackoverflow.com/questions/872310/javascript-swap-array-elements
Array.prototype.swap = function (x,y) {
var b = this[x];
this[x] = this[y];
this[y] = b;
return this;
}
//https://en.wikipedia.org/wiki/Heap's_algorithm
@olveirap
olveirap / freecodecamp-random-got-quote-machine.markdown
Last active October 18, 2016 22:52
FreeCodeCamp : Random GOT Quote Machine