Skip to content

Instantly share code, notes, and snippets.

View talhaHavadar's full-sized avatar
🎶
Listening Cankan - Yar Yar

Talha Can Havadar talhaHavadar

🎶
Listening Cankan - Yar Yar
View GitHub Profile
import socket, io, struct, time
s = socket.socket() # defaults family AF_INET and type SOCK_STREAM (tcp)
HOST = ""# "192.168.1.39" # computer's ip address
PORT = 51215 # port number that computer will listen
s.connect((HOST,PORT))
try:
@talhaHavadar
talhaHavadar / babylon.py
Created November 21, 2017 15:21
Implementation of Babylon algorithm to find root of the number
"""
Implementation of Babylon algorithm to find roots of the number
@author Talha Can Havadar
"""
def root(number, degree):
"""
Takes the root of the given number according to given degree
and returns the rooted number as a result
"""
@talhaHavadar
talhaHavadar / OperationTextBuilder.java
Last active February 19, 2018 09:57
WildflyCLIHelper to execute jboss cli from Java
package be.telenetgroup.services.tgapi.testing.support;
import org.springframework.util.CollectionUtils;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
/**
@talhaHavadar
talhaHavadar / InvalidPlateException.java
Last active October 28, 2022 13:18
Java validation structure by using combinator pattern #java #validation #combinator #designpatterns
package com.talhahavadar.exceptions;
/**
* Created by talhahavadar on 13.03.2018.
*/
public class InvalidPlateException extends RuntimeException {
private static final String message = "Plate information is not valid.";
public InvalidPlateException() {
@talhaHavadar
talhaHavadar / ostream.cpp
Last active April 22, 2019 09:53
Custom Output Stream in C++.
//
// ostream.cpp
// utility
//
// Created by Talha Havadar on 18.04.2019.
// Copyright © 2019 Talha Can Havadar. All rights reserved.
//
#include "ostream.hpp"
#include <iostream>
@talhaHavadar
talhaHavadar / asynciterators.js
Created July 25, 2019 18:25
Javascript async iterators to fetch data from paginated REST api.
async function pageRequest(params) {
if (params.start >= 100) {
return Promise.resolve({
start: params.start,
limit: 25,
isEndOfData: true
});
} else {
return Promise.resolve({
start: params.start,
@talhaHavadar
talhaHavadar / demo.js
Created July 26, 2019 11:03
Sourcebox for "Using Javascript Async Iterator to Fetch Data From Paginated REST API" article in my linkedin(https://www.linkedin.com/in/talha-can-havadar-536b76b7/).
let axios = require('axios');
const api = {
async version() {
let response = await axios.get("http://localhost:5454/rest/api/1.0/application-properties")
return response.data;
},
async branches(projectKey, repositorySlug, params) {
try {
let response = await axios.get(`http://localhost:5454/rest/api/1.0/projects/${projectKey}/repos/${repositorySlug}/branches`, {
@talhaHavadar
talhaHavadar / Makefile
Last active September 14, 2020 06:54
Basic Linux Char Device Example #chardevice #linux #kernel #driver
obj-m += chardev-ex.o
CROSS_COMPILE=
LINUX_DIR=/lib/modules/$(shell uname -r)/build
PWD=$(shell pwd)
all:
make -C $(LINUX_DIR) M=$(PWD) modules
clean:
@talhaHavadar
talhaHavadar / main.cpp
Created October 5, 2020 19:27
QT Generic Binary Data Parser Implementation
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QDebug>
#include "packet.h"
#include "packetparser.h"
#include "packetprocessor.h"
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
@talhaHavadar
talhaHavadar / modelvalidator.h
Last active August 18, 2021 10:10
Cpp Validator Pattern to reduce if statements in code. #chainofresponsibility, #validatorpattern, #cpp, #validator
#ifndef MODELVALIDATOR_H
#define MODELVALIDATOR_H
#include "memory"
#include <QList>
using namespace std;
enum class ModelType
{
PERSON,