Skip to content

Instantly share code, notes, and snippets.

Avatar
✍️
Author of Testing JavaScript Applications, by Manning Books

Lucas F. da Costa lucasfcosta

✍️
Author of Testing JavaScript Applications, by Manning Books
View GitHub Profile
View Heap.java
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;
@lucasfcosta
lucasfcosta / multithreadSorting.js
Last active Sep 14, 2015
Multithread array sorting in Node. It uses this module: https://www.npmjs.com/package/sugar-sorting
View multithreadSorting.js
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
View cracoCrawlerCSV.js
// 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>',
View cracoCrawler.js
// 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 Oct 10, 2014
HideMyTimeline Script
View HideMyTimeline.js
// ==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 Aug 29, 2015
Separes Lines of an Array Containing Table Cells' Contents
View separeLines.js
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 Aug 29, 2015
Finds all occurrences of a String between two other Strings
View findWithin.js
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));