Skip to content

Instantly share code, notes, and snippets.

View yunusemreayhan's full-sized avatar

Yunus Emre AYHAN yunusemreayhan

View GitHub Profile
@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 / 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;
/*
Mat out;
int kernel_size = 31;
double sig = 5 /* wave strength in wave direction */,
th = 0.0 /* wave angle */,
lm = 11.0 /* wavelength */,
gm = 0.7 /* wave strength perpendicular to wave (bigger, lowers strength)*/,
ps = 0 /* phase shift */;
Mat kernel = getGaborKernel(cv::Size(kernel_size,kernel_size), sig, th, lm, gm, ps);
imshow("gabor kernel", kernel);
filter2D(afterprocess, out, CV_32F, kernel);
@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
@yunusemreayhan
yunusemreayhan / perl_replace_command.sh
Last active January 5, 2018 05:55
perl find and replace command
# http://www.atrixnet.com/in-line-search-and-replace-in-files-with-real-perl-regular-expressions/
perl -p -i -e 's/change this/to that/g' file1 file2 file3...
perl -p -i'.backup' -e 's/(?<=replace )this(?= lolc[aA@]t)(?# with )/that/; s/(?# and as for all of the )([[:digit:]]+) (?i:fat|skinny|thirsty) camels(?# you really need those)/$1 white llamas/g;' file1 file2 /path/to/file3
perl -p -i -e 's/replace this/using that/g' /all/text/files/in/*.txt
@yunusemreayhan
yunusemreayhan / bash_cheat_sheet.sh
Last active February 14, 2018 08:40
BASH USEFULL COMMANDS
# cp or mv all executables under some folder
find . -maxdepth 1 -type f -perm +a=x -print0 | xargs -0 -I {} mv {} executables/
# read single byte from a file
temp=`hexdump -ve '1/1 "%0.2x" ""' -s $usageIndexOfSramByte -n 5 $sramdevicename 2> /dev/null`
temp=`hexdump -ve '1/1 "%d" ""' -s $usageIndexOfSramByte -n 5 $sramdevicename 2> /dev/null`
# Integer Comparison Operators
# -eq Is Equal To if [ $1 -eq 200 ]
# -ne Is Not Equal To if [ $1 -ne 1 ]
brew install qt ruby ncurses gawk binutils gperf grep gettext ncurses pkgconfig autotools automake autoconf-archive gawk binutils homebrew/dupes/gperf grep gettext ncurses pkgconfig gnu-tar bison coreutils
brew install gnu-sed --with-default-names
brew link gettext --force && brew link ncursesw --force
export PKG_CONFIG_PATH=/usr/local/Cellar/ncurses/6.0_4/lib/pkgconfig/
ln -s /usr/bin/tar ./output/host/bin/tar
ln -s /usr/local/bin/gxargs ./output/host/bin/xargs
sudo ln -s /usr/local/bin/gcc-7 ./output/host/bin/gcc
sudo ln -s /usr/local/bin/gsha256sum /usr/local/bin/sha256sum
sudo ln -s /usr/local/bin/gsha512sum /usr/local/bin/sha512sum
sudo ln -s /usr/local/bin/gsha1sum /usr/local/bin/sha1sum
@yunusemreayhan
yunusemreayhan / lossless_crop_rotate.py
Created July 10, 2018 08:43
image crop a partition and rotate without losing info during rotation
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 9 09:52:14 2018
@author: yunus.ayhan
"""
from PIL import Image
import numpy as np
import math
@yunusemreayhan
yunusemreayhan / dockerfile_ubuntu_12_04
Created July 29, 2018 13:41
Sample ubuntu 12.04 dockerfile with user in it
FROM ubuntu:12.04
RUN apt-get update && \
apt-get -y install sudo --no-install-recommends apt-utils
#RUN useradd -ms /bin/bash change && echo "change:change" | chpasswd && adduser change sudo
RUN adduser --disabled-password --gecos '' change
RUN adduser change sudo
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
@yunusemreayhan
yunusemreayhan / func_ptr_call_from_class_instance.cpp
Created November 13, 2018 08:08
running function pointer from class instance
/*
* File: MenuExecuterInstance.h
* Author: change
*
* Created on November 12, 2018, 2:58 PM
*/
#ifndef MENUEXECUTERFUNCTION_H
#define MENUEXECUTERFUNCTION_H