Skip to content

Instantly share code, notes, and snippets.

Eran Betzalel eranbetzalel

Block or report user

Report or block eranbetzalel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@eranbetzalel
eranbetzalel / ngrams.js
Last active Mar 7, 2016
Implementation of the n-gram algorithm using JavaScript
View ngrams.js
function ngrams(array, length) {
var ngramsArray = [];
for (var i = 0; i < array.length - (length - 1); i++) {
var subNgramsArray = [];
for (var j = 0; j < length; j++) {
subNgramsArray.push(array[i + j])
}
@eranbetzalel
eranbetzalel / DecimalBytesConvertor.cs
Created Apr 14, 2013
Two methods for bytes-decimal conversion.
View DecimalBytesConvertor.cs
public decimal BytesToDecimal(byte[] buffer, int offset = 0)
{
var decimalBits = new int[4];
decimalBits[0] = buffer[offset + 0] | (buffer[offset + 1] << 8) | (buffer[offset + 2] << 16) | (buffer[offset + 3] << 24);
decimalBits[1] = buffer[offset + 4] | (buffer[offset + 5] << 8) | (buffer[offset + 6] << 16) | (buffer[offset + 7] << 24);
decimalBits[2] = buffer[offset + 8] | (buffer[offset + 9] << 8) | (buffer[offset + 10] << 16) | (buffer[offset + 11] << 24);
decimalBits[3] = buffer[offset + 12] | (buffer[offset + 13] << 8) | (buffer[offset + 14] << 16) | (buffer[offset + 15] << 24);
return new Decimal(decimalBits);
@eranbetzalel
eranbetzalel / DelimitedFileWriter.cs
Created Apr 12, 2013
Simple implementation of CSV (or any other character delimited file) writer.
View DelimitedFileWriter.cs
class Car
{
public int CarId { get; set; }
public DateTime ManufactureDate { get; set; }
public decimal SomeDecimal { get; set; }
}
class DelimitedFileWriterExample
{
static void Main()
You can’t perform that action at this time.