Skip to content

Instantly share code, notes, and snippets.

View huseyinyilmaz's full-sized avatar

Huseyin Yilmaz huseyinyilmaz

  • Balikesir, Turkey
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Memcached Protocol

  • There are 2 kinds of lines text (commands), unstructured data.
  • All lines ends with /r/n.
  • Keys are 250 characters. Keys must not include control characters or whitespace.

Commands

There are 3 kinds of commands.

  • Storage commands (there are six: “set”, “add”, “replace”, “append”, “prepend” and “cas”)
  • Retrieval commands (“get”, “gets”, “gat”, and “gats”)
  • All other commands don’t involve unstructured data.
  • Command names are lower-case and are case-sensitive.
@huseyinyilmaz
huseyinyilmaz / make_logs.py
Created November 16, 2020 09:06
this file creates a sample log messages and sends them to /dev/log. I use this to test syslog config.
import logging
import logging.handlers
import time
my_logger = logging.getLogger('testlogger')
my_logger.setLevel(logging.DEBUG)
#add formatter to the handler
formatter = logging.Formatter(
'SAMPLE_CORE_KAMUSTA: { "loggerName":"%(name)s", "timestamp":"%(asctime)s", "pathName":"%(pathname)s", '
'"logRecordCreationTime":"%(created)f", "functionName":"%(funcName)s", "levelNo":"%(levelno)s", '
@huseyinyilmaz
huseyinyilmaz / main.rs
Last active January 29, 2020 01:51
test server with hyper and tower server.
#![deny(warnings)]
#![forbid(future_incompatible, rust_2018_idioms)]
#![deny(missing_debug_implementations, nonstandard_style)]
use std::task::{Context, Poll};
// use std::convert::Infallible;
use::std::future;
use hyper::service::Service;
use hyper::{Body, Request, Response, Server};
#![feature(impl_trait_in_bindings)]
fn iter_returner<'a>(names: Vec<&'a str>) -> impl Iterator<Item=String> + 'a {
let it = names.into_iter()
.map(|n| format!("hello {}", n))
.map(String::from);
it
}
fn main() {
@huseyinyilmaz
huseyinyilmaz / decode.rs
Created October 28, 2019 05:39
rust experiments
/*
Given the mapping a = 1, b = 2, ... z = 26, and an encoded message, count the number of ways it can be decoded.
For example, the message '111' would give 3, since it could be decoded as 'aaa', 'ka', and 'ak'.
You can assume that the messages are decodable. For example, '001' is not allowed.
*/
use std::collections::HashMap;
use std::rc;
@huseyinyilmaz
huseyinyilmaz / main.hs
Created April 30, 2019 01:12
example monad transformer stack
-- | An example module.
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
module Example (main) where
import Control.Monad.Reader(ReaderT, runReaderT)
import Control.Monad.Reader(MonadReader)
import Control.Monad.Reader(MonadIO, liftIO)
import Control.Monad.Reader(ask)
<html>
<body>
<div class="givva" data-uid="23179deb-2160-0f01-986d-c9cd54c163cd"></div>
<body>
</html>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.