Instantly share code, notes, and snippets.

Leandro Silva leandrosilva

View GitHub Profile
View gcd.js
function gcd(numbers) {
let results = {};
for (let i = 0; i < numbers.length; i++) {
let divisor = numbers[i];
for (let j = 0; j < numbers.length; j++) {
let number = numbers[j];
if (number == divisor) continue;
let result = number % divisor;
View kmers.js
// Problem: Count the number of times a string appears as a substring in a longer text.
function patternCount(text, pattern) {
if (!text || !pattern) return -1;
let textLength = text.length;
let k = pattern.length;
let count = 0;
for (let i = 0; i < (textLength - k + 1); i++) {
let kmer = text.substring(i, i + k);
View hashtable.js
let HashTable = function() {
let entries = [];
this.put = (key, value) => {
let hashKey = hashCode(key);
let entry = entries[hashKey];
// Linear Probing
while (entry) {
if (entry && entry[0] === key) break;
View BinaryPrintHelper.cs
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
View TaskHelper.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace CodeZone.Helpers.Async
{
public static class TaskHelper
View chuncks.js
Object.defineProperty(Array.prototype, 'chunk', {
value: function(chunkSize) {
var R = [];
for (var i=0; i<this.length; i+=chunkSize)
R.push(this.slice(i,i+chunkSize));
return R;
}
});
Array.range(10).chunk(3);
View beetle
#!/usr/bin/env ruby
require "csv"
require "net/http"
require "date"
require "json"
#
# Get log data
#
View Mamutinho.java
package br.com.mamutelanoso;
import java.io.IOException;
import java.util.Properties;
import javax.mail.BodyPart;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
View xsp4-stop.sh
kill `ps aux | grep xsp4.exe | grep -v grep | awk '{print $2}'`
View .gitignore
.DS_Store
*.dll
*.exe