<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kadir Kılıçoğlu on Medium]]></title>
        <description><![CDATA[Stories by Kadir Kılıçoğlu on Medium]]></description>
        <link>https://medium.com/@kadir.kilicoglu_67563?source=rss-9794d1a89206------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*oBJvDYkE6h_j_iXC</url>
            <title>Stories by Kadir Kılıçoğlu on Medium</title>
            <link>https://medium.com/@kadir.kilicoglu_67563?source=rss-9794d1a89206------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 20:10:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kadir.kilicoglu_67563/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Foucault Sarkacı Sözlüğü — 1.1]]></title>
            <link>https://medium.com/@kadir.kilicoglu_67563/foucault-sarkac%C4%B1-s%C3%B6zl%C3%BC%C4%9F%C3%BC-1-1-8941778fdb7f?source=rss-9794d1a89206------2</link>
            <guid isPermaLink="false">https://medium.com/p/8941778fdb7f</guid>
            <category><![CDATA[foucault-sarkacı]]></category>
            <category><![CDATA[foucaults-pendulum]]></category>
            <category><![CDATA[umberto-eco]]></category>
            <dc:creator><![CDATA[Kadir Kılıçoğlu]]></dc:creator>
            <pubDate>Thu, 06 Aug 2020 15:17:11 GMT</pubDate>
            <atom:updated>2020-08-06T15:26:21.034Z</atom:updated>
            <content:encoded><![CDATA[<h3>Foucault Sarkacı Sözlüğü — 1.1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*OJc9JdHwxFzk2AmjoRTNpA.jpeg" /><figcaption>Paris, Pantheon’daki Foucault Sarkacı. Kaynak: <a href="https://www.flickr.com/photos/msk13/4818027399/">Misko/Flickr</a></figcaption></figure><p>Umberto Eco’nun ikinci romanı Foucault Sarkacı, gizli bilimlerin tarihini çok katmanlı uyduruk (?) bir plan çevresinde okuyucusuna aktaran bir -Şadan Karadeniz’in ifadesiyle- Eco-roman!</p><p>Bu Eco-romanın konusu, hikayesi, akışı ve sonucu bizim serimizin konusu değil ancak her ne kadar dikkatli ve eğitimli gözler için keyifli bir anlatımı olsa da benim gibi sıradan canlılar için “plan”ı birkaç kez okumak bile işleri kolaylaştırmıyor zira kitap anlatılmak isteneni açıkça veya üstü kapalı olarak terimlerle, göndermelerle, tarihi kişiler, olaylar ve yerlerle, alıntılarla ve dolaylamalarla aktarıyor. Bir de üstüne Şadan Karadeniz’in öz Türkçe kullanımı ve sözlüklerde dahi bulunmayan bazı yeni kelimeleri işleri biraz daha zorlaştırıyor. Haliyle, anlatılanı kavramak ve romandan keyif almak için, bir süre sonra bir sayfayı okurken defalarca dipnotlara, bölüm ve çevirmen notlarına, kitap sonu sözlükçeye, harici bir sözlüğe, açıklanmayan veya kısmen açıklanan bazı terimler için internete bakmak zorunda kalıyorsunuz. Bu da kitabı bırakın tam olarak anlamayı, okumayı hayli zorlaştırıyor.</p><p>Ben de bu yüzden, kitabı yaklaşık 15 yıl önce ilk defa okurken bir sözlüğe bakma ihtiyacı hissettiğim, gözümde canladırmakta zorlandığım, bilmediğim, ya da halen yeniden okurken “neydi bu?” diye tekrar araştırmak zorunda kaldığım her şeyi böyle bir seride toparlamak istedim. Kendime bir kaynak oluştururken belki başka bir kitapseverin de hayatını az da olsa kolaylaştırabilirim diye.</p><p>Son olarak, bu seride sağlamaya çalışacağım ek bilgi derinlemesine olmayacaktır, yoksa binlerce hatta belki onbinlerce sayfalık bir derleme yazmam gerekirdi ki buna ne bilgim ne de zamanım yeter. Bu yüzden notlarımı ve açıklamalarımı bir okuyucu olarak, denk geldiği sırada kısaca yazmaya çalıştım.</p><h3>Genel Bilgi</h3><p>Foucault Sarkacı’nda Kabbala öğretisine bol bol göndermeler var. Bu yüzden, en azından temel olarak bu öğretiyi anlamakta fayda var. Kabbala veya Kabbalah, Yahudi mistisizminde içrek bir disiplin, düsünce okulu veya kurallar bütünüdür. İçrek, batıni veya ezoterik; TDK tanımına göre; belirli bir insan topluluğunun dışında kimseye bildirilmeyen, yalnızca sınırlı, dar bir çevreye aktarılan her türlü bilgi ve öğreti manasındadır. Kabbala, Yahudilik içindeki gizemli dini yorumların temelini oluşturur ve genel olarak sonsuz tanrı Yehova ile sonlu evren arasındaki ilişkiyi felsefi olarak araştıran bir öğretidir.</p><p>Sefirot yani Sefira(lar) Kabbala öğretisine göre tanrının yansımaları ya da özellikleri yanısıra bilginin 10 katmanda açığa çıkışını temsil eder. Bu yüzden 10 Sefirot, Tevrat’taki 10 emir olarak bildirilen bilgilerin içrek karşılığı olarak da kabul edilir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/1*4Rm9rRVfywe_MJF1vF_dpQ.png" /><figcaption>Kabbala’daki Sefirot ağacı. Kaynak: <a href="https://en.wikipedia.org/wiki/File:Ktreewnames.png">Wikipedia</a></figcaption></figure><p>Umberto Eco, kitabını bu 10 Sefirot’a göre 10 ana bölüme ayırmıştır. Biz de serimizi buna uygun olarak 10 ana bölüme böleceğiz.</p><h3>1. Keter</h3><p><strong>Keter:</strong> Sefirotun birincisi, dolayısıyla taç olarak da anılır. Keter, açığa çıkma; olmuşu, olanı ve olacağı kapsar. Burası ilk yayılmanın ve son dönüşün yeridir. Kutsal sıfatının doğası gereği, Tanrı’nın adı olarak belirtilir.</p><p><strong>Foucault Sarkacı:</strong> Foucault sarkacı fizik laboratuvarlarında karşılaşabileceğimiz bir basit sarkaç düzeneğidir. Sarkacın yapmış olduğu hareket düzenli aralıklarla kendisini tekrar eder yani periyodiktir. Üzerine etki eden bir dış kuvvet olmaksızın basit sarkacın hareket doğrultusu değişmez. Léon Foucault tarafından tasarlanan basit sarkaç düzeneğinde ise belirli bir zaman sonra sarkacın hareket ettiği doğrultu değişir. Léon Foucault, sarkacın hareket ettiği doğrultunun değişmesine sebep olan etkinin Dünya’nın kendi etrafındaki dönüşü olduğunu öne sürdü ve 31 Mart 1851 tarihinde Paris Gözlemevi’nde kurduğu sarkaç düzeneğiyle dünyanın döndüğünü deneysel olarak ispat etti.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oC_fVy4uQImG_TGxMvjPyQ.jpeg" /><figcaption>Paris, Pantheon’daki Foucault Sarkacı. Kaynak: <a href="https://500px.com/photo/142301085/Foucault-pendulum-by-umberto-labate">Umberto Labate, 500px.com</a></figcaption></figure><p><strong>Koro Yeri:</strong> Kilisede, koro üyeleri için ayrılmış bölüm. Mimari bir terimdir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yyLKkuk_hKR9h_AKoLGvfw.png" /><figcaption>Haç biçimli bir ortaçağ katedrali planı. Kaynak: <a href="https://www.britannica.com/topic/nave/images-videos#/media/1/406945/8097">Encyclopædia Britannica</a></figcaption></figure><p><strong>Tonoz:</strong> Tuğla ve harçla örülmüş, alttan obruk, yarım silindir biçiminde tavan örtüsü.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*g6TXvjkhmp-K5ZJ1snxcvA.png" /><figcaption>Farklı tonor şekilleri. Kaynak: <a href="http://the-mind-of-architecture.blogspot.com/2016/03/architecture-basics-vaults.html">The Mind of Architecture</a></figcaption></figure><p><strong>Devingen:</strong> Hareketli</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/63/1*vRG_tilE8HzWd6p7X42Zcg.png" /></figure><p><strong>Basit Sarkaç Formülü: </strong>Kitabın hemen girişinde edebi olarak ifade edilen formül T=2π√(L/g) şeklindedir. T, sarkacın dönüm zamanını, L telin uzunluğunu ve g de yer çekimini ifade etmektedir. Eco, burada tıpkı bir Kabalist gibi matematiksel olarak ifade edilebilen, bilinen bir kavramdan içrek bir olguya gönderme yapmaktadır.</p><p><strong>Devinim:</strong> Hareket</p><p><strong>Yıldızbakışım:</strong> Okuyucuların en çok şikayet ettiği kelime bu olsa gerek zira ben de TDK dahil hiçbir kaynakta bu kelimenin karşılığını bulamadım. Ancak orjinal metindeki “simmetria raggiata” ifadesi İngilizce çeviride “radial symmetry” olarak ifade edilmiş.</p><p>Bakışım, TDK’ya göre simetri demek. Şadan Karadeniz, “radial” terimini “merkezden yayılan ışınlar biçiminde” anlamıyla yorumlayıp “yıldızbakışım” gibi olağanüstü bir kelime türetmiş, çok da iyi yapmış.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YKgxwtxO6HCZXtvQ7HQy5g.jpeg" /><figcaption>Bir sarkaç salınımının yerde bıraktığı yıldızbakışım izi. Kaynak: <a href="https://www.lockhaven.edu/~dsimanek/puzzles/ideas-answers.htm">Lock Haven University</a></figcaption></figure><p><strong>Mandala:</strong> Hinduizm ve Budizm’de evrenin yapısını simgelediği düşünülen, ritüel ve meditasyon amacı ile kullanılan semboller. Eco burada sarkacın salınımıyla oluşan yıldızbakışım şeklinden içrek bir olguya gönderme yapmaktadır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*rTzPkA8hDLTsPADQw1Bk3g.png" /><figcaption><a href="https://en.wikipedia.org/wiki/Vajrayogini">Vajrayogini</a> mandalası. Kaynak: <a href="https://en.wikipedia.org/wiki/Mandala#/media/File:Painted_19th_century_Tibetan_mandala_of_the_Naropa_tradition,_Vajrayogini_stands_in_the_center_of_two_crossed_red_triangles,_Rubin_Museum_of_Art.jpg">Wikipedia</a></figcaption></figure><p><strong>Beş Köşeli Yıldız:</strong> Çeviri olarak doğru olsa da; beş köşeli yıldız, pentagram, pentaculum ya da pentacle; içrek bilimlerde tılsım olarak kullanılan nesnelere verilen genel isimdir ve 5 sayısıyla ilgisi pek yoktur. Hatta, Eco muhtemelen burada 6 köşeli Süleyman Mührüne yani Hz. Süleyman’a isnat edilen mühür ya da mucizevi yüzüğe ve bu yüzüğün üzerine hakkedilmiş altı köşeli yıldıza gönderme yapmaktadır.</p><p>Müslümanlar arasında “Hatem-i Süleyman”, Yahudi ve Hristiyanlarca “Davud Yıldızı” diye anılan mühür, Hermetik gelenekte makrokozmosu temsil eder. Kadim Hind’de yaratıcı Vişnu üçgeniyle yok edici Şiva üçgeninin iç içe geçmiş şekli olarak yorumlanır ve maddi evrenin yaratılışı ile yok oluşunu simgeler. Üçgenlerden birinin hayatın olumlu yönlerini, diğerinin olumsuzlukları temsil ettiğine inanılan bu sembol İslam öncesi Doğu kültürlerinde madde ile mana, iyi ile kötü, güzel ile çirkin, Tanrı ve kaos, kadın ve erkek gibi zıtlıkları temsil etmiştir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*CUr5w0ag_FGzMgOl0V7B6A.png" /><figcaption>Mühr-i Süleyman. Kaynak: <a href="https://islamansiklopedisi.org.tr/muhr-i-suleyman">TDV İslam Ansiklopedisi</a></figcaption></figure><p><strong>Gizemli Gül:</strong> Eco burada birçok şeye gönderme yapıyor aslında. İlk romanı Gülün Adı, ya da daha içrek manasıyla aydınlanmış insan, belki de Rosa Mystica ile ifade edilen Meryem. Nihayetinde gül; gizli cemiyetlerde, içrek öğretilerde, bazı dinlerde ve kültürlerde aydınlanmayı, sır saklamayı ya da kutsal birini temsil eder.</p><p><strong>Mu Kıtası ve Atlantis:</strong> Mu kıtası veya kısaca Mu, Büyük Okyanus’ta yer aldığı ve 14 bin yıl önce batarak yok olduğu ileri sürülen efsanevi kıtadır. Atlantis ise Girit ve Mısır uygarlıklarından çok daha eski bir uygarlığın beşiği olan, yeri bilinmeyen büyük bir adadır. Büyük bir yıkım sonucu sulara gömülmüş ve adı yalnızca söylenceler ve edebiyatta kalmıştır. Atlantis, söylencelerde Mu kıtası ile ilişkilendirilmektedir.</p><p>Eco, burda kürenin salınımını bir uçtan bir uca Atlantis halkının Tasmanya’dan (Avustralya), Grönland’a (Danimarka), Oğlak ve Yengeç Dönenceleri arasında ekvator dikine, Prens Edward Adası’ndan (Kanada) Svalbard’a (Norveç) seyahatlerine benzeştirerek sarkaca biraz daha anlam yüklemektedir.</p><p><strong>Zamoa ile Zemlia:</strong> Zamoa aslında Güney Yarımküre’de Yeni Zelanda yakınlarında bir adalar ülkesi olan Samoa Adaları. Zemlia ise Novaya Zemlya yani Avrupa’nın en kuzey uçlarında Arktik Okyanusu’nda, Rusya’ya bağlı takımadalar.</p><p><strong>Agarttha:</strong> Dünyanın çekirdeğinde ya da düz dünya teorisine göre dünyanın merkezinde yer aldığı iddia edilen efsanevi krallık.</p><p><strong>Avalon ve Ayers Kayası</strong>: Avalon, Kral Arthur efsanesinde adı geçen hayali bir adadır. Ayers Kayası ise Avustralya çöl bölgesinde kumtaşından oluşan ve Aborjinler tarafından kutsal sayılan bir kaya formasyonudur. Eco burada sadece sarkacın kuzeyden güneye salınımına gönderme yapmıyor, fiziksel olarak var olan ve kutsal sayılan bir yerden tamamen hayali bir şeye geçişi de vurguluyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*nu7pDQ3HVAb8zFURnRwX2A.png" /><figcaption>Ayers Kayası, Uluru’da gün batımı. Kaynak: <a href="https://tr.wikipedia.org/wiki/Uluru#/media/Dosya:Uluru_Australia(1).jpg">Wikipedia</a></figcaption></figure><p><strong>Süleyman Tapınağı:</strong> Tevrat’a göre, Kudüs’teki ilk Yahudi tapınağı. Süleyman’ın inşa ettirdiği, Yahudilerin Kutsal Ev dedikleri tapınak, Süleyman tarafından yapıldığı için de “Süleyman Mabedi” olarak bilinmektedir.</p><p>Günümüzde, tapınağın sadece batı duvarı yani Ağlama Duvarı ayaktadır. Mabedin yıkılışından sonra Yahudilik’te ibadet yeri olarak sinagog ortaya çıkmıştır.</p><p><strong>Saint-Martin-des-Champs Manastırı:</strong> Orjinal Foucault Sarkacı düzeneğinin kurulduğu yer.</p><p><strong>Panta Rei:</strong> Herakleitos’a göre evrenin bir süreç olduğunu ve gerçeğin sadece değişim olduğunu anlatan “herşey akar” anlamına gelen Yunanca söz. Her şey akar, her şey devinir ve hiçbir şey olduğu gibi kalmaz.</p><p><strong>Ensof:</strong> Kabbala öğretisine göre Ein Sof, henüz hiçbir şey olmadan var olan, sonsuz olan, sınırları olmayan gibi manalara gelen tanrıyı ifade eder.</p><p><strong>Numen:</strong> Yalnızca akıl ile idrak edilen şey, nesnenin kendisi, duyularla algılanamayan. Şadan Karadeniz’in notlarında “heilige” yani “holy” yani “kutsal ya da tanrısal” manasında kullanıldığı belirtilmiştir.</p><p><strong>Nef:</strong> Kiliselerin binanın diğer kısımlarından yüksekçe olan uzun ve dar orta kısmı. Yukarıda “Koro Yeri” maddesinin resmine bakabilirsiniz.</p><p><strong>Eğretileme:</strong> Benzetme, metafor.</p><p><strong>Arkontlar:</strong> Eski Yunan’da monarşiden aristokrasiye geçişi simgeleyen en üst düzey yöneticilere verilen isim. Ayrıca, Hermes Trismegistes in Gnostik öğretisine göre merkezinde yerin bulunduğu yedi kat gökyüzünün yedi yöneticisi. Sabit yıldızların bulunduğu sekizinci gök ise en yüce tanrı tarafından yönetilir.</p><p><strong>Arkeopteriks:</strong> Kuş biçimli bir dinozor türü.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*eIri99msovarjRVkoxSXyA.jpeg" /><figcaption>Bir arkeopteriks ilüstrasyonu. Kaynak: <a href="https://tr.pinterest.com/pin/507921664195153605/">Pinterest</a></figcaption></figure><p><strong>Breguet, Bleriot, Esnault ve Dufaux:</strong> Uçak ve helikopter modelleri geliştiren Fransız mucitler.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*jxTQfrUWEGOnvrSJ-wKAtg.png" /><figcaption>Armand ve Henri Dufaux. Kaynak: <a href="https://commons.wikimedia.org/wiki/File:Armand_%26_Henri_Dufaux_-_helicopter_-_April_1905.jpg">Wikimedia</a></figcaption></figure><p><strong>Conservatoire National des Arts et Métiers:</strong> Geçmişi 1794&#39;e uzanan, Fransa’nin Paris şehrinde bulunan teknik üniversitedir. Kitapta bahsedilen yer, üniversitenin koleksiyonlarının sergilendiği bir sanayi ve teknoloji müzesi olan Musée des Arts et Métiers’dir. Kitabın yazıldığı 1989 yılında sarkaç halen buradaydı ancak daha sonra Pantheon’a taşındı.</p><p><strong>Baal:</strong> Eski pagan/putperest dinlerdeki farklı tanrıları ya da bazen belirli bir tanrıyı veya iblisi ifade eden isim.</p><p><strong>Nürnberg Bakiresi:</strong> İç kısmı büyük uçlu, sivri çivilerden oluşan yaşamsal organları delmeyecek şekilde çiviler bulunan, kurbanın hayatta kalmasını ve acı çekmesini sağlayan işkence aleti.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*ujjMqxEPjeT8jZlIMPhRjg.jpeg" /><figcaption>Nürnberg Bakiresi. Kaynak: <a href="https://www.uludagsozluk.com/r/nuremberg-bakiresi-173608/">Uludağ Sözlük</a></figcaption></figure><p><strong>Cher Maitre:</strong> Sevgili üstat manasına gelen Fransızca cümle.</p><h3>Kaynaklar</h3><ol><li><a href="https://tr.wikipedia.org/wiki/Kabbala">https://tr.wikipedia.org/</a></li><li><a href="https://en.wikipedia.org/">https://en.wikipedia.org/</a></li><li><a href="https://www.salom.com.tr/arsiv/haber-88613-yahudilik_ve_melekler_2__hayat_agaci_ve_melekler.html">https://www.salom.com.tr/</a></li><li><a href="https://sozluk.gov.tr/">https://sozluk.gov.tr/</a></li><li><a href="https://www.britannica.com/">https://www.britannica.com/</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8941778fdb7f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Q For Mere Mortals: Transferring Huge Data Between KDB+ Servers]]></title>
            <link>https://medium.com/@kadir.kilicoglu_67563/q-for-mere-mortals-transferring-huge-data-between-kdb-servers-6d7bfcbd6f?source=rss-9794d1a89206------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d7bfcbd6f</guid>
            <category><![CDATA[kdb]]></category>
            <category><![CDATA[q]]></category>
            <dc:creator><![CDATA[Kadir Kılıçoğlu]]></dc:creator>
            <pubDate>Thu, 19 Mar 2020 22:05:06 GMT</pubDate>
            <atom:updated>2020-03-19T22:09:49.194Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hiEv0ayP4Rg3Y-9J" /><figcaption>Photo by <a href="https://unsplash.com/@mbaumi?utm_source=medium&amp;utm_medium=referral">Mika Baumeister</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Time-series data and analysis was always a trend for a bunch of sectors but recently it is most likely that it becomes a hype, very soon. I have to admit that the first time I learn how data is generated by a single stock market per day I was deeply astonished.</p><p>But nowadays, it is not only market data but also IoT signals, sensors data, medical applications, and many other fields generating a <em>huge amount</em> of data everyday.</p><p>Of course there are many big data players on the field which can handle literally billions of data like Hadoop, Couchbase and Cassandra but they all require a solid infrastructure with a lot of operational effort. On the other hand there are also time-series specialized databases like InfluxDB or MemSQL but still, they have some constraint one way or the other!</p><p><strong><em>Warning:</em></strong><em> The next lines in this article are just spit out from a novice’s fingers. I know that Q/KDB+ experts are a pretty rare species but if any of them coincidentally read this article, please show some mercy!</em></p><h3>KDB+</h3><p>Then I met KDB+; the so said, <em>world’s fastest time-series database</em>. That is a bold claim! Let’s continue with the official description from <a href="http://www.kx.con/">www.kx.co</a>m:</p><blockquote>Kdb+ is optimized for ingesting, analyzing, and storing <strong>massive amounts</strong> of <strong>structured </strong>data. The combination of the <strong>columnar </strong>design of kdb+ and its <strong>in-memory</strong> capabilities means it offers greater <strong>speed </strong>and <strong>efficiency </strong>than typical relational databases. Its <strong>native support for time-series</strong> operations vastly improves both the <strong>speed </strong>and <strong>performance </strong>of queries, aggregation and analysis of structured data.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*JK3T1cXqL4TWwML1qd5ZGQ.gif" /><figcaption>Tech Wheel by kx.com</figcaption></figure><p>As all technologies have a locomotive stack behind them, Kx is a suite of enterprise-level products and solutions centered around kdb+ and you can utilize their free tier products as well as enterprise level solutions to jump the production.</p><h3>Q</h3><p>The Q language is basically the query language for kdb+ which is backed by Kx Systems. Let me warn you; it is not a easily readable language the learning curve is quite steep. But the reward is pretty high: it enables writing the shortest possible code to apply highly complex queries!</p><p>Q has its own unique features like being executed from right to left, no operator precedence, polymorphic symbols and notations, and many more.</p><p>The documentation at <a href="https://code.kx.com/">https://code.kx.com/</a> is one of the best I’ve seen so far, so I will not dive deep into how to install Q, mumble about the basic building blocks of atoms, lists and functions, and will directly start to implement a useful utility.</p><h3>The Scenario</h3><p>Let’s assume that you have a remote KDB+ server which has several tables containing billions of daily data. Somehow, you require to fetch a single day data from these tables, or a single specific table.</p><p>Our problem is that fetching that much data into our humble memory may cause some issues. Also we cannot request all the data at once, so we have to get it in incremental blocks. Finally it would be best to save all the data into a common format like CSV so that we can import it into our super-special applications.</p><p>To sum up, our requirements are;</p><ul><li>Being able to connect to a remote KDB+ server.</li><li>Execute a custom function filter and get the data.</li><li>Asynchronous incremental read/write operations.</li><li>Stream the data to a CSV file in a non-blocking manner.</li></ul><h3>The Solution</h3><p>Let’s start by creating a namespace too keep everything nice and neat:</p><p>\d .importer</p><p>All lines after this command will be under the .importer namespace. Now let’s create a function with some parameters:</p><pre>fetch_data:{[table_names;batch_size;data_date]<br>  }</pre><p>A Q function is defined between curly-brackets and the parameters are set in square-brackets as seen above. Here we think that we may require a list of tables to get data, the batch size of the data for each iteration and the date of the data to be fetched.<em> Please note that there aren’t any types defined for any argument.</em></p><p>Now let start our function by defining a connection handle:</p><pre>h::hopen `$”tcp://host:port:username:password”;</pre><p>Here we re globally (::) setting a handle h with the hopen command and we just provide the hostname or IP, remote KDB+ port, and the user credentials.</p><p>Then, I just wanted to use local variables with shorter names for convenience, and learning purposes of course:</p><pre>tabs:enlist table_names;<br>bsize::batch_size;<br>dday::data_date;</pre><p>We have the list of tables in our function parameter and we assigned this to our tabs local variable. So we want to execute some steps for each of these tables:</p><pre>{[tab] }each tabs;</pre><p>This is a lambda-function where we can write some function to be executed for each element in a list. We first want to do some calculations based on the remote table size and so we query it:</p><pre>tcount:h({[t;d] count select from t where date=d};tab;dday);</pre><p>The tcount: is the assignment part, we are going to assign the righ-hand result to this local variable. The h() is executing what we have inside the paranthesis remotely using the handler h we created above. The rest of this line is pretty straightforward, filter the table with a date and get the count.</p><h4>The Boundaries Matrix</h4><p>Next, we want to calculate the splits:</p><pre>splits:$[tcount&gt;bsize; [batch:tcount div bsize;((0;bsize-1)+/:bsize*til batch),enlist (batch*bsize;tcount-1)];enlist(0;tcount-1)];</pre><p>This single line dark-magic is actually pretty cool. The $[;;] structure is an if-else block. So we can translate this like:</p><pre>if (tcount &gt; bsize)<br>    batch:tcount div bsize // Calculate how many blocks we require<br>    [batch:tcount div bsize;((0;bsize-1)+/:bsize*til batch),enlist (batch*bsize;tcount-1)] // Create batch blocks list</pre><pre>else<br>    enlist(0;tcount-1) // Create a single block starting from 0 to the end</pre><p>It still seems a bit complicated, so let’s go over each line one-by-one. tcount div bsize will just do a simple whole number division, simple enough.</p><ul><li>10%3 is 3.333333</li><li>10 div 3 is 3</li></ul><p>(0;bsize-1) will create a list like (0 999) if our batch-size is set as 1000. The right-side is bsize*til batch will create a vector starting from 0 and then increasing by bsize and this will repeat batch times. For example;</p><ul><li>Let’s say we have tcount:1293 rows remotely and we want to fetch them by bsize:10 rows per loop. Then the batch will be calculated as batch:129</li><li>bsize*til batch will be 10*til 129 which results in a vector like; 0 10 20 30 40 50 60 ..</li></ul><p>What is the point of having this? Well here comes the vector addition +/: operator. This will add a vector to each rows of the matrix. Hence, with the given values above and (0;bsize-1)+/:bsize*til batch will end up in a matrix like;</p><pre>0 9<br>10 19<br>20 29<br>30 39<br>..<br>..<br>1270 1279<br>1280 1289</pre><p>Isn’t that fascinating! We just defined our boundaries per loop in a single line of code. But still there is an issue, the last pair ends with 1289 but our hypothetical table had 1293 lines. So we have the append the rest 4 line.</p><p>The rest of the line continues as ,enlist (batch*bsize;tcount-1) . The comma here is important as it acts as a concatenation operator. It will add the right-hand list to the left-hand one. enlist is an operator to create a list. So this will end up as (1290 1292) and concatenate this to the matrix above. We start where we left of at 1290 and end at the 0-based index of the table.</p><h4>Create The File and Handle</h4><p>Phew! That was a lot to digest. But here comes more:</p><pre>tmeta: key h({[t] meta t};tab);</pre><p>What we are doing here is remotely executing the meta table-name function, which will simply return the table meta-data for each columns using the h handle we created before. Then we are taking only the keys. So the meta will look something like this..</p><pre>c      | t f a<br>-------| -----<br>date   | d<br>sym    | s   s<br>exg    | h<br>nxtime | t<br>exgtime| t<br>bid    | f<br>bidsz  | i<br>ask    | f<br>asksz  | i</pre><p>..and the key will take only:</p><pre>c<br>-------<br>date<br>sym<br>exg<br>nxtime<br>exgtime<br>bid<br>bidsz<br>ask<br>asksz</pre><p>Now we have the colum names. What we desire is to create a CSV file and add these columns as comma-seperated values as the first line.</p><pre>(hsym `$ raze string tab,&quot;.csv&quot;) 0: enlist &quot;,&quot; sv raze string flip tmeta cols tmeta;</pre><p>Remember to read it from right to left. string flip tmeta cols tmeta will take the column names list as strings and raze will flatten this. Then enlist &quot;,&quot; sv will add commas and join this column names vector. The rest will simply create a CSV file based on the table name and write the comma-delimeted colum names. Then we want to create a file handle to this file:</p><pre>fhandle:hopen (hsym `$ raze string tab,&quot;.csv&quot;);</pre><h4>Recursive Fetch and Write</h4><p>We have calculated our sizes and prepared a CSV file. Now it is time to fetch the data in batches and write it into the file.</p><pre>{[t;dday;tcount;fhandle;split]</pre><pre>neg[fhandle] peach 1_&quot;,&quot; 0:h({[t;y;dday] ?[t;((=;`date;dday);(within;`i;y));0b;()]};t;split;dday);</pre><pre>show raze string split[0],&quot;-&quot;,split[1],&quot; of &quot;, tcount; }[tab;dday;tcount;fhandle] each splits;</pre><p>It looks quite complex but bear with me! neg[fhandle] is the way of Q to define async operations, so we are writing to the file asynchronously. peach is the parallel version of each and 1_ part is dropping the 1st line of each batch, which is the headers. After all we don’t want repeating headers, right!</p><p>Then again we see the h() stuff which means we are going to execute some remote queries. It defines a function accepting 3 parameters; t as tablename, y as the boundaries like 400 409, and dday as the day to be filtered. The operation is ?[t;((=;`date;dday);(within;`i;y));0b;()] and it is intimidating to read it. But this is just a naive <a href="https://code.kx.com/q/basics/funsql/#select">functional form</a> of a select statement which simply says select from t where date=dday AND index is between y[0],y[1] .</p><blockquote>This is the single line which is doing the actual job! This is the single line which is doing the actual job! This is the single line which is doing the actual job! This is the single line which is doing the actual job! This is the single line which is doing the actual job…!</blockquote><p>The rest is just for printing pretty messages like 5000-5099 of 12548 .</p><h4>The Final Code</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e65b3b7915bee546489915026547f93a/href">https://medium.com/media/e65b3b7915bee546489915026547f93a/href</a></iframe><p>The last 3-lines are just projections which we can use like overloading. So for example:</p><pre>fetch_quotes_today:fetch_data[`quotes;;.z.d];</pre><p>Here we are projection fetch_data to a new function and we will only ask for a single parameter. Because we set the table_names as quotes and data_date as z.d which means today.</p><p>I tried to execute this code to transfer <strong><em>~700 Million</em></strong> rows of data, ending up with a ~40GB file and all was done within less than an hour and not consuming that much RAM nor other resources!</p><p>I tried to introduce some challenging concepts without diving deep or walking shallow and I hope that this article will open a mysterious door for mere mortals!</p><p><a href="https://github.com/kkadir/q-toolkit">https://github.com/kkadir/q-toolkit</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d7bfcbd6f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ASP.NET Core: Custom Authorization Policies with Multiple Requirements and Multiple Handlers]]></title>
            <link>https://medium.com/@kadir.kilicoglu_67563/asp-net-core-custom-authorization-policies-with-multiple-requirements-and-multiple-handlers-487f920ae13e?source=rss-9794d1a89206------2</link>
            <guid isPermaLink="false">https://medium.com/p/487f920ae13e</guid>
            <category><![CDATA[aspnetcore]]></category>
            <category><![CDATA[authorization]]></category>
            <dc:creator><![CDATA[Kadir Kılıçoğlu]]></dc:creator>
            <pubDate>Tue, 03 Mar 2020 18:58:11 GMT</pubDate>
            <atom:updated>2020-03-03T18:58:11.629Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JUFERc_c5Y0uCEtX" /><figcaption>Photo by <a href="https://unsplash.com/@franckinjapan?utm_source=medium&amp;utm_medium=referral">Franck V.</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>An authorization attribute, well as its name implies, is used to authorize or control user access to protected resources.</p><p>In good old days, when the .NET Framework still used to be a black-box, we had a simple <a href="https://docs.microsoft.com/en-us/dotnet/api/system.web.mvc.authorizeattribute">AuthorizeAttribute</a> class which we can extend to implement our most challenging authorization logic and furthermore handle what will happen to those sneaky unauthorized users.</p><p>Then in the dawn of the “Core” generation and the glorious open-source world, the shiny ASP.NET Core community decided to add a spice of politics seasoning into this well cooked meal. Don’t get me wrong, anyone can still go with the new version of the old school <a href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.authorization.authorizeattribute">AuthorizeAttribute</a> class mixing it with the <a href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.filters.iauthorizationfilter">IAuthorizationFilter</a> interface but regret the lack of the overridable AuthorizeCore and HandleUnauthorizedRequest methods.</p><p>To cut a long story short, ASP.NET Core supports and suggests using policy based authorization as a best practice. You can have a fairly good idea about authorization in ASP.NET Core by going through the <a href="https://docs.microsoft.com/en-us/aspnet/core/security/authorization/introduction">official documentation</a>. Here, you may notice that any rule to authorize a user, such as; roles, claims, as well as custom rules are combined to policies and applied through the AuthorizeAttribute.</p><p>This is what makes policies so powerful, combining various rules into a policy and evaluate the authorization context based on these rules.</p><blockquote>The result is a richer, reusable, testable authorization structure.</blockquote><p>Now, in this article, we are not going to dive deep into the basics or theory but rather we are going to run down some lines about custom policies and implement a basic one.</p><h3>Don’t Teach Me How To Catch A Fish…</h3><p>There are <strong>Four Horsemen</strong> of implementing a custom policy provider and the most obvious one is, of course, <strong>(1) the authorization attribute</strong>. This custom attribute should derive from the <a href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.authorization.authorizeattribute">AuthorizeAttribute</a> class and its sole purpose is to decorate actions and controllers to initiate the authorization process.</p><p>The most important property of the derived AuthorizeAttribute is the Policy, which is a humble string. Who would knew such a poor property will cause dramatic consequences.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sbYzWgAX5qZK82x5" /><figcaption>Photo by <a href="https://unsplash.com/@jhaland?utm_source=medium&amp;utm_medium=referral">Jørgen Håland</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Then, afterwards we have a policy set, it is going to be consumed by the <strong>(2) policy provider</strong>. As the official warning goes, please note that when using custom IAuthorizationPolicyProvider implementations, keep in mind that ASP.NET Core only uses one instance of IAuthorizationPolicyProvider. The GetPolicyAsync method of this provider will build up our policy and add our <strong>(3) custom requirements</strong> to this policy.</p><p>Here we mentioned the custom requirements. Basically, an authorization requirement is a collection of data parameters that a policy can use to evaluate the current user principal. This means that a requirement is nothing but a formal representation of a set of rules extracted from the policy name. The interpretation of these requirements is the task of the authorization handler.</p><p>Finally, our custom logic will reside in the <strong>(4) authorization handler</strong> in which we override the HandleRequirementAsync method to perform some dark magic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*I0NrO9Prfoj_hptXWxbc7A.png" /><figcaption>The 50.000 feet high overview of the authorization process</figcaption></figure><h3>Give Me the Fish!</h3><p>Let’s assume that we want to implement a custom authorization structure with the following requirements:</p><ul><li>Any user must be authenticated to reach out any protected resource.</li><li>The context may be challenged against a set of service based permissions, roles or scopes.</li><li>Permissions, roles or scopes may be defined as wild-cards.</li><li>The context may be challenged with no expectations which means no permissions, roles or scopes at all or any are expected.</li><li>All requirements should be combined as an OR relation. That is, if any of the requirements are satisfied, then the authorization should succeed.</li></ul><p><strong>Step 1.</strong> We can start to create our custom attribute by inheriting it from the AuthorizeAttribute class.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/71875a7aeb41a72d242ca1433bf17d6c/href">https://medium.com/media/71875a7aeb41a72d242ca1433bf17d6c/href</a></iframe><p>Here, the _isDefault is just for a precaution as if the Policy is set explicitly, we should clear it up before building our custom policy name. The end result of something like below..</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/957480b99fcb6ee275bd199730d5f231/href">https://medium.com/media/957480b99fcb6ee275bd199730d5f231/href</a></iframe><p>..will end up creating a policy name like Permissions$Read|Write;Roles$Admin; where the ; sign is the separator between groups, the $ sign is the separator between the key-value pairs and the | is the separator within the values.</p><p><strong>Step 2.</strong> As per our requirements, we have 3 requirements to create. These are not anything fancy, so let’s implement them quickly.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/15f5ed02009a617459b952cf4b0ab57c/href">https://medium.com/media/15f5ed02009a617459b952cf4b0ab57c/href</a></iframe><p>Multiple classes in a single file is a sin, I know, but let’s keep it that way for convenience. In these simple classes, we are just adding a single property to make them available as placeholders to carry our precious expected authorization data.</p><p>One may say that those are significantly same, and wouldn’t it be better to create only a single requirement for all. That is true in one way but the way other we have to understand that for each requirement we are going to apply slightly different logic, hence we will end up having different handlers for each requirement.</p><p>One intriguing point is the IIdentifiable interface and the Identifier property. We’ll come to that soon.</p><p><strong>Step 3.</strong> We have the attribute and the requirements defined. Thus, we have to implement the policy provider next.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f0241288ae532e060e7774fca130b11f/href">https://medium.com/media/f0241288ae532e060e7774fca130b11f/href</a></iframe><p>The GetPolicyAsync method will be triggered whenever a Policy is set and here is the first trick we perform. We know that our policies will be in format of Group1$permission1|permission2|..;Group2$permission1|..; so we are first splitting this string by ; into policy tokens.</p><p>Then, within each token, we split them by $ to retrieve the key-value or group-permissions pairs. Finally we create a requirement regarding the group (key) for each pair and add it to our policy.</p><p>Suddenly there is that mysterious identifier again, assigned a random GUID and passed to our requirements. Well, we’ll come to that soon. But please note that the identifier will be the same for all requirements added in the same policy.</p><p>You will notice 2 extra methods implemented regarding the realized interface.</p><ul><li>GetDefaultPolicyAsync returns the default authorization policy, the policy used for our attribute without a policy specified.</li><li>GetFallbackPolicyAsync returns the fallback authorization policy, the policy used by the Authorization Middleware when no policy is specified which is null by default.</li></ul><p>The GetDefaultPolicyAsync is going to be executed in case we apply the [Permission] attribute without any arguments. This is why we just check against if the user is authenticated and nothing more as there isn’t any expectation to check!</p><p>In case of any failure of format, data or anything else, we always tend to fall back to the Fallback Provider which is null by default. This means that no authorization checks are going to be performed.</p><p><strong><em>Note:</em></strong><em> I am using an authentication scheme here and called it </em><em>Bearer but please be aware that this is just a name and it may or may not related with using bearer tokens. You may leave it empty to use your custom authorization with the default authentication scheme.</em></p><p><strong>Step 4.</strong> Now that we have everything in place, we can implement our handlers. We need to have a handler per requirement, so in our scenario, we are going to have 3 handlers.</p><p>We want to have a OR combination of all our requirements, so we are not going to fail the context but will succeed whenever applies. That means; at first the context is unauthorized and if the first handler does not satisfy the expectations, it will just return so that the next handler will continue to process. If it succeeds, it will mark the context as authorized and the next handlers will not redundantly process and just return as-is.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/05fbc73ae73278b74f055a8fb72f49f5/href">https://medium.com/media/05fbc73ae73278b74f055a8fb72f49f5/href</a></iframe><p>We are merely focusing on respective claims for each handler as given below. Then we will challenge against the expected values again in an OR manner.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d729cdc40275e34debeecb002f84a47/href">https://medium.com/media/0d729cdc40275e34debeecb002f84a47/href</a></iframe><p>This time, violating <a href="https://learning.oreilly.com/library/view/clean-code/9780136083238/chapter04.html#ch4">Uncle Bob</a>’s commenting rules, I deliberately added explanatory comments in the snippet.</p><p>What we are doing here is; doing preliminary check to proceed further or not, tokenize expected permissions, and compare them with the user permissions coming from the user claims. The tricky part here is that we decided to have a format for our permissions like application-name:area-name:permission hence we are using tuples for each permission tokens.</p><p>Instead of using the standart context.Succeed(requirement) method, we call the Utility.Succeed(context, requirement.Identifier) helper method. Why is that? Normally, all expected requirement challenges are handled in an AND approach. It doesn’t matter if you apply all requirements in a single attribute or on multiple attributes.</p><blockquote>The context fetches all requirements and queue them as PendingRequirements</blockquote><p>That means all requirements are going to be evaluated and the status of all requirements may have unexpected side-effects towards the final result.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F5139389&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fmind-blow-mindblow-gif-5139389&amp;image=https%3A%2F%2Fmedia.tenor.com%2Fimages%2F0c844909cbfdd0d64acd3fe5bad95fe1%2Fraw&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/112f0386e7950c5b6bdf11aa349d88ec/href">https://medium.com/media/112f0386e7950c5b6bdf11aa349d88ec/href</a></iframe><p>What we do is, we define a random identifier for each requirement and assign them in the provider. If there are multiple requirements in a single attribute, they all will have the same identifier. Otherwise, if there are multiple requirements in multiple attributes they will have different identifiers. Whenever any requirement succeeds, it will also succeed other requirements having the same identifier:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d7c8adbf9799a1a9ca593fe67ac613ae/href">https://medium.com/media/d7c8adbf9799a1a9ca593fe67ac613ae/href</a></iframe><p>Then, we should implement similar handlers for our RolesRequirement and ScopeRequirement. This time, I will not add any comments to keep them cleaner. Also, it is important that if any other requirement having the same identifier succeeded before, the handler will shortcut and return as-is.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc007265ede6f6b0f015c9e9a2ac6c76/href">https://medium.com/media/dc007265ede6f6b0f015c9e9a2ac6c76/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/54378e1c5b52fee8efeefd4a981c695d/href">https://medium.com/media/54378e1c5b52fee8efeefd4a981c695d/href</a></iframe><h3>Wiring Everything Up</h3><p>I have created a demo application to wire everything explained above up. Authentication is not in our scope so I just added a mock-handler to simulate a token for a user.</p><p>I also added several end-points with various usages of our attribute. I have searched through the internet and at the time this article was written, everyone repeated the same “Multiple Handlers with a Requirement” approach but there wasn’t any “Multiple Handlers with Multiple Requirements” implementation. I hope this article will shed some light onto your blockers!</p><p><a href="https://github.com/kkadir/custom-policy-provider-demo">kkadir/custom-policy-provider-demo</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=487f920ae13e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>