Skip to content

Instantly share code, notes, and snippets.

View ollie314's full-sized avatar

Mehdi Lefebvre ollie314

View GitHub Profile
@ollie314
ollie314 / pmc.fs
Created August 7, 2020 06:30
Simple pi approximation using monte carlo method
open System
let pr x = printfn "%A" x
let mc nb =
let rnd = System.Random()
let n () = rnd.NextDouble()
let act () =
if System.Math.Sqrt(n() ** 2.0 + n() ** 2.0) < 1.0 then 1 else 0
@ollie314
ollie314 / normalize.js
Last active July 30, 2019 11:55
Simple camelcase normalization for object keys
const cap = (s) => (s.charAt(0).toUpperCase() + s.slice(1));
String.prototype.ucFirst = function () { return cap(this); }
String.prototype.toCamelCase = function() {
return this.toLowerCase().split('_').map((p, i) => {
return i === 0 ? p : p.ucFirst();
}).join('');
}
function normalize(data) {
@ollie314
ollie314 / scala-akkajs.scala
Created October 20, 2018 18:21
Simple akkajs example
import language.postfixOps
import akka.actor._
import akka.stream._
import akka.stream.scaladsl._
import akka.util.Timeout
import scala.util.Try
import scala.concurrent.Future
import scala.concurrent.duration._
@ollie314
ollie314 / API.md
Created October 25, 2016 06:04 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

Pull Request Process

  1. Ensure any install or build dependencies are removed before the end of the layer when doing a
@ollie314
ollie314 / fnv_hash_example.cpp
Created September 28, 2016 09:46 — forked from filsinger/fnv_hash_example.cpp
C++11 : FNV-1 and FNV-1a compile-time string hashing
// C++11 32bit FNV-1 and FNV-1a string hasing (Fowler–Noll–Vo hash)
//
// Requires a compiler with C++11 support
// See main(...) for examples
#include <iostream>
#include <cassert>
namespace hash
{
@ollie314
ollie314 / c_hashs.md
Created September 7, 2016 04:27
Shyni algorithms in c for hash caclulation

=hash.h=

typedef unsigned long ulong_t;
typedef unsigned int uint_t;

=djb2= this algorithm (k=33) was first reported by dan bernstein many years ago in comp.lang.c. another version of this algorithm (now favored by bernstein) uses xor: hash(i) = hash(i - 1) * 33 ^ str[i]; the magic of number 33 (why it works better than many other constants, prime or not) has never been adequately explained.

unsigned long hash(unsigned char *str)
{
@ollie314
ollie314 / hash.c
Created September 7, 2016 04:12 — forked from tonious/hash.c
A quick hashtable implementation in c.
#define _XOPEN_SOURCE 500 /* Enable certain library functions (strdup) on linux. See feature_test_macros(7) */
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <string.h>
struct entry_s {
char *key;
char *value;
@ollie314
ollie314 / hbase-indexing-solr.md
Created August 23, 2016 17:27 — forked from abajwa-hw/hbase-indexing-solr.md
Hbase indexing to solr in HDP 2.3

Hbase indexing to solr in HDP 2.3

  • Background:

The HBase Indexer provides the ability to stream events from HBase to Solr for near real time searching. The HBase indexer is included with HDPSearch as an additional service. The indexer works by acting as an HBase replication sink. As updates are written to HBase, the events are asynchronously replicated to the HBase Indexer processes, which in turn creates Solr documents and pushes them to Solr.

@ollie314
ollie314 / sshpub-to-rsa
Created August 11, 2016 06:13 — forked from thwarted/sshpub-to-rsa
converts an openssh RSA public key into a format usable by openssl rsautl (if you don't have openssh 5.6 or later with ssh-keygen PEM export format)
#!/usr/bin/env python
# with help and inspiration from
# * ASN1_generate_nconf(3) (specifically the SubjectPublicKeyInfo structure)
# * http://www.sysmic.org/dotclear/index.php?post/2010/03/24/Convert-keys-betweens-GnuPG%2C-OpenSsh-and-OpenSSL
# * http://blog.oddbit.com/2011/05/converting-openssh-public-keys.html
import sys
import base64
import struct