Skip to content

Instantly share code, notes, and snippets.

View Goblin80's full-sized avatar
🐿️

Mahmoud Goblin80

🐿️
View GitHub Profile
@Goblin80
Goblin80 / View Statistics.rb
Created October 17, 2015 19:09
Rewritting "View Statistics.bat" from "TP-LINK-Remote-Management" in Ruby
require "Date"
require "colorize"
DEFAULTDAY = 25
DIRECTORY= "Sample/Log"
(puts "ERROR: Log Directory Not Found"; gets; exit) if !Dir.exist? "Log"
class LogFile
attr_accessor :name, :date
@Goblin80
Goblin80 / Lyrics Sync.rb
Last active May 6, 2016 18:56
A tool to sync lyrics to songs
require 'colorize'
require 'clipboard'
class LyricFile
attr_accessor :name, :raw, :timed
def initialize(path)
if path == 'Clipboard'
@raw = arrayify(Clipboard.paste)
@name = 'Clipboard'
@Goblin80
Goblin80 / tmux-cheatsheet.markdown
Last active July 21, 2017 16:43 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@Goblin80
Goblin80 / .vimrc
Created January 20, 2018 11:57
personal (Neo)vim configuration Raw
set nocompatible " be iMproved, required
filetype off " required
syntax on
set number relativenumber
set mouse=a
"set t_Co=256
"recursive lookup when using find
set path+=**
@Goblin80
Goblin80 / pageReplacement.cpp
Created May 4, 2018 19:50
Implementation of various page replacement algorithms
#include <iostream>
#include <list>
#include <algorithm>
using namespace std;
template<typename T = int>
class Replacement
{
public:
@Goblin80
Goblin80 / sudoku.m
Created May 16, 2018 12:42
[MATLAB] A fitness function for a 4x4 sudoku using genetic algorithm
function score = sudoku(x)
x = reshape(round(x), 4, 4);
x(1,1) = 1;
x(1,4) = 2;
x(2,3) = 1;
x(3,2) = 3;
x(4,1) = 4;
x(4,4) = 3;
@Goblin80
Goblin80 / merge.cpp
Created May 30, 2018 12:37
General purpose merge sort implementation in C++11
#include <iostream>
#include <vector>
using namespace std;
template <typename T>
void _Merge(vector<T> &a, int low, int mid, int high)
{
int n, p, q,
l = mid - low + 1,
@Goblin80
Goblin80 / bigram.sh
Created August 17, 2018 18:09
MapReduce program to calculate the conditional probability that a word q occurs after another word p
#!/bin/bash
hadoop fs -rm -R shakespeare
hadoop fs -mkdir -p shakespeare/input
hadoop fs -put input/* shakespeare/input
hadoop jar /usr/lib/hadoop-mapreduce/hadoop-streaming-2.6.0-cdh5.13.0.jar -input shakespeare/input -output shakespeare/output -mapper "python `pwd`/mapper.py" -reducer "python `pwd`/reducer.py"
hadoop fs -cat shakespeare/output/part* | head -n 10
@Goblin80
Goblin80 / swap.sh
Created November 2, 2018 13:19
Add permanent swap space on Ubuntu
!#/bin/bash
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
@Goblin80
Goblin80 / BruteDES.java
Last active March 13, 2019 11:38
Crack DES (ECB) through searching whole key space using Java Streams
import javax.crypto.*;
import javax.crypto.spec.DESKeySpec;
import java.util.Arrays;
import java.util.stream.LongStream;
public class BruteDES {
public static byte[] encrypt(byte[] plaintext, byte[] rawkey) {
try {
return _digest(plaintext, rawkey, Cipher.ENCRYPT_MODE);