Skip to content

Instantly share code, notes, and snippets.

View kandebonfim's full-sized avatar
🚀
Make it work!

Kande Bonfim kandebonfim

🚀
Make it work!
View GitHub Profile
@kandebonfim
kandebonfim / index.html
Created July 13, 2015 19:49
HTML Basic
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Título da sua página</title>
</head>
<body>
</body>
</html>
@kandebonfim
kandebonfim / array_random_numbers_coffeescript
Last active February 4, 2016 18:05
A gist to generate an array with random numbers in CoffeeScript
random = (min, max) =>
Math.floor(Math.random() * (max - min) + min)
data = [1..100].map(() -> random(0,1000))
↑↑↑ Array length
// One line
data = [1..100].map(() -> Math.floor(Math.random() * (1000 - 0) + 0))
↑↑↑ Array length ↑max ↑min ↑min
@kandebonfim
kandebonfim / script.js
Created July 28, 2016 13:05
Search for links containing an specific string in a webpage
var str = 'www.maybeyourwebsite.here'
document.querySelectorAll('a').forEach(function(e) {
if (e.href.indexOf(str) > 0) {
console.log(e.href)
};
})
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"color_scheme": "Packages/Material Theme/schemes/Material-Theme.tmTheme",
"ensure_newline_at_eof_on_save": true,
"file_exclude_patterns":
[
"*.DS_store",
"*.gem",
"*.gz",
@kandebonfim
kandebonfim / script.js
Created February 8, 2017 13:22
Scrapping catarse website.
var allCards = document.querySelectorAll('.card-project')
var cards = [];
allCards.forEach( function(element, index) {
var currElem = {}
var name = element.querySelector('.link-hidden')
var author = element.querySelector('.w-hidden-small.w-hidden-tiny.fontsize-smallest.fontcolor-secondary.u-marginbottom-20')
var description = element.querySelector('.w-hidden-small.w-hidden-tiny.fontcolor-secondary.fontsize-smaller .link-hidden')
var percentage = element.querySelector('.card-project-stats .fontsize-base.fontweight-semibold')
var money = element.querySelector('.card-project-stats .fontsize-smaller.fontweight-semibold')
currElem.name = name.innerText;
@kandebonfim
kandebonfim / travelling-salesman-problem-in-r.R
Last active February 15, 2019 14:08
Travelling salesman problem in R
library(TSP)
library(tspmeta)
coords.df <- data.frame(long=runif(40, min=0, max=100), lat=runif(40, min=0, max=100))
coords.mx <- as.matrix(coords.df)
# Compute distance matrix
dist.mx <- dist(coords.mx)
# Construct a TSP object
date,revenue,margin
24-Apr-07,93.24,80
25-Apr-07,95.35,73.5
26-Apr-07,98.84,72.6
27-Apr-07,99.92,92.5
30-Apr-07,99.80,99
1-May-07,99.47,101
2-May-07,100.39,102
3-May-07,100.40,99
4-May-07,100.81,106
[{"UNITS":216863.95,"AVG_SALE_PRICE":27.4027,"Date":1490918400000,"MARGIN":5942659.315,"REVENUE":1.700522824E7,"CONVERSION":2.02,"PAGEVIEWS":486060.09,"UNITS_PER_ORDER":1.9747},{"UNITS":203857.95,"AVG_SALE_PRICE":27.4316,"Date":1490832000000,"MARGIN":5592153.693,"REVENUE":1.557704542E7,"CONVERSION":2.09,"PAGEVIEWS":472342.68,"UNITS_PER_ORDER":1.9478},{"UNITS":191919.68,"AVG_SALE_PRICE":27.5003,"Date":1490745600000,"MARGIN":5277862.032,"REVENUE":1.474203095E7,"CONVERSION":2.11,"PAGEVIEWS":458506.18,"UNITS_PER_ORDER":1.9253},{"UNITS":187973.59,"AVG_SALE_PRICE":27.6123,"Date":1490659200000,"MARGIN":5190392.777,"REVENUE":1.51979661E7,"CONVERSION":2.07,"PAGEVIEWS":458921.95,"UNITS_PER_ORDER":1.8987},{"UNITS":201077.68,"AVG_SALE_PRICE":27.7819,"Date":1490572800000,"MARGIN":5586336.623,"REVENUE":1.747735456E7,"CONVERSION":2.03,"PAGEVIEWS":480242.68,"UNITS_PER_ORDER":1.9171},{"UNITS":215274.09,"AVG_SALE_PRICE":27.95,"Date":1490486400000,"MARGIN":6016915.571,"REVENUE":1.946879568E7,"CONVERSION":2.02,"PAGEVIEWS":504199
@kandebonfim
kandebonfim / postgree_server.sh
Created May 24, 2017 13:04
How to start and stop postgree server
# Start Manually
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
# Stop Manually
pg_ctl -D /usr/local/var/postgres stop -s -m fast