Skip to content

Instantly share code, notes, and snippets.

View huseyinyilmaz's full-sized avatar

Huseyin Yilmaz huseyinyilmaz

  • Balikesir, Turkey
View GitHub Profile
@huseyinyilmaz
huseyinyilmaz / grep.hs
Created December 3, 2015 22:32
haskell implementation of grep tool
{-
Haskell implementation of grep tool.
http://linux.die.net/man/1/grep
-- from stdin:
$ ls | ./grep ep.hs
-- with file names
$ ./grep List grep.hs
grep.hs:import Data.List(isInfixOf)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@huseyinyilmaz
huseyinyilmaz / normalize_email.py
Created January 10, 2012 08:06
Normalize email
def normalize_email(self, email):
"""
Normalazing email addres. An email address
has following properties:
1) It is case-insensitive
2) "." characters on username part of email address is ommited.
For instance foobar@gmail.com and foo.bar@gmail.com are the
same address.
3) Anything after "+" sign is ommited. foo@gmail.com and
foo+bar@gmail.com are same email address.

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 / xmlutils.py
Last active November 26, 2020 12:19
Convert python dictionary to xml
# -*- coding: utf-8 -*-
import unittest
import xmlutils
from xml.dom import minidom
from collections import Mapping
def dict2element(root, structure, doc):
"""
@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", '
if __name__ == '__main__':
#get wordlist
f = open('wordlist.txt','r')
wordlist = [line.strip()for line in f]
f.close()
#get given words
f = open('words.txt')
words = [line[1:].strip()for line in f]
f.close()
#result will be stored in this list
@huseyinyilmaz
huseyinyilmaz / .tmux.conf
Last active March 19, 2020 19:15
My Tmux configuration
unbind C-b
set -g prefix C-q
bind-key C-q send-prefix
# enable vi keys.
# setw -g mode-keys vi
# set window split
bind-key v split-window -h
bind-key s split-window -v
@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() {