Skip to content

Instantly share code, notes, and snippets.

View lucasfcosta's full-sized avatar
Building @briefercloud

Lucas da Costa lucasfcosta

Building @briefercloud
View GitHub Profile
import java.util.Arrays;
import java.lang.Math;
class Heap {
public int[] data;
public int lastIndex;
Heap(int size) {
this.data = new int[size];
this.lastIndex = -1;
// Instale o Node.js (baixe no site e use o instalador, facil facil)
// Instale o modulo do twitter (pode ser global: npm install twitter -g)
// Coloque isso no C:/ pra facilitar e digite no terminal node /cracocrawler.js
// Os resultados vao ser salvos num arquivo chamado tweets.json
var Twitter = require('twitter');
var fs = require('fs');
// Preencha os valores com as suas chaves da API do twitter
var client = new Twitter({
consumer_key: '<PREENCHA_ISSO>',
@lucasfcosta
lucasfcosta / multithreadSorting.js
Last active September 14, 2015 18:42
Multithread array sorting in Node. It uses this module: https://www.npmjs.com/package/sugar-sorting
var Sorter = require('sugar-sorting');
var cluster = require('cluster');
// Number of threads we're going to create
var numThreads = 5;
// How many arrays you want to create
var totalArrays = 1000;
// The process will only get inside this if it isn't a worker
// Instale o Node.js (baixe no site e use o instalador, facil facil)
// Instale o modulo do twitter (pode ser global: npm install twitter -g)
// Coloque isso no C:/ pra facilitar e digite no terminal node /cracocrawler.js
// Os resultados vao ser salvos num arquivo chamado tweets.json
var Twitter = require('twitter');
var fs = require('fs');
// Preencha os valores com as suas chaves da API do twitter
var client = new Twitter({
consumer_key: '<PREENCHA_ISSO>',
@lucasfcosta
lucasfcosta / HideMyTimeline.js
Created October 10, 2014 01:41
HideMyTimeline Script
// ==UserScript==
// @name HideMyTimeline
// @namespace http://github.com/lucasfcosta
// @description Hides Facebook timeline so you can focus on what really matters
// @include https://www.facebook.com/*
// @version 1
// @grant none
// ==/UserScript==
$(document).ready(function() {
@lucasfcosta
lucasfcosta / separeLines.js
Last active August 29, 2015 14:06
Separes Lines of an Array Containing Table Cells' Contents
function separeLines(table, tableCol) {
var lines = [];
var divisionNumber = table.length/tableCol;
var startPos = 0;
var endPos = 0 + tableCol;
for(var i = 0; i < divisionNumber; i++) {
lines.push(table.slice(startPos, endPos));
startPos += tableCol;
@lucasfcosta
lucasfcosta / findWithin.js
Last active August 29, 2015 14:04
Finds all occurrences of a String between two other Strings
function findWithin(text, first, last, caseSensitive) {
if (!caseSensitive) {
text = text.toLowerCase();
first = first.toLowerCase();
last = last.toLowerCase();
}
var rex = new RegExp(first + '(.*?)' + last, 'gm'),
results = text.match(rex);
for (var i in results) {
results[i] = results[i].slice(first.length, results[i].indexOf(last));