Skip to content

Instantly share code, notes, and snippets.

View shahril96's full-sized avatar
🐢

Mohd Shahril shahril96

🐢
View GitHub Profile
@shahril96
shahril96 / int2basen.c
Last active April 6, 2016 13:23
Convert base-10 integer to any base-N (base 2 until base 10) presentation
#include <stdio.h>
void int2bin(int n, int base) {
if(n > 0) {
int2bin(n / base, base);
printf("%d ", n % base);
}
}
int main() {
@shahril96
shahril96 / 8queensolver.c
Created April 9, 2016 15:28
Solve 8 Queens Problem using backtracking algorithm
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <time.h>
#define SIZE 8
int base[SIZE][SIZE];
void shuffle(int arrayNum[]) {
@shahril96
shahril96 / ratmazeprob.c
Created April 10, 2016 16:00
Using backtracking algorithm in order to solve "Rat in a Maze" problem
#include <stdio.h>
#include <stdbool.h>
#define N 6
// 0 = valid box to step
// x = invalid box to step (halangan)
char board[N][N] = {
{ 0 ,'x','x','x','x','x'},
{ 0 , 0 , 0 ,'x', 0 ,'x'},
@shahril96
shahril96 / socat-reverse-shell.sh
Last active January 15, 2024 13:29
Post-exploitation reverse shell using socat plus encrypted connection
#!/usr/bin/env bash
# Author : shahril96
# Licensed under the WTFPL license - http://www.wtfpl.net/about/
# Make sure only root can run our script
[[ $EUID -ne 0 ]] && { echo "This script must be run as root" 1>&2; exit 1; }
# print help msg if not enough argument given
[ $# -ne 1 ] && { echo "Usage: `basename $0` port-to-listen"; exit 1; }
@shahril96
shahril96 / tmux.conf
Last active November 10, 2016 14:44
My global tmux.conf
# set ctrl-b for sending prefix
set-option -g prefix ^B
bind-key ^B send-keys ^B
set -g default-terminal "screen-256color"
bind | split-window -h
bind - split-window -v
bind N break-pane
@shahril96
shahril96 / .vimrc
Last active November 5, 2016 17:46
My simple .vimrc conf file
" ---------------------------------------------
"
" Do this beforehand :
"
" $ git clone https://github.com/VundleVim/Vundle.vim.git
" ~/.vim/bundle/Vundle.vim
"
" If you have upgraded your YCM, then follow instruction from line (/search .ycm.extra_conf.py)
" if you want C-family auto-complete feature
@shahril96
shahril96 / .screenrc
Last active November 10, 2016 12:56
My GNU screen simple config
# Don't display the copyright page
startup_message off
# change default key binding to ctrl+b
escape ^Bb
# enable 256-bit color instead of default 8-bit colors
term screen-256color
hardstatus alwayslastline
@shahril96
shahril96 / kruskal_algo.cpp
Last active June 30, 2016 15:15
Find minimum spanning tree using Kruskal's algorithm
/*
* references
* 1) http://www.geeksforgeeks.org/greedy-algorithms-set-2-kruskals-minimum-spanning-tree-mst/
* 2) https://en.wikipedia.org/wiki/Kruskal%27s_algorithm
*/
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
@shahril96
shahril96 / prim_algo.cpp
Last active July 1, 2016 18:15
Find MST in weighted graph using Prim's algorithm
/*
* references
*
* 1) http://www.geeksforgeeks.org/greedy-algorithms-set-5-prims-minimum-spanning-tree-mst-2/
* 2) https://www.cse.ust.hk/~dekai/271/notes/L07/L07.pdf
*
*/
#include <iostream>
#include <set>
@shahril96
shahril96 / dijkstras_algo.cpp
Created July 3, 2016 14:49
Using Dijkstra's algorithm to find the shortest path between 2 vertices inside a graph
/*
* references
*
* 1) http://www.geeksforgeeks.org/greedy-algorithms-set-6-dijkstras-shortest-path-algorithm/
* 2) http://home.cse.ust.hk/faculty/golin/COMP271Sp03/Notes/MyL09.pdf
*
*/
#include <iostream>
#include <set>