This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# Le codage de Huffman | |
# Théorie de l'information et du codage | |
# Etudiant: Boubakr NOUR <[email protected]> | |
# Universite Djilali Liabes (UDL) de Sidi Bel Abbes | |
import heapq | |
from collections import defaultdict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# Lampel-Ziv 78 (LZ78) | |
# Théorie de l'information et du codage | |
# Etudiant: Boubakr NOUR <[email protected]> | |
# Universite Djilali Liabes (UDL) de Sidi Bel Abbes | |
def compress(data): | |
dictionary, word = {0: ''}, 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def union(A, i, B, j, C): | |
if (i >= len(A)) and (j >= len(B)) and (max(A[-1], B[-1]) == C[-1]): | |
return C | |
if (i == len(A)) and (j <= len(B)) and (C[-1] < B[j]): | |
C.append(B[j]) | |
return union(A, i, B, j + 1, C) | |
if (j == len(B)) and (i <= len(A)) and (C[-1] < A[i]): | |
C.append(A[i]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Stack; | |
/** | |
* | |
* @author Boubakr | |
*/ | |
public class Ackermann { | |
public static int RecursiveAckerman(int m, int n) { | |
if (m == 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def generate_random_mac_address(): | |
"""Generate a random MAC Address using the VM OUI code""" | |
rand_mac_addr = [0x00, 0x50, 0x56, random.randint(0x00, 0x7f), random.randint(0x00, 0xff), random.randint(0x00, 0xff)] | |
return ':'.join(map(lambda x: "%02x" % x, rand_mac_addr)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void createDirectory(final String directoryName) { | |
final File homeDirectory = new File(System.getProperty("user.home")); | |
final File newDirectory = new File(homeDirectory, directoryName); | |
if(!newDirectory.exists()) { | |
boolean result = newDirectory.mkdir(); | |
if(result) { | |
System.out.println("The directory is created !"); | |
} | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void downloadFile(string sourceURL, string destinationPath) | |
{ | |
long fileSize = 0; | |
int bufferSize = 1024; | |
bufferSize *= 1000; | |
long existLen = 0; | |
System.IO.FileStream saveFileStream; | |
if (System.IO.File.Exists(destinationPath)) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean IsValidAddress(String ipAddr) { | |
int nDC = 0; | |
int nC = 0; | |
ipAddr = ipAddr.trim(); | |
String s = ipAddr; | |
char[] chars = s.toCharArray(); | |
/* 0- Error: Empty */ | |
if (s.isEmpty()) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#! -*- coding: utf-8 -*- | |
# Three Way Handshaking using Scapy | |
from scapy.all import * | |
ip = IP(src="192.168.0.2", dst="172.16.24.1") | |
SYN = TCP(sport=1500, dport=80, flags='S', seq=100) | |
SYNACK = sr1(ip/SYN) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#! -*- coding: utf-8 -*- | |
# Enumerate a string to substrings | |
# Y is a substring for X if: X = U.Y.V | |
def enumerate(string): | |
"""Function that will enumerate a string to substring | |
return: A list with all the substrings |
NewerOlder