Skip to content

Instantly share code, notes, and snippets.

#
# score, provided for compatibility
# for speed one should really prepare the query once then reuse it
#
score = (string,query) ->
scorePrepared(string,prepare(query))
#
# Match an item against a prepared query
function normalize(str) {
if (!str)return "";
return str.toLowerCase().replace(/[^\u0000-\u007E]/g, function (a) {
return diacriticsMap[a] || a;
});
}
function getDiacriticsMap() {
// replace most common accents in french-spanish by their base letter
//"ãàáäâæ?èéëêìíïîõòóöôœùúüûñç"
// For use whithin node.js
referenceStack = null;
wrapperCache = null;
privilegiedCallback = null;
lastPrepareStackTrace = null;
//
// Each wrapper contain a link to their own callback
{
"name": "minimap",
"repository": {
"type": "git",
"url": "https:\/\/github.com\/atom-minimap\/minimap"
},
"downloads": 971268,
"stargazers_count": 2109,
"releases": {
"latest": "4.16.2"
/**
* @file
* CRC function implementations
*/
#include "ga-crc.h"
/**
* CRC5-CCITT table
* Generate with the commands:
private ulong CalculateCRCdirect(byte[] data, int length)
{
// Initialize all variables for seeding and builing based upon the given coding type
// at first, compute constant bit masks for whole CRC and CRC high bit
crcmask = ((((ulong)1 << (order - 1)) - 1) << 1) | 1; //ORDER = 5
crchighbit = (ulong)1 << (order - 1);
poly = 0x09 // CRC5 EPC
public static T HttpUploadFile<T>(string url, string fileName, byte[] fileBytes, string fileContentType = null, string fileFieldName = "file", Dictionary<string, string> extraFields = null)
where T : class
{
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, new Uri(url));
var boundary = "Upload----" + DateTime.UtcNow.Ticks.ToString("x");
var multiPartContent = new MultipartFormDataContent(boundary);
@jeancroy
jeancroy / AESGCM.cs
Created August 5, 2016 03:10 — forked from jbtule/AESGCM.cs
I have two code examples that I wrote for best practices encrypting a string in c#. They are both using authenticated encryption. http://stackoverflow.com/a/10366194/637783
/*
* This work (Modern Encryption of a String C#, by James Tuley),
* identified by James Tuley, is free of known copyright restrictions.
* https://gist.github.com/4336842
* http://creativecommons.org/publicdomain/mark/1.0/
*/
using System;
using System.IO;
using System.Text;
public static class SendGridDeliveryServices
{
private static string _sendGridApiKey = "...";
public static bool SendMailToCustomerServices(string name, string email, string subject, string body)
{
var from = new EmailAddress("system@xyz.com", name);
var reply = new EmailAddress(email, name);
@jeancroy
jeancroy / SelectInverseRank.js
Last active July 19, 2023 17:52
Random selection form a list with power law probability (closed form solution) .
//
// Select the n-th item with probability `1/n`.
// Return an 0 based index (`i = n-1`)
//
// If parameter `a` is given, we select from probability `1/(n^a)`
// In particular, if a negative value of `a` is given, we select with probability `n^y, y = -a`;
//
// The code use the inverse of the cumulative probability function, to map the uniform distribution to the power distribution.
//
// Caveat: