Skip to content

Instantly share code, notes, and snippets.

def calc_eth(eth_currency, target_eth, eth_asset, try_asset)
x = 1
loop do
if (((x / eth_currency.to_f) + eth_asset) * target_eth.to_f) <= try_asset + x
x = x + 1
else
break
end
end
x
#include <iostream>
#include <sstream>
using namespace std;
float get_input(){
stringstream ss (stringstream::in | stringstream::out);
float min = 1;
float ret_integer = 0.0;
string str_number;
@canozel
canozel / travelling_salesman_problem.rb
Created December 20, 2016 00:11
Travelling salesman problem
@graph = { "A" => "BDFH", "B" => "ACRJI", "C" => "BDQR", "D" => "AEPQC", "E" => "DFNP",
"F" => "AENMG","G" => "FLMH", "H" => "AGLKI", "I" => "HKJB", "J" => "IB",
"K" => "IH", "L" => "HG", "M" => "GF", "N" => "FE", "P" => "ED",
"Q" => "DC", "R" => "CB" }
@counter = 0
@path = []
def find_paths(city, last_city)
# Gelen şehri listeye ekliyor
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Node.js\n');
}).listen(8124, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8124/');
# -*- coding: utf-8 -*-
import sys, string, datetime, cx_Oracle, os
import logging
from subprocess import check_output
from logging.handlers import RotatingFileHandler
os.environ["NLS_LANG"] = 'TURKISH_TURKEY.WE8ISO8859P9'
# -*- coding: utf-8 -*-
import sys, string, datetime, os, codecs, logging
from jira.client import JIRA
from subprocess import check_output
from logging.handlers import RotatingFileHandler
reload(sys)
sys.setdefaultencoding('utf-8')
sys.stdout = codecs.getwriter('iso-8859-9')(sys.stdout)
@canozel
canozel / RaceCondition.c
Created June 13, 2016 00:09
Cümlenin karakter sayısını thread'lerle hesaplayan kod parçası
#include <stdio.h>
#include <stdint.h>
#include <pthread.h>
#include <stdlib.h>
void *addition(void *);
#define NUMBER_OF_THREADS 4
char word[1024] = "lorem ipsum dolor sit amet consectetur adipiscing elit";
@canozel
canozel / csh.c
Created March 31, 2016 20:02
Basic Shell
#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define MAX_LENGTH 100
#define BRACKETS " \t\r\n\a"
@canozel
canozel / haram.js
Last active March 10, 2019 21:31
csgodouble hile
var base=2;
var stop=640; // 9 bets
var count=base;
var lastBet=base;
var didIBet=false;
var didIChecked = false;
var seriesOfLoosing=0;
var cashSinceLastWin=0;
var type = 0; //0-martingale, 1-d'alembert
var countGreen = 0;
@canozel
canozel / prime_factor.rb
Created March 24, 2016 15:42
Asal çarpanlarına ayırma
def prime?(num)
k = 0
(2..Math.sqrt(num)).each do |i|
if num % i == 0
k = 1
break
end
end
k != 1
end