Skip to content

Instantly share code, notes, and snippets.

@mortymacs
mortymacs / env.yaml
Last active August 31, 2017 06:28
My TMUXP Config
session_name: ENV
windows:
- window_name: DEV
panes:
- cd Workspace
- window_name: WORK
panes:
- cd Workspace
- window_name: WORK
panes:
@mortymacs
mortymacs / pacman-sample-cmd.md
Created August 14, 2017 04:11
Pacman Sample Commands

Update All Sources and Packages:

$ pacman -Syu

Search Package:

$ pacman -Ss <PACKAGE NAME>
@mortymacs
mortymacs / quick-sort.py
Created August 17, 2017 19:57
Quick sort in Python
#!/usr/bin/env python
class QuickSort:
"""Quick sort implementation."""
def __init__(self, data):
"""Initialize array."""
self._array = data
def partition(self, left, right):
@mortymacs
mortymacs / enable_port_forwarding.md
Created August 19, 2017 04:57
Check and Enable Port Forwarding In Linux

To check that is port forwarding enable or not:

$ cat /proc/sys/net/ipv4/conf/eth0/forwarding

If result is "1" it means that it's enable, otherwise it's disable.

To enable port forwarding:

echo "1" | tee /proc/sys/net/ipv4/conf/eth0/forwarding
@mortymacs
mortymacs / proxy-jump-ssh-connection.md
Last active March 28, 2018 01:53
Proxy Jump in SSH Connections

Create config file for ssh (my.conf):

Host Server1
    User root
    HostName 192.168.100.10
Host Server2
    User root
    HostName 192.168.100.5
Host Server3
 User root
@mortymacs
mortymacs / radixsort.py
Created August 25, 2017 13:18 — forked from mre/radixsort.py
Radix Sort implementation in Python
from math import log10
from random import randint
def get_digit(number, base, pos):
return (number // base ** pos) % base
def prefix_sum(array):
for i in range(1, len(array)):
array[i] = array[i] + array[i-1]
return array
@mortymacs
mortymacs / passing-function-str.c
Last active March 2, 2018 15:31
Passing Function As Parameter
#include <stdio.h>
void callback(void(*func)(char*), char *text){
(*func)(text);
}
void print(char* text) {
printf("%s\n", text);
}
@mortymacs
mortymacs / install-erlang-manually.md
Created August 29, 2017 05:22
Install Erlang From Source code Wothout wx and doc

Requirements

$ apt-get install libncurses5-dev

Manually

$ wget -c http://erlang.org/download/otp_src_19.3.tar.gz
$ tar xzf otp_src_19.3.tar.gz
$ cd otp_src_19.3/
@mortymacs
mortymacs / sample-debug-code.py
Created August 30, 2017 05:01
Sample Code For Debug Situation
import inspect
print("LINE NUMBER:{} {}".format(__file__, inspect.getframeinfo(inspect.currentframe()).lineno))
# __file__ : shows current file name
# inspect.getframeinfo(inspect.currentframe()).lineno: shows current line number
@mortymacs
mortymacs / avl_tree.py
Created September 1, 2017 07:56 — forked from girish3/avl_tree.py
AVL tree implementation in python
#import random, math
outputdebug = False
def debug(msg):
if outputdebug:
print msg
class Node():
def __init__(self, key):