Skip to content

Instantly share code, notes, and snippets.

View yunusemreayhan's full-sized avatar

Yunus Emre AYHAN yunusemreayhan

View GitHub Profile
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 / 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
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 / 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 ]
@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
#include "zmq.hpp"
#include "unistd.h"
#include <string.h>
#include <string>
#include <iostream>
#include <thread>
void print_zmq_message(zmq::message_t &toprint);
void server ()
@yunusemreayhan
yunusemreayhan / Dockerfile
Last active December 14, 2018 08:07
sample ubuntu compile machine
FROM ubuntu:18.04
CMD /bin/bash
RUN apt-get update --upgrade
RUN apt-get install -y make cmake g++ gcc git libczmq-dev libwebsockets-dev build-essential
RUN apt-get -y install sudo --no-install-recommends apt-utils
RUN adduser --disabled-password --gecos '' yunus
RUN adduser yunus sudo
@yunusemreayhan
yunusemreayhan / example_tmux_configuration.conf
Created March 12, 2019 08:03
example tmux configuration
#!/bin/bash
tmux start-server
tmux new-session -d -s dummy
for var in "$@"
do
m_current_env=$var
m_current_session_name=$m_current_env
tmux has-session -t $m_current_session_name