Skip to content

Instantly share code, notes, and snippets.

View samilkahraman's full-sized avatar
🌲
сначала кофе потом бить

Şamil Kahraman samilkahraman

🌲
сначала кофе потом бить
View GitHub Profile
@samilkahraman
samilkahraman / React
Created February 25, 2020 13:06
ornekAuth
export default function AuthExample() {
return (
<Router>
<div>
<AuthButton />
<ul>
<li>
<Link to="/public">Public Page</Link>
</li>
@samilkahraman
samilkahraman / gist:fff61d2a7586002db6412948c4cecf11
Last active December 6, 2022 12:43
NodeJS ile Aras Kargo API'lerinin Kullanımı
const soap = require("soap");
const url =
"http://customerservices.araskargo.com.tr/ArasCargoCustomerIntegrationService/ArasCargoIntegrationService.svc?wsdl";
//Esasweb uzerinden alinan bilgiler
const loginInfo =
"<LoginInfo>" +
"<UserName>samilkahraman</UserName>" +
"<Password>sifre</Password>" +
"<CustomerCode>123456789musterino</CustomerCode>" +
@samilkahraman
samilkahraman / storehouseModel.js
Last active January 9, 2021 13:24
Storehouse Model
const StorehouseSchema = new Schema(
{
id: {
type: Number,
unique: true,
},
parentID: {
type: String,
required: false,
},
@samilkahraman
samilkahraman / tree.js
Created January 9, 2021 13:55
Nodejs Tree Yapısı
function Node(data) {
this.id = data.id;
this.name = data.name;
this.children = [];
}
class Tree {
constructor() {
this.root = null;
}
@samilkahraman
samilkahraman / sampleStorehouse.json
Created January 9, 2021 17:55
Storehouse tree as json
"storehousesAsTree": [
{
"root": {
"id": 1,
"name": "Fabrika Depo",
"children": [
{
"id": 2,
"name": "Ankara Depo",
"children": [
@samilkahraman
samilkahraman / storehouseHelper.js
Last active January 9, 2021 18:14
data tree creation
const createDataTree = (dataset) => { // dataset - parentID ve id içeren objelerle dolu
const storehousesAsTree = []; // apinin geri döneceği array
let depth = 0; // başlangıç ağaç derinliğimiz
for (let i = 0; i < dataset.length; i += 1) { // bu döngünün amacı birden fazla root olma durumu içindir. Farklı ağaçlar oluşturmaktadır.
if (dataset[i].parentID === 0) { // Parent ID'si default 0 olanın parentı yok demektir ve Root kategoridir.
const parentID = dataset[i].id;
const tree = new Tree(); // Bulduğumuz elemanın root olduğu Treemizi oluşturuyoruz.
tree.add(dataset[i]); // add metodu tek parametre alırsa eklenen eleman root demektir.
const filteredDataSet = dataset.filter((el) => el.id !== parentID); // Bu filtreleme işlemi datasetten, ağaca eklediğimiz elemanı çıkarmak için
depth = findChilds(filteredDataSet, parentID, tree, 1); // ağacın rootunu yardımcı metodumuza gönderiyoruz ve o recursive olarak çocuklarını buluyor.
@samilkahraman
samilkahraman / hiyerarsikSelect.js
Created January 9, 2021 18:30
Ağacın kategori şeklinde gözükmesi için.
const menuItem = (obj, depth) => {
let line = "";
for (let i = 0; i < depth; i++) {
line += " — ";
}
return (
<MenuItem value={obj.id} onChange={handleMultiple}>
{line} {obj.name}
</MenuItem>
);