Skip to content

Instantly share code, notes, and snippets.

View alex179ohm's full-sized avatar
🏠
Working from home

Alessandro Cresto Miseroglio alex179ohm

🏠
Working from home
View GitHub Profile
@alex179ohm
alex179ohm / rotate.rs
Last active April 28, 2020 14:11
Rotate Vec
pub enum Direction {
Left,
Right
}
// Efficiently perform left rotation of Vec's items r times.
fn rotate_left(v: &mut Vec<i32>, r: i32) {
rotate(v, Direction::Left, r)
}
@alex179ohm
alex179ohm / Dockerfile
Last active March 11, 2020 16:34
c2rust Dockerfile
FROM rust:1.41-slim
WORKDIR /app
RUN apt update
RUN apt install -y build-essential llvm-7 clang-7 libclang-7-dev cmake libssl-dev pkg-config python3 \
&& apt clean \
&& rm -rf /var/lib/apt/lists/*
@alex179ohm
alex179ohm / init.vim
Created January 17, 2020 17:01
nvim init.vim file
call plug#begin()
Plug 'tpope/vim-sensible'
Plug 'vim-airline/vim-airline'
Plug 'mkitt/tabline.vim'
Plug 'NLKNguyen/papercolor-theme'
Plug 'jiangmiao/auto-pairs'
Plug 'bling/vim-bufferline'
Plug 'othree/jspc.vim', { 'for': ['javascript', 'javascript.jsx'] }
Plug 'posva/vim-vue'
Plug 'neoclide/coc.nvim', { 'tag': '*', 'branch': 'release' }
call plug#begin()
Plug 'tpope/vim-sensible'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'NLKNguyen/papercolor-theme'
Plug 'scrooloose/nerdtree'
Plug 'jiangmiao/auto-pairs'
Plug 'bling/vim-bufferline'
Plug 'othree/jspc.vim', { 'for': ['javascript', 'javascript.jsx'] }
Plug 'posva/vim-vue'
@alex179ohm
alex179ohm / crc16.rs
Last active October 17, 2019 12:57
Redis hash function in Rust
/*
* Copyright 2001-2010 Georges Menie (www.menie.org)
* Copyright 2010-2012 Salvatore Sanfilippo (adapted to Redis coding style)
* Copyright 2019-2021 Alessandro Cresto Miseroglio (ported to Rust programming language)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright
use std::collections::HashMap;
use actix::prelude::*;
use std::sync::mspc::channel;
use rand;
// we have a lot of resources to process (centinaia di migliaia di risorse per centinaia di migliaia di requests :))
const N_SESSIONS = 12;
#[derive(Message)]

Keybase proof

I hereby claim:

  • I am alex179ohm on github.
  • I am alex179ohm (https://keybase.io/alex179ohm) on keybase.
  • I have a public key ASCAwVjgrd4KYtV4xoAgz1gX-c-P4EuwOaO5ZR0Qipwe8Qo

To claim this, I am signing this object:

extern crate nsqueue;
extern crate actix;
extern crate futures;
use actix::prelude::*;
use std::time::Duration;
use futures::future::Future;
use nsqueue::{Producer, Pub, Error, NsqValue};
struct MyClient ( Addr<Producer> );
extern crate nsqueue;
extern crate actix;
use nsqueue::{Consumer, Connection, Ctx, Msg, Error, Cmd, fin, Config};
use actix::prelude::*;
struct MyReader;
impl Consumer<Ctx> for MyReader {
// on_message callback
@alex179ohm
alex179ohm / config.json
Created April 2, 2017 11:12 — forked from anonymous/config.json
Bootstrap Customizer Config
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#428bca, 6.5%)",
"@brand-success": "#5cb85c",