Skip to content

Instantly share code, notes, and snippets.

@hackerdem
hackerdem / test
Created May 25, 2017 04:01
test preparation application, needs a excel file of question and answers, application asks one by one
from tkinter import *
import pandas as pd
import xdrlib
import random
from pynput import keyboard
from array import array as ar
def main():
@hackerdem
hackerdem / server.js
Created May 23, 2017 05:04
simple server app with node.js
var express=require('express');
var app=express();
var fs=require('fs');
app.get('/',function(req,res){
fs.readFile('index.html',function(err,buffer){
var html=buffer.toString();
res.setHeader('Content-Type','text/html');
res.send(html);
});
});
import sys,re
with open('C:/Users/erdem/Desktop/memories/newe.txt', 'r') as test_cases:
for test in test_cases:
if test in ['','\n']:pass
else:
v=re.search('([-;\w]+)', test).group(0)
vqq=';'.join(re.findall('([\d|\w]+-[\d|\w]+)', test))
st=''
if vqq==v and 'END' in v and 'BEGIN' in v:
@hackerdem
hackerdem / solutions.js
Created June 19, 2016 05:50
solutions for codewars challenges in javascript
//Rearange Number to Get its Maximum
var maxRedigit = function(num) {
var ou=[];
var snum=num.toString();
if (num<=0 || snum.length!=3){return null}
for (var i=0,len=snum.length;i<len;i+=1){
ou.push(+snum.charAt(i));}
var a=ou.sort(function(a,b){return b-a}).join('');
return parseInt(a)
};
@hackerdem
hackerdem / solutions.py
Created June 19, 2016 05:45
solutions for codewars challenges in python
#Product of consecutive Fib numbers in python
def productFib(n):
f=[1,1]
d1,d2,d3,pro=0,0,0,0
while pro<=n:
if pro==n:return ([d1,d2,True])
else:pro=0
d1,d2=f[0],f[1]
d3=d1+d2
pro=d1*d2
@hackerdem
hackerdem / file_1.rb
Created May 20, 2016 16:53
Ruby code for opening a file and truncating and after, recording new data
filename=ARGV.first
script=$0
puts "Data in the file named as #{filename} will be deleted"
puts "Press enter to continue"
print "? "
STDIN.gets
puts "Opening the file...."
target=File.open(filename,'w')
@hackerdem
hackerdem / aes_enc_dec.py
Created May 14, 2016 16:52
simple AES encryption and decryption
from Crypto.Cipher import AES
from Crypto import Random
def encrypt(key,message):
cipher=AES.new(key,AES.MODE_CFB,iv)
msg=cipher.encrypt(message)
print(msg)
return msg
def decrypt(key,msg):
dec=AES.new(key,AES.MODE_CFB,iv)
return dec.decrypt(msg).decode('ascii')
@hackerdem
hackerdem / encrypt_1.py
Created May 14, 2016 07:45
python simple encryption and database connection example
from passlib.hash import pbkdf2_sha256
import getpass
import mysql.connector
def enc_pass(pwd):
hash=pbkdf2_sha256.encrypt(pwd,rounds=200,salt_size=16)
return hash
def con_database(pwd):
cnx=mysql.connector.connect(user='*****',password='*****',host='*******',database='******')
cursor=cnx.cursor()
try:
@hackerdem
hackerdem / scanner.py
Created May 13, 2016 16:26
basic port scanner
import socket
import subprocess
import sys
from datetime import datetime
subprocess.call('CLS', shell=True)
remoteServer = input("Enter a remote host to scan: ")
remoteServerIP = socket.gethostbyname(remoteServer)
print ("-" * 60)
print ("Please wait, scanning remote host", remoteServerIP)
@hackerdem
hackerdem / client_server.py
Created May 13, 2016 15:39
UDP client server application
import argparse
import socket
from datetime import datetime
maxbyte=65535
def server(port):
sock=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
sock.bind(('127.0.0.1',port))
print('Listining at {}'.format(sock.getsockname()))
while True: