Skip to content

Instantly share code, notes, and snippets.

View yunusemreayhan's full-sized avatar

Yunus Emre AYHAN yunusemreayhan

View GitHub Profile
@yunusemreayhan
yunusemreayhan / example-iterator.cpp
Last active August 6, 2022 12:09
Range Based Looper From Array
#include <iostream>
using namespace std;
template<typename itemType>
class RangeBasedLooper {
itemType *beginItem;
int count;
public:
RangeBasedLooper(itemType *initialItem, int size_) : beginItem(initialItem), count(size_){}
@yunusemreayhan
yunusemreayhan / ConcurrentMap.hpp
Created July 19, 2020 11:15
Concurrent Map for c++
#pragma once
#include <mutex>
#include <map>
#include <functional>
#include <chrono>
template<class keyType, class dataType>
class ConcurrentMap {
std::map<keyType, dataType> dataMap;
@yunusemreayhan
yunusemreayhan / bash_important_functions.sh
Last active June 22, 2020 08:41
BASH PROMPT FAV PS1
listen_for_process() {
__keyword=$1; (while :; do __arg=$(pgrep -d',' -f $__keyword); if [ -z "$__arg" ]; then top -u 65536 -n 1; else top -c -n 1 -p $__arg; fi; sleep 1; done;)
}
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="[\[$(tput sgr0)\]\[\033[38;5;10m\]\d\[$(tput sgr0)\]\[\033[38;5;15m\]] [\[$(tput sgr0)\]\[\033[38;5;10m\]\t\[$(tput sgr0)\]\[\033[38;5;15m\]] - [\[$(tput sgr0)\]\[\033[38;5;10m\]\w\[$(tput sgr0)\]\[\033[38;5;15m\]] - [\[$(tput bold)\]\u\[$(tput sgr0)\]] \$(parse_git_branch) :\n\\$ \[$(tput sgr0)\]"
parse_git_branch() {
@yunusemreayhan
yunusemreayhan / diff_file_generator.py
Created April 29, 2020 14:35
generates diff from given regexp pattern
import os
import re
def line_similarity_level(line1, line2):
matchlinecnt = 0
for idx in range(len(line1)):
idx = idx + 1
char1 = ' '
char2 = ' '
try:
@yunusemreayhan
yunusemreayhan / my-vim-install.sh
Created March 20, 2020 18:38
YouCompleteMe and amix vimconfig
#!/bin/bash
sudo apt-get install git cmake build-essential vim python3-dev
# amix vim configs
git clone --depth=1 https://github.com/amix/vimrc.git ~/.vim_runtime
sh ~/.vim_runtime/install_awesome_vimrc.sh
# youCompleteMe
cd ~/.vim_runtime/
@yunusemreayhan
yunusemreayhan / lightdm.conf
Created December 14, 2019 08:19
lightdm auto login configuration
# /usr/share/lightdm/lightdm.conf.d/01_debian.conf
[Seat:*]
greeter-session=lightdm-greeter
greeter-hide-users=false
autologin-session=true
autologin-user=<username>
autologin-user-timeout=1
session-wrapper=/etc/X11/Xsession
@yunusemreayhan
yunusemreayhan / connected_component_wrapper.h
Created December 9, 2017 14:08
OPENCV CONNECTED COMPONENT LIBRARY WRAPPER CODE
#include "opencv2/opencv.hpp"
#include "opencv2/xfeatures2d.hpp"
#include <istream>
#include <string>
#include <stdint.h>
using namespace std;
using namespace cv;
/*
@yunusemreayhan
yunusemreayhan / my_configs.vim
Last active September 12, 2019 05:50
vim rc file for amix/vimrc
set number
set showcmd
set tabstop=4
set shiftwidth=4
set expandtab
set showmatch
let mapleader="," " leader is comma
inoremap jk <esc>
colorscheme torte
set incsearch " search as characters are entered
#!/bin/bash
echo "processing file `pwd`/cscope_create_db.sh"
curdir=`pwd`
project_dir="asdasdasd"
cscope_dir="${project_dir}/cscope"
cscope_file="${cscope_dir}/cscope.files"
NEW_CSCOPE_DB="asdasdasdcscope/cscope.out"
@yunusemreayhan
yunusemreayhan / cscope_database_build.sh
Created August 15, 2019 20:04
builds cscope database into project folder, this one is only for kernel
#!/bin/bash
cur_dir=`pwd`
project_dir=$1
cscope_dir=${project_dir}/cscope
rm -rf ${cscope_dir}
mkdir -p ${cscope_dir}
find ${project_dir}/ -type f \( \
-name *.c \