Skip to content

Instantly share code, notes, and snippets.

Avatar

Huseyin Yilmaz huseyinyilmaz

View GitHub Profile
View memcached_protocol.org

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 Nov 16, 2020
this file creates a sample log messages and sends them to /dev/log. I use this to test syslog config.
View make_logs.py
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 Jan 29, 2020
test server with hyper and tower server.
View main.rs
#![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};
View trait_and_borrow.rs
#![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() {
View decode.rs
/*
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 Apr 30, 2019
example monad transformer stack
View main.hs
-- | 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)
View index.html
<html>
<body>
<div class="givva" data-uid="23179deb-2160-0f01-986d-c9cd54c163cd"></div>
<body>
</html>
View duplicates.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View gmail_javascript_setup.js
(function injected(eventName, injectedIntoContentWindow)
{
let checkRequest;
/*
* Frame context wrapper
*
* For some edge-cases Chrome will not run content scripts inside of frames.
* Website have started to abuse this fact to access unwrapped APIs via a
* frame's contentWindow (#4586, 5207). Therefore until Chrome runs content